From 687f7b21169723eb52c39efe8118982ef918c49c Mon Sep 17 00:00:00 2001 From: swve Date: Sat, 8 Jul 2023 13:26:23 +0100 Subject: [PATCH] fix: more bugs --- .../[courseid]/activity/[activityid]/activity.tsx | 2 +- .../(withmenu)/course/[courseid]/course.tsx | 4 ++-- .../(withmenu)/course/[courseid]/edit/page.tsx | 13 +++++++++++++ .../Objects/Modals/Course/Create/CreateCourse.tsx | 3 ++- .../Security/AuthenticatedClientElement.tsx | 4 ++-- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/activity.tsx b/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/activity.tsx index 77d3319f..4086f673 100644 --- a/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/activity.tsx +++ b/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/activity.tsx @@ -107,7 +107,7 @@ export function MarkStatus(props: { activityid: string, course: any, orgslug: st router.refresh(); // refresh page (FIX for Next.js BUG) - window.location.reload(); + //window.location.reload(); } diff --git a/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx b/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx index d1aafc72..865748d6 100644 --- a/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx +++ b/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx @@ -27,7 +27,7 @@ const CourseClient = (props: any) => { router.refresh(); // refresh page (FIX for Next.js BUG) - window.location.reload(); + // window.location.reload(); } async function quitCourse() { @@ -38,7 +38,7 @@ const CourseClient = (props: any) => { router.refresh(); // refresh page (FIX for Next.js BUG) - window.location.reload(); + //window.location.reload(); } 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 5bbecf64..5bf52f01 100644 --- a/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/edit/page.tsx +++ b/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/edit/page.tsx @@ -16,6 +16,7 @@ import Modal from "@components/StyledElements/Modal/Modal"; import { denyAccessToUser } from "@services/utils/react/middlewares/views"; import { Folders, Package2, SaveIcon } from "lucide-react"; import GeneralWrapperStyled from "@components/StyledElements/Wrappers/GeneralWrapper"; +import { revalidateTags } from "@services/utils/ts/requests"; function CourseEdit(params: any) { @@ -75,6 +76,8 @@ function CourseEdit(params: any) { const submitChapter = async (chapter: any) => { await createChapter(chapter, courseid); await getCourseChapters(); + revalidateTags(['courses'], orgslug); + router.refresh(); setNewChapterModal(false); }; @@ -86,6 +89,8 @@ function CourseEdit(params: any) { await createActivity(activity, activity.chapterId, org.org_id); await getCourseChapters(); setNewActivityModal(false); + revalidateTags(['courses'], orgslug); + router.refresh(); }; // Submit File Upload @@ -94,6 +99,8 @@ function CourseEdit(params: any) { await createFileActivity(file, type, activity, chapterId); await getCourseChapters(); setNewActivityModal(false); + revalidateTags(['courses'], orgslug); + router.refresh(); }; // Submit YouTube Video Upload @@ -103,17 +110,23 @@ function CourseEdit(params: any) { await createExternalVideoActivity(external_video_data, activity, chapterId); await getCourseChapters(); setNewActivityModal(false); + revalidateTags(['courses'], orgslug); + router.refresh(); }; const deleteChapterUI = async (chapterId: any) => { console.log("deleteChapter", chapterId); await deleteChapter(chapterId); getCourseChapters(); + revalidateTags(['courses'], orgslug); + router.refresh(); }; const updateChapters = () => { console.log(data); updateChaptersMetadata(courseid, data); + revalidateTags(['courses'], orgslug); + router.refresh(); }; /* diff --git a/front/components/Objects/Modals/Course/Create/CreateCourse.tsx b/front/components/Objects/Modals/Course/Create/CreateCourse.tsx index e9870b9f..dd92a7d1 100644 --- a/front/components/Objects/Modals/Course/Create/CreateCourse.tsx +++ b/front/components/Objects/Modals/Course/Create/CreateCourse.tsx @@ -49,9 +49,10 @@ function CreateCourseModal({ closeModal, orgslug }: any) { if (status.org_id == orgId) { closeModal(); router.refresh(); + revalidateTags(['courses'], orgslug); // refresh page (FIX for Next.js BUG) - window.location.reload(); + // window.location.reload(); } else { alert("Error creating course, please see console logs"); console.log(status); diff --git a/front/components/Security/AuthenticatedClientElement.tsx b/front/components/Security/AuthenticatedClientElement.tsx index 6ced1f88..e46618bd 100644 --- a/front/components/Security/AuthenticatedClientElement.tsx +++ b/front/components/Security/AuthenticatedClientElement.tsx @@ -14,9 +14,9 @@ export const AuthenticatedClientElement = (props: AuthenticatedClientElementProp // Available roles const org_roles_values = ["admin", "owner"]; - const user_roles_values = ["role_admin"]; + const user_roles_values = ["role_admin", "role_super_admin"]; + - function checkRoles() { const org_id = props.orgId;