fix: layout updates

This commit is contained in:
swve 2023-01-14 01:36:54 +01:00
parent 26e077eed4
commit 88dc060bae
18 changed files with 3479 additions and 328 deletions

View file

@ -57,7 +57,7 @@ function NewCollection(params : any) {
}, [params.params.orgslug]); }, [params.params.orgslug]);
return ( return (
<Layout> <>
<Title>Add new</Title> <Title>Add new</Title>
<br /> <br />
<input type="text" placeholder="Name" value={name} onChange={handleNameChange} /> <input type="text" placeholder="Name" value={name} onChange={handleNameChange} />
@ -90,7 +90,7 @@ function NewCollection(params : any) {
<input type="text" placeholder="Description" value={description} onChange={handleDescriptionChange} /> <input type="text" placeholder="Description" value={description} onChange={handleDescriptionChange} />
<br /> <br />
<button onClick={handleSubmit}>Submit</button> <button onClick={handleSubmit}>Submit</button>
</Layout> </>
); );
} }

View file

@ -35,7 +35,7 @@ function Collections(params:any) {
}, []); }, []);
return ( return (
<Layout> <>
<Title> <Title>
{orgslug} Collections :{" "} {orgslug} Collections :{" "}
<Link href={"/collections/new"}> <Link href={"/collections/new"}>
@ -61,7 +61,7 @@ function Collections(params:any) {
))} ))}
</div> </div>
)} )}
</Layout> </>
); );
} }

View file

@ -225,7 +225,7 @@ function CourseEdit(params: any) {
}; };
return ( return (
<Layout> <>
<Header></Header> <Header></Header>
<Title> <Title>
Edit Course Chapters{" "} Edit Course Chapters{" "}
@ -283,7 +283,7 @@ function CourseEdit(params: any) {
</DragDropContext> </DragDropContext>
</ChapterlistWrapper> </ChapterlistWrapper>
)} )}
</Layout> </>
); );
} }

View file

@ -42,7 +42,7 @@ function ElementPage(params: any) {
}, [elementid]); }, [elementid]);
return ( return (
<Layout> <>
{isLoading ? ( {isLoading ? (
<div>Loading...</div> <div>Loading...</div>
) : ( ) : (
@ -88,7 +88,7 @@ function ElementPage(params: any) {
</CourseContent> </CourseContent>
</LectureLayout> </LectureLayout>
)} )}
</Layout> </>
); );
} }

View file

@ -33,7 +33,7 @@ const CourseIdPage = (params: any) => {
}, [courseid && orgslug]); }, [courseid && orgslug]);
return ( return (
<Layout> <>
{isLoading ? ( {isLoading ? (
<div>Loading...</div> <div>Loading...</div>
) : ( ) : (
@ -106,7 +106,7 @@ const CourseIdPage = (params: any) => {
</BoxWrapper> </BoxWrapper>
</CoursePageLayout> </CoursePageLayout>
)} )}
</Layout> </>
); );
}; };

View file

@ -1,3 +1,4 @@
"use client";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import React from "react"; import React from "react";
import { Header } from "../../../../../components/UI/Header"; import { Header } from "../../../../../components/UI/Header";
@ -55,8 +56,7 @@ const NewCoursePage = (params: any) => {
return ( return (
<Layout title="New course"> <>
<Header></Header>
<Title>New Course </Title> <Title>New Course </Title>
<hr /> <hr />
Name : <input onChange={handleNameChange} type="text" /> <br /> Name : <input onChange={handleNameChange} type="text" /> <br />
@ -64,7 +64,7 @@ const NewCoursePage = (params: any) => {
Cover Photo : <input onChange={handleThumbnailChange} type="file" /> <br /> Cover Photo : <input onChange={handleThumbnailChange} type="file" /> <br />
Learnings (empty for now) (separated by ; ) : <textarea id="story" name="story" rows={5} cols={33} /> <br /> Learnings (empty for now) (separated by ; ) : <textarea id="story" name="story" rows={5} cols={33} /> <br />
<button onClick={handleSubmit}>Create</button> <button onClick={handleSubmit}>Create</button>
</Layout> </>
); );
}; };

View file

