diff --git a/client/src/components/AddCourseModal.tsx b/client/src/components/AddCourseModal.tsx index 7c4eded..b4d82ad 100755 --- a/client/src/components/AddCourseModal.tsx +++ b/client/src/components/AddCourseModal.tsx @@ -51,6 +51,12 @@ const AddCourseModal: React.FC = ({ onClose, refreshData }) }; }, []); + useEffect(() => { + if (activeTab === "text" && currentStep === 3) { + setCurrentStep(2); + } + }, [activeTab, currentStep]); + useEffect(() => { let isCancelled = false; @@ -190,6 +196,11 @@ const AddCourseModal: React.FC = ({ onClose, refreshData }) return; } + if (activeTab === "text") { + handleSubmit(); + return; + } + setSubmitError(""); setCurrentStep(3); }; @@ -205,8 +216,13 @@ const AddCourseModal: React.FC = ({ onClose, refreshData }) return; } - if (!goalValue.trim()) { - setSubmitError("Please add what you want to achieve from this roadmap."); + const userGoalPayload = activeTab === "text" ? textValue.trim() : goalValue.trim(); + if (!userGoalPayload) { + setSubmitError( + activeTab === "text" + ? "Please enter your topic description." + : "Please add what you want to achieve from this roadmap." + ); return; } @@ -227,7 +243,7 @@ const AddCourseModal: React.FC = ({ onClose, refreshData }) } payload.append("time_query", durationValue.trim()); - payload.append("user_goal", goalValue.trim()); + payload.append("user_goal", userGoalPayload); setIsSubmitting(true); setSubmitError(""); @@ -297,24 +313,26 @@ const AddCourseModal: React.FC = ({ onClose, refreshData }) > Duration - + {activeTab !== "text" && ( + + )} - Step {currentStep} of 3 + Step {currentStep} of {activeTab === "text" ? 2 : 3} @@ -559,7 +577,7 @@ const AddCourseModal: React.FC = ({ onClose, refreshData }) > {currentStep === 1 ? "Cancel" : "Back"} - {currentStep === 3 ? ( + {currentStep === (activeTab === "text" ? 2 : 3) ? (