Align admin panel with unified LMS hierarchy

This commit is contained in:
Yared Yemane 2026-10-22 13:47:25 +03:00
parent a9ee56cfa7
commit 61c0b1c276
52 changed files with 534 additions and 891 deletions

View File

@ -31,6 +31,8 @@ import type {
UpdateModuleStatusRequest, UpdateModuleStatusRequest,
GetQuestionSetsResponse, GetQuestionSetsResponse,
GetQuestionSetsParams, GetQuestionSetsParams,
ExamPrepAssessmentParent,
ExamPrepAssessmentLinkRequest,
GetQuestionSetDetailResponse, GetQuestionSetDetailResponse,
GetQuestionSetQuestionsResponse, GetQuestionSetQuestionsResponse,
GetPracticeQuestionsByPracticeResponse, GetPracticeQuestionsByPracticeResponse,
@ -1164,6 +1166,17 @@ export const getPracticesByModule = (moduleId: number) =>
export const getQuestionSets = (params?: GetQuestionSetsParams) => export const getQuestionSets = (params?: GetQuestionSetsParams) =>
http.get<GetQuestionSetsResponse>("/question-sets", { params }) http.get<GetQuestionSetsResponse>("/question-sets", { params })
export const getExamPrepAssessments = (parent: ExamPrepAssessmentParent) =>
http.get<GetQuestionSetsResponse>("/exam-prep/assessments", {
params: { parent_kind: parent.kind, parent_id: parent.id },
})
export const linkExamPrepAssessment = (data: ExamPrepAssessmentLinkRequest) =>
http.post("/exam-prep/assessments", data)
export const unlinkExamPrepAssessment = (questionSetId: number, parent: ExamPrepAssessmentParent) =>
http.delete(`/exam-prep/assessments/${questionSetId}/parents/${parent.kind}/${parent.id}`)
export const getQuestionSetsByOwner = (ownerType: string, ownerId: number) => export const getQuestionSetsByOwner = (ownerType: string, ownerId: number) =>
http.get<GetQuestionSetsResponse>("/question-sets/by-owner", { http.get<GetQuestionSetsResponse>("/question-sets/by-owner", {
params: { params: {

View File

@ -14,11 +14,9 @@ import {
} from "../types/user.types"; } from "../types/user.types";
import type { import type {
LearningActivityAccess, LearningActivityAccess,
LearningActivityCompletedIds,
LearningActivityCourse, LearningActivityCourse,
LearningActivityLesson, LearningActivityLesson,
LearningActivityModule, LearningActivityModule,
LearningActivityProgram,
LearningActivityUnit, LearningActivityUnit,
UserLearningActivityData, UserLearningActivityData,
UserLearningActivityResponse, UserLearningActivityResponse,
@ -152,14 +150,10 @@ function normalizeLearningActivityModule(raw: unknown): LearningActivityModule |
.filter((entry): entry is LearningActivityLesson => entry !== null) .filter((entry): entry is LearningActivityLesson => entry !== null)
: []; : [];
const programId = Number(raw.program_id);
const courseId = Number(raw.course_id);
const unitId = Number(raw.unit_id); const unitId = Number(raw.unit_id);
return { return {
id, id,
program_id: Number.isFinite(programId) ? programId : undefined,
course_id: Number.isFinite(courseId) ? courseId : undefined,
unit_id: Number.isFinite(unitId) ? unitId : undefined, unit_id: Number.isFinite(unitId) ? unitId : undefined,
name: String(raw.name ?? ""), name: String(raw.name ?? ""),
access: normalizeLearningActivityAccess(raw.access), access: normalizeLearningActivityAccess(raw.access),
@ -208,12 +202,10 @@ function normalizeLearningActivityCourse(raw: unknown): LearningActivityCourse |
.filter((entry): entry is LearningActivityUnit => entry !== null) .filter((entry): entry is LearningActivityUnit => entry !== null)
: undefined; : undefined;
const programId = Number(raw.program_id);
const catalogCourseId = Number(raw.catalog_course_id); const catalogCourseId = Number(raw.catalog_course_id);
return { return {
id, id,
program_id: Number.isFinite(programId) ? programId : undefined,
catalog_course_id: Number.isFinite(catalogCourseId) ? catalogCourseId : undefined, catalog_course_id: Number.isFinite(catalogCourseId) ? catalogCourseId : undefined,
name: String(raw.name ?? ""), name: String(raw.name ?? ""),
access: normalizeLearningActivityAccess(raw.access), access: normalizeLearningActivityAccess(raw.access),
@ -222,58 +214,11 @@ function normalizeLearningActivityCourse(raw: unknown): LearningActivityCourse |
}; };
} }
function normalizeLearningActivityProgram(raw: unknown): LearningActivityProgram | null {
if (!isRecord(raw)) return null;
const id = Number(raw.id);
if (!Number.isFinite(id)) return null;
const coursesRaw = raw.courses;
const courses = Array.isArray(coursesRaw)
? coursesRaw
.map((entry) => normalizeLearningActivityCourse(entry))
.filter((entry): entry is LearningActivityCourse => entry !== null)
: [];
return {
id,
name: String(raw.name ?? ""),
access: normalizeLearningActivityAccess(raw.access),
courses,
};
}
function normalizeCompletedIds(raw: unknown): LearningActivityCompletedIds {
if (!isRecord(raw)) {
return { lesson_ids: [], module_ids: [], course_ids: [], program_ids: [] };
}
const toIds = (value: unknown) =>
Array.isArray(value)
? value.map((entry) => Number(entry)).filter((entry) => Number.isFinite(entry))
: [];
return {
lesson_ids: toIds(raw.lesson_ids),
module_ids: toIds(raw.module_ids),
course_ids: toIds(raw.course_ids),
program_ids: toIds(raw.program_ids),
};
}
export function normalizeUserLearningActivity(raw: unknown): UserLearningActivityData | null { export function normalizeUserLearningActivity(raw: unknown): UserLearningActivityData | null {
if (!isRecord(raw)) return null; if (!isRecord(raw)) return null;
const userId = Number(raw.user_id); const userId = Number(raw.user_id);
if (!Number.isFinite(userId)) return null; if (!Number.isFinite(userId)) return null;
const lmsRaw = isRecord(raw.lms) ? raw.lms : {};
const lmsProgressRaw = isRecord(lmsRaw.progress) ? lmsRaw.progress : {};
const programsRaw = lmsProgressRaw.programs;
const programs = Array.isArray(programsRaw)
? programsRaw
.map((entry) => normalizeLearningActivityProgram(entry))
.filter((entry): entry is LearningActivityProgram => entry !== null)
: [];
const examPrepRaw = isRecord(raw.exam_prep) ? raw.exam_prep : {}; const examPrepRaw = isRecord(raw.exam_prep) ? raw.exam_prep : {};
const examProgressRaw = isRecord(examPrepRaw.progress) ? examPrepRaw.progress : {}; const examProgressRaw = isRecord(examPrepRaw.progress) ? examPrepRaw.progress : {};
const catalogCoursesRaw = examProgressRaw.catalog_courses; const catalogCoursesRaw = examProgressRaw.catalog_courses;
@ -283,19 +228,10 @@ export function normalizeUserLearningActivity(raw: unknown): UserLearningActivit
.filter((entry): entry is LearningActivityCourse => entry !== null) .filter((entry): entry is LearningActivityCourse => entry !== null)
: []; : [];
const lmsCompletionsRaw = isRecord(lmsRaw.completions) ? lmsRaw.completions : {};
const examCompletionsRaw = isRecord(examPrepRaw.completions) ? examPrepRaw.completions : {}; const examCompletionsRaw = isRecord(examPrepRaw.completions) ? examPrepRaw.completions : {};
return { return {
user_id: userId, user_id: userId,
lms: {
completed_ids: normalizeCompletedIds(lmsRaw.completed_ids),
progress: { programs },
completions: {
user_id: Number(lmsCompletionsRaw.user_id) || userId,
programs: Array.isArray(lmsCompletionsRaw.programs) ? lmsCompletionsRaw.programs : [],
},
},
exam_prep: { exam_prep: {
progress: { catalog_courses: catalogCourses }, progress: { catalog_courses: catalogCourses },
completions: { completions: {

View File

@ -19,12 +19,8 @@ import { AddVideoPage } from "../pages/content-management/AddVideoPage";
import { AddPracticePage } from "../pages/content-management/AddPracticePage"; import { AddPracticePage } from "../pages/content-management/AddPracticePage";
import { NewContentPage } from "../pages/content-management/NewContentPage"; import { NewContentPage } from "../pages/content-management/NewContentPage";
import { ReorderContentPage } from "../pages/content-management/ReorderContentPage"; import { ReorderContentPage } from "../pages/content-management/ReorderContentPage";
import { LearnEnglishPage } from "../pages/content-management/LearnEnglishPage";
import { ProgramCoursesPage } from "../pages/content-management/ProgramCoursesPage";
import { CourseDetailPage } from "../pages/content-management/CourseDetailPage";
import { LessonPracticesPage } from "../pages/content-management/LessonPracticesPage"; import { LessonPracticesPage } from "../pages/content-management/LessonPracticesPage";
import { ModuleDetailPage } from "../pages/content-management/ModuleDetailPage"; import { LessonAssessmentsPage } from "../pages/content-management/LessonAssessmentsPage";
import { AddVideoFlow } from "../pages/content-management/AddVideoFlow";
import { AddPracticeFlow } from "../pages/content-management/AddPracticeFlow"; import { AddPracticeFlow } from "../pages/content-management/AddPracticeFlow";
import { LinkExistingPracticeFlow } from "../pages/content-management/LinkExistingPracticeFlow"; import { LinkExistingPracticeFlow } from "../pages/content-management/LinkExistingPracticeFlow";
import { EditPracticeFlow } from "../pages/content-management/EditPracticeFlow"; import { EditPracticeFlow } from "../pages/content-management/EditPracticeFlow";
@ -33,7 +29,6 @@ import { ProgramTypeSelectionPage } from "../pages/content-management/ProgramTyp
import { ProgramDetailPage } from "../pages/content-management/ProgramDetailPage"; import { ProgramDetailPage } from "../pages/content-management/ProgramDetailPage";
import { CourseManagementPage } from "../pages/content-management/CourseManagementPage"; import { CourseManagementPage } from "../pages/content-management/CourseManagementPage";
import { UnitManagementPage } from "../pages/content-management/UnitManagementPage"; import { UnitManagementPage } from "../pages/content-management/UnitManagementPage";
import { InitialAssessmentPage } from "../pages/content-management/InitialAssessmentPage";
import { QuestionTypeLibraryPage } from "../pages/content-management/QuestionTypeLibraryPage"; import { QuestionTypeLibraryPage } from "../pages/content-management/QuestionTypeLibraryPage";
import { CreateQuestionTypeFlow } from "../pages/content-management/CreateQuestionTypeFlow"; import { CreateQuestionTypeFlow } from "../pages/content-management/CreateQuestionTypeFlow";
import { NotFoundPage } from "../pages/NotFoundPage"; import { NotFoundPage } from "../pages/NotFoundPage";
@ -172,6 +167,7 @@ export function AppRoutes() {
<Route path="practices" element={<PracticeDetailsPage />} /> <Route path="practices" element={<PracticeDetailsPage />} />
<Route path="practices/members" element={<PracticeMembersPage />} /> <Route path="practices/members" element={<PracticeMembersPage />} />
<Route path="questions" element={<QuestionsPage />} /> <Route path="questions" element={<QuestionsPage />} />
<Route path="question-sets/:practiceId/questions" element={<PracticeQuestionsPage />} />
<Route path="questions/add" element={<AddQuestionPage />} /> <Route path="questions/add" element={<AddQuestionPage />} />
<Route path="questions/edit/:id" element={<AddQuestionPage />} /> <Route path="questions/edit/:id" element={<AddQuestionPage />} />
</Route> </Route>
@ -182,13 +178,21 @@ export function AppRoutes() {
path="/new-content/courses" path="/new-content/courses"
element={<ProgramTypeSelectionPage />} element={<ProgramTypeSelectionPage />}
/> />
<Route
path="/new-content/courses/proficiency"
element={<Navigate to="/new-content/courses/ielts" replace />}
/>
<Route
path="/new-content/courses/skill-based"
element={<Navigate to="/new-content/courses/education" replace />}
/>
<Route <Route
path="/new-content/question-types" path="/new-content/question-types"
element={<QuestionTypeLibraryPage />} element={<QuestionTypeLibraryPage />}
/> />
<Route <Route
path="/new-content/initial-assessment" path="/new-content/initial-assessment"
element={<InitialAssessmentPage />} element={<Navigate to="/new-content/courses/education" replace />}
/> />
<Route <Route
path="/new-content/question-types/:definitionId/create-practice" path="/new-content/question-types/:definitionId/create-practice"
@ -266,53 +270,17 @@ export function AppRoutes() {
path="/new-content/courses/:programType/:courseId/:unitId/:moduleId/lessons/:lessonId/practices" path="/new-content/courses/:programType/:courseId/:unitId/:moduleId/lessons/:lessonId/practices"
element={<LessonPracticesPage />} element={<LessonPracticesPage />}
/> />
<Route
path="/new-content/courses/:programType/:courseId/:unitId/:moduleId/lessons/:lessonId/assessments"
element={<LessonAssessmentsPage />}
/>
<Route <Route
path="/new-content/courses/:programType/:courseId/:unitId/:moduleId/lessons/:lessonId/edit-practice/:practiceId" path="/new-content/courses/:programType/:courseId/:unitId/:moduleId/lessons/:lessonId/edit-practice/:practiceId"
element={<EditPracticeFlow />} element={<EditPracticeFlow />}
/> />
<Route <Route
path="/new-content/learn-english" path="/new-content/learn-english/*"
element={<LearnEnglishPage />} element={<Navigate to="/new-content/courses/education" replace />}
/>
<Route
path="/new-content/learn-english/:level/courses"
element={<ProgramCoursesPage />}
/>
<Route
path="/new-content/learn-english/:level/courses/:courseId"
element={<CourseDetailPage />}
/>
<Route
path="/new-content/learn-english/:level/courses/:courseId/modules/:moduleId"
element={<ModuleDetailPage />}
/>
<Route
path="/new-content/learn-english/:level/courses/:courseId/modules/:moduleId/add-video"
element={<AddVideoFlow />}
/>
<Route
path="/new-content/learn-english/:level/courses/:courseId/modules/:moduleId/lessons/:lessonId/practices"
element={<LessonPracticesPage />}
/>
<Route
path="/new-content/learn-english/:level/courses/:courseId/edit-practice/:practiceId"
element={<EditPracticeFlow />}
/>
<Route
path="/new-content/learn-english/:level/courses/:courseId/modules/:moduleId/edit-practice/:practiceId"
element={<EditPracticeFlow />}
/>
<Route
path="/new-content/learn-english/:level/courses/:courseId/modules/:moduleId/lessons/:lessonId/edit-practice/:practiceId"
element={<EditPracticeFlow />}
/>
<Route
path="/new-content/learn-english/:level/courses/add-practice"
element={<AddPracticeFlow />}
/>
<Route
path="/new-content/learn-english/:level/courses/attach-practice"
element={<LinkExistingPracticeFlow />}
/> />
<Route path="/personas" element={<PersonasPage />} /> <Route path="/personas" element={<PersonasPage />} />

Binary file not shown.

After

Width:  |  Height:  |  Size: 1010 KiB

View File

@ -14,7 +14,7 @@ import {
CreditCard, CreditCard,
UsersRound, UsersRound,
} from "lucide-react" } from "lucide-react"
import spinnerSrc from "../assets/Circular-indeterminate progress indicator.svg" import spinnerSrc from "../assets/05d37a91-04f9-41d8-99a2-b11bf20a6af2.png"
import { import {
Area, Area,
AreaChart, AreaChart,
@ -330,7 +330,6 @@ export function DashboardPage() {
label="Videos" label="Videos"
value={dashboard.courses.total_videos.toLocaleString()} value={dashboard.courses.total_videos.toLocaleString()}
deltaLabel={getVideoLessonsSummary( deltaLabel={getVideoLessonsSummary(
dashboard.courses.lms?.lessons_with_video,
dashboard.courses.exam_prep?.lessons_with_video, dashboard.courses.exam_prep?.lessons_with_video,
)} )}
deltaPositive={dashboard.courses.total_videos > 0} deltaPositive={dashboard.courses.total_videos > 0}

View File

@ -1,5 +1,6 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { useEffect, useState, type ElementType, type ReactNode } from "react" import { useEffect, useState, type ElementType, type ReactNode } from "react"
import spinnerSrc from "../../assets/Circular-indeterminate progress indicator.svg" import spinnerSrc from "../../assets/05d37a91-04f9-41d8-99a2-b11bf20a6af2.png"
import { import {
Area, Area,
AreaChart, AreaChart,
@ -407,7 +408,6 @@ export function AnalyticsPage() {
const { users, subscriptions, payments, courses, content, notifications, team, videos } = dashboard const { users, subscriptions, payments, courses, content, notifications, team, videos } = dashboard
const subscriptionMetrics = getSubscriptionMetrics(subscriptions) const subscriptionMetrics = getSubscriptionMetrics(subscriptions)
const seriesPeriodLabel = getSeriesPeriodLabel(dashboard.date_filter) const seriesPeriodLabel = getSeriesPeriodLabel(dashboard.date_filter)
const lms = courses.lms
const examPrep = courses.exam_prep const examPrep = courses.exam_prep
const registrationData = users.registrations_last_30_days.map((d) => ({ const registrationData = users.registrations_last_30_days.map((d) => ({
@ -485,7 +485,7 @@ export function AnalyticsPage() {
</span> </span>
<AnalyticsTimeRangeFilter value={filters} onChange={setFilters} /> <AnalyticsTimeRangeFilter value={filters} onChange={setFilters} />
<Button variant="outline" size="sm" onClick={() => fetchData(filters)} disabled={loading}> <Button variant="outline" size="sm" onClick={() => fetchData(filters)} disabled={loading}>
<RefreshCw className={cn("mr-2 h-3.5 w-3.5", loading && "animate-spin")} /> {loading ? <SpinnerIcon className="mr-2 h-3.5 w-3.5" /> : <RefreshCw className="mr-2 h-3.5 w-3.5" />}
Refresh Refresh
</Button> </Button>
</div> </div>
@ -909,16 +909,16 @@ export function AnalyticsPage() {
/> />
<KpiCard <KpiCard
icon={BookOpen} icon={BookOpen}
label="LMS Programs" label="Catalog courses"
value={(lms?.programs ?? 0).toLocaleString()} value={(examPrep?.catalog_courses ?? 0).toLocaleString()}
sub={`${lms?.courses ?? 0} courses · ${lms?.practices ?? 0} practices`} sub={`${examPrep?.units ?? 0} units · ${examPrep?.lesson_practices ?? 0} practices`}
trend="neutral" trend="neutral"
/> />
<KpiCard <KpiCard
icon={Video} icon={Video}
label="Videos" label="Videos"
value={courses.total_videos.toLocaleString()} value={courses.total_videos.toLocaleString()}
sub={getVideoLessonsSummary(lms?.lessons_with_video, examPrep?.lessons_with_video)} sub={getVideoLessonsSummary(examPrep?.lessons_with_video)}
trend={courses.total_videos > 0 ? "up" : "neutral"} trend={courses.total_videos > 0 ? "up" : "neutral"}
/> />
<KpiCard <KpiCard
@ -931,28 +931,12 @@ export function AnalyticsPage() {
</div> </div>
{/* ─── Course Management ─── */} {/* ─── Course Management ─── */}
{(lms || examPrep) && ( {examPrep && (
<Section title="Course Management" icon={BookOpen} count={courses.total_videos} defaultOpen> <Section title="Course Management" icon={BookOpen} count={courses.total_videos} defaultOpen>
<div className="grid items-start gap-4 lg:grid-cols-2"> <div className="grid items-start gap-4 lg:grid-cols-2">
{lms && (
<BreakdownList
title="LMS"
data={[
{ label: "Programs", count: lms.programs },
{ label: "Courses", count: lms.courses },
{ label: "Modules", count: lms.modules },
{ label: "Lessons", count: lms.lessons },
{ label: "Lessons with video", count: lms.lessons_with_video },
{ label: "Practices", count: lms.practices },
{ label: "Practices at course", count: lms.practices_at_course },
{ label: "Practices at module", count: lms.practices_at_module },
{ label: "Practices at lesson", count: lms.practices_at_lesson },
]}
/>
)}
{examPrep && ( {examPrep && (
<BreakdownList <BreakdownList
title="Duolingo/IELTS" title="Exam prep catalog"
data={[ data={[
{ label: "Catalog courses", count: examPrep.catalog_courses }, { label: "Catalog courses", count: examPrep.catalog_courses },
{ label: "Units", count: examPrep.units }, { label: "Units", count: examPrep.units },

View File

@ -1,18 +1,8 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { notifyApiError } from "../../lib/apiErrors" import { notifyApiError } from "../../lib/apiErrors"
import { useMemo, useRef, useState, type ChangeEvent } from "react"; import { useMemo, useRef, useState, type ChangeEvent } from "react";
import { Link, useLocation, useParams, useNavigate } from "react-router-dom"; import { Link, useLocation, useParams, useNavigate } from "react-router-dom";
import { import { ArrowLeft, ArrowRight, ChevronDown, Grid3X3, Check, Plus, Trash2, GripVertical, Upload } from "lucide-react";
ArrowLeft,
ArrowRight,
ChevronDown,
Grid3X3,
Check,
Plus,
Trash2,
GripVertical,
Loader2,
Upload,
} from "lucide-react";
import { toast } from "sonner"; import { toast } from "sonner";
import { Card } from "../../components/ui/card"; import { Card } from "../../components/ui/card";
import { Button } from "../../components/ui/button"; import { Button } from "../../components/ui/button";
@ -608,7 +598,7 @@ export function AddNewPracticePage() {
className="gap-1.5" className="gap-1.5"
> >
{uploadingIntroVideo ? ( {uploadingIntroVideo ? (
<Loader2 className="h-4 w-4 animate-spin" /> <SpinnerIcon className="h-4 w-4" />
) : ( ) : (
<Upload className="h-4 w-4" /> <Upload className="h-4 w-4" />
)} )}
@ -629,7 +619,7 @@ export function AddNewPracticePage() {
> >
{importingIntroVideoUrl ? ( {importingIntroVideoUrl ? (
<> <>
<Loader2 className="mr-1.5 h-4 w-4 animate-spin" /> <SpinnerIcon className="mr-1.5 h-4 w-4" />
Importing URL… Importing URL…
</> </>
) : ( ) : (

View File

@ -32,7 +32,7 @@ import { toast } from "sonner"
import { countActiveFilters } from "../../lib/adminFilterUtils" import { countActiveFilters } from "../../lib/adminFilterUtils"
import { cn } from "../../lib/utils" import { cn } from "../../lib/utils"
import { TABLE_PAGE_SIZE_OPTIONS } from "../../lib/tablePagination" import { TABLE_PAGE_SIZE_OPTIONS } from "../../lib/tablePagination"
import spinnerSrc from "../../assets/Circular-indeterminate progress indicator.svg" import spinnerSrc from "../../assets/05d37a91-04f9-41d8-99a2-b11bf20a6af2.png"
import { PageBackLink } from "../../components/navigation/PageBackLink" import { PageBackLink } from "../../components/navigation/PageBackLink"
import { SearchHighlight } from "../../components/SearchHighlight" import { SearchHighlight } from "../../components/SearchHighlight"

View File

@ -2,7 +2,7 @@ import { notifyApiError } from "../../lib/apiErrors"
import { useEffect, useState } from "react" import { useEffect, useState } from "react"
import { Link } from "react-router-dom" import { Link } from "react-router-dom"
import { FolderOpen, RefreshCw, BookOpen, Plus, Trash2 } from "lucide-react" import { FolderOpen, RefreshCw, BookOpen, Plus, Trash2 } from "lucide-react"
import spinnerSrc from "../../assets/Circular-indeterminate progress indicator.svg" import spinnerSrc from "../../assets/05d37a91-04f9-41d8-99a2-b11bf20a6af2.png"
import alertSrc from "../../assets/Alert.svg" import alertSrc from "../../assets/Alert.svg"
import { Card, CardContent, CardHeader, CardTitle } from "../../components/ui/card" import { Card, CardContent, CardHeader, CardTitle } from "../../components/ui/card"
import { Button } from "../../components/ui/button" import { Button } from "../../components/ui/button"

View File

@ -25,7 +25,7 @@ import {
import { Input } from "../../components/ui/input"; import { Input } from "../../components/ui/input";
import { Textarea } from "../../components/ui/textarea"; import { Textarea } from "../../components/ui/textarea";
import { cn } from "../../lib/utils"; import { cn } from "../../lib/utils";
import spinnerSrc from "../../assets/Circular-indeterminate progress indicator.svg"; import spinnerSrc from "../../assets/05d37a91-04f9-41d8-99a2-b11bf20a6af2.png";
import alertSrc from "../../assets/Alert.svg"; import alertSrc from "../../assets/Alert.svg";
import { import {
deleteTopLevelCourseModule, deleteTopLevelCourseModule,

View File

@ -18,6 +18,7 @@ import { Button } from "../../components/ui/button";
import { Card } from "../../components/ui/card"; import { Card } from "../../components/ui/card";
import { PracticeActionButton } from "./components/PracticeActionButton"; import { PracticeActionButton } from "./components/PracticeActionButton";
import { CatalogCoursePracticesPanel } from "./components/CatalogCoursePracticesPanel"; import { CatalogCoursePracticesPanel } from "./components/CatalogCoursePracticesPanel";
import { ExamPrepAssessmentsPanel } from "./components/ExamPrepAssessmentsPanel";
import { cn } from "../../lib/utils"; import { cn } from "../../lib/utils";
import { import {
Dialog, Dialog,
@ -118,7 +119,7 @@ export function CourseManagementPage() {
>(null); >(null);
const [catalogCoursePublishStatusUpdating, setCatalogCoursePublishStatusUpdating] = const [catalogCoursePublishStatusUpdating, setCatalogCoursePublishStatusUpdating] =
useState(false); useState(false);
const [activeTab, setActiveTab] = useState<"units" | "practices">("units"); const [activeTab, setActiveTab] = useState<"units" | "practices" | "assessments">("units");
const catalogCoursePracticePathOptions = useMemo( const catalogCoursePracticePathOptions = useMemo(
() => ({ () => ({
@ -740,6 +741,13 @@ export function CourseManagementPage() {
> >
Practices Practices
</button> </button>
<button
type="button"
onClick={() => setActiveTab("assessments")}
className={cn("pb-4 text-[16px] font-medium transition-all relative", activeTab === "assessments" ? "text-brand-500 after:absolute after:bottom-0 after:left-0 after:right-0 after:h-[3px] after:bg-brand-500 after:rounded-t-full" : "text-grayScale-400 hover:text-grayScale-600")}
>
Assessment exams
</button>
</div> </div>
</div> </div>
@ -760,7 +768,9 @@ export function CourseManagementPage() {
{/* Grid of Units / Practices */} {/* Grid of Units / Practices */}
<div className="space-y-4 pt-4"> <div className="space-y-4 pt-4">
{activeTab === "practices" ? ( {activeTab === "assessments" ? (
<ExamPrepAssessmentsPanel parent={{ kind: "CATALOG_COURSE", id: catalogCourseId }} />
) : activeTab === "practices" ? (
<CatalogCoursePracticesPanel <CatalogCoursePracticesPanel
catalogCourseId={catalogCourseId} catalogCourseId={catalogCourseId}
programType={programType ?? "proficiency"} programType={programType ?? "proficiency"}

View File

@ -24,6 +24,7 @@ import uploadIcon from "../../assets/icons/upload.png";
import { toast } from "sonner"; import { toast } from "sonner";
import { ResolvedImage } from "../../components/media/ResolvedImage"; import { ResolvedImage } from "../../components/media/ResolvedImage";
import { VideoCard } from "./components/VideoCard"; import { VideoCard } from "./components/VideoCard";
import { ExamPrepAssessmentsPanel } from "./components/ExamPrepAssessmentsPanel";
import { import {
createExamPrepModuleLesson, createExamPrepModuleLesson,
updateExamPrepModuleLesson, updateExamPrepModuleLesson,
@ -898,6 +899,7 @@ export function CourseModuleDetailPage() {
}) })
} }
onViewPractices={() => navigate(lessonPracticesPath(lesson))} onViewPractices={() => navigate(lessonPracticesPath(lesson))}
onViewAssessments={() => navigate(`/new-content/courses/${programType}/${courseId}/${unitId}/${moduleId}/lessons/${lesson.id}/assessments?lessonTitle=${encodeURIComponent(lesson.title)}`)}
onTogglePublishStatus={(nextStatus) => onTogglePublishStatus={(nextStatus) =>
void handleToggleLessonPublishStatus(lesson.id, nextStatus) void handleToggleLessonPublishStatus(lesson.id, nextStatus)
} }
@ -1165,6 +1167,7 @@ export function CourseModuleDetailPage() {
} }
/> />
) : null} ) : null}
<ExamPrepAssessmentsPanel parent={{ kind: "MODULE", id: parsedModuleId }} />
</div> </div>
); );
} }

View File

@ -18,7 +18,7 @@ import {
Eye, Eye,
} from "lucide-react" } from "lucide-react"
import practiceSrc from "../../assets/Practice.svg" import practiceSrc from "../../assets/Practice.svg"
import spinnerSrc from "../../assets/Circular-indeterminate progress indicator.svg" import spinnerSrc from "../../assets/05d37a91-04f9-41d8-99a2-b11bf20a6af2.png"
import alertSrc from "../../assets/Alert.svg" import alertSrc from "../../assets/Alert.svg"
import { Button } from "../../components/ui/button" import { Button } from "../../components/ui/button"
import { Badge } from "../../components/ui/badge" import { Badge } from "../../components/ui/badge"

View File

@ -1,7 +1,7 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { notifyApiError } from "../../lib/apiErrors" import { notifyApiError } from "../../lib/apiErrors"
import { useEffect, useMemo, useState } from "react" import { useEffect, useMemo, useState } from "react"
import { useNavigate, useParams, useSearchParams } from "react-router-dom" import { useNavigate, useParams, useSearchParams } from "react-router-dom"
import { Loader2 } from "lucide-react"
import { PageBackLink } from "../../components/navigation/PageBackLink" import { PageBackLink } from "../../components/navigation/PageBackLink"
import { toast } from "sonner" import { toast } from "sonner"
import { Button } from "../../components/ui/button" import { Button } from "../../components/ui/button"
@ -380,7 +380,7 @@ export function CreateQuestionTypeFlow() {
> >
{saving ? ( {saving ? (
<> <>
<Loader2 className="h-4 w-4 mr-2 animate-spin" /> <SpinnerIcon className="h-4 w-4 mr-2 " />
Saving… Saving…
</> </>
) : isEdit ? ( ) : isEdit ? (

View File

@ -1,7 +1,8 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { getApiErrorMessage, notifyApiError } from "../../lib/apiErrors" import { getApiErrorMessage, notifyApiError } from "../../lib/apiErrors"
import { useEffect, useMemo, useRef, useState } from "react"; import { useEffect, useMemo, useRef, useState } from "react";
import { useNavigate, useParams, useSearchParams } from "react-router-dom"; import { useNavigate, useParams, useSearchParams } from "react-router-dom";
import { Loader2 } from "lucide-react";
import { PageBackLink } from "../../components/navigation/PageBackLink"; import { PageBackLink } from "../../components/navigation/PageBackLink";
import { navigateBack } from "../../lib/navigateBack"; import { navigateBack } from "../../lib/navigateBack";
import { toast } from "sonner"; import { toast } from "sonner";
@ -580,7 +581,7 @@ export function EditPracticeFlow() {
if (loadingPractice || definitionsLoading) { if (loadingPractice || definitionsLoading) {
return ( return (
<div className="flex min-h-screen flex-col items-center justify-center gap-4 px-6 text-center"> <div className="flex min-h-screen flex-col items-center justify-center gap-4 px-6 text-center">
<Loader2 className="h-10 w-10 animate-spin text-brand-500" /> <SpinnerIcon className="h-10 w-10 text-brand-500" />
<p className="text-sm font-medium text-grayScale-600">Loading practice details…</p> <p className="text-sm font-medium text-grayScale-600">Loading practice details…</p>
</div> </div>
); );
@ -787,7 +788,7 @@ export function EditPracticeFlow() {
> >
{submitting ? ( {submitting ? (
<> <>
<Loader2 className="mr-2 h-4 w-4 animate-spin" /> <SpinnerIcon className="mr-2 h-4 w-4" />
Saving… Saving…
</> </>
) : ( ) : (

View File

@ -18,7 +18,7 @@ import {
import { Input } from "../../components/ui/input"; import { Input } from "../../components/ui/input";
import { Textarea } from "../../components/ui/textarea"; import { Textarea } from "../../components/ui/textarea";
import uploadIcon from "../../assets/icons/upload.png"; import uploadIcon from "../../assets/icons/upload.png";
import spinnerSrc from "../../assets/Circular-indeterminate progress indicator.svg"; import spinnerSrc from "../../assets/05d37a91-04f9-41d8-99a2-b11bf20a6af2.png";
import alertSrc from "../../assets/Alert.svg"; import alertSrc from "../../assets/Alert.svg";
import { import {
getLearningPrograms, getLearningPrograms,

View File

@ -0,0 +1,19 @@
import { Link, useParams, useSearchParams } from "react-router-dom";
import { ArrowLeft } from "lucide-react";
import { ExamPrepAssessmentsPanel } from "./components/ExamPrepAssessmentsPanel";
export function LessonAssessmentsPage() {
const { programType, courseId, unitId, moduleId, lessonId } = useParams();
const [searchParams] = useSearchParams();
const parentId = Number(lessonId);
return (
<div className="mx-auto max-w-4xl space-y-6 px-4 py-6">
<Link to={`/new-content/courses/${programType}/${courseId}/${unitId}/${moduleId}`} className="inline-flex items-center gap-2 text-sm font-medium text-grayScale-600 hover:text-brand-500">
<ArrowLeft className="h-4 w-4" /> Back to lessons
</Link>
<h1 className="text-2xl font-semibold text-grayScale-900">{searchParams.get("lessonTitle") || `Lesson #${lessonId}`} assessments</h1>
{Number.isFinite(parentId) && parentId > 0 ? <ExamPrepAssessmentsPanel parent={{ kind: "LESSON", id: parentId }} /> : null}
</div>
);
}

View File

@ -1,3 +1,4 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { notifyApiError } from "../../lib/apiErrors" import { notifyApiError } from "../../lib/apiErrors"
import { useCallback, useEffect, useMemo, useState } from "react"; import { useCallback, useEffect, useMemo, useState } from "react";
import { ArrowLeft, BookOpen, Calendar, RefreshCw } from "lucide-react"; import { ArrowLeft, BookOpen, Calendar, RefreshCw } from "lucide-react";
@ -368,9 +369,7 @@ export function LessonPracticesPage() {
disabled={loading} disabled={loading}
onClick={() => void load()} onClick={() => void load()}
> >
<RefreshCw {loading ? <SpinnerIcon className="h-4 w-4" /> : <RefreshCw className="h-4 w-4" />}
className={cn("h-4 w-4", loading && "animate-spin")}
/>
Refresh Refresh
</Button> </Button>
<PracticeActionButton <PracticeActionButton

View File

@ -1,99 +1,60 @@
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { Mic } from "lucide-react"; import { BookOpen, GraduationCap, ListChecks, Shuffle } from "lucide-react";
import { Card, CardContent } from "../../components/ui/card"; import { Card, CardContent } from "../../components/ui/card";
import { Button } from "../../components/ui/button"; import { Button } from "../../components/ui/button";
export function NewContentPage() { export function NewContentPage() {
return ( return (
<div className="space-y-8"> <div className="space-y-8">
{/* Header section */}
<div className="flex items-start justify-between gap-4"> <div className="flex items-start justify-between gap-4">
<div> <div>
<h1 className="text-2xl font-bold tracking-tight text-grayScale-700"> <h1 className="text-2xl font-bold tracking-tight text-grayScale-700">
Content Management Learning Content
</h1> </h1>
<p className="mt-1 text-sm text-grayScale-500"> <p className="mt-1 max-w-2xl text-sm text-grayScale-500">
Upload, organize, and manage learning content across programs and Build one curriculum for education courses and exam preparation.
courses Add practice activities and assessment exams to each hierarchy level.
</p> </p>
</div> </div>
<div className="flex shrink-0 flex-wrap items-center justify-end gap-3"> <div className="flex shrink-0 flex-wrap justify-end gap-3">
<Link to="/new-content/question-types"> <Link to="/new-content/question-types">
<Button className="h-10 px-6 rounded-[6px] bg-brand-500 font-bold text-white shadow-sm hover:bg-brand-600 transition-all"> <Button variant="outline" className="h-10 gap-2 px-4">
Manage Question Types <ListChecks className="h-4 w-4" /> Question Types
</Button> </Button>
</Link> </Link>
<Link to="/new-content/reorder"> <Link to="/new-content/reorder">
<Button <Button variant="outline" className="h-10 gap-2 px-4">
variant="outline" <Shuffle className="h-4 w-4" /> Reorder
className="h-10 px-6 rounded-[6px] border-brand-500 font-bold text-brand-500 hover:bg-brand-50 transition-all"
>
Reorder Content
</Button> </Button>
</Link> </Link>
</div> </div>
</div> </div>
{/* Gradient Divider */} <Card className="max-w-5xl overflow-hidden border-grayScale-100 shadow-soft">
<div className="relative"> <div className="grid md:grid-cols-[280px_1fr]">
<div className="absolute inset-0 flex items-center" aria-hidden="true"> <div className="flex min-h-52 items-center justify-center bg-brand-50/40">
<div className="w-full border-t border-grayScale-100" /> <div className="flex h-20 w-20 items-center justify-center rounded-full bg-white shadow-sm">
</div> <GraduationCap className="h-10 w-10 text-brand-500" />
<div className="relative flex justify-center">
<div
className="h-[0.5px] w-full opacity-20 rounded-full"
style={{
background: "gray",
}}
/>
</div>
</div>
{/* Cards Grid — equal-height cards with bottom-aligned actions */}
<div className="grid max-w-5xl gap-8 grid-cols-1 items-stretch md:grid-cols-2">
{/* Learn English Card */}
<Card className="flex h-full flex-col overflow-hidden border-none shadow-soft">
<div className="flex h-56 shrink-0 items-center justify-center bg-white/50">
<div className="flex h-20 w-20 items-center justify-center rounded-full bg-brand-100/30">
<Mic className="h-10 w-10 text-brand-500" />
</div> </div>
</div> </div>
<CardContent className="flex flex-1 flex-col border-t border-grayScale-200 bg-white p-8 text-center"> <CardContent className="flex flex-col justify-center p-8">
<h3 className="text-xl font-bold text-grayScale-700"> <h2 className="text-xl font-bold text-grayScale-800">
Learn English Exam prep catalog
</h3> </h2>
<p className="mt-3 flex-1 text-sm leading-relaxed text-grayScale-500"> <p className="mt-2 max-w-2xl text-sm leading-relaxed text-grayScale-500">
Manage structured English learning content based on levels and Organize catalog courses into units, modules, and lessons. Use the
modules. same structure for Education, IELTS, and Duolingo English Test
content. Attach practice activities and assessment question sets
where they belong.
</p> </p>
<Link to="/new-content/learn-english" className="mt-8 block w-full"> <Link to="/new-content/courses" className="mt-6 w-fit">
<Button className="h-12 w-full rounded-[6px] bg-brand-500 text-base font-semibold"> <Button className="h-11 gap-2 bg-brand-500 px-6 font-semibold text-white hover:bg-brand-600">
Manage Learn English <BookOpen className="h-4 w-4" /> Manage Catalog
</Button> </Button>
</Link> </Link>
</CardContent> </CardContent>
</Card> </div>
</Card>
{/* Courses Card */}
<Card className="flex h-full flex-col overflow-hidden border-none shadow-soft">
<div className="flex h-56 shrink-0 items-center justify-center bg-white/50">
<div className="flex h-20 w-20 items-center justify-center rounded-full bg-brand-100/30">
<Mic className="h-10 w-10 text-brand-500" />
</div>
</div>
<CardContent className="flex flex-1 flex-col border-t border-grayScale-200 bg-white p-8 text-center">
<h3 className="text-xl font-bold text-grayScale-700">Courses</h3>
<p className="mt-3 flex-1 text-sm leading-relaxed text-grayScale-500">
Manage skill-based and Duolingo/IELTS courses.
</p>
<Link to="/new-content/courses" className="mt-8 block w-full">
<Button className="h-12 w-full rounded-[6px] bg-brand-500 text-base font-semibold">
Manage Courses
</Button>
</Link>
</CardContent>
</Card>
</div>
</div> </div>
); );
} }

View File

@ -2,7 +2,7 @@ import { useCallback, useEffect, useMemo, useState } from "react"
import { Link, useLocation, useParams } from "react-router-dom" import { Link, useLocation, useParams } from "react-router-dom"
import { ArrowLeft, Plus, Edit, Trash2, X, Check, ChevronDown, ChevronUp, SlidersHorizontal, ArrowUpDown } from "lucide-react" import { ArrowLeft, Plus, Edit, Trash2, X, Check, ChevronDown, ChevronUp, SlidersHorizontal, ArrowUpDown } from "lucide-react"
import practiceSrc from "../../assets/Practice.svg" import practiceSrc from "../../assets/Practice.svg"
import spinnerSrc from "../../assets/Circular-indeterminate progress indicator.svg" import spinnerSrc from "../../assets/05d37a91-04f9-41d8-99a2-b11bf20a6af2.png"
import { Card, CardContent, CardHeader, CardTitle } from "../../components/ui/card" import { Card, CardContent, CardHeader, CardTitle } from "../../components/ui/card"
import alertSrc from "../../assets/Alert.svg" import alertSrc from "../../assets/Alert.svg"
import { Badge } from "../../components/ui/badge" import { Badge } from "../../components/ui/badge"
@ -110,6 +110,9 @@ export function PracticeQuestionsPage() {
const [saveError, setSaveError] = useState<string | null>(null) const [saveError, setSaveError] = useState<string | null>(null)
const backLink = useMemo(() => { const backLink = useMemo(() => {
const returnPath = (location.state as { from?: unknown } | null)?.from
if (typeof returnPath === "string" && returnPath.startsWith("/new-content/")) return returnPath
if (location.pathname.includes("/content/question-sets/")) return "/new-content"
if (location.pathname.includes("/content/human-language/") && location.pathname.includes("/level/") && levelId) { if (location.pathname.includes("/content/human-language/") && location.pathname.includes("/level/") && levelId) {
return "/content/human-language" return "/content/human-language"
} }

View File

@ -18,7 +18,7 @@ import {
import { Input } from "../../components/ui/input"; import { Input } from "../../components/ui/input";
import { Textarea } from "../../components/ui/textarea"; import { Textarea } from "../../components/ui/textarea";
import uploadIcon from "../../assets/icons/upload.png"; import uploadIcon from "../../assets/icons/upload.png";
import spinnerSrc from "../../assets/Circular-indeterminate progress indicator.svg"; import spinnerSrc from "../../assets/05d37a91-04f9-41d8-99a2-b11bf20a6af2.png";
import alertSrc from "../../assets/Alert.svg"; import alertSrc from "../../assets/Alert.svg";
import { import {
createProgramCourse, createProgramCourse,

View File

@ -27,18 +27,11 @@ import { toast } from "sonner";
import { ResolvedImage } from "../../components/media/ResolvedImage"; import { ResolvedImage } from "../../components/media/ResolvedImage";
import { import {
createExamPrepCatalogCourse, createExamPrepCatalogCourse,
createProgramCourse,
deleteExamPrepCatalogCourse, deleteExamPrepCatalogCourse,
deleteTopLevelCourse,
getExamPrepCatalogCourses, getExamPrepCatalogCourses,
getLearningPrograms,
getProgramCourses,
setExamPrepCatalogCourseAccessTier, setExamPrepCatalogCourseAccessTier,
setExamPrepCatalogCoursePublishStatus, setExamPrepCatalogCoursePublishStatus,
setProgramCourseAccessTier,
setProgramCoursePublishStatus,
updateExamPrepCatalogCourse, updateExamPrepCatalogCourse,
updateTopLevelCourse,
} from "../../api/courses.api"; } from "../../api/courses.api";
import { ContentPublishStatusChip } from "./components/ContentPublishStatusChip"; import { ContentPublishStatusChip } from "./components/ContentPublishStatusChip";
import { ContentAccessTierChip } from "./components/ContentAccessTierChip"; import { ContentAccessTierChip } from "./components/ContentAccessTierChip";
@ -48,9 +41,7 @@ import type {
ContentAccessTier, ContentAccessTier,
ExamPrepCatalogCategory, ExamPrepCatalogCategory,
ExamPrepCatalogCourseItem, ExamPrepCatalogCourseItem,
LearningProgramListItem,
PracticePublishStatus, PracticePublishStatus,
ProgramCourseListItem,
} from "../../types/course.types"; } from "../../types/course.types";
import { import {
filterBySearchAndPublishStatus, filterBySearchAndPublishStatus,
@ -68,8 +59,6 @@ import {
type CourseListRow = { type CourseListRow = {
id: number; id: number;
programId?: number;
programName?: string;
category?: ExamPrepCatalogCategory | string | null; category?: ExamPrepCatalogCategory | string | null;
name: string; name: string;
description: string; description: string;
@ -85,21 +74,21 @@ type CourseListRow = {
export function ProgramDetailPage() { export function ProgramDetailPage() {
const navigate = useNavigate(); const navigate = useNavigate();
const { programType } = useParams<{ programType: string }>(); const { programType } = useParams<{ programType: string }>();
const categoryByRoute: Record<string, ExamPrepCatalogCategory> = {
education: "EDUCATION",
ielts: "IELTS",
duolingo: "DUOLINGO",
};
const category = programType ? categoryByRoute[programType.toLowerCase()] : undefined;
const [createOpen, setCreateOpen] = useState(false); const [createOpen, setCreateOpen] = useState(false);
const [createName, setCreateName] = useState(""); const [createName, setCreateName] = useState("");
const [createDescription, setCreateDescription] = useState(""); const [createDescription, setCreateDescription] = useState("");
const [createSortOrder, setCreateSortOrder] = useState("");
const [createProgramId, setCreateProgramId] = useState("");
const [createCategory, setCreateCategory] = useState<ExamPrepCatalogCategory | "">("");
const [createThumbnail, setCreateThumbnail] = useState(""); const [createThumbnail, setCreateThumbnail] = useState("");
const [createThumbnailFromUpload, setCreateThumbnailFromUpload] = useState(false); const [createThumbnailFromUpload, setCreateThumbnailFromUpload] = useState(false);
const [creating, setCreating] = useState(false); const [creating, setCreating] = useState(false);
const [uploadingThumbnail, setUploadingThumbnail] = useState(false); const [uploadingThumbnail, setUploadingThumbnail] = useState(false);
const createThumbnailFileInputRef = useRef<HTMLInputElement>(null); const createThumbnailFileInputRef = useRef<HTMLInputElement>(null);
const [createdCourses, setCreatedCourses] = useState<CourseListRow[]>([]); const [createdCourses, setCreatedCourses] = useState<CourseListRow[]>([]);
const [learningPrograms, setLearningPrograms] = useState<
LearningProgramListItem[]
>([]);
const [publishStatusUpdatingId, setPublishStatusUpdatingId] = useState< const [publishStatusUpdatingId, setPublishStatusUpdatingId] = useState<
number | null number | null
>(null); >(null);
@ -119,26 +108,18 @@ export function ProgramDetailPage() {
const [deletingCourseId, setDeletingCourseId] = useState<number | null>(null); const [deletingCourseId, setDeletingCourseId] = useState<number | null>(null);
const [deletingCourse, setDeletingCourse] = useState(false); const [deletingCourse, setDeletingCourse] = useState(false);
// Mock data for "proficiency" program type const categoryLabels: Record<ExamPrepCatalogCategory, string> = {
const programs: Record<string, any> = { EDUCATION: "Education",
proficiency: { IELTS: "IELTS",
title: "Duolingo/IELTS", DUOLINGO: "Duolingo English Test",
description:
"Manage Duolingo/IELTS learning programs.",
courses: [],
},
"skill-based": {
title: "Skill-Based Courses",
description:
"Practice-focused communication and skills training for real-world scenarios.",
courses: [], // To be implemented or shown if needed
},
}; };
const currentProgram = category
const currentProgram = ? {
programs[programType || "proficiency"] || programs.proficiency; title: categoryLabels[category],
const isProficiency = programType === "proficiency"; description: `Manage ${categoryLabels[category]} catalog courses and their learning hierarchy.`,
const isSkillBased = programType === "skill-based"; }
: { title: "Catalog courses", description: "Choose a valid catalog category." };
const isExamPrepCatalog = Boolean(category);
const mapExamPrepCourse = (row: ExamPrepCatalogCourseItem): CourseListRow => ({ const mapExamPrepCourse = (row: ExamPrepCatalogCourseItem): CourseListRow => ({
id: Number(row.id), id: Number(row.id),
@ -154,84 +135,25 @@ export function ProgramDetailPage() {
lessonsCount: Number(row.lessons_count ?? 0), lessonsCount: Number(row.lessons_count ?? 0),
}); });
const mapProgramCourse = (
row: ProgramCourseListItem,
programName?: string,
): CourseListRow => ({
id: Number(row.id),
programId: Number(row.program_id),
programName: programName?.trim() || undefined,
name: row.name?.trim() || `Course ${row.id}`,
description: row.description?.trim() || "",
thumbnail: row.thumbnail?.trim() || row.thumbnail_url?.trim() || null,
sortOrder: Number(row.sort_order ?? 0),
publishStatus: row.publish_status ?? null,
accessTier: row.access_tier ?? null,
unitsCount: 0,
modulesCount: Number(row.module_count ?? row.modules_count ?? 0),
lessonsCount: Number(row.lesson_count ?? 0),
});
const loadCourses = useCallback(async () => { const loadCourses = useCallback(async () => {
if (!isProficiency && !isSkillBased) return; if (!category) return;
setCatalogLoading(true); setCatalogLoading(true);
try { try {
if (isProficiency) { const list = await fetchAllOffsetPages(async (offset, limit) =>
const list = await fetchAllOffsetPages(async (offset, limit) => offsetPageFromListEnvelope<ExamPrepCatalogCourseItem>(
offsetPageFromListEnvelope<ExamPrepCatalogCourseItem>( await getExamPrepCatalogCourses({ limit, offset }),
await getExamPrepCatalogCourses({ limit, offset }), "catalog_courses",
"catalog_courses",
),
);
setCreatedCourses(list.map(mapExamPrepCourse));
setLearningPrograms([]);
return;
}
const programsList = await fetchAllOffsetPages(async (offset, limit) =>
offsetPageFromListEnvelope<LearningProgramListItem>(
await getLearningPrograms({ limit, offset }),
"programs",
), ),
); );
setLearningPrograms(programsList); setCreatedCourses(list.filter((row) => row.category === category).map(mapExamPrepCourse));
const programNameById = new Map(
programsList.map((program) => [program.id, program.name?.trim() || ""]),
);
const coursePages = await Promise.all(
programsList.map((program) =>
fetchAllOffsetPages(async (offset, limit) =>
offsetPageFromListEnvelope<ProgramCourseListItem>(
await getProgramCourses(program.id, { limit, offset }),
"courses",
),
),
),
);
setCreatedCourses(
coursePages
.flat()
.map((row) =>
mapProgramCourse(row, programNameById.get(row.program_id)),
)
.sort((a, b) => a.sortOrder - b.sortOrder || a.id - b.id),
);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
notifyApiError( notifyApiError(error, "Failed to fetch catalog courses");
error,
isProficiency ? "Failed to fetch catalog courses" : "Failed to fetch courses",
);
setCreatedCourses([]); setCreatedCourses([]);
if (isSkillBased) {
setLearningPrograms([]);
}
} finally { } finally {
setCatalogLoading(false); setCatalogLoading(false);
} }
}, [isProficiency, isSkillBased]); }, [category]);
useEffect(() => { useEffect(() => {
void loadCourses(); void loadCourses();
@ -240,8 +162,6 @@ export function ProgramDetailPage() {
() => () =>
createdCourses.map((course) => ({ createdCourses.map((course) => ({
id: course.id, id: course.id,
programId: course.programId,
programName: course.programName,
category: course.category, category: course.category,
name: course.name, name: course.name,
description: course.description, description: course.description,
@ -269,7 +189,6 @@ export function ProgramDetailPage() {
getSearchFields: (c) => [ getSearchFields: (c) => [
c.name, c.name,
c.description, c.description,
c.programName ?? "",
], ],
getPublishStatus: (c) => c.publish_status, getPublishStatus: (c) => c.publish_status,
}), }),
@ -282,15 +201,9 @@ export function ProgramDetailPage() {
) => { ) => {
setPublishStatusUpdatingId(courseId); setPublishStatusUpdatingId(courseId);
try { try {
if (isProficiency) { await setExamPrepCatalogCoursePublishStatus(courseId, {
await setExamPrepCatalogCoursePublishStatus(courseId, { publish_status: nextStatus,
publish_status: nextStatus, });
});
} else {
await setProgramCoursePublishStatus(courseId, {
publish_status: nextStatus,
});
}
setCreatedCourses((prev) => setCreatedCourses((prev) =>
prev.map((c) => prev.map((c) =>
c.id === courseId ? { ...c, publishStatus: nextStatus } : c, c.id === courseId ? { ...c, publishStatus: nextStatus } : c,
@ -312,15 +225,9 @@ export function ProgramDetailPage() {
) => { ) => {
setAccessTierUpdatingId(courseId); setAccessTierUpdatingId(courseId);
try { try {
if (isProficiency) { await setExamPrepCatalogCourseAccessTier(courseId, {
await setExamPrepCatalogCourseAccessTier(courseId, { access_tier: nextTier,
access_tier: nextTier, });
});
} else {
await setProgramCourseAccessTier(courseId, {
access_tier: nextTier,
});
}
setCreatedCourses((prev) => setCreatedCourses((prev) =>
prev.map((c) => prev.map((c) =>
c.id === courseId ? { ...c, accessTier: nextTier } : c, c.id === courseId ? { ...c, accessTier: nextTier } : c,
@ -388,9 +295,6 @@ export function ProgramDetailPage() {
const clearCreateCourseForm = () => { const clearCreateCourseForm = () => {
setCreateName(""); setCreateName("");
setCreateDescription(""); setCreateDescription("");
setCreateSortOrder("");
setCreateProgramId("");
setCreateCategory("");
setCreateThumbnail(""); setCreateThumbnail("");
setCreateThumbnailFromUpload(false); setCreateThumbnailFromUpload(false);
}; };
@ -418,47 +322,17 @@ export function ProgramDetailPage() {
thumbnailToSend = uploadedUrl; thumbnailToSend = uploadedUrl;
} }
if (isProficiency) { if (!category) {
if (createCategory !== "IELTS" && createCategory !== "DUOLINGO") { toast.error("Choose a valid catalog category");
toast.error("Please select an exam category");
return;
}
const response = await createExamPrepCatalogCourse({
name,
description: null,
category: createCategory,
thumbnail: thumbnailToSend,
});
const row = response.data?.data;
if (!row?.id) {
throw new Error("Missing created course payload");
}
} else if (isSkillBased) {
const programId = Number(createProgramId);
if (!Number.isFinite(programId) || programId < 1) {
toast.error("Please select a program");
return;
}
const sortOrderRaw = createSortOrder.trim();
if (!sortOrderRaw) {
toast.error("Sort order is required");
return;
}
const sort_order = Number(sortOrderRaw);
if (!Number.isInteger(sort_order) || sort_order < 0) {
toast.error("Sort order must be a whole number of 0 or greater");
return;
}
await createProgramCourse(programId, {
name,
description: createDescription.trim(),
thumbnail: thumbnailToSend ?? "",
sort_order,
});
} else {
toast.error("Unsupported program type");
return; return;
} }
const response = await createExamPrepCatalogCourse({
name,
description: createDescription.trim() || null,
category,
thumbnail: thumbnailToSend,
});
if (!response.data?.data?.id) throw new Error("Missing created course payload");
await loadCourses(); await loadCourses();
toast.success("Course created"); toast.success("Course created");
@ -479,9 +353,9 @@ export function ProgramDetailPage() {
setEditName(String(course.name ?? "")); setEditName(String(course.name ?? ""));
setEditDescription(String(course.description ?? "")); setEditDescription(String(course.description ?? ""));
setEditCategory( setEditCategory(
course.category === "IELTS" || course.category === "DUOLINGO" course.category === "EDUCATION" || course.category === "IELTS" || course.category === "DUOLINGO"
? course.category ? course.category
: "", : category ?? "",
); );
setEditThumbnail(String(course.thumbnail ?? "")); setEditThumbnail(String(course.thumbnail ?? ""));
setEditSortOrder(String(course.sort_order ?? 1)); setEditSortOrder(String(course.sort_order ?? 1));
@ -538,26 +412,19 @@ export function ProgramDetailPage() {
setSavingEdit(true); setSavingEdit(true);
try { try {
const minioThumbnail = await resolveThumbnailToMinioUrl(editThumbnail); const minioThumbnail = await resolveThumbnailToMinioUrl(editThumbnail);
const existing = createdCourses.find((c) => c.id === editingCourseId); if (editCategory !== "EDUCATION" && editCategory !== "IELTS" && editCategory !== "DUOLINGO") {
const preservedDescription =
typeof existing?.description === "string"
? existing.description.trim() || null
: null;
if (isProficiency) {
if (editCategory !== "IELTS" && editCategory !== "DUOLINGO") {
toast.error("Please select an exam category"); toast.error("Please select an exam category");
return; return;
} }
const response = await updateExamPrepCatalogCourse(editingCourseId, { const response = await updateExamPrepCatalogCourse(editingCourseId, {
name, name,
description: preservedDescription, description: editDescription.trim() || null,
category: editCategory, category: editCategory,
thumbnail: minioThumbnail || null, thumbnail: minioThumbnail || null,
sort_order: sortOrderNum, sort_order: sortOrderNum,
}); });
const row = response.data?.data; const row = response.data?.data;
setCreatedCourses((prev) => setCreatedCourses((prev) =>
prev.map((course) => prev.map((course) =>
course.id === editingCourseId course.id === editingCourseId
? { ? {
@ -565,7 +432,7 @@ export function ProgramDetailPage() {
category: row?.category ?? editCategory, category: row?.category ?? editCategory,
name: row?.name ?? name, name: row?.name ?? name,
description: description:
row?.description?.trim() || preservedDescription || "", row?.description?.trim() || editDescription.trim() || "",
thumbnail: row?.thumbnail?.trim() || null, thumbnail: row?.thumbnail?.trim() || null,
sortOrder: Number(row?.sort_order ?? sortOrderNum), sortOrder: Number(row?.sort_order ?? sortOrderNum),
unitsCount: Number(row?.units_count ?? course.unitsCount ?? 0), unitsCount: Number(row?.units_count ?? course.unitsCount ?? 0),
@ -578,15 +445,7 @@ export function ProgramDetailPage() {
} }
: course, : course,
), ),
); );
} else {
await updateTopLevelCourse(editingCourseId, {
name,
description: editDescription.trim(),
thumbnail: minioThumbnail,
sort_order: sortOrderNum,
});
}
await loadCourses(); await loadCourses();
toast.success("Course updated"); toast.success("Course updated");
@ -603,11 +462,7 @@ export function ProgramDetailPage() {
if (!deletingCourseId) return; if (!deletingCourseId) return;
setDeletingCourse(true); setDeletingCourse(true);
try { try {
if (isProficiency) { await deleteExamPrepCatalogCourse(deletingCourseId);
await deleteExamPrepCatalogCourse(deletingCourseId);
} else {
await deleteTopLevelCourse(deletingCourseId);
}
await loadCourses(); await loadCourses();
toast.success("Course deleted"); toast.success("Course deleted");
setDeletingCourseId(null); setDeletingCourseId(null);
@ -698,91 +553,9 @@ export function ProgramDetailPage() {
</DialogHeader> </DialogHeader>
<div className="min-h-0 flex-1 space-y-8 overflow-y-auto p-8"> <div className="min-h-0 flex-1 space-y-8 overflow-y-auto p-8">
{isProficiency ? ( <div className="rounded-lg bg-grayScale-50 px-4 py-3 text-sm text-grayScale-600">
<div className="space-y-3"> Category: <span className="font-semibold text-grayScale-900">{category ? categoryLabels[category] : "Unknown"}</span>
<label className="text-[15px] text-grayScale-800"> </div>
Exam Category
</label>
<select
value={createCategory}
onChange={(e) =>
setCreateCategory(e.target.value as ExamPrepCatalogCategory | "")
}
className="h-12 w-full rounded-[8px] border border-grayScale-400 bg-white px-4 text-[15px] text-grayScale-900 focus:outline-none focus:ring-2 focus:ring-brand-500/20"
disabled={creating || uploadingThumbnail}
>
<option value="">Select IELTS or Duolingo…</option>
<option value="IELTS">IELTS</option>
<option value="DUOLINGO">Duolingo</option>
</select>
</div>
) : null}
{isSkillBased ? (
<>
<div className="space-y-3">
<label className="text-[15px] text-grayScale-800">
Program
</label>
{learningPrograms.length === 0 ? (
<p className="text-sm text-grayScale-500">
No learning programs found. Create a program first
from{" "}
<Link
to="/new-content/learn-english"
className="font-semibold text-brand-500 hover:underline"
>
Learn English
</Link>
.
</p>
) : (
<select
value={createProgramId}
onChange={(e) => setCreateProgramId(e.target.value)}
className="h-12 w-full rounded-[8px] border border-grayScale-400 bg-white px-4 text-[15px] text-grayScale-900 focus:outline-none focus:ring-2 focus:ring-brand-500/20"
disabled={creating}
>
<option value="">Select a program…</option>
{learningPrograms.map((program) => (
<option key={program.id} value={String(program.id)}>
{program.name?.trim() || `Program ${program.id}`}
</option>
))}
</select>
)}
</div>
<div className="space-y-3">
<label className="text-[15px] text-grayScale-800">
Description
</label>
<Textarea
value={createDescription}
onChange={(e) => setCreateDescription(e.target.value)}
placeholder="Short summary of the course"
rows={3}
className="min-h-[88px] resize-y rounded-[8px] border-grayScale-400 px-4 text-[15px]"
disabled={creating || uploadingThumbnail}
/>
</div>
<div className="space-y-3">
<label className="text-[15px] text-grayScale-800">
Sort Order
</label>
<Input
type="number"
min={0}
value={createSortOrder}
onChange={(e) => setCreateSortOrder(e.target.value)}
placeholder="e.g. 1"
className="h-12 border-grayScale-400 rounded-[8px] px-4 placeholder:text-grayScale-400 text-[15px] focus:ring-brand-500/20"
disabled={creating}
/>
</div>
</>
) : null}
<div className="space-y-3"> <div className="space-y-3">
<label className="text-[15px] text-grayScale-800"> <label className="text-[15px] text-grayScale-800">
Name Name
@ -790,16 +563,24 @@ export function ProgramDetailPage() {
<Input <Input
value={createName} value={createName}
onChange={(e) => setCreateName(e.target.value)} onChange={(e) => setCreateName(e.target.value)}
placeholder={ placeholder="e.g. English for Professionals or IELTS Academic"
isSkillBased
? "e.g. English For Professionals"
: "e.g. TOEFL, IELTS"
}
className="h-12 border-grayScale-400 rounded-[8px] px-4 placeholder:text-grayScale-400 text-[15px] focus:ring-brand-500/20" className="h-12 border-grayScale-400 rounded-[8px] px-4 placeholder:text-grayScale-400 text-[15px] focus:ring-brand-500/20"
disabled={creating} disabled={creating}
/> />
</div> </div>
<div className="space-y-3">
<label className="text-[15px] text-grayScale-800">Description</label>
<Textarea
value={createDescription}
onChange={(e) => setCreateDescription(e.target.value)}
placeholder="Short summary of the catalog course"
rows={3}
className="min-h-[88px] resize-y rounded-[8px] border-grayScale-400 px-4 text-[15px]"
disabled={creating || uploadingThumbnail}
/>
</div>
<div className="space-y-3"> <div className="space-y-3">
<label className="text-[15px] text-grayScale-800"> <label className="text-[15px] text-grayScale-800">
Thumbnail Thumbnail
@ -878,9 +659,7 @@ export function ProgramDetailPage() {
<Button <Button
className="h-11 px-8 rounded-[6px] bg-brand-500 text-white font-bold hover:bg-brand-600" className="h-11 px-8 rounded-[6px] bg-brand-500 text-white font-bold hover:bg-brand-600"
disabled={ disabled={
creating || creating || uploadingThumbnail || !category
uploadingThumbnail ||
(isSkillBased && learningPrograms.length === 0)
} }
onClick={() => void handleCreateCourse()} onClick={() => void handleCreateCourse()}
> >
@ -916,14 +695,8 @@ export function ProgramDetailPage() {
onSearchChange={setListSearch} onSearchChange={setListSearch}
publishStatusFilter={publishStatusFilter} publishStatusFilter={publishStatusFilter}
onPublishStatusFilterChange={setPublishStatusFilter} onPublishStatusFilterChange={setPublishStatusFilter}
searchPlaceholder={ searchPlaceholder="Search courses by name or description…"
isSkillBased searchAriaLabel="Search catalog courses"
? "Search courses by name, description, or program…"
: "Search courses by name or description…"
}
searchAriaLabel={
isSkillBased ? "Search skill-based courses" : "Search catalog courses"
}
/> />
) : null} ) : null}
<div className="flex flex-wrap gap-8"> <div className="flex flex-wrap gap-8">
@ -933,12 +706,10 @@ export function ProgramDetailPage() {
{displayCourses.length === 0 && !catalogLoading ? ( {displayCourses.length === 0 && !catalogLoading ? (
<div className="w-full rounded-xl border border-dashed border-grayScale-200 bg-grayScale-50/50 px-6 py-14 text-center"> <div className="w-full rounded-xl border border-dashed border-grayScale-200 bg-grayScale-50/50 px-6 py-14 text-center">
<p className="text-sm font-medium text-grayScale-600"> <p className="text-sm font-medium text-grayScale-600">
{isSkillBased ? "No skill-based courses yet" : "No catalog courses yet"} No catalog courses yet
</p> </p>
<p className="mt-1 text-sm text-grayScale-400"> <p className="mt-1 text-sm text-grayScale-400">
{isSkillBased {`Create your first ${category ? categoryLabels[category] : "catalog"} course to organize units, modules, and lessons.`}
? "Create your first course under a learning program to start organizing modules and lessons."
: "Create your first Duolingo/IELTS catalog course to start organizing units, modules, and lessons."}
</p> </p>
</div> </div>
) : filteredCourses.length === 0 ? ( ) : filteredCourses.length === 0 ? (
@ -1017,12 +788,7 @@ export function ProgramDetailPage() {
} }
/> />
</div> </div>
{isSkillBased && course.programName ? ( {isExamPrepCatalog && course.category ? (
<p className="text-[12px] font-semibold uppercase tracking-wide text-brand-500">
<SearchHighlight text={course.programName} query={listSearch} />
</p>
) : null}
{isProficiency && course.category ? (
<p className="text-[12px] font-semibold uppercase tracking-wide text-brand-500"> <p className="text-[12px] font-semibold uppercase tracking-wide text-brand-500">
{course.category === "DUOLINGO" ? "Duolingo" : course.category} {course.category === "DUOLINGO" ? "Duolingo" : course.category}
</p> </p>
@ -1037,7 +803,7 @@ export function ProgramDetailPage() {
{/* Badges/Stats */} {/* Badges/Stats */}
<div className="flex items-center pt-4 gap-4"> <div className="flex items-center pt-4 gap-4">
{isProficiency ? ( {isExamPrepCatalog ? (
<div className="h-10 px-4 rounded-[6px] bg-grayScale-100 border border-grayScale-100 flex items-center gap-2 text-grayScale-700"> <div className="h-10 px-4 rounded-[6px] bg-grayScale-100 border border-grayScale-100 flex items-center gap-2 text-grayScale-700">
<ClipboardList className="h-3 w-3 text-grayScale-400" /> <ClipboardList className="h-3 w-3 text-grayScale-400" />
<span className="text-[12px] "> <span className="text-[12px] ">
@ -1063,12 +829,6 @@ export function ProgramDetailPage() {
<Button <Button
className="w-full mt-4 h-10 bg-brand-500 text-white rounded-[6px] font-bold flex items-center justify-center gap-2 group/btn" className="w-full mt-4 h-10 bg-brand-500 text-white rounded-[6px] font-bold flex items-center justify-center gap-2 group/btn"
onClick={() => { onClick={() => {
if (isSkillBased && course.programId) {
navigate(
`/new-content/learn-english/${course.programId}/courses/${course.id}`,
);
return;
}
navigate(`/new-content/courses/${programType}/${course.id}`); navigate(`/new-content/courses/${programType}/${course.id}`);
}} }}
> >
@ -1106,8 +866,7 @@ export function ProgramDetailPage() {
/> />
</div> </div>
{isSkillBased ? ( <div className="space-y-3">
<div className="space-y-3">
<label className="text-[15px] text-grayScale-800"> <label className="text-[15px] text-grayScale-800">
Description Description
</label> </label>
@ -1119,13 +878,10 @@ export function ProgramDetailPage() {
disabled={savingEdit || uploadingEditThumbnail} disabled={savingEdit || uploadingEditThumbnail}
/> />
</div> </div>
) : null}
{isProficiency ? ( {isExamPrepCatalog ? (
<div className="space-y-3"> <div className="space-y-3">
<label className="text-[15px] text-grayScale-800"> <label className="text-[15px] text-grayScale-800">Category</label>
Exam Category
</label>
<select <select
value={editCategory} value={editCategory}
onChange={(e) => onChange={(e) =>
@ -1134,7 +890,8 @@ export function ProgramDetailPage() {
className="h-12 w-full rounded-[8px] border border-grayScale-400 bg-white px-4 text-[15px] text-grayScale-900 focus:outline-none focus:ring-2 focus:ring-brand-500/20" className="h-12 w-full rounded-[8px] border border-grayScale-400 bg-white px-4 text-[15px] text-grayScale-900 focus:outline-none focus:ring-2 focus:ring-brand-500/20"
disabled={savingEdit || uploadingEditThumbnail} disabled={savingEdit || uploadingEditThumbnail}
> >
<option value="">Select IELTS or Duolingo…</option> <option value="">Select a category…</option>
<option value="EDUCATION">Education</option>
<option value="IELTS">IELTS</option> <option value="IELTS">IELTS</option>
<option value="DUOLINGO">Duolingo</option> <option value="DUOLINGO">Duolingo</option>
</select> </select>

View File

@ -1,77 +1,55 @@
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { GraduationCap, Brain } from "lucide-react"; import { BookOpen, Languages, Target } from "lucide-react";
import { PageBackLink } from "../../components/navigation/PageBackLink"; import { PageBackLink } from "../../components/navigation/PageBackLink";
const categories = [
{
slug: "education",
title: "Education",
description: "Structured learning courses with lessons, practice, and assessments.",
icon: BookOpen,
},
{
slug: "ielts",
title: "IELTS",
description: "Prepare learners for IELTS sections, skills, and exam practice.",
icon: Target,
},
{
slug: "duolingo",
title: "Duolingo English Test",
description: "Build courses and exam preparation for the Duolingo English Test.",
icon: Languages,
},
];
export function ProgramTypeSelectionPage() { export function ProgramTypeSelectionPage() {
return ( return (
<div className="space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-500"> <div className="animate-in fade-in space-y-8 duration-500">
<PageBackLink fallbackTo="/new-content" label="Back to Content Management" /> <PageBackLink fallbackTo="/new-content" label="Back to Learning Content" />
{/* Header section */} <div className="space-y-2 pt-2">
<div className="space-y-1.5 pt-2">
<h1 className="text-[28px] font-bold tracking-tight text-grayScale-900"> <h1 className="text-[28px] font-bold tracking-tight text-grayScale-900">
Courses Catalog Courses
</h1> </h1>
<p className="max-w-2xl text-[15px] font-medium text-grayScale-500"> <p className="max-w-2xl text-[15px] text-grayScale-500">
Organize courses under skill-based learning or English Proficiency Choose a catalog category. Each category uses the same course → unit → module → lesson structure.
Exams. Select a program type to manage curriculum and modules.
</p> </p>
</div> </div>
<div className="grid max-w-6xl grid-cols-1 gap-6 md:grid-cols-3">
{/* Gradient Divider */} {categories.map(({ slug, title, description, icon: Icon }) => (
<div className="relative"> <Link key={slug} to={`/new-content/courses/${slug}`} className="group h-full">
<div className="absolute inset-0 flex items-center" aria-hidden="true"> <div className="flex h-full min-h-64 flex-col rounded-xl border border-grayScale-100 bg-white p-7 shadow-sm transition hover:border-brand-200 hover:shadow-md">
<div className="w-full border-t border-grayScale-200" /> <div className="mb-6 flex h-14 w-14 items-center justify-center rounded-full bg-brand-50">
</div> <Icon className="h-7 w-7 text-brand-500" />
<div className="relative flex justify-center"> </div>
<div <h2 className="text-lg font-bold text-grayScale-900">{title}</h2>
className="h-[0.5px] w-full opacity-20 rounded-full" <p className="mt-2 flex-1 text-sm leading-relaxed text-grayScale-500">{description}</p>
style={{ <span className="mt-5 text-sm font-semibold text-brand-600 group-hover:underline">
background: "gray", Manage courses →
}} </span>
/>
</div>
</div>
{/* Selection Cards Grid — equal width/height, consistent content alignment */}
<div className="grid max-w-5xl grid-cols-1 items-stretch gap-8 pt-4 md:grid-cols-2">
{/* Skill-Based Courses Card */}
<Link to="/new-content/courses/skill-based" className="group h-full">
<div className="flex h-full flex-col items-start gap-10 rounded-[6px] border border-grayScale-100 bg-white px-10 py-12 transition-all">
<div className="flex h-16 w-16 shrink-0 items-center justify-center rounded-full bg-brand-50/10">
<Brain className="h-8 w-8 text-brand-500" />
</div> </div>
</Link>
<div className="flex min-h-0 flex-1 flex-col space-y-3"> ))}
<h3 className="text-[20px] font-bold text-grayScale-900">
Skill-Based Courses
</h3>
<p className="flex-1 text-[15px] font-medium leading-relaxed text-grayScale-500">
Practice-focused communication and skills training. Create
modules for vocabulary, grammar, and real-world conversation
scenarios.
</p>
</div>
</div>
</Link>
{/* English Proficiency Exams Card */}
<Link to="/new-content/courses/proficiency" className="group h-full">
<div className="flex h-full flex-col items-start gap-10 rounded-[6px] border border-grayScale-100 bg-white px-10 py-12 transition-all">
<div className="flex h-16 w-16 shrink-0 items-center justify-center rounded-full bg-brand-50/10">
<GraduationCap className="h-8 w-8 text-brand-500" />
</div>
<div className="flex min-h-0 flex-1 flex-col space-y-3">
<h3 className="text-[20px] font-bold text-grayScale-900 transition-colors">
English Proficiency Exams
</h3>
<p className="flex-1 text-[15px] font-medium leading-relaxed text-grayScale-500">
English Proficiency Exams courses. Structure content by band
scores, sections, and mock tests.
</p>
</div>
</div>
</Link>
</div> </div>
</div> </div>
); );

View File

@ -229,7 +229,7 @@ export function QuestionTypeLibraryPage() {
void load() void load()
}} }}
> >
<RefreshCw className={cn("mr-2 h-4 w-4", loading && "animate-spin")} /> {loading ? <SpinnerIcon className="mr-2 h-4 w-4" /> : <RefreshCw className="mr-2 h-4 w-4" />}
Refresh Refresh
</Button> </Button>
</div> </div>

View File

@ -1,7 +1,7 @@
import { useCallback, useEffect, useMemo, useState } from "react" import { useCallback, useEffect, useMemo, useState } from "react"
import { Link } from "react-router-dom" import { Link } from "react-router-dom"
import { Plus, Search, Edit, Trash2, HelpCircle, X, ChevronDown, ChevronLeft, ChevronRight } from "lucide-react" import { Plus, Search, Edit, Trash2, HelpCircle, X, ChevronDown, ChevronLeft, ChevronRight } from "lucide-react"
import spinnerSrc from "../../assets/Circular-indeterminate progress indicator.svg" import spinnerSrc from "../../assets/05d37a91-04f9-41d8-99a2-b11bf20a6af2.png"
import { Button } from "../../components/ui/button" import { Button } from "../../components/ui/button"
import { AdminFiltersPanel } from "../../components/filters/AdminFiltersPanel" import { AdminFiltersPanel } from "../../components/filters/AdminFiltersPanel"
import { Card, CardContent, CardHeader, CardTitle } from "../../components/ui/card" import { Card, CardContent, CardHeader, CardTitle } from "../../components/ui/card"

View File

@ -1,14 +1,7 @@
import { useState } from "react";
import { ContentHierarchyList } from "./components/ContentHierarchyList";
import { ExamPrepContentHierarchyList } from "./components/ExamPrepContentHierarchyList";
import { PageBackLink } from "../../components/navigation/PageBackLink"; import { PageBackLink } from "../../components/navigation/PageBackLink";
import { cn } from "../../lib/utils"; import { ExamPrepContentHierarchyList } from "./components/ExamPrepContentHierarchyList";
type ReorderTab = "learn_english" | "exam_prep";
export function ReorderContentPage() { export function ReorderContentPage() {
const [tab, setTab] = useState<ReorderTab>("learn_english");
return ( return (
<div className="animate-in fade-in space-y-4 pb-10 duration-500"> <div className="animate-in fade-in space-y-4 pb-10 duration-500">
<div className="space-y-3"> <div className="space-y-3">
@ -17,51 +10,17 @@ export function ReorderContentPage() {
label="Back to Content Management" label="Back to Content Management"
iconClassName="h-4 w-4 group-hover:-translate-x-1" iconClassName="h-4 w-4 group-hover:-translate-x-1"
/> />
<div className="space-y-0.5">
<div className="flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between"> <h1 className="text-xl font-bold tracking-tight text-grayScale-700">
<div className="min-w-0 space-y-0.5"> Reorder Content
<h1 className="text-xl font-bold tracking-tight text-grayScale-700"> </h1>
Reorder Content <p className="max-w-2xl text-xs text-grayScale-500">
</h1> Drag items to reorder catalog courses, units, modules, and lessons.
<p className="max-w-2xl text-xs text-grayScale-500"> Changes save when you release an item.
Drag and drop to change order. Changes save automatically on drop. </p>
</p>
</div>
<div className="flex w-fit shrink-0 gap-0.5 rounded-md border border-grayScale-200 bg-grayScale-50 p-0.5">
<button
type="button"
onClick={() => setTab("learn_english")}
className={cn(
"rounded px-3 py-1.5 text-xs font-semibold transition-colors",
tab === "learn_english"
? "bg-white text-grayScale-900 shadow-sm"
: "text-grayScale-500 hover:text-grayScale-700",
)}
>
Learn English
</button>
<button
type="button"
onClick={() => setTab("exam_prep")}
className={cn(
"rounded px-3 py-1.5 text-xs font-semibold transition-colors",
tab === "exam_prep"
? "bg-white text-grayScale-900 shadow-sm"
: "text-grayScale-500 hover:text-grayScale-700",
)}
>
Duolingo/IELTS
</button>
</div>
</div> </div>
</div> </div>
<ExamPrepContentHierarchyList />
{tab === "learn_english" ? (
<ContentHierarchyList />
) : (
<ExamPrepContentHierarchyList />
)}
</div> </div>
); );
} }

View File

@ -1,7 +1,7 @@
import { useEffect, useState } from "react" import { useEffect, useState } from "react"
import { Link, useNavigate, useParams } from "react-router-dom" import { Link, useNavigate, useParams } from "react-router-dom"
import { ArrowLeft, BookOpen, ChevronRight } from "lucide-react" import { ArrowLeft, BookOpen, ChevronRight } from "lucide-react"
import spinnerSrc from "../../assets/Circular-indeterminate progress indicator.svg" import spinnerSrc from "../../assets/05d37a91-04f9-41d8-99a2-b11bf20a6af2.png"
import alertSrc from "../../assets/Alert.svg" import alertSrc from "../../assets/Alert.svg"
import { Badge } from "../../components/ui/badge" import { Badge } from "../../components/ui/badge"
import { getCoursesBySubCategoryId, getSubCategoriesByCategoryId } from "../../api/courses.api" import { getCoursesBySubCategoryId, getSubCategoriesByCategoryId } from "../../api/courses.api"

View File

@ -1,7 +1,7 @@
import { useEffect, useState } from "react" import { useEffect, useState } from "react"
import { Link, useParams, useNavigate } from "react-router-dom" import { Link, useParams, useNavigate } from "react-router-dom"
import { ArrowLeft, Plus, FileText, Layers, Edit, Trash2, X, Video, MoreVertical, Star, ChevronLeft, ChevronRight, MessageSquare, Play } from "lucide-react" import { ArrowLeft, Plus, FileText, Layers, Edit, Trash2, X, Video, MoreVertical, Star, ChevronLeft, ChevronRight, MessageSquare, Play } from "lucide-react"
import spinnerSrc from "../../assets/Circular-indeterminate progress indicator.svg" import spinnerSrc from "../../assets/05d37a91-04f9-41d8-99a2-b11bf20a6af2.png"
import { Card } from "../../components/ui/card" import { Card } from "../../components/ui/card"
import alertSrc from "../../assets/Alert.svg" import alertSrc from "../../assets/Alert.svg"
import { Badge } from "../../components/ui/badge" import { Badge } from "../../components/ui/badge"

View File

@ -9,7 +9,7 @@ import {
LayoutList, LayoutList,
Layers, Layers,
} from "lucide-react" } from "lucide-react"
import spinnerSrc from "../../assets/Circular-indeterminate progress indicator.svg" import spinnerSrc from "../../assets/05d37a91-04f9-41d8-99a2-b11bf20a6af2.png"
import alertSrc from "../../assets/Alert.svg" import alertSrc from "../../assets/Alert.svg"
import { Badge } from "../../components/ui/badge" import { Badge } from "../../components/ui/badge"
import { Button } from "../../components/ui/button" import { Button } from "../../components/ui/button"

View File

@ -54,6 +54,7 @@ import {
} from "../../lib/contentListFilters"; } from "../../lib/contentListFilters";
import { PracticeActionButton } from "./components/PracticeActionButton"; import { PracticeActionButton } from "./components/PracticeActionButton";
import { UnitPracticesPanel } from "./components/UnitPracticesPanel"; import { UnitPracticesPanel } from "./components/UnitPracticesPanel";
import { ExamPrepAssessmentsPanel } from "./components/ExamPrepAssessmentsPanel";
import { cn } from "../../lib/utils"; import { cn } from "../../lib/utils";
import { DisplayValue } from "../../lib/displayValue" import { DisplayValue } from "../../lib/displayValue"
import { SearchHighlight } from "../../components/SearchHighlight" import { SearchHighlight } from "../../components/SearchHighlight"
@ -125,7 +126,7 @@ export function UnitManagementPage() {
const [listSearch, setListSearch] = useState(""); const [listSearch, setListSearch] = useState("");
const [publishStatusFilter, setPublishStatusFilter] = const [publishStatusFilter, setPublishStatusFilter] =
useState<PublishStatusFilter>("all"); useState<PublishStatusFilter>("all");
const [activeTab, setActiveTab] = useState<"modules" | "practices">("modules"); const [activeTab, setActiveTab] = useState<"modules" | "practices" | "assessments">("modules");
const unitPracticePathOptions = useMemo( const unitPracticePathOptions = useMemo(
() => ({ () => ({
@ -831,6 +832,13 @@ export function UnitManagementPage() {
> >
Practices Practices
</button> </button>
<button
type="button"
onClick={() => setActiveTab("assessments")}
className={cn("pb-4 text-[16px] font-medium transition-all relative", activeTab === "assessments" ? "text-brand-500 after:absolute after:bottom-0 after:left-0 after:right-0 after:h-[3px] after:bg-brand-500 after:rounded-t-full" : "text-grayScale-400 hover:text-grayScale-600")}
>
Assessment exams
</button>
</div> </div>
</div> </div>
@ -850,7 +858,9 @@ export function UnitManagementPage() {
</div> </div>
{/* Grid of Modules */} {/* Grid of Modules */}
{activeTab === "practices" ? ( {activeTab === "assessments" ? (
<ExamPrepAssessmentsPanel parent={{ kind: "UNIT", id: parsedUnitId }} />
) : activeTab === "practices" ? (
<UnitPracticesPanel <UnitPracticesPanel
unitId={parsedUnitId} unitId={parsedUnitId}
programType={programType ?? ""} programType={programType ?? ""}

View File

@ -1,7 +1,8 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { notifyApiError } from "../../../lib/apiErrors" import { notifyApiError } from "../../../lib/apiErrors"
import { useCallback, useEffect, useMemo, useState } from "react" import { useCallback, useEffect, useMemo, useState } from "react"
import { useNavigate } from "react-router-dom" import { useNavigate } from "react-router-dom"
import { BookOpen, Loader2, RefreshCw } from "lucide-react" import { BookOpen, RefreshCw } from "lucide-react"
import { toast } from "sonner" import { toast } from "sonner"
import { import {
deleteExamPrepPractice, deleteExamPrepPractice,
@ -212,7 +213,7 @@ export function CatalogCoursePracticesPanel({
if (loading) { if (loading) {
return ( return (
<div className="flex flex-col items-center justify-center py-24 text-grayScale-500"> <div className="flex flex-col items-center justify-center py-24 text-grayScale-500">
<Loader2 className="mb-3 h-8 w-8 animate-spin text-brand-500" /> <SpinnerIcon className="mb-3 h-8 w-8 text-brand-500" />
<p className="text-sm font-medium">Loading practices…</p> <p className="text-sm font-medium">Loading practices…</p>
</div> </div>
) )

View File

@ -1,5 +1,6 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { useState } from "react" import { useState } from "react"
import { Crown, Loader2, Sparkles } from "lucide-react" import { Crown, Sparkles } from "lucide-react"
import type { ContentAccessTier } from "../../../types/course.types" import type { ContentAccessTier } from "../../../types/course.types"
import { import {
accessTierLabel, accessTierLabel,
@ -34,7 +35,7 @@ export function ContentAccessTierChip({
const body = ( const body = (
<> <>
{updating ? ( {updating ? (
<Loader2 className="h-3 w-3 shrink-0 animate-spin" /> <SpinnerIcon className="h-3 w-3 shrink-0" />
) : isPremium ? ( ) : isPremium ? (
<Crown className="h-3 w-3 shrink-0" aria-hidden /> <Crown className="h-3 w-3 shrink-0" aria-hidden />
) : ( ) : (

View File

@ -1,3 +1,4 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { notifyApiError } from "../../../lib/apiErrors" import { notifyApiError } from "../../../lib/apiErrors"
import React, { useState, useEffect, useCallback } from "react"; import React, { useState, useEffect, useCallback } from "react";
import { import {
@ -22,19 +23,7 @@ import {
useSortable, useSortable,
} from "@dnd-kit/sortable"; } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities"; import { CSS } from "@dnd-kit/utilities";
import { import { GripVertical, ChevronDown, ChevronRight, LayoutGrid, BookOpen, Layers, PlayCircle, RotateCcw, Edit2, Trash2 } from "lucide-react";
GripVertical,
ChevronDown,
ChevronRight,
LayoutGrid,
BookOpen,
Layers,
PlayCircle,
RotateCcw,
Edit2,
Trash2,
Loader2,
} from "lucide-react";
import { cn } from "../../../lib/utils"; import { cn } from "../../../lib/utils";
import { toast } from "sonner"; import { toast } from "sonner";
import { import {
@ -578,7 +567,7 @@ export function ContentHierarchyList() {
> >
{loading.program ? ( {loading.program ? (
<div className="flex items-center justify-center py-4"> <div className="flex items-center justify-center py-4">
<Loader2 className="h-5 w-5 animate-spin text-brand-500" /> <SpinnerIcon className="h-5 w-5 text-brand-500" />
</div> </div>
) : ( ) : (
<DraggableList <DraggableList
@ -601,7 +590,7 @@ export function ContentHierarchyList() {
> >
{loading.course ? ( {loading.course ? (
<div className="flex items-center justify-center py-4"> <div className="flex items-center justify-center py-4">
<Loader2 className="h-5 w-5 animate-spin text-brand-500" /> <SpinnerIcon className="h-5 w-5 text-brand-500" />
</div> </div>
) : ( ) : (
programs.map((program) => { programs.map((program) => {
@ -637,7 +626,7 @@ export function ContentHierarchyList() {
> >
{loading.module ? ( {loading.module ? (
<div className="flex items-center justify-center py-4"> <div className="flex items-center justify-center py-4">
<Loader2 className="h-5 w-5 animate-spin text-brand-500" /> <SpinnerIcon className="h-5 w-5 text-brand-500" />
</div> </div>
) : ( ) : (
courses.map((course) => { courses.map((course) => {
@ -673,7 +662,7 @@ export function ContentHierarchyList() {
> >
{loading.lesson ? ( {loading.lesson ? (
<div className="flex items-center justify-center py-4"> <div className="flex items-center justify-center py-4">
<Loader2 className="h-5 w-5 animate-spin text-brand-500" /> <SpinnerIcon className="h-5 w-5 text-brand-500" />
</div> </div>
) : ( ) : (
modules.map((module) => { modules.map((module) => {

View File

@ -1,5 +1,5 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { useState } from "react" import { useState } from "react"
import { Loader2 } from "lucide-react"
import type { PracticePublishStatus } from "../../../types/course.types" import type { PracticePublishStatus } from "../../../types/course.types"
import { import {
isPublishedPublishStatus, isPublishedPublishStatus,
@ -36,7 +36,7 @@ export function ContentPublishStatusChip({
const body = ( const body = (
<> <>
{updating ? ( {updating ? (
<Loader2 className="h-3 w-3 shrink-0 animate-spin" /> <SpinnerIcon className="h-3 w-3 shrink-0" />
) : ( ) : (
<span <span
className={cn( className={cn(

View File

@ -0,0 +1,167 @@
import { useCallback, useEffect, useState } from "react";
import { Link2, Loader2, Unlink } from "lucide-react";
import { Link, useLocation } from "react-router-dom";
import { Button } from "../../../components/ui/button";
import { Select } from "../../../components/ui/select";
import { notifyApiError } from "../../../lib/apiErrors";
import {
getExamPrepAssessments,
getQuestionSets,
createQuestionSet,
linkExamPrepAssessment,
unlinkExamPrepAssessment,
} from "../../../api/courses.api";
import type { ExamPrepAssessmentParent, QuestionSet } from "../../../types/course.types";
function readSets(value: unknown): QuestionSet[] {
if (!value || typeof value !== "object") return [];
const data = (value as { data?: unknown }).data;
if (Array.isArray(data)) return data as QuestionSet[];
if (data && typeof data === "object") {
const container = data as { question_sets?: unknown; assessments?: unknown };
const sets = Array.isArray(container.assessments) ? container.assessments : container.question_sets;
if (Array.isArray(sets)) return sets as QuestionSet[];
}
return [];
}
const parentLabel: Record<ExamPrepAssessmentParent["kind"], string> = {
CATALOG_COURSE: "catalog course",
UNIT: "unit",
MODULE: "module",
LESSON: "lesson",
};
export function ExamPrepAssessmentsPanel({ parent }: { parent: ExamPrepAssessmentParent }) {
const location = useLocation();
const [linked, setLinked] = useState<QuestionSet[]>([]);
const [available, setAvailable] = useState<QuestionSet[]>([]);
const [selectedId, setSelectedId] = useState("");
const [newTitle, setNewTitle] = useState("");
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
const reload = useCallback(async () => {
setLoading(true);
try {
const [linkedResponse, availableResponse] = await Promise.all([
getExamPrepAssessments(parent),
getQuestionSets({ set_type: "EXAM", limit: 200, offset: 0 }),
]);
setLinked(readSets(linkedResponse.data));
setAvailable(readSets(availableResponse.data).filter((set) => set.set_type === "EXAM"));
} catch (error) {
notifyApiError(error, "Could not load assessments");
} finally {
setLoading(false);
}
}, [parent.kind, parent.id]);
useEffect(() => { void reload(); }, [reload]);
const linkedIds = new Set(linked.map((set) => set.id));
const attachable = available.filter((set) => !linkedIds.has(set.id));
const attach = async () => {
if (!selectedId) return;
setSaving(true);
try {
await linkExamPrepAssessment({
question_set_id: Number(selectedId),
parent_kind: parent.kind,
parent_id: parent.id,
});
setSelectedId("");
await reload();
} catch (error) {
notifyApiError(error, "Could not attach assessment");
} finally {
setSaving(false);
}
};
const detach = async (questionSetId: number) => {
setSaving(true);
try {
await unlinkExamPrepAssessment(questionSetId, parent);
await reload();
} catch (error) {
notifyApiError(error, "Could not remove assessment");
} finally {
setSaving(false);
}
};
const createExam = async () => {
if (!newTitle.trim()) return;
setSaving(true);
try {
const response = await createQuestionSet({ title: newTitle.trim(), set_type: "EXAM", status: "DRAFT" });
const id = response.data?.data?.id;
if (id == null) throw new Error("The exam question set was not created");
await linkExamPrepAssessment({ question_set_id: id, parent_kind: parent.kind, parent_id: parent.id });
setNewTitle("");
await reload();
} catch (error) {
notifyApiError(error, "Could not create exam");
} finally {
setSaving(false);
}
};
return (
<section className="space-y-4 rounded-xl border border-grayScale-200 bg-white p-4">
<div>
<h3 className="text-sm font-semibold text-grayScale-800">Assessment exams</h3>
<p className="mt-1 text-xs text-grayScale-500">
Attach EXAM question sets to this {parentLabel[parent.kind]}.
</p>
</div>
{loading ? (
<p className="flex items-center gap-2 text-xs text-grayScale-500"><Loader2 className="h-3.5 w-3.5 animate-spin" /> Loading assessments…</p>
) : (
<>
<div className="flex flex-col gap-2 sm:flex-row">
<Select value={selectedId} onChange={(event) => setSelectedId(event.target.value)} disabled={!attachable.length || saving}>
<option value="">{attachable.length ? "Select an exam question set…" : "No unlinked exam sets available"}</option>
{attachable.map((set) => <option key={set.id} value={set.id}>{set.title}</option>)}
</Select>
<Button type="button" onClick={() => void attach()} disabled={!selectedId || saving}>
<Link2 className="mr-2 h-4 w-4" /> Attach exam
</Button>
</div>
<div className="flex flex-col gap-2 sm:flex-row">
<input
className="h-10 min-w-0 flex-1 rounded-md border border-grayScale-200 bg-white px-3 text-sm text-grayScale-700 outline-none focus:border-brand-500"
value={newTitle}
onChange={(event) => setNewTitle(event.target.value)}
placeholder="New assessment exam title"
aria-label="New assessment exam title"
disabled={saving}
/>
<Button type="button" variant="outline" onClick={() => void createExam()} disabled={!newTitle.trim() || saving}>
Create exam
</Button>
</div>
{linked.length ? (
<ul className="divide-y divide-grayScale-100 rounded-lg border border-grayScale-100">
{linked.map((set) => (
<li key={set.id} className="flex items-center justify-between gap-3 px-3 py-2.5">
<span className="text-sm text-grayScale-700">{set.title}</span>
<div className="flex gap-2">
<Button asChild type="button" size="sm" variant="outline">
<Link to={`/content/question-sets/${set.id}/questions`} state={{ from: `${location.pathname}${location.search}` }}>Edit questions</Link>
</Button>
<Button type="button" size="sm" variant="outline" disabled={saving} onClick={() => void detach(set.id)}>
<Unlink className="mr-1.5 h-3.5 w-3.5" /> Remove
</Button>
</div>
</li>
))}
</ul>
) : <p className="text-xs text-grayScale-400">No assessment exams are attached here.</p>}
</>
)}
</section>
);
}

View File

@ -1,13 +1,7 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { notifyApiError } from "../../../lib/apiErrors" import { notifyApiError } from "../../../lib/apiErrors"
import { useCallback, useEffect, useState } from "react" import { useCallback, useEffect, useState } from "react"
import { import { BookOpen, GraduationCap, Layers, PlayCircle, RotateCcw } from "lucide-react"
BookOpen,
GraduationCap,
Layers,
Loader2,
PlayCircle,
RotateCcw,
} from "lucide-react"
import { toast } from "sonner" import { toast } from "sonner"
import { import {
getExamPrepCatalogCourses, getExamPrepCatalogCourses,
@ -302,7 +296,7 @@ export function ExamPrepContentHierarchyList() {
> >
{loading.catalogCourse ? ( {loading.catalogCourse ? (
<div className="flex items-center justify-center py-4"> <div className="flex items-center justify-center py-4">
<Loader2 className="h-5 w-5 animate-spin text-brand-500" /> <SpinnerIcon className="h-5 w-5 text-brand-500" />
</div> </div>
) : ( ) : (
<DraggableList <DraggableList
@ -321,7 +315,7 @@ export function ExamPrepContentHierarchyList() {
> >
{loading.unit ? ( {loading.unit ? (
<div className="flex items-center justify-center py-4"> <div className="flex items-center justify-center py-4">
<Loader2 className="h-5 w-5 animate-spin text-brand-500" /> <SpinnerIcon className="h-5 w-5 text-brand-500" />
</div> </div>
) : ( ) : (
catalogCourses.map((course) => { catalogCourses.map((course) => {
@ -353,7 +347,7 @@ export function ExamPrepContentHierarchyList() {
> >
{loading.module ? ( {loading.module ? (
<div className="flex items-center justify-center py-4"> <div className="flex items-center justify-center py-4">
<Loader2 className="h-5 w-5 animate-spin text-brand-500" /> <SpinnerIcon className="h-5 w-5 text-brand-500" />
</div> </div>
) : ( ) : (
units.map((unit) => { units.map((unit) => {
@ -385,7 +379,7 @@ export function ExamPrepContentHierarchyList() {
> >
{loading.lesson ? ( {loading.lesson ? (
<div className="flex items-center justify-center py-4"> <div className="flex items-center justify-center py-4">
<Loader2 className="h-5 w-5 animate-spin text-brand-500" /> <SpinnerIcon className="h-5 w-5 text-brand-500" />
</div> </div>
) : ( ) : (
modules.map((module) => { modules.map((module) => {

View File

@ -1,5 +1,6 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { useEffect, useMemo, useState } from "react"; import { useEffect, useMemo, useState } from "react";
import { Edit2, Loader2, MoreVertical, Unlink } from "lucide-react"; import { Edit2, MoreVertical, Unlink } from "lucide-react";
import { Button } from "../../../components/ui/button"; import { Button } from "../../../components/ui/button";
import { Card } from "../../../components/ui/card"; import { Card } from "../../../components/ui/card";
import { import {
@ -146,7 +147,7 @@ export function ModulePracticeCard({
onClick={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}
> >
{statusUpdating ? ( {statusUpdating ? (
<Loader2 className="h-4 w-4 animate-spin" /> <SpinnerIcon className="h-4 w-4" />
) : ( ) : (
<MoreVertical className="h-4 w-4" /> <MoreVertical className="h-4 w-4" />
)} )}

View File

@ -1,5 +1,5 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { useCallback, useEffect, useState } from "react" import { useCallback, useEffect, useState } from "react"
import { Loader2 } from "lucide-react"
import { toast } from "sonner" import { toast } from "sonner"
import { notifyApiError } from "../../../lib/apiErrors" import { notifyApiError } from "../../../lib/apiErrors"
import { import {
@ -173,7 +173,7 @@ export function PublishPracticeButton({
} }
> >
{(loading || acting) && ( {(loading || acting) && (
<Loader2 className="mr-2 h-4 w-4 animate-spin" /> <SpinnerIcon className="mr-2 h-4 w-4 " />
)} )}
{label} {label}
</Button> </Button>

View File

@ -1,7 +1,8 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { notifyApiError } from "../../../lib/apiErrors" import { notifyApiError } from "../../../lib/apiErrors"
import { useCallback, useEffect, useMemo, useState } from "react" import { useCallback, useEffect, useMemo, useState } from "react"
import { useNavigate } from "react-router-dom" import { useNavigate } from "react-router-dom"
import { BookOpen, Loader2, RefreshCw } from "lucide-react" import { BookOpen, RefreshCw } from "lucide-react"
import { toast } from "sonner" import { toast } from "sonner"
import { import {
deleteExamPrepPractice, deleteExamPrepPractice,
@ -208,7 +209,7 @@ export function UnitPracticesPanel({
if (loading) { if (loading) {
return ( return (
<div className="flex flex-col items-center justify-center py-24 text-grayScale-500"> <div className="flex flex-col items-center justify-center py-24 text-grayScale-500">
<Loader2 className="mb-3 h-8 w-8 animate-spin text-brand-500" /> <SpinnerIcon className="mb-3 h-8 w-8 text-brand-500" />
<p className="text-sm font-medium">Loading practices…</p> <p className="text-sm font-medium">Loading practices…</p>
</div> </div>
) )

View File

@ -1,6 +1,7 @@
import { useEffect, useMemo, useState } from "react"; import { useEffect, useMemo, useState } from "react";
import { import {
BookOpen, BookOpen,
ClipboardCheck,
Calendar, Calendar,
Edit2, Edit2,
MoreVertical, MoreVertical,
@ -90,6 +91,7 @@ interface VideoCardProps {
addPracticeDisabled?: boolean; addPracticeDisabled?: boolean;
/** When set with hoverModuleActions, shows a book icon next to edit/delete on thumbnail hover. */ /** When set with hoverModuleActions, shows a book icon next to edit/delete on thumbnail hover. */
onViewPractices?: () => void; onViewPractices?: () => void;
onViewAssessments?: () => void;
onPublish?: () => void; onPublish?: () => void;
/** Toggle draft ↔ published via PUT /lessons/:id (module lesson cards). */ /** Toggle draft ↔ published via PUT /lessons/:id (module lesson cards). */
onTogglePublishStatus?: (nextStatus: PracticePublishStatus) => void; onTogglePublishStatus?: (nextStatus: PracticePublishStatus) => void;
@ -118,6 +120,7 @@ export function VideoCard({
onAddPractice, onAddPractice,
addPracticeDisabled = false, addPracticeDisabled = false,
onViewPractices, onViewPractices,
onViewAssessments,
onTogglePublishStatus, onTogglePublishStatus,
publishStatusUpdating = false, publishStatusUpdating = false,
accessTier, accessTier,
@ -309,7 +312,7 @@ export function VideoCard({
!useGradient && "bg-grayScale-100", !useGradient && "bg-grayScale-100",
)} )}
> >
{hoverModuleActions && (onEdit || onDelete || onViewPractices) ? ( {hoverModuleActions && (onEdit || onDelete || onViewPractices || onViewAssessments) ? (
<div <div
className="absolute right-2 top-2 z-20 flex translate-y-1 gap-1 opacity-0 pointer-events-none transition-all duration-300 ease-out group-hover:translate-y-0 group-hover:opacity-100 group-hover:pointer-events-auto" className="absolute right-2 top-2 z-20 flex translate-y-1 gap-1 opacity-0 pointer-events-none transition-all duration-300 ease-out group-hover:translate-y-0 group-hover:opacity-100 group-hover:pointer-events-auto"
> >
@ -328,6 +331,18 @@ export function VideoCard({
<BookOpen className="h-3.5 w-3.5" /> <BookOpen className="h-3.5 w-3.5" />
</Button> </Button>
) : null} ) : null}
{onViewAssessments ? (
<Button
type="button"
variant="secondary"
size="icon"
className="h-8 w-8 rounded-[6px] bg-white/95 text-brand-600 shadow-sm transition-colors hover:bg-brand-50"
aria-label={`Manage assessments for ${title}`}
onClick={(e) => { e.stopPropagation(); onViewAssessments(); }}
>
<ClipboardCheck className="h-3.5 w-3.5" />
</Button>
) : null}
{onEdit ? ( {onEdit ? (
<Button <Button
type="button" type="button"

View File

@ -1,6 +1,7 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { notifyApiError } from "../../../../lib/apiErrors" import { notifyApiError } from "../../../../lib/apiErrors"
import { useRef, useState, type ChangeEvent } from "react"; import { useRef, useState, type ChangeEvent } from "react";
import { ArrowRight, ChevronDown, ChevronUp, Loader2, Upload } from "lucide-react"; import { ArrowRight, ChevronDown, ChevronUp, Upload } from "lucide-react";
import { Button } from "../../../../components/ui/button"; import { Button } from "../../../../components/ui/button";
import { Card } from "../../../../components/ui/card"; import { Card } from "../../../../components/ui/card";
import { Input } from "../../../../components/ui/input"; import { Input } from "../../../../components/ui/input";
@ -260,7 +261,7 @@ export function ContextStep({
className="gap-2" className="gap-2"
> >
{uploadingStory ? ( {uploadingStory ? (
<Loader2 className="h-4 w-4 animate-spin" /> <SpinnerIcon className="h-4 w-4" />
) : ( ) : (
<Upload className="h-4 w-4" /> <Upload className="h-4 w-4" />
)} )}

View File

@ -1,5 +1,6 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { useMemo } from "react" import { useMemo } from "react"
import { Loader2, Rocket } from "lucide-react" import { Rocket } from "lucide-react"
import { Button } from "../../../../components/ui/button" import { Button } from "../../../../components/ui/button"
import { Card } from "../../../../components/ui/card" import { Card } from "../../../../components/ui/card"
import { import {
@ -37,7 +38,7 @@ function ParentsSummaryValue({
if (loading) { if (loading) {
return ( return (
<span className="inline-flex items-center gap-2 text-grayScale-500"> <span className="inline-flex items-center gap-2 text-grayScale-500">
<Loader2 className="h-3.5 w-3.5 animate-spin" /> <SpinnerIcon className="h-3.5 w-3.5" />
Loading locations… Loading locations…
</span> </span>
) )
@ -165,7 +166,7 @@ export function LinkExistingPracticeReviewStep({
> >
{saving ? ( {saving ? (
<> <>
<Loader2 className="h-4 w-4 animate-spin" /> <SpinnerIcon className="h-4 w-4" />
Linking… Linking…
</> </>
) : ( ) : (

View File

@ -1,4 +1,5 @@
import { Check, ArrowRight, Loader2 } from "lucide-react"; import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { Check, ArrowRight } from "lucide-react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { Button } from "../../../../components/ui/button"; import { Button } from "../../../../components/ui/button";
import { PersonaAvatar } from "../../../../components/personas/PersonaAvatar"; import { PersonaAvatar } from "../../../../components/personas/PersonaAvatar";
@ -39,7 +40,7 @@ export function PersonaStep({
{loading ? ( {loading ? (
<div className="flex flex-col items-center justify-center py-16"> <div className="flex flex-col items-center justify-center py-16">
<Loader2 className="h-10 w-10 animate-spin text-brand-500" /> <SpinnerIcon className="h-10 w-10 text-brand-500" />
<p className="mt-4 text-sm font-medium text-grayScale-500"> <p className="mt-4 text-sm font-medium text-grayScale-500">
Loading personas… Loading personas…
</p> </p>

View File

@ -1,6 +1,7 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { notifyApiError } from "../../../../lib/apiErrors" import { notifyApiError } from "../../../../lib/apiErrors"
import { useMemo, useState } from "react" import { useMemo, useState } from "react"
import { Loader2, Plus, Trash2 } from "lucide-react" import { Plus, Trash2 } from "lucide-react"
import { usePracticeParentTitles } from "../../../../hooks/usePracticeParentTitles" import { usePracticeParentTitles } from "../../../../hooks/usePracticeParentTitles"
import { toast } from "sonner" import { toast } from "sonner"
import { Button } from "../../../../components/ui/button" import { Button } from "../../../../components/ui/button"
@ -228,7 +229,7 @@ export function PracticeParentsField({
aria-label="Remove location" aria-label="Remove location"
> >
{isUnlinking ? ( {isUnlinking ? (
<Loader2 className="h-4 w-4 animate-spin" /> <SpinnerIcon className="h-4 w-4" />
) : ( ) : (
<Trash2 className="h-4 w-4" /> <Trash2 className="h-4 w-4" />
)} )}

View File

@ -1,5 +1,6 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { useState } from "react"; import { useState } from "react";
import { Edit, Info, Loader2, Play, Rocket } from "lucide-react"; import { Edit, Info, Play, Rocket } from "lucide-react";
import { PersonaAvatar } from "../../../../components/personas/PersonaAvatar"; import { PersonaAvatar } from "../../../../components/personas/PersonaAvatar";
import { Button } from "../../../../components/ui/button"; import { Button } from "../../../../components/ui/button";
import { Card } from "../../../../components/ui/card"; import { Card } from "../../../../components/ui/card";
@ -399,7 +400,7 @@ export function PracticeSequentialReview({
> >
{saving ? ( {saving ? (
<> <>
<Loader2 className="mr-2 h-4 w-4 animate-spin" /> <SpinnerIcon className="mr-2 h-4 w-4" />
Saving… Saving…
</> </>
) : ( ) : (
@ -413,7 +414,7 @@ export function PracticeSequentialReview({
className="h-10 gap-2 rounded-[6px] bg-brand-500 px-8 text-sm font-bold text-white shadow-md shadow-brand-500/20 hover:bg-brand-600 disabled:opacity-50" className="h-10 gap-2 rounded-[6px] bg-brand-500 px-8 text-sm font-bold text-white shadow-md shadow-brand-500/20 hover:bg-brand-600 disabled:opacity-50"
> >
{saving ? ( {saving ? (
<Loader2 className="h-4 w-4 animate-spin" /> <SpinnerIcon className="h-4 w-4" />
) : ( ) : (
<Rocket className="h-4 w-4" /> <Rocket className="h-4 w-4" />
)} )}

View File

@ -1,7 +1,8 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { notifyApiError } from "../../../../lib/apiErrors" import { notifyApiError } from "../../../../lib/apiErrors"
import { useRef, useState, type ChangeEvent } from "react"; import { useRef, useState, type ChangeEvent } from "react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { Upload, ArrowRight, Loader2 } from "lucide-react"; import { Upload, ArrowRight } from "lucide-react";
import { Button } from "../../../../components/ui/button"; import { Button } from "../../../../components/ui/button";
import { Card } from "../../../../components/ui/card"; import { Card } from "../../../../components/ui/card";
import { Input } from "../../../../components/ui/input"; import { Input } from "../../../../components/ui/input";
@ -86,7 +87,7 @@ export function ScenarioStep({
className="gap-2" className="gap-2"
> >
{uploadingBanner ? ( {uploadingBanner ? (
<Loader2 className="h-4 w-4 animate-spin" /> <SpinnerIcon className="h-4 w-4" />
) : ( ) : (
<Upload className="h-4 w-4" /> <Upload className="h-4 w-4" />
)} )}

View File

@ -1,5 +1,6 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { useState } from "react" import { useState } from "react"
import { ArrowLeft, Loader2 } from "lucide-react" import { ArrowLeft } from "lucide-react"
import { useNavigate } from "react-router-dom" import { useNavigate } from "react-router-dom"
import { toast } from "sonner" import { toast } from "sonner"
import { notifyApiError } from "../../../../lib/apiErrors" import { notifyApiError } from "../../../../lib/apiErrors"
@ -149,7 +150,7 @@ export function QuestionTypeReviewPublishStep({
onClick={() => void submit("INACTIVE")} onClick={() => void submit("INACTIVE")}
> >
{submitting ? ( {submitting ? (
<Loader2 className="h-4 w-4 animate-spin" /> <SpinnerIcon className="h-4 w-4" />
) : isEdit ? ( ) : isEdit ? (
"Save as inactive" "Save as inactive"
) : ( ) : (
@ -163,7 +164,7 @@ export function QuestionTypeReviewPublishStep({
onClick={() => void submit("ACTIVE")} onClick={() => void submit("ACTIVE")}
> >
{submitting ? ( {submitting ? (
<Loader2 className="h-4 w-4 animate-spin" /> <SpinnerIcon className="h-4 w-4" />
) : isEdit ? ( ) : isEdit ? (
"Save as active" "Save as active"
) : ( ) : (

View File

@ -1,5 +1,6 @@
import { SpinnerIcon } from "@/components/ui/spinner-icon";
import { useCallback, useEffect, useState } from "react" import { useCallback, useEffect, useState } from "react"
import { CheckCircle2, Loader2 } from "lucide-react" import { CheckCircle2 } from "lucide-react"
import { toast } from "sonner" import { toast } from "sonner"
import { Button } from "../../../../components/ui/button" import { Button } from "../../../../components/ui/button"
import { Card } from "../../../../components/ui/card" import { Card } from "../../../../components/ui/card"
@ -95,7 +96,7 @@ export function QuestionTypeValidatePreviewStep({
> >
{validating ? ( {validating ? (
<> <>
<Loader2 className="h-4 w-4 mr-2 animate-spin" /> <SpinnerIcon className="h-4 w-4 mr-2" />
Validating… Validating…
</> </>
) : ( ) : (

View File

@ -10,13 +10,10 @@ import type {
LearningActivityCourse, LearningActivityCourse,
LearningActivityLesson, LearningActivityLesson,
LearningActivityModule, LearningActivityModule,
LearningActivityProgram,
LearningActivityUnit, LearningActivityUnit,
UserLearningActivityData, UserLearningActivityData,
} from "../../../types/userAdmin.types"; } from "../../../types/userAdmin.types";
type Track = "lms" | "exam_prep";
function ProgressBar({ access }: { access: LearningActivityAccess }) { function ProgressBar({ access }: { access: LearningActivityAccess }) {
const percent = Math.min(100, Math.max(0, access.progress_percent)); const percent = Math.min(100, Math.max(0, access.progress_percent));
return ( return (
@ -154,9 +151,9 @@ function UnitBlock({ unit }: { unit: LearningActivityUnit }) {
); );
} }
function CourseBlock({ course, examPrep }: { course: LearningActivityCourse; examPrep?: boolean }) { function CourseBlock({ course }: { course: LearningActivityCourse }) {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const children = examPrep ? (course.units ?? []) : (course.modules ?? []); const children = course.units ?? [];
return ( return (
<div className="rounded-xl border border-grayScale-200 bg-white"> <div className="rounded-xl border border-grayScale-200 bg-white">
@ -184,10 +181,8 @@ function CourseBlock({ course, examPrep }: { course: LearningActivityCourse; exa
<div className="space-y-3 border-t border-grayScale-100 px-4 py-3"> <div className="space-y-3 border-t border-grayScale-100 px-4 py-3">
{children.length === 0 ? ( {children.length === 0 ? (
<p className="text-xs text-grayScale-400">No content available.</p> <p className="text-xs text-grayScale-400">No content available.</p>
) : examPrep ? (
(course.units ?? []).map((unit) => <UnitBlock key={unit.id} unit={unit} />)
) : ( ) : (
(course.modules ?? []).map((module) => <ModuleBlock key={module.id} module={module} />) (course.units ?? []).map((unit) => <UnitBlock key={unit.id} unit={unit} />)
)} )}
</div> </div>
) : null} ) : null}
@ -214,23 +209,10 @@ export function UserLearningActivitySection({
error: string | null; error: string | null;
}) { }) {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [track, setTrack] = useState<Track>("lms");
const programs = activity?.lms.progress.programs ?? [];
const catalogCourses = activity?.exam_prep.progress.catalog_courses ?? []; const catalogCourses = activity?.exam_prep.progress.catalog_courses ?? [];
const [selectedProgramId, setSelectedProgramId] = useState<number | null>(null);
const [selectedCatalogCourseId, setSelectedCatalogCourseId] = useState<number | null>(null); const [selectedCatalogCourseId, setSelectedCatalogCourseId] = useState<number | null>(null);
useEffect(() => {
if (programs.length === 0) {
setSelectedProgramId(null);
return;
}
if (!selectedProgramId || !programs.some((program) => program.id === selectedProgramId)) {
setSelectedProgramId(programs[0].id);
}
}, [programs, selectedProgramId]);
useEffect(() => { useEffect(() => {
if (catalogCourses.length === 0) { if (catalogCourses.length === 0) {
setSelectedCatalogCourseId(null); setSelectedCatalogCourseId(null);
@ -244,18 +226,11 @@ export function UserLearningActivitySection({
} }
}, [catalogCourses, selectedCatalogCourseId]); }, [catalogCourses, selectedCatalogCourseId]);
const selectedProgram = useMemo(
() => programs.find((program) => program.id === selectedProgramId) ?? null,
[programs, selectedProgramId],
);
const selectedCatalogCourse = useMemo( const selectedCatalogCourse = useMemo(
() => catalogCourses.find((course) => course.id === selectedCatalogCourseId) ?? null, () => catalogCourses.find((course) => course.id === selectedCatalogCourseId) ?? null,
[catalogCourses, selectedCatalogCourseId], [catalogCourses, selectedCatalogCourseId],
); );
const completedIds = activity?.lms.completed_ids;
return ( return (
<Card className="shadow-soft"> <Card className="shadow-soft">
<CardHeader className="pb-3"> <CardHeader className="pb-3">
@ -272,7 +247,7 @@ export function UserLearningActivitySection({
<div> <div>
<CardTitle className="text-base">Learning activity</CardTitle> <CardTitle className="text-base">Learning activity</CardTitle>
<p className="mt-0.5 text-xs text-grayScale-500"> <p className="mt-0.5 text-xs text-grayScale-500">
LMS and Duolingo/IELTS progress trees for this learner. Progress through catalog course → unit → module → lesson.
</p> </p>
</div> </div>
</div> </div>
@ -285,32 +260,6 @@ export function UserLearningActivitySection({
</CardHeader> </CardHeader>
{open ? ( {open ? (
<CardContent className="space-y-4"> <CardContent className="space-y-4">
<div className="flex justify-end">
<div className="flex rounded-lg border border-grayScale-200 p-1">
<button
type="button"
className={cn(
"rounded-[6px] px-3 py-1.5 text-xs font-medium transition-colors",
track === "lms" ? "bg-brand-500 text-white" : "text-grayScale-500 hover:text-grayScale-700",
)}
onClick={() => setTrack("lms")}
>
Learn English
</button>
<button
type="button"
className={cn(
"rounded-[6px] px-3 py-1.5 text-xs font-medium transition-colors",
track === "exam_prep"
? "bg-brand-500 text-white"
: "text-grayScale-500 hover:text-grayScale-700",
)}
onClick={() => setTrack("exam_prep")}
>
Duolingo/IELTS
</button>
</div>
</div>
{loading ? ( {loading ? (
<div className="flex items-center gap-2 rounded-lg border border-grayScale-200 bg-grayScale-100 px-3 py-2 text-xs text-grayScale-500"> <div className="flex items-center gap-2 rounded-lg border border-grayScale-200 bg-grayScale-100 px-3 py-2 text-xs text-grayScale-500">
<SpinnerIcon className="h-3.5 w-3.5" /> <SpinnerIcon className="h-3.5 w-3.5" />
@ -324,56 +273,10 @@ export function UserLearningActivitySection({
</div> </div>
) : null} ) : null}
{!loading && !error && activity && track === "lms" ? ( {!loading && !error && activity ? (
<>
<div className="grid gap-2 sm:grid-cols-2 lg:grid-cols-4">
<Metric label="Programs" value={programs.length} />
<Metric label="Completed programs" value={completedIds?.program_ids.length ?? 0} />
<Metric label="Completed courses" value={completedIds?.course_ids.length ?? 0} />
<Metric label="Completed lessons" value={completedIds?.lesson_ids.length ?? 0} />
</div>
<div className="w-full sm:max-w-sm">
<Select
value={selectedProgramId ? String(selectedProgramId) : ""}
onChange={(e) => setSelectedProgramId(e.target.value ? Number(e.target.value) : null)}
disabled={programs.length === 0}
>
<option value="">{programs.length === 0 ? "No programs available" : "Select program..."}</option>
{programs.map((program: LearningActivityProgram) => (
<option key={program.id} value={program.id}>
{program.name}
</option>
))}
</Select>
</div>
{selectedProgram ? (
<div className="space-y-3">
<div className="rounded-xl border border-brand-100 bg-brand-50/40 px-4 py-3">
<p className="text-sm font-semibold text-grayScale-800">{selectedProgram.name}</p>
<div className="mt-2">
<AccessMeta access={selectedProgram.access} />
</div>
</div>
{selectedProgram.courses.length === 0 ? (
<p className="py-6 text-center text-sm text-grayScale-400">No courses in this program.</p>
) : (
selectedProgram.courses.map((course) => (
<CourseBlock key={course.id} course={course} />
))
)}
</div>
) : (
<p className="py-6 text-center text-sm text-grayScale-400">No LMS learning activity yet.</p>
)}
</>
) : null}
{!loading && !error && activity && track === "exam_prep" ? (
<> <>
<div className="grid gap-2 sm:grid-cols-2 lg:grid-cols-3"> <div className="grid gap-2 sm:grid-cols-2 lg:grid-cols-3">
<Metric label="Duolingo/IELTS courses" value={catalogCourses.length} /> <Metric label="Catalog courses" value={catalogCourses.length} />
<Metric <Metric
label="Accessible courses" label="Accessible courses"
value={catalogCourses.filter((course) => course.access.is_accessible).length} value={catalogCourses.filter((course) => course.access.is_accessible).length}
@ -393,7 +296,7 @@ export function UserLearningActivitySection({
disabled={catalogCourses.length === 0} disabled={catalogCourses.length === 0}
> >
<option value=""> <option value="">
{catalogCourses.length === 0 ? "No Duolingo/IELTS courses" : "Select Duolingo/IELTS course..."} {catalogCourses.length === 0 ? "No catalog courses" : "Select catalog course..."}
</option> </option>
{catalogCourses.map((course) => ( {catalogCourses.map((course) => (
<option key={course.id} value={course.id}> <option key={course.id} value={course.id}>
@ -404,9 +307,9 @@ export function UserLearningActivitySection({
</div> </div>
{selectedCatalogCourse ? ( {selectedCatalogCourse ? (
<CourseBlock course={selectedCatalogCourse} examPrep /> <CourseBlock course={selectedCatalogCourse} />
) : ( ) : (
<p className="py-6 text-center text-sm text-grayScale-400">No Duolingo/IELTS activity yet.</p> <p className="py-6 text-center text-sm text-grayScale-400">No catalog course activity yet.</p>
)} )}
</> </>
) : null} ) : null}

View File

@ -100,18 +100,6 @@ export interface DashboardPayments {
revenue_last_30_days: DateRevenue[] revenue_last_30_days: DateRevenue[]
} }
export interface DashboardCoursesLms {
programs: number
courses: number
modules: number
lessons: number
lessons_with_video: number
practices: number
practices_at_course: number
practices_at_module: number
practices_at_lesson: number
}
export interface DashboardCoursesExamPrep { export interface DashboardCoursesExamPrep {
catalog_courses: number catalog_courses: number
units: number units: number
@ -126,7 +114,6 @@ export interface DashboardCourses {
total_courses: number total_courses: number
total_sub_courses: number total_sub_courses: number
total_videos: number total_videos: number
lms?: DashboardCoursesLms
exam_prep?: DashboardCoursesExamPrep exam_prep?: DashboardCoursesExamPrep
} }

View File

@ -159,7 +159,7 @@ export interface CreateProgramCourseResponse {
} }
/** Exam prep catalog course row (e.g. IELTS / DET cards) */ /** Exam prep catalog course row (e.g. IELTS / DET cards) */
export type ExamPrepCatalogCategory = "IELTS" | "DUOLINGO" export type ExamPrepCatalogCategory = "EDUCATION" | "IELTS" | "DUOLINGO"
export interface ExamPrepCatalogCourseItem { export interface ExamPrepCatalogCourseItem {
id: number id: number
@ -1286,6 +1286,19 @@ export type QuestionSetType = "PRACTICE" | "EXAM"
export type QuestionSetStatus = "PUBLISHED" | "DRAFT" | "ARCHIVED" export type QuestionSetStatus = "PUBLISHED" | "DRAFT" | "ARCHIVED"
export type QuestionSetOwnerType = "SUB_COURSE" | "SUB_MODULE" | "COURSE" export type QuestionSetOwnerType = "SUB_COURSE" | "SUB_MODULE" | "COURSE"
export type ExamPrepAssessmentParentKind = "CATALOG_COURSE" | "UNIT" | "MODULE" | "LESSON"
export interface ExamPrepAssessmentParent {
kind: ExamPrepAssessmentParentKind
id: number
}
export interface ExamPrepAssessmentLinkRequest {
question_set_id: number
parent_kind: ExamPrepAssessmentParentKind
parent_id: number
}
export interface QuestionSet { export interface QuestionSet {
id: number id: number
title: string title: string

View File

@ -20,8 +20,6 @@ export interface LearningActivityLesson {
export interface LearningActivityModule { export interface LearningActivityModule {
id: number id: number
program_id?: number
course_id?: number
unit_id?: number unit_id?: number
name: string name: string
access: LearningActivityAccess access: LearningActivityAccess
@ -38,7 +36,6 @@ export interface LearningActivityUnit {
export interface LearningActivityCourse { export interface LearningActivityCourse {
id: number id: number
program_id?: number
catalog_course_id?: number catalog_course_id?: number
name: string name: string
access: LearningActivityAccess access: LearningActivityAccess
@ -46,32 +43,8 @@ export interface LearningActivityCourse {
units?: LearningActivityUnit[] units?: LearningActivityUnit[]
} }
export interface LearningActivityProgram {
id: number
name: string
access: LearningActivityAccess
courses: LearningActivityCourse[]
}
export interface LearningActivityCompletedIds {
lesson_ids: number[]
module_ids: number[]
course_ids: number[]
program_ids: number[]
}
export interface UserLearningActivityData { export interface UserLearningActivityData {
user_id: number user_id: number
lms: {
completed_ids: LearningActivityCompletedIds
progress: {
programs: LearningActivityProgram[]
}
completions: {
user_id: number
programs: unknown[]
}
}
exam_prep: { exam_prep: {
progress: { progress: {
catalog_courses: LearningActivityCourse[] catalog_courses: LearningActivityCourse[]