diff --git a/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/page.tsx b/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/page.tsx index 1ba17cb3..480040f2 100644 --- a/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/page.tsx +++ b/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/page.tsx @@ -2,13 +2,12 @@ import { useRouter } from "next/navigation"; import Link from "next/link"; import React, { useMemo } from "react"; -import Layout from "@components/UI/Layout"; import { getActivity } from "@services/courses/activities"; import { getAPIUrl, getBackendUrl, getUriWithOrg } from "@services/config/config"; -import Canva from "@components/ActivityViews/DynamicCanva/DynamicCanva"; +import Canva from "@components/Pages/Activities/DynamicCanva/DynamicCanva"; import styled from "styled-components"; import { getCourse } from "@services/courses/courses"; -import VideoActivity from "@components/ActivityViews/Video/Video"; +import VideoActivity from "@components/Pages/Activities/Video/Video"; import useSWR, { mutate } from "swr"; import { Check } from "lucide-react"; import { swrFetcher } from "@services/utils/requests"; diff --git a/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/edit/page.tsx b/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/edit/page.tsx index d4be427d..45f0d10f 100644 --- a/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/edit/page.tsx +++ b/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/edit/page.tsx @@ -1,23 +1,24 @@ "use client"; import React from "react"; + import { useState, useEffect } from "react"; 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 } from "react-beautiful-dnd"; -import { initialData, initialData2 } from "@components/Drags/data"; -import Chapter from "@components/Drags/Chapter"; +import { initialData, initialData2 } from "@components/Pages/CourseEdit/Draggables/data"; +import Chapter from "@components/Pages/CourseEdit/Draggables/Chapter"; import { createChapter, deleteChapter, getCourseChaptersMetadata, updateChaptersMetadata } from "@services/courses/chapters"; import { useRouter } from "next/navigation"; -import NewChapterModal from "@components/Modals/CourseEdit/NewChapter"; -import NewActivityModal from "@components/Modals/CourseEdit/NewActivity"; +import NewChapterModal from "@components/Pages/CourseEdit/NewChapter"; +import NewActivityModal from "@components/Pages/CourseEdit/NewActivity"; import { createActivity, createFileActivity } from "@services/courses/activities"; import { getOrganizationContextInfo } from "@services/organizations/orgs"; +import Modal from "@components/UI/Modal/Modal"; +import AuthProvider from "@components/Security/AuthProvider"; function CourseEdit(params: any) { - const router = useRouter(); + const router = useRouter(); // Initial Course State const [data, setData] = useState(initialData2) as any; @@ -32,12 +33,15 @@ function CourseEdit(params: any) { const courseid = params.params.courseid; const orgslug = params.params.orgslug; - - async function getCourseChapters() { - const courseChapters = await getCourseChaptersMetadata(courseid); - setData(courseChapters); - console.log("courseChapters", courseChapters); + try { + const courseChapters = await getCourseChaptersMetadata(courseid); + setData(courseChapters); + } catch (error: any) { + if (error.status === 401) { + router.push("/login"); + } + } } useEffect(() => { @@ -106,9 +110,7 @@ function CourseEdit(params: any) { }; /* - Modals - */ const openNewActivityModal = async (chapterId: any) => { @@ -123,6 +125,8 @@ function CourseEdit(params: any) { }; const closeNewActivityModal = () => { + console.log("closeNewActivityModal"); + setNewActivityModal(false); }; @@ -233,13 +237,22 @@ function CourseEdit(params: any) { Edit Course {" "} - <button - onClick={() => { - setNewChapterModal(true); - }} - > - Add chapter + - </button> + <Modal + isDialogOpen={newChapterModal} + onOpenChange={setNewChapterModal} + minHeight="sm" + dialogContent={<NewChapterModal + closeModal={closeNewChapterModal} + submitChapter={submitChapter} + ></NewChapterModal>} + dialogTitle="Create chapter" + dialogDescription="Add a new chapter to the course" + dialogTrigger={ + <button> Add chapter + + </button> + } + /> + <button onClick={() => { updateChapters(); @@ -247,16 +260,23 @@ function CourseEdit(params: any) { > Save </button> - - {newChapterModal && } - {newActivityModal && ( - - + + - )} + >} + dialogTitle="Create Activity" + dialogDescription="Choose between types of activities to add to the course" + + />
{winReady && ( @@ -287,7 +307,7 @@ function CourseEdit(params: any) { )} -
+ ); } diff --git a/front/app/_orgs/[orgslug]/(withmenu)/courses/new/page.tsx b/front/app/_orgs/[orgslug]/(withmenu)/courses/new/page.tsx index 435bbb24..a615e102 100644 --- a/front/app/_orgs/[orgslug]/(withmenu)/courses/new/page.tsx +++ b/front/app/_orgs/[orgslug]/(withmenu)/courses/new/page.tsx @@ -1,8 +1,6 @@ "use client"; import { useRouter } from "next/navigation"; import React from "react"; -import { Header } from "@components/UI/Header"; -import Layout from "@components/UI/Layout"; import { Title } from "@components/UI/Elements/Styles/Title"; import { createNewCourse } from "@services/courses/courses"; import { getOrganizationContextInfo } from "@services/organizations/orgs"; diff --git a/front/app/_orgs/[orgslug]/settings/layout.tsx b/front/app/_orgs/[orgslug]/settings/layout.tsx index 6ea3bb6b..ce669246 100644 --- a/front/app/_orgs/[orgslug]/settings/layout.tsx +++ b/front/app/_orgs/[orgslug]/settings/layout.tsx @@ -3,18 +3,16 @@ import React, { createContext, useState } from 'react' import { styled } from '@stitches/react'; import Link from 'next/link'; import LearnHouseWhiteLogo from '@public/learnhouse_text_white.png'; -import { AuthContext } from '@components/Security/AuthProvider'; +import AuthProvider, { AuthContext } from '@components/Security/AuthProvider'; import Avvvatars from 'avvvatars-react'; import Image from 'next/image'; - - - function SettingsLayout({ children, params }: { children: React.ReactNode, params: any }) { const auth: any = React.useContext(AuthContext); return ( - <> + <> +
diff --git a/front/app/layout.tsx b/front/app/layout.tsx index fc7645c4..dfad1471 100644 --- a/front/app/layout.tsx +++ b/front/app/layout.tsx @@ -1,6 +1,6 @@ "use client"; import "../styles/globals.css"; -import StyledComponentsRegistry from "../components/lib/styled-registry"; +import StyledComponentsRegistry from "../components/UI/libs/styled-registry"; import { motion } from "framer-motion"; export default function RootLayout({ children }: { children: React.ReactNode }) { diff --git a/front/app/login/page.tsx b/front/app/login/page.tsx index 19bf4ba7..50698b2a 100644 --- a/front/app/login/page.tsx +++ b/front/app/login/page.tsx @@ -1,8 +1,6 @@ "use client"; import { useRouter } from 'next/navigation'; import React from "react"; -import { Header } from "../../components/UI/Header"; -import Layout from "../../components/UI/Layout"; import { Title } from "../../components/UI/Elements/Styles/Title"; import { loginAndGetToken } from "../../services/auth/auth"; @@ -35,7 +33,6 @@ const Login = () => { return (
< > -
Login
diff --git a/front/app/organizations/new/page.tsx b/front/app/organizations/new/page.tsx index a645e3d8..6fa3dcb3 100644 --- a/front/app/organizations/new/page.tsx +++ b/front/app/organizations/new/page.tsx @@ -1,6 +1,5 @@ "use client"; import React from "react"; -import Layout from "../../../components/UI/Layout"; import { Title } from "../../../components/UI/Elements/Styles/Title"; import { createNewOrganization } from "../../../services/organizations/orgs"; @@ -34,7 +33,7 @@ const Organizations = () => { }; return ( - +
New Organization Name:
@@ -45,7 +44,7 @@ const Organizations = () => { Email Address:
- +
); }; diff --git a/front/app/organizations/page.tsx b/front/app/organizations/page.tsx index 93ef7e4d..ba286b4c 100644 --- a/front/app/organizations/page.tsx +++ b/front/app/organizations/page.tsx @@ -1,12 +1,12 @@ "use client"; //todo: use server components import Link from "next/link"; import React from "react"; -import Layout from "../../components/UI/Layout"; import { Title } from "../../components/UI/Elements/Styles/Title"; import { deleteOrganizationFromBackend } from "@services/organizations/orgs"; import useSWR, { mutate } from "swr"; import { swrFetcher } from "@services/utils/requests"; import { getAPIUrl, getUriWithOrg } from "@services/config/config"; +import AuthProvider from "@components/Security/AuthProvider"; const Organizations = () => { const { data : organizations , error } = useSWR(`${getAPIUrl()}orgs/user/page/1/limit/10`, swrFetcher) @@ -18,6 +18,7 @@ const Organizations = () => { return ( <> + Your Organizations{" "} <Link href={"/organizations/new"}> diff --git a/front/app/signup/page.tsx b/front/app/signup/page.tsx index 6c30f89d..2860c4d8 100644 --- a/front/app/signup/page.tsx +++ b/front/app/signup/page.tsx @@ -1,7 +1,5 @@ "use client"; import React from "react"; -import { Header } from "../../components/UI/Header"; -import Layout from "../../components/UI/Layout"; import { Title } from "../../components/UI/Elements/Styles/Title"; import { signup } from "../../services/auth/auth"; @@ -31,8 +29,7 @@ const SignUp = () => { return ( <div> - <Layout title="Sign up"> - <Header></Header> + <div title="Sign up"> <Title>Sign up @@ -43,7 +40,7 @@ const SignUp = () => { Sign up -
+
); }; diff --git a/front/components/Modals/CourseEdit/NewActivity.tsx b/front/components/Modals/CourseEdit/NewActivity.tsx deleted file mode 100644 index f82d4d50..00000000 --- a/front/components/Modals/CourseEdit/NewActivity.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import React, { useState } from "react"; -import { ArrowLeftIcon, Cross1Icon } from "@radix-ui/react-icons"; -import Modal from "../Modal"; -import styled from "styled-components"; -import DynamicCanvaModal from "./NewActivityModal/DynamicCanva"; -import VideoModal from "./NewActivityModal/Video"; - -function NewActivityModal({ closeModal, submitActivity, submitFileActivity, chapterId }: any) { - const [selectedView, setSelectedView] = useState("home"); - - return ( - - - -

Add New Activity

-
- - {selectedView === "home" && ( - - {setSelectedView("dynamic")}}>✨📄 - {setSelectedView("video")}}>📹 - - )} - - {selectedView === "dynamic" && ( - - )} - - {selectedView === "video" && ( - - )} - -
- ); -} - -const ActivityChooserWrapper = styled.div` - display: flex; - flex-direction: row; - align-items: center; - justify-content: center; - gap: 20px; -`; - -const ActivityButton = styled.button` - padding: 40px; - border-radius: 10px !important; - border: none; - font-size: 80px !important; - margin: 40px; - background-color: #8c949c33 !important; - cursor: pointer; - &:hover { - background-color: #8c949c7b; - } -`; - -export default NewActivityModal; diff --git a/front/components/Modals/CourseEdit/NewActivityModal/DynamicCanva.tsx b/front/components/Modals/CourseEdit/NewActivityModal/DynamicCanva.tsx deleted file mode 100644 index e53052d3..00000000 --- a/front/components/Modals/CourseEdit/NewActivityModal/DynamicCanva.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import React, { useState } from "react"; - -function DynamicCanvaModal({ submitActivity, chapterId }: any) { - const [activityName, setActivityName] = useState(""); - const [activityDescription, setActivityDescription] = useState(""); - - const handleActivityNameChange = (e: any) => { - setActivityName(e.target.value); - }; - - const handleActivityDescriptionChange = (e: any) => { - setActivityDescription(e.target.value); - }; - - const handleSubmit = async (e: any) => { - e.preventDefault(); - console.log({ activityName, activityDescription, chapterId }); - submitActivity({ - name: activityName, - chapterId: chapterId, - type: "dynamic", - }); - }; - return ( -
-
-
- -
- -
-
- ); -} - -export default DynamicCanvaModal; diff --git a/front/components/Modals/CourseEdit/NewActivityModal/Video.tsx b/front/components/Modals/CourseEdit/NewActivityModal/Video.tsx deleted file mode 100644 index 1c8f03ae..00000000 --- a/front/components/Modals/CourseEdit/NewActivityModal/Video.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import React from "react"; - -function VideoModal({ submitFileActivity, chapterId }: any) { - const [video, setVideo] = React.useState(null) as any; - const [name, setName] = React.useState(""); - - const handleVideoChange = (event: React.ChangeEvent) => { - setVideo(event.target.files[0]); - }; - - const handleNameChange = (event: React.ChangeEvent) => { - setName(event.target.value); - }; - - const handleSubmit = async (e: any) => { - e.preventDefault(); - let status = await submitFileActivity(video, "video", { name, type: "video" }, chapterId); - }; - - /* TODO : implement some sort of progress bar for file uploads, it is not possible yet because i'm not using axios. - and the actual upload isn't happening here anyway, it's in the submitFileActivity function */ - - return ( -
- -
-
- -
- -
- -
- ); -} - -export default VideoModal; diff --git a/front/components/Modals/CourseEdit/NewChapter.tsx b/front/components/Modals/CourseEdit/NewChapter.tsx deleted file mode 100644 index 1910ebde..00000000 --- a/front/components/Modals/CourseEdit/NewChapter.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import React, { useState } from "react"; -import Modal from "../Modal"; - -function NewChapterModal({ submitChapter , closeModal }: any) { - const [chapterName, setChapterName] = useState(""); - const [chapterDescription, setChapterDescription] = useState(""); - - const handleChapterNameChange = (e: any) => { - setChapterName(e.target.value); - }; - - const handleChapterDescriptionChange = (e: any) => { - setChapterDescription(e.target.value); - }; - - const handleSubmit = async (e: any) => { - e.preventDefault(); - console.log({ chapterName, chapterDescription }); - submitChapter({ name : chapterName, description : chapterDescription , activities : [] }); - }; - - return ( - -

Add New Chapter

-
- -
- -
- ); -} - -export default NewChapterModal; diff --git a/front/components/Modals/Modal.tsx b/front/components/Modals/Modal.tsx deleted file mode 100644 index 7923df5b..00000000 --- a/front/components/Modals/Modal.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import React from "react"; -import styled from "styled-components"; -import { motion, AnimatePresence } from "framer-motion"; - -function Modal(props: any) { - return ( -
- - - - {props.children} - - - -
- ); -} - -const Overlay = styled.div` - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - z-index: 100; - background-color: #00000029; - backdrop-filter: blur(1px); - -`; - -const Content = styled.div` - background-color: white; - border-radius: 5px; - padding: 20px; - width: 500px; - height: 500px; - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - box-shadow: 0px 64px 84px 15px rgb(0 0 0 / 10%); -`; -export default Modal; diff --git a/front/components/ActivityViews/DynamicCanva/DynamicCanva.tsx b/front/components/Pages/Activities/DynamicCanva/DynamicCanva.tsx similarity index 100% rename from front/components/ActivityViews/DynamicCanva/DynamicCanva.tsx rename to front/components/Pages/Activities/DynamicCanva/DynamicCanva.tsx diff --git a/front/components/ActivityViews/Video/Video.tsx b/front/components/Pages/Activities/Video/Video.tsx similarity index 100% rename from front/components/ActivityViews/Video/Video.tsx rename to front/components/Pages/Activities/Video/Video.tsx diff --git a/front/components/Drags/Activity.tsx b/front/components/Pages/CourseEdit/Draggables/Activity.tsx similarity index 100% rename from front/components/Drags/Activity.tsx rename to front/components/Pages/CourseEdit/Draggables/Activity.tsx diff --git a/front/components/Drags/Chapter.tsx b/front/components/Pages/CourseEdit/Draggables/Chapter.tsx similarity index 98% rename from front/components/Drags/Chapter.tsx rename to front/components/Pages/CourseEdit/Draggables/Chapter.tsx index f4253593..850e189a 100644 --- a/front/components/Drags/Chapter.tsx +++ b/front/components/Pages/CourseEdit/Draggables/Chapter.tsx @@ -21,8 +21,11 @@ function Chapter(props: any) { props.openNewActivityModal(props.info.list.chapter.id); }} > + Create Activity + +