diff --git a/src/components/admin/TablePagination.tsx b/src/components/admin/TablePagination.tsx index bb9bac1..71927ff 100644 --- a/src/components/admin/TablePagination.tsx +++ b/src/components/admin/TablePagination.tsx @@ -83,7 +83,7 @@ export function TablePagination({ onClick={() => onPageChange(Math.max(1, currentPage - 1))} disabled={disabled || currentPage <= 1} className={cn( - "flex h-8 w-8 items-center justify-center rounded-md border bg-white text-grayScale-500", + "flex h-8 w-8 items-center justify-center rounded-[6px] border bg-white text-grayScale-500", (disabled || currentPage <= 1) && "cursor-not-allowed opacity-50", )} aria-label="Previous page" @@ -102,7 +102,7 @@ export function TablePagination({ disabled={disabled} onClick={() => onPageChange(n)} className={cn( - "h-8 w-8 rounded-md border text-sm font-medium", + "h-8 w-8 rounded-[6px] border text-sm font-medium", n === currentPage ? "border-brand-500 bg-brand-500 text-white" : "bg-white text-grayScale-600 hover:bg-grayScale-50", @@ -117,7 +117,7 @@ export function TablePagination({ onClick={() => onPageChange(Math.min(totalPages, currentPage + 1))} disabled={disabled || currentPage >= totalPages} className={cn( - "flex h-8 w-8 items-center justify-center rounded-md border bg-white text-grayScale-500", + "flex h-8 w-8 items-center justify-center rounded-[6px] border bg-white text-grayScale-500", (disabled || currentPage >= totalPages) && "cursor-not-allowed opacity-50", )} aria-label="Next page" diff --git a/src/components/analytics/AnalyticsTimeRangeFilter.tsx b/src/components/analytics/AnalyticsTimeRangeFilter.tsx index 6824b12..f2dbb68 100644 --- a/src/components/analytics/AnalyticsTimeRangeFilter.tsx +++ b/src/components/analytics/AnalyticsTimeRangeFilter.tsx @@ -165,7 +165,7 @@ export function AnalyticsTimeRangeFilter({ value, onChange, className }: Analyti @@ -897,7 +897,7 @@ export function PracticeQuestionEditorFields({ @@ -910,7 +910,7 @@ export function AddNewPracticePage() { diff --git a/src/pages/content-management/AddQuestionPage.tsx b/src/pages/content-management/AddQuestionPage.tsx index 0ad9934..1097e53 100644 --- a/src/pages/content-management/AddQuestionPage.tsx +++ b/src/pages/content-management/AddQuestionPage.tsx @@ -354,7 +354,7 @@ export function AddQuestionPage() { variant="ghost" size="icon" onClick={() => navigateBack(navigate, "/content/questions")} - className="h-9 w-9 shrink-0 rounded-lg bg-grayScale-50 hover:bg-brand-500/10 hover:text-brand-500" + className="h-9 w-9 shrink-0 rounded-[6px] bg-grayScale-50 hover:bg-brand-500/10 hover:text-brand-500" > diff --git a/src/pages/content-management/AddVideoFlow.tsx b/src/pages/content-management/AddVideoFlow.tsx index 2c5284e..b5d5e81 100644 --- a/src/pages/content-management/AddVideoFlow.tsx +++ b/src/pages/content-management/AddVideoFlow.tsx @@ -192,7 +192,7 @@ export function AddVideoFlow() { diff --git a/src/pages/content-management/AllCoursesPage.tsx b/src/pages/content-management/AllCoursesPage.tsx index 8b15879..ad13bdd 100644 --- a/src/pages/content-management/AllCoursesPage.tsx +++ b/src/pages/content-management/AllCoursesPage.tsx @@ -448,7 +448,7 @@ export function AllCoursesPage() { onClick={() => safePage > 1 && setPage(safePage - 1)} disabled={safePage === 1} className={cn( - "flex h-8 w-8 items-center justify-center rounded-md border bg-white text-grayScale-500", + "flex h-8 w-8 items-center justify-center rounded-[6px] border bg-white text-grayScale-500", safePage === 1 && "cursor-not-allowed opacity-50", )} > @@ -465,7 +465,7 @@ export function AllCoursesPage() { type="button" onClick={() => setPage(n)} className={cn( - "h-8 w-8 rounded-md border text-sm font-medium", + "h-8 w-8 rounded-[6px] border text-sm font-medium", n === safePage ? "border-brand-500 bg-brand-500 text-white" : "bg-white text-grayScale-600 hover:bg-grayScale-50", @@ -479,7 +479,7 @@ export function AllCoursesPage() { onClick={() => safePage < totalPages && setPage(safePage + 1)} disabled={safePage === totalPages} className={cn( - "flex h-8 w-8 items-center justify-center rounded-md border bg-white text-grayScale-500", + "flex h-8 w-8 items-center justify-center rounded-[6px] border bg-white text-grayScale-500", safePage === totalPages && "cursor-not-allowed opacity-50", )} > diff --git a/src/pages/content-management/AttachProgramPracticeFlow.tsx b/src/pages/content-management/AttachProgramPracticeFlow.tsx index d0bc98f..16c4de3 100644 --- a/src/pages/content-management/AttachProgramPracticeFlow.tsx +++ b/src/pages/content-management/AttachProgramPracticeFlow.tsx @@ -53,7 +53,7 @@ export function AttachProgramPracticeFlow() {
@@ -63,7 +63,7 @@ export function AttachProgramPracticeFlow() { setIsPublished(false); setCurrentStep(1); }} - className="h-14 rounded-[12px] border-[#9E2891] text-[#9E2891] font-bold text-[16px] bg-white " + className="h-14 rounded-[6px] border-[#9E2891] text-[#9E2891] font-bold text-[16px] bg-white " > Attach More Practice diff --git a/src/pages/content-management/ContentOverviewPage.tsx b/src/pages/content-management/ContentOverviewPage.tsx index d88c1dd..14303ff 100644 --- a/src/pages/content-management/ContentOverviewPage.tsx +++ b/src/pages/content-management/ContentOverviewPage.tsx @@ -176,7 +176,7 @@ export function ContentOverviewPage() {
diff --git a/src/pages/content-management/CourseCategoryPage.tsx b/src/pages/content-management/CourseCategoryPage.tsx index 9de5898..2913975 100644 --- a/src/pages/content-management/CourseCategoryPage.tsx +++ b/src/pages/content-management/CourseCategoryPage.tsx @@ -80,7 +80,7 @@ export function CourseCategoryPage() {
diff --git a/src/pages/content-management/CourseFlowBuilderPage.tsx b/src/pages/content-management/CourseFlowBuilderPage.tsx index cbbd681..3919405 100644 --- a/src/pages/content-management/CourseFlowBuilderPage.tsx +++ b/src/pages/content-management/CourseFlowBuilderPage.tsx @@ -125,7 +125,7 @@ function SortableChip({ @@ -677,7 +677,7 @@ export function CoursesPage() {

Edit Sub-category

@@ -761,7 +761,7 @@ export function CoursesPage() {

Delete Sub-category

diff --git a/src/pages/content-management/EditPracticeFlow.tsx b/src/pages/content-management/EditPracticeFlow.tsx index 3614f86..3b61674 100644 --- a/src/pages/content-management/EditPracticeFlow.tsx +++ b/src/pages/content-management/EditPracticeFlow.tsx @@ -785,14 +785,14 @@ export function EditPracticeFlow() {
diff --git a/src/pages/content-management/LessonPracticesPage.tsx b/src/pages/content-management/LessonPracticesPage.tsx index e5a7f9b..2d78d02 100644 --- a/src/pages/content-management/LessonPracticesPage.tsx +++ b/src/pages/content-management/LessonPracticesPage.tsx @@ -1,22 +1,11 @@ import { notifyApiError } from "../../lib/apiErrors" import { useCallback, useEffect, useMemo, useState } from "react"; -import { - AlertCircle, - ArrowLeft, - BookOpen, - Calendar, - Clock, - Edit2, - Hash, - Loader2, - RefreshCw, - Sparkles, - Trash2, -} from "lucide-react"; +import { ArrowLeft, BookOpen, Calendar, RefreshCw } from "lucide-react"; import { Link, useNavigate, useParams, useSearchParams } from "react-router-dom"; import { toast } from "sonner"; import { deleteExamPrepPractice, + deleteParentLinkedPractice, getExamPrepLessonPractices, getPracticesByParentLesson, setExamPrepPracticePublishStatus, @@ -25,14 +14,11 @@ import { import { parentsFromPractice } from "../../lib/practiceParents"; import { isPracticeParentUnlinkNotLinkedError, - mapPracticeParentUnlinkError, unlinkPracticeFromParent, } from "../../lib/practiceParentUnlink"; -import { Badge } from "../../components/ui/badge"; import { Button } from "../../components/ui/button"; import { PracticeActionButton } from "./components/PracticeActionButton"; import { ModulePracticeCard } from "./components/ModulePracticeCard"; -import { Card, CardContent } from "../../components/ui/card"; import { Dialog, DialogContent, @@ -43,27 +29,19 @@ import { import type { ExamPrepLessonPractice, GetExamPrepLessonPracticesResponse, - GetPracticesByParentContextResponse, ParentContextPractice, PracticeParent, PracticePublishStatus, } from "../../types/course.types"; -import { ContentPublishStatusChip } from "./components/ContentPublishStatusChip"; import { ContentListSearchFilterBar } from "./components/ContentListSearchFilterBar"; +import { ContentPageDescription } from "./components/ContentPageDescription"; import { filterBySearchAndPublishStatus, type PublishStatusFilter, } from "../../lib/contentListFilters"; -import { resolveThumbnailForPreview } from "../../lib/videoPreview"; import { cn } from "../../lib/utils"; - -function unwrapPracticesEnvelope( - res: { data?: GetPracticesByParentContextResponse & { Data?: GetPracticesByParentContextResponse["data"] } }, -): GetPracticesByParentContextResponse["data"] | null { - const b = res.data; - if (!b) return null; - return b.data ?? b.Data ?? null; -} +import { fetchAllOffsetPages } from "../../lib/fetchAllOffsetPages"; +import { unwrapPracticesPage } from "../../lib/parentContextPractice"; function unwrapExamPrepPracticesEnvelope( res: { data?: GetExamPrepLessonPracticesResponse & { Data?: GetExamPrepLessonPracticesResponse["data"] } }, @@ -92,171 +70,6 @@ function mapExamPrepPracticeToCard( }; } -function formatPracticeDate(iso: string): string { - const d = new Date(iso); - return Number.isNaN(d.getTime()) - ? iso - : d.toLocaleString(undefined, { dateStyle: "medium", timeStyle: "short" }); -} - -function PracticeCard({ - practice, - index, - total, - onEdit, - onUnlink, - onDelete, - onTogglePublishStatus, - publishStatusUpdating, -}: { - practice: ParentContextPractice; - index: number; - total: number; - onEdit?: () => void; - onUnlink?: () => void; - onDelete?: () => void; - onTogglePublishStatus?: (nextStatus: PracticePublishStatus) => void; - publishStatusUpdating?: boolean; -}) { - const [imgFailed, setImgFailed] = useState(false); - const thumb = resolveThumbnailForPreview(practice.story_image); - const showThumb = Boolean(thumb) && !imgFailed; - - return ( - - -
-
-
- {showThumb ? ( - <> - setImgFailed(true)} - /> -
- - ) : ( -
-
- -
- - No cover image - -
- )} -
-
- -
-
-
- - Practice {index + 1} of {total} - - - ID {practice.id} - - -
- {onUnlink ? ( - - ) : null} - {onDelete ? ( - - ) : null} -
- -

- {practice.title} -

- - {practice.story_description?.trim() ? ( -
-

- Story & instructions -

-

- {practice.story_description} -

-
- ) : null} - - {practice.quick_tips?.trim() ? ( -
-

- Quick tips -

-

- {practice.quick_tips} -

-
- ) : null} - -
- - - Question set {practice.question_set_id} - - - - {formatPracticeDate(practice.created_at)} - - {onEdit ? ( - - ) : null} -
-
-
- - - ); -} - export function LessonPracticesPage() { const navigate = useNavigate(); const { level, programType, courseId, unitId, moduleId, lessonId } = useParams<{ @@ -319,27 +132,27 @@ export function LessonPracticesPage() { setLoadError(null); try { if (isExamPrep) { - const res = await getExamPrepLessonPractices(lid, { limit: 100, offset: 0 }); - const envelope = unwrapExamPrepPracticesEnvelope(res); - const list = Array.isArray(envelope?.practices) - ? envelope.practices.map(mapExamPrepPracticeToCard) - : []; + const list = await fetchAllOffsetPages(async (offset, limit) => { + const res = await getExamPrepLessonPractices(lid, { limit, offset }); + const envelope = unwrapExamPrepPracticesEnvelope(res); + const practices = Array.isArray(envelope?.practices) + ? envelope.practices.map(mapExamPrepPracticeToCard) + : []; + return { + items: practices, + total_count: envelope?.total_count, + }; + }); setPractices(list); - setTotalCount( - typeof envelope?.total_count === "number" - ? envelope.total_count - : list.length, - ); + setTotalCount(list.length); } else { - const res = await getPracticesByParentLesson(lid, { limit: 100, offset: 0 }); - const envelope = unwrapPracticesEnvelope(res); - const list = Array.isArray(envelope?.practices) ? envelope.practices : []; - setPractices(list); - setTotalCount( - typeof envelope?.total_count === "number" - ? envelope.total_count - : list.length, + const list = await fetchAllOffsetPages(async (offset, limit) => + unwrapPracticesPage( + await getPracticesByParentLesson(lid, { limit, offset }), + ), ); + setPractices(list); + setTotalCount(list.length); } } catch (error) { setPractices([]); @@ -368,7 +181,7 @@ export function LessonPracticesPage() { moduleId, lessonId: validLesson ? String(lid) : null, lessonTitle: lessonTitle || displayTitle, - backTo: isExamPrep ? "lesson" : "module", + backTo: "lesson", }), [ isExamPrep, @@ -444,14 +257,14 @@ export function LessonPracticesPage() { toast.success(`Practice removed from ${displayTitle}`); setPracticeToUnlink(null); await load(); - } catch (e) { - if (isPracticeParentUnlinkNotLinkedError(e)) { + } catch (error) { + if (isPracticeParentUnlinkNotLinkedError(error)) { toast.info("This location was already removed."); setPracticeToUnlink(null); await load(); return; } - notifyApiError(err, "Could not remove from lesson"); + notifyApiError(error, "Could not remove from lesson"); } finally { setUnlinking(false); } @@ -461,7 +274,11 @@ export function LessonPracticesPage() { if (!practiceToDelete) return; setDeleting(true); try { - await deleteExamPrepPractice(practiceToDelete.id); + if (isExamPrep) { + await deleteExamPrepPractice(practiceToDelete.id); + } else { + await deleteParentLinkedPractice(practiceToDelete.id); + } toast.success("Practice deleted"); setPracticeToDelete(null); await load(); @@ -474,223 +291,136 @@ export function LessonPracticesPage() { }; return ( -
-
-
-
+
+
+ + + Back to module +
-
-
- +
+

+ {displayTitle} +

+ + Review speaking practices linked to this lesson. + + {!loading && !loadError ? ( +

+ {totalCount} practice{totalCount === 1 ? "" : "s"} linked to this + lesson + {totalCount > practices.length + ? ` · showing ${practices.length}` + : ""} +

+ ) : null} +
+
+ + + + Add Practice + +
+
- - -
-
-
- -
-
-

- Lesson practices -

-

- {displayTitle} -

-

- Review speaking practices linked to this lesson. Thumbnails - and copy come from your published practice content. -

- {!loading && !loadError ? ( -
- - {practices.length}{" "} - {practices.length === 1 ? "practice" : "practices"} - - {totalCount > practices.length ? ( - - Showing {practices.length} of {totalCount} - - ) : null} -
- ) : null} -
-
- -
- - - Add practice - - -
-
-
-
- - {loading ? ( - - -
- -
-
-

- Loading practices -

-

- Fetching content for this lesson… -

-
-
-
- ) : loadError ? ( - - -
- -
-
-

- Something went wrong -

-

- {loadError} -

-
- -
-
- ) : practices.length === 0 ? ( - - -
- -
-

- No practices yet -

-

- This lesson does not have any linked practices. Create one to - give learners a structured speaking activity after the video. -

-
- - - Create practice - - -
-
-
+ {loading ? ( +
+ Loading practices… +
+ ) : loadError ? ( +
+ {loadError} +
+ +
+
+ ) : practices.length === 0 ? ( +
+ +

+ No practices for this lesson yet +

+

+ Add a practice to give learners a structured speaking activity after + the video. +

+ + + Add Practice + +
+ ) : ( +
+ + {filteredPractices.length === 0 ? ( +
+

+ No practices match your search or status filter +

+
) : ( -
- - {filteredPractices.length === 0 ? ( - - -

- No practices match your search or status filter -

-
-
- ) : isExamPrep ? ( -
- {filteredPractices.map((p) => ( - void navigate(editPracticeHref(p.id))} - onPublish={() => - void handlePracticePublishStatus(p.id, "PUBLISHED") - } - onSaveAsDraft={() => - void handlePracticePublishStatus(p.id, "DRAFT") - } - onUnlink={() => setPracticeToUnlink(p)} - onDelete={() => setPracticeToDelete(p)} - /> - ))} -
- ) : ( - filteredPractices.map((p, i) => ( - + {filteredPractices.map((p) => ( + void navigate(editPracticeHref(p.id))} - onUnlink={() => setPracticeToUnlink(p)} - onDelete={isExamPrep ? () => setPracticeToDelete(p) : undefined} - publishStatusUpdating={publishStatusUpdatingId === p.id} - onTogglePublishStatus={(nextStatus) => - void handlePracticePublishStatus(p.id, nextStatus) + onPublish={() => + void handlePracticePublishStatus(p.id, "PUBLISHED") } + onSaveAsDraft={() => + void handlePracticePublishStatus(p.id, "DRAFT") + } + onUnlink={() => setPracticeToUnlink(p)} + onDelete={() => setPracticeToDelete(p)} /> - )) - )} + ))}
)}
-
+ )} - + Remove from this lesson?

- + {practiceToUnlink?.title} {" "} will be detached from{" "} - {displayTitle}. + {displayTitle}. {practiceToUnlink && parentsFromPractice(practiceToUnlink).filter( (p) => @@ -719,7 +449,7 @@ export function LessonPracticesPage() { ? " The practice will be unlinked until you attach it again. Questions are kept." : " Other locations are unaffected."}

- + diff --git a/src/pages/content-management/PracticeDetailsPage.tsx b/src/pages/content-management/PracticeDetailsPage.tsx index 28857d1..57ad635 100644 --- a/src/pages/content-management/PracticeDetailsPage.tsx +++ b/src/pages/content-management/PracticeDetailsPage.tsx @@ -682,7 +682,7 @@ export function PracticeDetailsPage() { aria-selected={flowMode === "view"} onClick={() => setFlowMode("view")} className={cn( - "inline-flex items-center justify-center gap-1.5 rounded-xl px-4 py-2 text-sm font-semibold transition", + "inline-flex items-center justify-center gap-1.5 rounded-[6px] px-4 py-2 text-sm font-semibold transition", flowMode === "view" ? "bg-white text-brand-600 shadow-sm" : "text-grayScale-500 hover:text-grayScale-800", @@ -697,7 +697,7 @@ export function PracticeDetailsPage() { aria-selected={flowMode === "create"} onClick={() => setFlowMode("create")} className={cn( - "inline-flex items-center justify-center gap-1.5 rounded-xl px-4 py-2 text-sm font-semibold transition", + "inline-flex items-center justify-center gap-1.5 rounded-[6px] px-4 py-2 text-sm font-semibold transition", flowMode === "create" ? "bg-white text-brand-600 shadow-sm" : "text-grayScale-500 hover:text-grayScale-800", diff --git a/src/pages/content-management/PracticeQuestionsPage.tsx b/src/pages/content-management/PracticeQuestionsPage.tsx index 0551ff6..a320433 100644 --- a/src/pages/content-management/PracticeQuestionsPage.tsx +++ b/src/pages/content-management/PracticeQuestionsPage.tsx @@ -678,7 +678,7 @@ export function PracticeQuestionsPage() { @@ -831,7 +831,7 @@ export function PracticeQuestionsPage() {

Add New Question

@@ -919,7 +919,7 @@ export function PracticeQuestionsPage() { @@ -929,7 +929,7 @@ export function PracticeQuestionsPage() { @@ -1135,7 +1135,7 @@ export function PracticeQuestionsPage() { @@ -1145,7 +1145,7 @@ export function PracticeQuestionsPage() { diff --git a/src/pages/content-management/ProgramDetailPage.tsx b/src/pages/content-management/ProgramDetailPage.tsx index caf4c0e..83384d0 100644 --- a/src/pages/content-management/ProgramDetailPage.tsx +++ b/src/pages/content-management/ProgramDetailPage.tsx @@ -36,7 +36,11 @@ import { ContentPublishStatusChip } from "./components/ContentPublishStatusChip" import { ContentAccessTierChip } from "./components/ContentAccessTierChip"; import { ContentListSearchFilterBar } from "./components/ContentListSearchFilterBar"; import { ContentPageDescription } from "./components/ContentPageDescription"; -import type { ContentAccessTier, PracticePublishStatus } from "../../types/course.types"; +import type { + ContentAccessTier, + ExamPrepCatalogCourseItem, + PracticePublishStatus, +} from "../../types/course.types"; import { filterBySearchAndPublishStatus, hasActiveContentFilters, @@ -46,6 +50,10 @@ import { uploadImageFile } from "../../api/files.api"; import uploadIcon from "../../assets/icons/upload.png"; import { DisplayValue } from "../../lib/displayValue" import { SearchHighlight } from "../../components/SearchHighlight" +import { + fetchAllOffsetPages, + offsetPageFromListEnvelope, +} from "../../lib/fetchAllOffsetPages"; export function ProgramDetailPage() { const navigate = useNavigate(); @@ -111,9 +119,12 @@ export function ProgramDetailPage() { if (programType !== "proficiency") return; setCatalogLoading(true); try { - const response = await getExamPrepCatalogCourses({ limit: 20, offset: 0 }); - const rows = response.data?.data?.catalog_courses; - const list = Array.isArray(rows) ? rows : []; + const list = await fetchAllOffsetPages(async (offset, limit) => + offsetPageFromListEnvelope( + await getExamPrepCatalogCourses({ limit, offset }), + "catalog_courses", + ), + ); setCreatedCourses( list.map((row) => ({ id: Number(row.id), @@ -551,7 +562,7 @@ export function ProgramDetailPage() { /> diff --git a/src/pages/content-management/QuestionTypeLibraryPage.tsx b/src/pages/content-management/QuestionTypeLibraryPage.tsx index 49f754d..6457027 100644 --- a/src/pages/content-management/QuestionTypeLibraryPage.tsx +++ b/src/pages/content-management/QuestionTypeLibraryPage.tsx @@ -197,7 +197,7 @@ export function QuestionTypeLibraryPage() {

- @@ -223,7 +223,7 @@ export function QuestionTypeLibraryPage() { type="button" variant="outline" size="sm" - className="rounded-[8px] border-grayScale-200" + className="rounded-[6px] border-grayScale-200" disabled={loading} onClick={() => { void load() @@ -254,7 +254,7 @@ export function QuestionTypeLibraryPage() { ) : ( - @@ -414,7 +414,7 @@ export function QuestionTypeLibraryPage() { type="button" variant="outline" size="sm" - className="rounded-[8px] border-grayScale-200" + className="rounded-[6px] border-grayScale-200" disabled={!canPrev || loading} onClick={() => setOffset((o) => Math.max(0, o - pageSize))} > @@ -425,7 +425,7 @@ export function QuestionTypeLibraryPage() { type="button" variant="outline" size="sm" - className="rounded-[8px] border-grayScale-200" + className="rounded-[6px] border-grayScale-200" disabled={!canNext || loading} onClick={() => setOffset((o) => o + pageSize)} > @@ -511,7 +511,7 @@ function FilterChip({ disabled={disabled} onClick={onClick} className={cn( - "rounded-full border px-3.5 py-1.5 text-xs font-semibold transition-all", + "rounded-[6px] border px-3.5 py-1.5 text-xs font-semibold transition-all", active ? "border-brand-500 bg-brand-500 text-white shadow-sm shadow-brand-500/20" : "border-grayScale-200 bg-white text-grayScale-600 hover:border-brand-200 hover:text-brand-600", diff --git a/src/pages/content-management/QuestionsPage.tsx b/src/pages/content-management/QuestionsPage.tsx index d5c8deb..0450b5c 100644 --- a/src/pages/content-management/QuestionsPage.tsx +++ b/src/pages/content-management/QuestionsPage.tsx @@ -596,7 +596,7 @@ export function QuestionsPage() { onClick={() => safePage > 1 && setPage(safePage - 1)} disabled={safePage === 1} className={cn( - "flex h-8 w-8 items-center justify-center rounded-md border bg-white text-grayScale-500", + "flex h-8 w-8 items-center justify-center rounded-[6px] border bg-white text-grayScale-500", safePage === 1 && "cursor-not-allowed opacity-50", )} > @@ -613,7 +613,7 @@ export function QuestionsPage() { type="button" onClick={() => setPage(n)} className={cn( - "h-8 w-8 rounded-md border text-sm font-medium", + "h-8 w-8 rounded-[6px] border text-sm font-medium", n === safePage ? "border-brand-500 bg-brand-500 text-white" : "bg-white text-grayScale-600 hover:bg-grayScale-50", @@ -627,7 +627,7 @@ export function QuestionsPage() { onClick={() => safePage < totalPages && setPage(safePage + 1)} disabled={safePage === totalPages} className={cn( - "flex h-8 w-8 items-center justify-center rounded-md border bg-white text-grayScale-500", + "flex h-8 w-8 items-center justify-center rounded-[6px] border bg-white text-grayScale-500", safePage === totalPages && "cursor-not-allowed opacity-50", )} > @@ -648,7 +648,7 @@ export function QuestionsPage() { @@ -681,7 +681,7 @@ export function QuestionsPage() {

Question Details

@@ -798,7 +798,7 @@ export function QuestionsPage() {

Edit Question

diff --git a/src/pages/content-management/SpeakingPage.tsx b/src/pages/content-management/SpeakingPage.tsx index d7483c1..5ade463 100644 --- a/src/pages/content-management/SpeakingPage.tsx +++ b/src/pages/content-management/SpeakingPage.tsx @@ -1356,7 +1356,7 @@ export function SpeakingPage() { @@ -718,7 +718,7 @@ export function SubModuleContentPage() {
@@ -918,7 +918,7 @@ export function SubModuleContentPage() {

Delete Practice

@@ -949,7 +949,7 @@ export function SubModuleContentPage() {

Edit Practice

@@ -1007,7 +1007,7 @@ export function SubModuleContentPage() {

Add Video

@@ -1150,7 +1150,7 @@ export function SubModuleContentPage() {

Edit Video

@@ -1208,7 +1208,7 @@ export function SubModuleContentPage() {

Delete Video

@@ -1248,7 +1248,7 @@ export function SubModuleContentPage() {
diff --git a/src/pages/content-management/SubCoursesPage.tsx b/src/pages/content-management/SubCoursesPage.tsx index 40b8715..c67460b 100644 --- a/src/pages/content-management/SubCoursesPage.tsx +++ b/src/pages/content-management/SubCoursesPage.tsx @@ -195,7 +195,7 @@ export function SubModulesPage() {
diff --git a/src/pages/content-management/UnitManagementPage.tsx b/src/pages/content-management/UnitManagementPage.tsx index 901c41f..2aee46e 100644 --- a/src/pages/content-management/UnitManagementPage.tsx +++ b/src/pages/content-management/UnitManagementPage.tsx @@ -42,7 +42,12 @@ import { ContentPublishStatusChip } from "./components/ContentPublishStatusChip" import { ContentAccessTierChip } from "./components/ContentAccessTierChip"; import { ContentListSearchFilterBar } from "./components/ContentListSearchFilterBar"; import { ContentPageDescription } from "./components/ContentPageDescription"; -import type { ContentAccessTier, PracticePublishStatus } from "../../types/course.types"; +import type { + ContentAccessTier, + ExamPrepCatalogUnitItem, + ExamPrepUnitModuleItem, + PracticePublishStatus, +} from "../../types/course.types"; import { filterBySearchAndPublishStatus, type PublishStatusFilter, @@ -52,6 +57,10 @@ import { UnitPracticesPanel } from "./components/UnitPracticesPanel"; import { cn } from "../../lib/utils"; import { DisplayValue } from "../../lib/displayValue" import { SearchHighlight } from "../../components/SearchHighlight" +import { + fetchAllOffsetPages, + offsetPageFromListEnvelope, +} from "../../lib/fetchAllOffsetPages"; export function UnitManagementPage() { const navigate = useNavigate(); @@ -172,12 +181,12 @@ export function UnitManagementPage() { return; } try { - const response = await getExamPrepCatalogUnits(catalogCourseId, { - limit: 100, - offset: 0, - }); - const rows = response.data?.data?.units; - const list = Array.isArray(rows) ? rows : []; + const list = await fetchAllOffsetPages(async (offset, limit) => + offsetPageFromListEnvelope( + await getExamPrepCatalogUnits(catalogCourseId, { limit, offset }), + "units", + ), + ); const row = list.find((u) => Number(u.id) === parsedUnitId); if (row) { setUnitDisplayName(row.name?.trim() || `Unit ${parsedUnitId}`); @@ -201,12 +210,12 @@ export function UnitManagementPage() { } setModulesLoading(true); try { - const response = await getExamPrepUnitModules(parsedUnitId, { - limit: 20, - offset: 0, - }); - const rows = response.data?.data?.modules; - const list = Array.isArray(rows) ? rows : []; + const list = await fetchAllOffsetPages(async (offset, limit) => + offsetPageFromListEnvelope( + await getExamPrepUnitModules(parsedUnitId, { limit, offset }), + "modules", + ), + ); setModules( list.map((row, index) => ({ id: Number(row.id), @@ -614,7 +623,7 @@ export function UnitManagementPage() { Create Modules - + Close @@ -764,7 +773,7 @@ export function UnitManagementPage() { @@ -574,7 +574,7 @@ export function VideoCard({ diff --git a/src/pages/content-management/components/video-steps/VideoDetailStep.tsx b/src/pages/content-management/components/video-steps/VideoDetailStep.tsx index 1430a0a..2ebdfcf 100644 --- a/src/pages/content-management/components/video-steps/VideoDetailStep.tsx +++ b/src/pages/content-management/components/video-steps/VideoDetailStep.tsx @@ -186,21 +186,21 @@ export function VideoDetailStep({ @@ -210,7 +210,7 @@ export function VideoDetailStep({ const url = prompt("Enter URL:"); if (url) handleCommand("createLink", url); }} - className="h-9 w-9 flex items-center justify-center rounded-lg hover:bg-white hover:shadow-sm text-grayScale-900 transition-all active:bg-grayScale-50" + className="h-9 w-9 flex items-center justify-center rounded-[6px] hover:bg-white hover:shadow-sm text-grayScale-900 transition-all active:bg-grayScale-50" > diff --git a/src/pages/notifications/CreateNotificationPage.tsx b/src/pages/notifications/CreateNotificationPage.tsx index 931c492..cf96bda 100644 --- a/src/pages/notifications/CreateNotificationPage.tsx +++ b/src/pages/notifications/CreateNotificationPage.tsx @@ -838,7 +838,7 @@ export function CreateNotificationPage() { type="button" onClick={() => setAudienceMode("platform_role")} className={cn( - "rounded-lg px-3 py-2 transition-all", + "rounded-[6px] px-3 py-2 transition-all", audienceMode === "platform_role" ? "bg-brand-500 text-white shadow-sm" : "border border-grayScale-200 bg-white text-grayScale-500 hover:border-grayScale-300 hover:text-grayScale-700", @@ -853,7 +853,7 @@ export function CreateNotificationPage() { setUserSearchQuery("") }} className={cn( - "rounded-lg px-3 py-2 transition-all", + "rounded-[6px] px-3 py-2 transition-all", audienceMode === "platform_selected" ? "bg-brand-500 text-white shadow-sm" : "border border-grayScale-200 bg-white text-grayScale-500 hover:border-grayScale-300 hover:text-grayScale-700", @@ -866,7 +866,7 @@ export function CreateNotificationPage() { type="button" onClick={() => setAudienceMode("direct")} className={cn( - "rounded-lg px-3 py-2 transition-all", + "rounded-[6px] px-3 py-2 transition-all", audienceMode === "direct" ? "bg-brand-500 text-white shadow-sm" : "border border-grayScale-200 bg-white text-grayScale-500 hover:border-grayScale-300 hover:text-grayScale-700", @@ -1051,7 +1051,7 @@ export function CreateNotificationPage() { type="button" onClick={() => setAudienceMode("team_role")} className={cn( - "rounded-lg px-3 py-2 transition-all", + "rounded-[6px] px-3 py-2 transition-all", audienceMode === "team_role" ? "bg-brand-500 text-white shadow-sm" : "border border-grayScale-200 bg-white text-grayScale-500 hover:border-grayScale-300 hover:text-grayScale-700", @@ -1066,7 +1066,7 @@ export function CreateNotificationPage() { setTeamSearchQuery("") }} className={cn( - "rounded-lg px-3 py-2 transition-all", + "rounded-[6px] px-3 py-2 transition-all", audienceMode === "team_selected" ? "bg-brand-500 text-white shadow-sm" : "border border-grayScale-200 bg-white text-grayScale-500 hover:border-grayScale-300 hover:text-grayScale-700", diff --git a/src/pages/notifications/EmailTemplatesPage.tsx b/src/pages/notifications/EmailTemplatesPage.tsx index df267c6..9f2979d 100644 --- a/src/pages/notifications/EmailTemplatesPage.tsx +++ b/src/pages/notifications/EmailTemplatesPage.tsx @@ -139,7 +139,7 @@ export function EmailTemplatesPage() { type="button" onClick={() => setStatusFilter(tab)} className={cn( - "h-9 rounded-full px-3 text-xs font-semibold transition-colors", + "h-9 rounded-[6px] px-3 text-xs font-semibold transition-colors", statusFilter === tab ? "bg-brand-500 text-white" : "bg-grayScale-100 text-grayScale-600 hover:bg-grayScale-200", diff --git a/src/pages/notifications/NotificationsPage.tsx b/src/pages/notifications/NotificationsPage.tsx index 58043bb..8742e16 100644 --- a/src/pages/notifications/NotificationsPage.tsx +++ b/src/pages/notifications/NotificationsPage.tsx @@ -138,7 +138,7 @@ function NotificationItem({ disabled={toggling} onClick={() => onToggleRead(notification.id, notification.is_read)} className={cn( - "grid h-7 w-7 place-items-center rounded-lg transition-colors", + "grid h-7 w-7 place-items-center rounded-[6px] transition-colors", "opacity-0 group-hover:opacity-100 focus:opacity-100", notification.is_read ? "text-grayScale-400 hover:bg-brand-50 hover:text-brand-600" @@ -628,7 +628,7 @@ export function NotificationsPage() { + ))}
diff --git a/src/pages/settings/AppVersionsTab.tsx b/src/pages/settings/AppVersionsTab.tsx index 389ec60..8e96ed0 100644 --- a/src/pages/settings/AppVersionsTab.tsx +++ b/src/pages/settings/AppVersionsTab.tsx @@ -288,7 +288,7 @@ export function AppVersionsTab() { type="button" onClick={() => setPlatformFilter(tab.id)} className={cn( - "rounded-full px-3 py-1.5 text-xs font-semibold transition-colors", + "rounded-[6px] px-3 py-1.5 text-xs font-semibold transition-colors", platformFilter === tab.id ? "bg-brand-500 text-white" : "bg-grayScale-100 text-grayScale-600 hover:bg-grayScale-200", @@ -312,7 +312,7 @@ export function AppVersionsTab() { type="button" onClick={() => setStatusFilter(tab.id)} className={cn( - "rounded-full px-3 py-1.5 text-xs font-semibold transition-colors", + "rounded-[6px] px-3 py-1.5 text-xs font-semibold transition-colors", statusFilter === tab.id ? "bg-grayScale-800 text-white" : "bg-grayScale-100 text-grayScale-600 hover:bg-grayScale-200", diff --git a/src/pages/settings/SubscriptionPlansTab.tsx b/src/pages/settings/SubscriptionPlansTab.tsx index 4e558db..2b53d21 100644 --- a/src/pages/settings/SubscriptionPlansTab.tsx +++ b/src/pages/settings/SubscriptionPlansTab.tsx @@ -232,7 +232,7 @@ export function SubscriptionPlansTab() { type="button" onClick={() => setStatusFilter(tab.id)} className={cn( - "rounded-full px-3 py-1.5 text-xs font-semibold transition-colors", + "rounded-[6px] px-3 py-1.5 text-xs font-semibold transition-colors", statusFilter === tab.id ? "bg-brand-500 text-white" : "bg-grayScale-100 text-grayScale-600 hover:bg-grayScale-200", diff --git a/src/pages/subscriptions/SubscriptionsExportPage.tsx b/src/pages/subscriptions/SubscriptionsExportPage.tsx index ae0002d..7cb8935 100644 --- a/src/pages/subscriptions/SubscriptionsExportPage.tsx +++ b/src/pages/subscriptions/SubscriptionsExportPage.tsx @@ -194,7 +194,7 @@ export function SubscriptionsExportPage() { diff --git a/src/pages/team/TeamMemberDetailPage.tsx b/src/pages/team/TeamMemberDetailPage.tsx index 2c06dea..99e28ed 100644 --- a/src/pages/team/TeamMemberDetailPage.tsx +++ b/src/pages/team/TeamMemberDetailPage.tsx @@ -444,7 +444,7 @@ export function TeamMemberDetailPage() { diff --git a/src/pages/user-log/components/ActivityLogListPanel.tsx b/src/pages/user-log/components/ActivityLogListPanel.tsx index 369ee9a..bad4bd6 100644 --- a/src/pages/user-log/components/ActivityLogListPanel.tsx +++ b/src/pages/user-log/components/ActivityLogListPanel.tsx @@ -62,6 +62,7 @@ import { cn } from "../../../lib/utils" import { EXPORT_PERMISSIONS, EXPORT_ROUTES } from "../../../lib/csv-export" import { activityLogExportQuery } from "../../../lib/csvExportFilters" import { TABLE_PAGE_SIZE_OPTIONS } from "../../../lib/tablePagination" +import { fetchAllOffsetPages } from "../../../lib/fetchAllOffsetPages" import type { ActivityLog, ActivityLogFilters } from "../../../types/activity-log.types" import { ActorCell, ActorLabel } from "./ActorLabel" import { ActorHoverCard } from "./ActorHoverCard" @@ -97,7 +98,6 @@ export function ActivityLogListPanel({ const [logs, setLogs] = useState([]) const [loading, setLoading] = useState(false) const [error, setError] = useState(null) - const [totalCount, setTotalCount] = useState(0) const [page, setPage] = useState(1) const [pageSize, setPageSize] = useState(10) @@ -112,9 +112,8 @@ export function ActivityLogListPanel({ const [detailLoading, setDetailLoading] = useState(false) const [dialogOpen, setDialogOpen] = useState(false) - const serverFilters = useMemo((): ActivityLogFilters => { - const offset = (page - 1) * pageSize - const filters: ActivityLogFilters = { limit: pageSize, offset } + const listFilters = useMemo((): ActivityLogFilters => { + const filters: ActivityLogFilters = {} if (fixedActorId != null) filters.actor_id = fixedActorId if (actionFilter) filters.action = actionFilter if (resourceTypeFilter) filters.resource_type = resourceTypeFilter @@ -126,8 +125,6 @@ export function ActivityLogListPanel({ if (dateBefore) filters.before = toRfc3339EndOfDay(dateBefore) return filters }, [ - page, - pageSize, fixedActorId, actionFilter, resourceTypeFilter, @@ -137,28 +134,29 @@ export function ActivityLogListPanel({ ]) const exportParams = useMemo( - () => activityLogExportQuery(serverFilters), - [serverFilters], + () => activityLogExportQuery(listFilters), + [listFilters], ) const fetchLogs = useCallback(async () => { setLoading(true) setError(null) try { - const data = await getActivityLogs(serverFilters) - setLogs(data.logs) - setTotalCount(data.total_count) + const all = await fetchAllOffsetPages(async (offset, limit) => { + const data = await getActivityLogs({ ...listFilters, limit, offset }) + return { items: data.logs, total_count: data.total_count } + }) + setLogs(all) } catch (e) { console.error("Failed to fetch activity logs:", e) setLogs([]) - setTotalCount(0) const msg = getApiErrorMessage(e, "Failed to load activity logs") setError(msg) notifyApiError(e, "Failed to load activity logs") } finally { setLoading(false) } - }, [serverFilters]) + }, [listFilters]) useEffect(() => { void fetchLogs() @@ -166,7 +164,7 @@ export function ActivityLogListPanel({ useEffect(() => { setPage(1) - }, [actionFilter, resourceTypeFilter, resourceIdFilter, dateAfter, dateBefore, fixedActorId, pageSize]) + }, [actionFilter, resourceTypeFilter, resourceIdFilter, dateAfter, dateBefore, fixedActorId, pageSize, searchQuery]) const handleViewDetail = async (logId: number) => { setDialogOpen(true) @@ -225,10 +223,15 @@ export function ActivityLogListPanel({ }) }, [logs, searchQuery]) + const totalCount = filteredLogs.length const pageCount = Math.max(1, Math.ceil(totalCount / pageSize)) const safePage = Math.min(page, pageCount) const startEntry = totalCount === 0 ? 0 : (safePage - 1) * pageSize + 1 const endEntry = Math.min(safePage * pageSize, totalCount) + const paginatedLogs = useMemo(() => { + const start = (safePage - 1) * pageSize + return filteredLogs.slice(start, start + pageSize) + }, [filteredLogs, safePage, pageSize]) const showActorColumn = fixedActorId == null const columnCount = showActorColumn ? 6 : 5 @@ -284,7 +287,7 @@ export function ActivityLogListPanel({

{logs[0]?.created_at ? getRelativeActivityTime(logs[0].created_at) : }

-

Latest on this page

+

Latest loaded

@@ -293,7 +296,7 @@ export function ActivityLogListPanel({

{filteredLogs.length}

-

Rows after search (this page)

+

Rows after search

@@ -306,7 +309,7 @@ export function ActivityLogListPanel({
setSearchQuery(e.target.value)} @@ -415,7 +418,7 @@ export function ActivityLogListPanel({
- ) : filteredLogs.length === 0 ? ( + ) : paginatedLogs.length === 0 ? (
@@ -432,7 +435,7 @@ export function ActivityLogListPanel({ ) : ( - filteredLogs.map((log) => ( + paginatedLogs.map((log) => ( diff --git a/src/pages/user-management/UsersListPage.tsx b/src/pages/user-management/UsersListPage.tsx index 3e85461..95ce4ea 100644 --- a/src/pages/user-management/UsersListPage.tsx +++ b/src/pages/user-management/UsersListPage.tsx @@ -82,7 +82,7 @@ function UserListFilterDropdown({ id={id} disabled={disabled} className={cn( - "flex h-9 w-full items-center justify-between gap-2 rounded-md border border-grayScale-200 bg-white px-3 text-left text-sm text-grayScale-600", + "flex h-9 w-full items-center justify-between gap-2 rounded-[6px] border border-grayScale-200 bg-white px-3 text-left text-sm text-grayScale-600", "outline-none focus-visible:ring-1 focus-visible:ring-brand-500", disabled && "cursor-not-allowed bg-grayScale-50 text-grayScale-400", )} @@ -726,7 +726,7 @@ export function UsersListPage() { onClick={handlePrev} disabled={safePage === 1} className={cn( - "h-8 w-8 flex items-center justify-center rounded-md border bg-white text-grayScale-500", + "h-8 w-8 flex items-center justify-center rounded-[6px] border bg-white text-grayScale-500", safePage === 1 && "opacity-50 cursor-not-allowed" )} > @@ -744,7 +744,7 @@ export function UsersListPage() { type="button" onClick={() => setPage(n)} className={cn( - "h-8 w-8 rounded-md border text-sm font-medium", + "h-8 w-8 rounded-[6px] border text-sm font-medium", n === safePage ? "border-brand-500 bg-brand-500 text-white" : "bg-white text-grayScale-600 hover:bg-grayScale-50" @@ -759,7 +759,7 @@ export function UsersListPage() { onClick={handleNext} disabled={safePage === pageCount} className={cn( - "h-8 w-8 flex items-center justify-center rounded-md border bg-white text-grayScale-500", + "h-8 w-8 flex items-center justify-center rounded-[6px] border bg-white text-grayScale-500", safePage === pageCount && "opacity-50 cursor-not-allowed" )} > @@ -776,7 +776,7 @@ export function UsersListPage() {

Confirm Status Change

diff --git a/src/pages/user-management/components/GrantSubscriptionDialog.tsx b/src/pages/user-management/components/GrantSubscriptionDialog.tsx index a829628..823c756 100644 --- a/src/pages/user-management/components/GrantSubscriptionDialog.tsx +++ b/src/pages/user-management/components/GrantSubscriptionDialog.tsx @@ -268,7 +268,7 @@ export function GrantSubscriptionDialog({ role="option" aria-selected={selected} className={cn( - "w-full rounded-md px-2 py-2 text-left text-sm transition", + "w-full rounded-[6px] px-2 py-2 text-left text-sm transition", selected ? "bg-brand-100/50 text-brand-700" : "text-grayScale-600 hover:bg-grayScale-100", diff --git a/src/pages/user-management/components/UserLearningActivitySection.tsx b/src/pages/user-management/components/UserLearningActivitySection.tsx index 987b1f3..e5c400e 100644 --- a/src/pages/user-management/components/UserLearningActivitySection.tsx +++ b/src/pages/user-management/components/UserLearningActivitySection.tsx @@ -290,7 +290,7 @@ export function UserLearningActivitySection({