diff --git a/src/modules/admin/pages/courses/lessons/AddLesson.jsx b/src/modules/admin/pages/courses/lessons/AddLesson.jsx index 14c184d..cfa7f49 100644 --- a/src/modules/admin/pages/courses/lessons/AddLesson.jsx +++ b/src/modules/admin/pages/courses/lessons/AddLesson.jsx @@ -211,7 +211,7 @@ export default function AddLesson() { const navigate = useNavigate(); const { courseId, unitId } = useParams(); const { - createLesson, saveLessonPage, fetchUnit, unit, loading, + createLesson, saveLessonPage, fetchUnit, fetchCourse, unit, course, loading, syncLessonRequirements, } = useCourses(); const { user } = useAuth(); @@ -232,6 +232,9 @@ export default function AddLesson() { useEffect(() => { fetchUnit(courseId, unitId); + if (!course || String(course.course_id) !== String(courseId)) { + fetchCourse(courseId); + } }, [courseId, unitId]); const handleNext = async () => { @@ -288,7 +291,11 @@ export default function AddLesson() {
Add a new lesson to this unit.
++ Creates a new lesson in the shared Lessons Library and attaches it to + {unit ? ` "${unit.title}"` : " this unit"} — affiliated with + {course ? ` "${course.title}"` : " this course"}. +
Update lesson details.
++ Lessons live in the shared Library — changes here apply everywhere this + lesson is used, not just{unit ? ` "${unit.title}"` : " this unit"} + {course ? ` (${course.title})` : ""}. +
{unit.description}
)} ++ Affiliated with course: {course?.title ?? "—"} +
{/* Stats row */} diff --git a/src/modules/admin/pages/courses/units/EditUnit.jsx b/src/modules/admin/pages/courses/units/EditUnit.jsx index 368f9b7..c5eb928 100644 --- a/src/modules/admin/pages/courses/units/EditUnit.jsx +++ b/src/modules/admin/pages/courses/units/EditUnit.jsx @@ -30,7 +30,7 @@ function FieldError({ message }) { export default function EditUnit() { const [unitTitle, setUnitTitle] = useState(""); const { courseId, unitId } = useParams(); - const { fetchUnit, updateUnit, course, loading, fetchUnitRequirements, syncUnitRequirements } = useCourses(); + const { fetchUnit, updateUnit, fetchCourse, course, loading, fetchUnitRequirements, syncUnitRequirements } = useCourses(); const { user } = useAuth(); const navigate = useNavigate(); @@ -51,6 +51,9 @@ export default function EditUnit() { }); setUnitTitle(unit.title ?? ""); })(); + if (!course || String(course.course_id) !== String(courseId)) { + fetchCourse(courseId); + } }, [courseId, unitId]); @@ -76,7 +79,10 @@ export default function EditUnit() {Update unit details.
++ Units live in the shared Library — changes here apply everywhere this unit + is used{course ? `, not just "${course.title}"` : ""}. +