mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
fix: throttle request issue per video,audio as indicated requirements in units and lessons
Signed-off-by: rgrgogu <obsequio.rus@gmail.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import AppBreadcrumb from "@/components/generic/Breadcrumb/AppBreadcrumb";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import {
|
||||
House, Timer, CheckCircle2, Check, ClipboardList, Hourglass,
|
||||
House, Timer, CheckCircle2, Check, CheckCheck, ClipboardList, Hourglass,
|
||||
} from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
@@ -14,6 +14,7 @@ import { useLibrary } from "@/contexts/ClientLibraryContext";
|
||||
import { useClientTiers } from "@/contexts/ClientTiersProvider";
|
||||
import { PageMeta } from "@/contexts/MetadataContext";
|
||||
import LockedContentPanel from "@/modules/client/components/LockedContentPanel";
|
||||
import { TYPE_DEFS } from "@/modules/admin/components/courses/completionRequirementTypes";
|
||||
|
||||
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -157,6 +158,10 @@ const UnitDetails = () => {
|
||||
const currentLesson = lessons.find((l) => l.status !== "completed") ?? null;
|
||||
const progressPct = lessons.length > 0 ? Math.round((completedCount / lessons.length) * 100) : 0;
|
||||
|
||||
// Admin-configured completion requirement for the unit itself (null when nothing's set).
|
||||
const requirementDef = unitDetail?.completion?.type ? TYPE_DEFS[unitDetail.completion.type] : null;
|
||||
const RequirementIcon = requirementDef?.icon;
|
||||
|
||||
const handleLessonClick = (lesson) => {
|
||||
navigate(`/lessons/${lesson.uuid}`);
|
||||
};
|
||||
@@ -187,14 +192,28 @@ const UnitDetails = () => {
|
||||
) : (
|
||||
<>
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex items-center gap-2 text-sm text-muted-foreground [&_svg]:size-4">
|
||||
<div className="flex flex-wrap items-center gap-2 text-sm text-muted-foreground [&_svg]:size-4">
|
||||
<span>{lessons.length} {lessons.length === 1 ? "lesson" : "lessons"}</span>
|
||||
<span>·</span>
|
||||
<span className="flex items-center gap-1"><Timer /> {formatDuration(unitDetail.duration_seconds) ?? "—"} total</span>
|
||||
<span>·</span>
|
||||
<span className="text-blue-600 dark:text-blue-400 font-medium">{completedCount} of {lessons.length} complete</span>
|
||||
{requirementDef && (
|
||||
<>
|
||||
<span>·</span>
|
||||
<span className="flex items-center gap-1">
|
||||
{RequirementIcon && <RequirementIcon />} {requirementDef.label}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<Progress value={progressPct} />
|
||||
{unitDetail.is_completed && (
|
||||
<div className="flex items-center gap-1.5 text-sm font-medium text-emerald-600 dark:text-emerald-400 w-fit">
|
||||
<CheckCheck className="size-4" />
|
||||
Success — you've completed this unit.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-3">
|
||||
|
||||
Reference in New Issue
Block a user