@ -10,7 +10,7 @@ import { getBackendUrl } from "../../../../services/config";
import { deleteCourseFromBackend, getOrgCourses } from "../../../../services/courses/courses"; import { deleteCourseFromBackend, getOrgCourses } from "../../../../services/courses/courses";
import { getOrganizationContextInfo } from "../../../../services/orgs"; import { getOrganizationContextInfo } from "../../../../services/orgs";
const CoursesIndexPage = (params : any) => { const CoursesIndexPage = (params: any) => {
const router = useRouter(); const router = useRouter();
const orgslug = params.params.orgslug; const orgslug = params.params.orgslug;
@ -46,14 +46,11 @@ const CoursesIndexPage = (params : any) => {
}, [isLoading, orgslug]); }, [isLoading, orgslug]);
return ( return (
<Layout title="Courses"> <>
<Header></Header>
<Title> <Title>
{orgslug} Courses :{" "} {orgslug} Courses :{" "}
<Link href={"/courses/new"}> <Link href={"/courses/new"}>
<button>+</button> <button>+</button>
</Link>{" "} </Link>{" "}
</Title> </Title>
@ -65,26 +62,22 @@ const CoursesIndexPage = (params : any) => {
{courses.map((course: any) => ( {courses.map((course: any) => (
<div key={course.course_id}> <div key={course.course_id}>
<Link href={"/org/" + orgslug + "/course/" + removeCoursePrefix(course.course_id)}> <Link href={"/org/" + orgslug + "/course/" + removeCoursePrefix(course.course_id)}>
<h2>{course.name}</h2> <h2>{course.name}</h2>
<CourseWrapper> <CourseWrapper>
<img src={`${getBackendUrl()}content/uploads/img/${course.thumbnail}`} alt="" /> <img src={`${getBackendUrl()}content/uploads/img/${course.thumbnail}`} alt="" />
</CourseWrapper> </CourseWrapper>
</Link> </Link>
<button style={{ backgroundColor: "red", border: "none" }} onClick={() => deleteCourses(course.course_id)}> <button style={{ backgroundColor: "red", border: "none" }} onClick={() => deleteCourses(course.course_id)}>
Delete Delete
</button> </button>
<Link href={"/org/" + orgslug + "/course/" + removeCoursePrefix(course.course_id) + "/edit"}> <Link href={"/org/" + orgslug + "/course/" + removeCoursePrefix(course.course_id) + "/edit"}>
<button>Edit Chapters</button> <button>Edit Chapters</button>
</Link> </Link>
</div> </div>
))} ))}
</div> </div>
)} )}
</Layout> </>
); );
}; };

View file

@ -0,0 +1,14 @@
import "../../../styles/globals.css";
import { Menu } from "../../../components/UI/Elements/Menu";
import AuthProvider from "../../../components/Security/AuthProvider";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<>
<AuthProvider>
<Menu></Menu>
{children}
</AuthProvider>
</>
);
}

View file

