diff --git a/front/components/Drags/Element.tsx b/front/components/Drags/Element.tsx index ba8b46d5..3d5d30d0 100644 --- a/front/components/Drags/Element.tsx +++ b/front/components/Drags/Element.tsx @@ -15,7 +15,7 @@ function Element(props: any) {   -   +   )} diff --git a/front/components/Editor/Editor.tsx b/front/components/Editor/Editor.tsx index 12138f7d..c30ea651 100644 --- a/front/components/Editor/Editor.tsx +++ b/front/components/Editor/Editor.tsx @@ -24,8 +24,6 @@ interface Editor { function Editor(props: Editor) { const auth: any = React.useContext(AuthContext); - console.log(props.element); - console.log(props.course); const editor: any = useEditor({ extensions: [ @@ -53,7 +51,7 @@ function Editor(props: Editor) { return (
- + {!auth.isAuthenticated && Loading} + {auth.isAuthenticated && } - - - + + +
); diff --git a/front/components/Security/AuthProvider.tsx b/front/components/Security/AuthProvider.tsx index 59e4f103..3eb88197 100644 --- a/front/components/Security/AuthProvider.tsx +++ b/front/components/Security/AuthProvider.tsx @@ -12,14 +12,15 @@ export interface Auth { isLoading: boolean; } - const AuthProvider = (props: any) => { const router = useRouter(); const [auth, setAuth] = React.useState({ access_token: "", isAuthenticated: false, userInfo: {}, isLoading: true }); async function checkRefreshToken() { let data = await getRefreshToken(); - return data.access_token; + if (data) { + return data.access_token; + } } async function checkAuth() { @@ -27,13 +28,13 @@ const AuthProvider = (props: any) => { let access_token = await checkRefreshToken(); let userInfo = {}; let isLoading = false; - + if (access_token) { userInfo = await getUserInfo(access_token); 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)) { + if (NON_AUTHENTICATED_ROUTES.includes(router.pathname)) { router.push("/"); } } else { diff --git a/front/pages/org/[orgslug]/course/[courseid]/edit/index.tsx b/front/pages/org/[orgslug]/course/[courseid]/edit/index.tsx index a0ff2f16..5dd3e650 100644 --- a/front/pages/org/[orgslug]/course/[courseid]/edit/index.tsx +++ b/front/pages/org/[orgslug]/course/[courseid]/edit/index.tsx @@ -4,7 +4,7 @@ import styled from "styled-components"; import { Header } from "../../../../../../components//UI/Header"; import Layout from "../../../../../../components//UI/Layout"; import { Title } from "../../../../../../components//UI/Elements/Styles/Title"; -import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd"; +import { DragDropContext, Droppable } from "react-beautiful-dnd"; import { initialData, initialData2 } from "../../../../../../components/Drags/data"; import Chapter from "../../../../../../components/Drags/Chapter"; import { createChapter, deleteChapter, getCourseChaptersMetadata, updateChaptersMetadata } from "../../../../../../services/courses/chapters";