From a82a0e6efb7414f155dbf2fc57911be9eeeb4b27 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed <kamranahmed.se@gmail.com> Date: Tue, 18 Mar 2025 00:30:46 +0000 Subject: [PATCH] Moving next should be mark it as done --- .../GenerateCourse/AICourseLesson.tsx | 51 ++++++++++++++----- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/src/components/GenerateCourse/AICourseLesson.tsx b/src/components/GenerateCourse/AICourseLesson.tsx index c64966d16..4ab35c429 100644 --- a/src/components/GenerateCourse/AICourseLesson.tsx +++ b/src/components/GenerateCourse/AICourseLesson.tsx @@ -334,19 +334,44 @@ export function AICourseLesson(props: AICourseLessonProps) { Previous <span className="hidden lg:inline"> Lesson</span> </button> - <button - onClick={onGoToNextLesson} - disabled={cantGoForward} - className={cn( - 'flex items-center rounded-full px-4 py-2 disabled:opacity-50 max-lg:px-3 max-lg:py-1.5 max-lg:text-sm', - cantGoForward - ? 'cursor-not-allowed text-gray-400' - : 'bg-gray-800 text-white hover:bg-gray-700', - )} - > - Next <span className="hidden lg:inline"> Lesson</span> - <ChevronRight size={16} className="ml-2" /> - </button> + <div> + <button + onClick={() => { + if (!isLessonDone) { + toggleDone(undefined, { + onSuccess: () => { + onGoToNextLesson(); + }, + }); + } else { + onGoToNextLesson(); + } + }} + disabled={cantGoForward || isTogglingDone} + className={cn( + 'flex items-center rounded-full px-4 py-2 disabled:opacity-50 max-lg:px-3 max-lg:py-1.5 max-lg:text-sm', + cantGoForward + ? 'cursor-not-allowed text-gray-400' + : 'bg-gray-800 text-white hover:bg-gray-700', + )} + > + {isTogglingDone ? ( + <> + <Loader2Icon + size={16} + strokeWidth={3} + className="animate-spin text-white" + /> + Please wait ... + </> + ) : ( + <> + Next <span className="hidden lg:inline"> Lesson</span> + <ChevronRight size={16} className="ml-2" /> + </> + )} + </button> + </div> </div> </div>