@ -4,7 +4,7 @@ import Layout from "../../../components/UI/Layout";
import { Title } from "../../../components/UI/Elements/Styles/Title"; import { Title } from "../../../components/UI/Elements/Styles/Title";
import { Header } from "../../../components/UI/Header"; import { Header } from "../../../components/UI/Header";
import Link from "next/link"; import Link from "next/link";
import { usePathname } from 'next/navigation'; import { usePathname } from "next/navigation";
const OrgHomePage = (params: any) => { const OrgHomePage = (params: any) => {
const orgslug = params.params.orgslug; const orgslug = params.params.orgslug;
@ -12,13 +12,10 @@ const OrgHomePage = (params: any) => {
return ( return (
<div> <div>
<Layout orgslug={orgslug} title={"Org " + orgslug}> <Title>Welcome {orgslug} 👋🏻</Title>
<Link href={pathname + "/courses"}>
<Title>Welcome {orgslug} 👋🏻</Title> <button>See Courses </button>
<Link href={pathname + "/courses"}> </Link>
<button>See Courses </button>
</Link>
</Layout>
</div> </div>
); );
}; };

View file

@ -0,0 +1,25 @@
"use client";
import { motion } from "framer-motion";
export default function Template({ children }: { children: React.ReactNode }) {
const variants = {
hidden: { opacity: 0, x: 0, y: 0 },
enter: { opacity: 1, x: 0, y: 0 },
exit: { opacity: 0, x: 0, y: 0 },
};
return (
<div>
<motion.main
variants={variants} // Pass the variant object into Framer Motion
initial="hidden" // Set the initial state to variants.hidden
animate="enter" // Animated state to variants.enter
exit="exit" // Exit state (used later) to variants.exit
transition={{ type: "linear" }} // Set the transition to linear
className=""
>
{children}
</motion.main>
</div>
);
}

View file

@ -1,13 +1,31 @@
"use client";
import "../styles/globals.css"; import "../styles/globals.css";
import StyledComponentsRegistry from "../services/lib/styled-registry"; import StyledComponentsRegistry from "../services/lib/styled-registry";
import { Menu } from "../components/UI/Elements/Menu";
import { motion } from "framer-motion";
export default function RootLayout({ children }: { children: React.ReactNode }) { export default function RootLayout({ children }: { children: React.ReactNode }) {
const variants = {
hidden: { opacity: 0, x: 0, y: 0 },
enter: { opacity: 1, x: 0, y: 0 },
exit: { opacity: 0, x: 0, y: 0 },
};
return ( return (
<html className="" lang="en"> <html className="" lang="en">
<head /> <head />
<body> <body>
<StyledComponentsRegistry>{children}</StyledComponentsRegistry> <StyledComponentsRegistry>
<motion.main
variants={variants} // Pass the variant object into Framer Motion
initial="hidden" // Set the initial state to variants.hidden
animate="enter" // Animated state to variants.enter
exit="exit" // Exit state (used later) to variants.exit
transition={{ type: "linear" }} // Set the transition to linear
className=""
>
{children}
</motion.main>
</StyledComponentsRegistry>
</body> </body>
</html> </html>
); );

View file

@ -34,7 +34,7 @@ const Login = () => {
return ( return (
<div> <div>
<Layout title="Login"> < >
<Header></Header> <Header></Header>
<Title>Login</Title> <Title>Login</Title>
@ -45,7 +45,7 @@ const Login = () => {
Login Login
</button> </button>
</form> </form>
</Layout> </>
</div> </div>
); );
}; };

View file

@ -6,7 +6,7 @@ import learnhouseBigIcon from "public/learnhouse_bigicon.png";
import Image from "next/legacy/image"; import Image from "next/legacy/image";
import Link from "next/link"; import Link from "next/link";
const Home: NextPage = () => { export default function Home() {
return ( return (
<HomePage> <HomePage>
<motion.div <motion.div
@ -89,4 +89,3 @@ const HomePage = styled.div`
} }
`; `;
export default Home;

View file

@ -1,3 +1,4 @@
"use client";
import React from "react"; import React from "react";
import { Header } from "../../components/UI/Header"; import { Header } from "../../components/UI/Header";
import Layout from "../../components/UI/Layout"; import Layout from "../../components/UI/Layout";

View file

@ -34,10 +34,7 @@ const AuthProvider = ({ children }: any) => {
userInfo = await getUserInfo(access_token); userInfo = await getUserInfo(access_token);
setAuth({ access_token, isAuthenticated: true, userInfo, isLoading }); setAuth({ access_token, isAuthenticated: true, userInfo, isLoading });
// if user is authenticated and tries to access login or signup page, redirect to home
if (NON_AUTHENTICATED_ROUTES.includes(router.pathname)) {
router.push("/");
}
} else { } else {
setAuth({ access_token, isAuthenticated: false, userInfo, isLoading }); setAuth({ access_token, isAuthenticated: false, userInfo, isLoading });
//router.push("/login"); //router.push("/login");

3673
front/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -24,7 +24,7 @@
"react": "^18.2.0", "react": "^18.2.0",
"react-beautiful-dnd": "^13.1.1", "react-beautiful-dnd": "^13.1.1",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"styled-components": "^5.3.5", "styled-components": "^6.0.0-beta.9",
"y-indexeddb": "^9.0.9", "y-indexeddb": "^9.0.9",
"y-webrtc": "^10.2.3", "y-webrtc": "^10.2.3",
"yjs": "^13.5.42" "yjs": "^13.5.42"

View file

@ -76,3 +76,5 @@ export async function signup(body: NewAccountBody): Promise<any> {
.then((result) => result.json()) .then((result) => result.json())
.catch((error) => console.log("error", error)); .catch((error) => console.log("error", error));
} }