This commit is contained in:
rgrgogu
2026-07-20 03:24:40 +08:00
parent 51133a51a5
commit 84311e632b
4 changed files with 30 additions and 6 deletions
@@ -34,7 +34,7 @@ function FieldError({ message }) {
export default function EditLesson() {
const navigate = useNavigate();
const { courseId, unitId, lessonId } = useParams();
const { fetchLesson, updateLesson, course, unit, loading, fetchLessonRequirements, syncLessonRequirements } = useCourses();
const { fetchLesson, updateLesson, fetchCourse, fetchUnit, course, unit, loading, fetchLessonRequirements, syncLessonRequirements } = useCourses();
const { user } = useAuth();
const [lessonTitle, setLessonTitle] = useState("");
@@ -60,6 +60,10 @@ export default function EditLesson() {
objectives: lesson.objectives?.map((v) => ({ value: v.text })) ?? [],
});
})();
fetchUnit(courseId, unitId);
if (!course || String(course.course_id) !== String(courseId)) {
fetchCourse(courseId);
}
}, [courseId, unitId, lessonId]);
const onSubmit = async (data) => {
@@ -90,7 +94,11 @@ export default function EditLesson() {
</Button>
<div>
<h1 className="text-xl font-semibold">Edit Lesson</h1>
<p className="text-sm text-muted-foreground">Update lesson details.</p>
<p className="text-sm text-muted-foreground">
Lessons live in the shared Library — changes here apply everywhere this
lesson is used, not just{unit ? ` "${unit.title}"` : " this unit"}
{course ? ` (${course.title})` : ""}.
</p>
</div>
</div>