updated some of things

This commit is contained in:
rgrgogu
2026-08-03 12:03:11 +08:00
parent 1315796412
commit 6be0c29850
75 changed files with 1743 additions and 1702 deletions
@@ -25,6 +25,7 @@ export default function ViewLibraryUnit() {
const [initializing, setInitializing] = useState(true);
const [attachOpen, setAttachOpen] = useState(false);
const [descExpanded, setDescExpanded] = useState(false);
useEffect(() => {
(async () => {
@@ -82,11 +83,21 @@ export default function ViewLibraryUnit() {
{/* ── Unit header ── */}
<div className="bg-card rounded-xl border p-6 space-y-4">
<div className="flex items-start justify-between gap-4">
<div>
<h6 className="text-xs tracking-widest mb-1">STANDALONE UNIT</h6>
<div className="max-w-2xl">
<h1 className="text-xl font-semibold">{unit?.title}</h1>
{unit?.description && (
<p className="text-sm text-muted-foreground mt-0.5">{unit.description}</p>
<div className="mt-0.5">
<p className={`text-sm text-muted-foreground ${descExpanded ? '' : 'line-clamp-2'}`}>
{unit.description}
</p>
<button
type="button"
onClick={() => setDescExpanded((v) => !v)}
className="text-xs font-medium text-primary hover:underline mt-0.5"
>
{descExpanded ? 'See less' : 'See more'}
</button>
</div>
)}
</div>
<div className="flex gap-2 shrink-0">
@@ -154,15 +165,15 @@ export default function ViewLibraryUnit() {
<div>
<h2 className="font-semibold">Lessons</h2>
<p className="text-xs text-muted-foreground">
Lessons are standalone too — attach existing ones or create new. Order here is this unit's order.
It can be standalone too attach existing ones or create new.
</p>
</div>
<div className="flex gap-2">
<Button size="sm" variant="outline" onClick={() => setAttachOpen(true)}>
<Link2 className="h-3.5 w-3.5 mr-1.5" /> Attach Existing
<Link2 className="h-3.5 w-3.5 mr-1.5" /> Select
</Button>
<Button size="sm" onClick={() => navigate(`/admin/lessons/add?unit_id=${unitId}`)}>
<Plus className="h-3.5 w-3.5 mr-1.5" /> New Lesson
<Plus className="h-3.5 w-3.5 mr-1.5" /> Create
</Button>
</div>
</div>
@@ -201,27 +212,27 @@ export default function ViewLibraryUnit() {
<div className="flex-1 min-w-0">
<p className="text-sm font-medium truncate">{l.title}</p>
{l.description && (
<p className="text-xs text-muted-foreground truncate">{l.description}</p>
<p className="text-xs w-64 text-muted-foreground truncate">{l.description}</p>
)}
</div>
<Badge variant="secondary" className="text-xs shrink-0 tabular-nums">
<Clock className="h-3 w-3 mr-1" /> {formatDuration(l.duration_seconds ?? 0)}
</Badge>
<Button
size="sm" variant="ghost"
size="sm" variant="outline"
onClick={() => navigate(`/admin/lessons/${l.lesson_id}/page`)}
title="Page Builder"
>
<LayoutTemplate className="h-3.5 w-3.5" />
<LayoutTemplate /> Page Builder
</Button>
<Button
size="sm" variant="ghost"
className="text-destructive hover:text-destructive"
size="sm"
variant="destructive"
onClick={() => handleDetach(l.lesson_id)}
disabled={loading}
title="Detach from unit (lesson stays in library)"
>
<Unlink className="h-3.5 w-3.5" />
<Unlink className="h-3.5 w-3.5" /> Detach
</Button>
</div>
))}