@@ -296,10 +296,10 @@ function CourseDetailsTab({ course, loading, instructors, achievementKeys, achie
// ─── Tabs config ───────────────────────────────────────────────────────────────
const TABS = [
- { key: "details", label: "Course Details", icon: BookOpen },
- { key: "progress", label: "Reading Progress", icon: BarChart2 },
- { key: "units", label: "Units", icon: Layers },
- { key: "assessment", label: "Assessment", icon: ClipboardList },
+ { key: "details", label: "Course Details", icon: BookOpen },
+ { key: "assessment", label: "Assessment", icon: ClipboardList },
+ { key: "units", label: "Units", icon: Layers },
+ { key: "progress", label: "Reading Progress", icon: BarChart2 },
];
const WIDE_TABS = new Set(["units", "assessment"]);
@@ -311,29 +311,29 @@ export default function ViewCourse() {
const { courseId } = useParams();
const { fetchCourse, course, loading } = useCourses();
- const [activeTab, setActiveTab] = useState("details");
- const [instructors, setInstructors] = useState([]);
+ const [activeTab, setActiveTab] = useState("details");
+ const [instructors, setInstructors] = useState([]);
const [achievementKeys, setAchievementKeys] = useState([]);
const [achievementRegistry, setAchievementRegistry] = useState([]);
- const [badgeImageUrl, setBadgeImageUrl] = useState(null);
+ const [badgeImageUrl, setBadgeImageUrl] = useState(null);
useEffect(() => {
fetchCourse(courseId);
api.get(`/admin/courses/${courseId}/instructors`)
.then(({ data }) => setInstructors(data.data?.data ?? data.data ?? []))
- .catch(() => {});
+ .catch(() => { });
api.get(`/admin/courses/${courseId}/achievements`)
.then(({ data }) => {
const rows = data?.data?.data ?? [];
setAchievementKeys(rows.map((r) => r.achievement_key));
})
- .catch(() => {});
+ .catch(() => { });
api.get("/admin/achievements")
.then(({ data }) => setAchievementRegistry(data.data ?? []))
- .catch(() => {});
+ .catch(() => { });
}, [courseId]);
useEffect(() => {
@@ -345,7 +345,7 @@ export default function ViewCourse() {
api.post("/admin/media/token", { asset_id: course.badge_asset_id })
.then(({ data }) => {
const thumbUrl = data.data?.thumbnail_url;
- const token = data.data?.token;
+ const token = data.data?.token;
setBadgeImageUrl(thumbUrl ?? (token ? `${STREAM_BASE}/${token}` : null));
})
.catch(() => setBadgeImageUrl(course.badge_image_url ?? null));
diff --git a/src/modules/admin/pages/courses/lessons/AddLesson.jsx b/src/modules/admin/pages/courses/lessons/AddLesson.jsx
index f9f5fa2..aed02e7 100644
--- a/src/modules/admin/pages/courses/lessons/AddLesson.jsx
+++ b/src/modules/admin/pages/courses/lessons/AddLesson.jsx
@@ -7,13 +7,14 @@ import { nanoid } from "nanoid";
import {
ChevronLeft, ChevronRight, Check,
FileText, LayoutTemplate, ListChecks,
- Plus, Trash2,
+ Plus, Trash2, Link2,
} from "lucide-react";
import { useCourses } from "@/contexts/AdminCoursesContext";
import { useAuth } from "@/contexts/AuthContext";
import { PageMeta } from "@/contexts/MetadataContext";
import { cn } from "@/lib/utils";
+import api from "@/utils/api.util";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
@@ -28,6 +29,7 @@ import { AddBlockMenu } from "@/components/generic/AddBlockMenu";
import { PreviewContent, PreviewChrome } from "../../../components/courses/LessonsPreview";
import { useUnsavedChangesGuard } from "@/hooks/useUnsavedChangesGuard";
import DraftRequirementsEditor from "@/modules/admin/components/courses/DraftRequirementsEditor";
+import AttachLessonsDialog from "@/modules/admin/components/library/AttachLessonsDialog";
function makeBlock(type) {
return { id: nanoid(), type, content: { ...DEFAULT_CONTENT[type] } };
@@ -231,8 +233,10 @@ export default function AddLesson() {
} = useCourses();
const { user } = useAuth();
+ const [mode, setMode] = useState(null); // null | "create" — the wizard only shows once "Create" is chosen
const [step, setStep] = useState(0);
const [requirements, setRequirements] = useState([]);
+ const [attachOpen, setAttachOpen] = useState(false);
const {
register, control, trigger, getValues, setValue,
@@ -294,6 +298,14 @@ export default function AddLesson() {
navigate(`/admin/courses/${courseId}/units/${unitId}/lessons`);
};
+ const handleAttachLessons = async (lessonIds) => {
+ for (const lesson_id of lessonIds) {
+ await api.post(`/admin/courses/${courseId}/units/${unitId}/lessons`, { lesson_id });
+ }
+ bypassOnce();
+ navigate(`/admin/courses/${courseId}/units/${unitId}/lessons`);
+ };
+
return (
@@ -301,7 +313,12 @@ export default function AddLesson() {
-
+ (mode === "create" && step > 0 ? setStep(0) : handleBack())}
+ >
@@ -314,93 +331,120 @@ export default function AddLesson() {
- {/* Stepper */}
-
- {STEPS.map((s, i) => {
- const Icon = s.icon;
- const isActive = step === i;
- const isDone = step > i;
+ {/* Select existing vs. create new */}
+
+
+ Attach an existing library lesson to reuse its content, or create a new one from scratch.
+
+
+
setAttachOpen(true)}>
+ Select
+
+
setMode("create")}>
+ Create
+
+
+
- return (
-
-
-
- {isDone ?
:
}
+ {mode === "create" && (
+ <>
+ {/* Stepper */}
+
+ {STEPS.map((s, i) => {
+ const Icon = s.icon;
+ const isActive = step === i;
+ const isDone = step > i;
+
+ return (
+
+
+
+ {isDone ? : }
+
+
+ {s.label}
+
+
+ {i < STEPS.length - 1 && (
+
i ? "bg-emerald-600" : "bg-border"
+ )} />
+ )}
-
- {s.label}
-
-
- {i < STEPS.length - 1 && (
-
i ? "bg-emerald-600" : "bg-border"
- )} />
- )}
-
- );
- })}
-
-
- {/* Step content */}
-
- {step === 0 && (
-
- )}
-
- {step === 1 && (
-
- )}
-
- {step === 2 && (
-
-
- Configure how learners complete this lesson — optional, sensible defaults apply automatically. This is created together with the rest of the lesson when you finish.
-
-
b.type)}
- />
+ );
+ })}
- )}
-
-
-
-
- {step === 0 ? "Cancel" : "Back"}
-
+ {/* Step content */}
+
+ {step === 0 && (
+
+ )}
- {step < 2 ? (
-
- Next
-
-
- ) : (
- // Only the true final step (Requirements) actually persists
- // anything — the lesson, its page content, and any draft
- // requirements are all created together in one shot here.
-
- {loading && }
- Create Lesson
-
- )}
-
+ {step === 1 && (
+
+ )}
+
+ {step === 2 && (
+
+
+ Configure how learners complete this lesson — optional, sensible defaults apply automatically. This is created together with the rest of the lesson when you finish.
+
+
b.type)}
+ />
+
+ )}
+
+
+
+
+
+ {step === 0 ? "Cancel" : "Back"}
+
+
+ {step < 2 ? (
+
+ Next
+
+
+ ) : (
+ // Only the true final step (Requirements) actually persists
+ // anything — the lesson, its page content, and any draft
+ // requirements are all created together in one shot here.
+
+ {loading && }
+ Create Lesson
+
+ )}
+
+ >
+ )}
{unsavedChangesDialog}
+
+
l.lesson_id) ?? []}
+ onAttach={handleAttachLessons}
+ loading={loading}
+ />
);
}
diff --git a/src/modules/admin/pages/task_list/ViewTaskList.jsx b/src/modules/admin/pages/task_list/ViewTaskList.jsx
index e31595d..19c6cf3 100644
--- a/src/modules/admin/pages/task_list/ViewTaskList.jsx
+++ b/src/modules/admin/pages/task_list/ViewTaskList.jsx
@@ -248,7 +248,7 @@ export default function ViewTaskList() {
{index + 1}.
-
+
{task.name ?? `Task ${index + 1}`}
{task.requirements?.length > 0 && (