From 5ff89fa184f37ed183b004ab8e05ee5b2cb3db6e Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Fri, 14 Mar 2025 14:46:27 +0000 Subject: [PATCH] Add regenerate lessons --- .../GenerateCourse/AICourseLesson.tsx | 15 ++- .../GenerateCourse/RegenerateLesson.tsx | 100 ++++++++++++++++++ 2 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 src/components/GenerateCourse/RegenerateLesson.tsx diff --git a/src/components/GenerateCourse/AICourseLesson.tsx b/src/components/GenerateCourse/AICourseLesson.tsx index b0e9fd364..c64966d16 100644 --- a/src/components/GenerateCourse/AICourseLesson.tsx +++ b/src/components/GenerateCourse/AICourseLesson.tsx @@ -20,12 +20,13 @@ import { httpPatch } from '../../lib/query-http'; import { slugify } from '../../lib/slugger'; import { getAiCourseLimitOptions, - getAiCourseOptions + getAiCourseOptions, } from '../../queries/ai-course'; import { useIsPaidUser } from '../../queries/billing'; import { queryClient } from '../../stores/query-client'; import { AICourseFollowUp } from './AICourseFollowUp'; import './AICourseFollowUp.css'; +import { RegenerateLesson } from './RegenerateLesson'; type AICourseLessonProps = { courseSlug: string; @@ -78,7 +79,10 @@ export function AICourseLesson(props: AICourseLessonProps) { [activeModuleIndex, activeLessonIndex], ); - const generateAiCourseContent = async () => { + const generateAiCourseContent = async ( + isForce?: boolean, + customPrompt?: string, + ) => { setIsLoading(true); setError(''); setLessonHtml(''); @@ -107,6 +111,8 @@ export function AICourseLesson(props: AICourseLessonProps) { body: JSON.stringify({ moduleIndex: activeModuleIndex, lessonIndex: activeLessonIndex, + isForce, + customPrompt, }), }, ); @@ -219,6 +225,11 @@ export function AICourseLesson(props: AICourseLessonProps) { {!isGenerating && !isLoading && (
+ { + generateAiCourseContent(true, prompt); + }} + /> + {isDropdownVisible && ( +
+ + +
+ )} +
+ + ); +}