From 967a598154659a2b8378682d9befb6ec9c91dbca Mon Sep 17 00:00:00 2001 From: Mohd Mawan Ahmad Date: Thu, 14 Mar 2024 03:54:53 +0530 Subject: [PATCH] Removed Debug statements --- src/components/Sidebar.tsx | 4 +--- src/components/admin/ContentRendererClient.tsx | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 079ab21c3..836ed972f 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -59,8 +59,6 @@ export function Sidebar({ const pathArray = findPathToContent(fullCourseContent, contentId); if (pathArray) { const path = `/courses/${courseId}/${pathArray.join('/')}`; - console.log(`Path is this ${path}`); - router.push(path); } }; @@ -255,7 +253,7 @@ function Check({ content , pathCheck } : { content: any , pathCheck : any}) { <> { + onChange={async (e) => { setCompleted(!completed); handleMarkAsCompleted(!completed, content.id); setMarkAsComplete({ diff --git a/src/components/admin/ContentRendererClient.tsx b/src/components/admin/ContentRendererClient.tsx index 5badb9fb5..1f04f914e 100644 --- a/src/components/admin/ContentRendererClient.tsx +++ b/src/components/admin/ContentRendererClient.tsx @@ -1,10 +1,12 @@ 'use client'; -import { useSearchParams, useRouter } from 'next/navigation'; +import { useSearchParams, useRouter, usePathname } from 'next/navigation'; // import { QualitySelector } from '../QualitySelector'; import { VideoPlayerSegment } from '@/components/VideoPlayerSegment'; import VideoContentChapters from '../VideoContentChapters'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { handleMarkAsCompleted } from '@/lib/utils'; +import { useRecoilState } from 'recoil'; +import { markAsCompleteAtom } from '@/store/atoms/markAsComplete'; export const ContentRendererClient = ({ metadata, @@ -70,7 +72,10 @@ export const ContentRendererClient = ({ type: 'video/mp4', }; } + const [currentPath] = useState(usePathname()); + const [markAsComplete , setMarkAsComplete] = useRecoilState(markAsCompleteAtom); + const toggleShowChapters = () => { setShowChapters((prev) => !prev); }; @@ -86,8 +91,12 @@ export const ContentRendererClient = ({ setContentCompleted((prev) => !prev); } setLoadingMarkAs(false); + setMarkAsComplete({ + isValid : true, + path : currentPath, + isCompleted : contentCompleted + }) }; - return (
@@ -130,7 +139,8 @@ export const ContentRendererClient = ({ disabled={loadingMarkAs} onClick={handleMarkCompleted} > - {contentCompleted ? 'Mark as Incomplete' : 'Mark as completed'} + {markAsComplete.isValid && markAsComplete?.path === currentPath ? (markAsComplete?.isCompleted ? "Mark as Incomplete" : "Mark as completed") : (contentCompleted ? "Mark as Incomplete" : "Mark as completed")} + {/* {contentCompleted ? 'Mark as Incomplete' : 'Mark as completed'} */}