feat: use Next.js 13 App directory

This commit is contained in:
swve 2023-01-08 21:32:12 +01:00
parent cb3fc9a488
commit 379a0e9859
28 changed files with 418 additions and 295 deletions

View file

@ -10,7 +10,7 @@ interface EditorWrapperProps {
course:any
}
function EditorWrapper(props: EditorWrapperProps) {
function EditorWrapper(props: EditorWrapperProps) : JSX.Element {
// A new Y document
const ydoc = new Y.Doc();
const [providerState, setProviderState] = React.useState<any>({});
@ -33,6 +33,7 @@ function EditorWrapper(props: EditorWrapperProps) {
if (isLoading) {
createRTCProvider();
return <div>Loading...</div>;
} else {
return <Editor course={props.course} element={props.element} content={props.content} setContent={setContent} provider={providerState} ydoc={ydocState}></Editor>;
}

View file

@ -1,6 +1,7 @@
"use client";
import React, { useEffect } from "react";
import { getRefreshToken, getUserInfo } from "../../services/auth/auth";
import { useRouter } from "next/router";
import { useRouter, usePathname } from "next/navigation";
export const AuthContext: any = React.createContext({});
@ -12,7 +13,7 @@ export interface Auth {
isLoading: boolean;
}
const AuthProvider = (props: any) => {
const AuthProvider = ({ children }: any) => {
const router = useRouter();
const [auth, setAuth] = React.useState<Auth>({ access_token: "", isAuthenticated: false, userInfo: {}, isLoading: true });
@ -55,7 +56,7 @@ const AuthProvider = (props: any) => {
};
}, []);
return <AuthContext.Provider value={auth}>{props.children}</AuthContext.Provider>;
return <AuthContext.Provider value={auth}>{children}</AuthContext.Provider>;
};
export default AuthProvider;

View file

@ -1,15 +1,15 @@
"use client";
import React from "react";
import styled from "styled-components";
import { HeaderProfileBox } from "../../Security/HeaderProfileBox";
import learnhouseIcon from "public/learnhouse_icon.png";
import learnhouseLogo from "public/learnhouse_logo.png";
import Link from "next/link";
import Image from "next/legacy/image";
import { useRouter } from "next/router";
import Image from "next/image";
import { useRouter, useSearchParams } from "next/navigation";
import { headers } from 'next/headers';
export const Menu = () => {
const router = useRouter();
const { orgslug } = router.query;
export const Menu = ({orgslug } : any) => {
return (
<GlobalHeader>
@ -30,10 +30,10 @@ export const Menu = () => {
<MenuArea>
<ul>
<li>
<Link href={"/org/" + orgslug + "/courses"}>Courses</Link>
<Link href={ "/courses"}>Courses</Link>
</li>
<li>
<Link href={"/org/" + orgslug + "/collections"}>Collections</Link>
<Link href={ "/collections"}>Collections</Link>
</li>
<li>Activity</li>
<li>More</li>

View file

@ -1,3 +1,4 @@
import React from "react";
import Head from "next/head";
import styled from "styled-components";
@ -13,15 +14,11 @@ const Layout = (props: any) => {
};
return (
<div>
<html>
<body>
<AuthProvider>
<Head>
<title>{props.title}</title>
<meta name="description" content={props.description} />
<link rel="icon" href="/favicon.ico" />
</Head>
<ProjectPhaseLabel>🚧 Dev Phase</ProjectPhaseLabel>
<Menu></Menu>
<Menu orgslug={props.orgslug}></Menu>
<motion.main
variants={variants} // Pass the variant object into Framer Motion
initial="hidden" // Set the initial state to variants.hidden
@ -36,7 +33,8 @@ const Layout = (props: any) => {
<p>LearnHouse © 2021 - {new Date().getFullYear()} - All rights reserved</p>
</Footer>
</AuthProvider>
</div>
</body>
</html>
);
};