mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
fix more
This commit is contained in:
@@ -48,7 +48,6 @@ const lessonSchema = z.object({
|
|||||||
z.object({ value: z.string().min(1, "Objective cannot be empty.") })
|
z.object({ value: z.string().min(1, "Objective cannot be empty.") })
|
||||||
).optional(),
|
).optional(),
|
||||||
blocks: z.array(z.any()).optional(),
|
blocks: z.array(z.any()).optional(),
|
||||||
requirements: z.array(z.any()).optional(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
@@ -198,7 +197,7 @@ function StepLessons({ control, register, errors }) {
|
|||||||
type="button"
|
type="button"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
onClick={() => append({ title: "", description: "", objectives: [], blocks: [], requirements: [] })}
|
onClick={() => append({ title: "", description: "", objectives: [], blocks: [] })}
|
||||||
>
|
>
|
||||||
<Plus className="h-4 w-4 mr-1" /> Add Lesson
|
<Plus className="h-4 w-4 mr-1" /> Add Lesson
|
||||||
</Button>
|
</Button>
|
||||||
@@ -243,9 +242,6 @@ function StepPageBuilder({ control, setValue }) {
|
|||||||
return next;
|
return next;
|
||||||
});
|
});
|
||||||
|
|
||||||
const requirements = activeLesson?.requirements ?? [];
|
|
||||||
const setRequirements = (next) => setValue(`lessons.${activeIndex}.requirements`, next, { shouldDirty: true });
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
{lessons.map((l, i) => (
|
{lessons.map((l, i) => (
|
||||||
@@ -254,7 +250,6 @@ function StepPageBuilder({ control, setValue }) {
|
|||||||
<p className="text-sm font-medium">{l.title || `Lesson ${i + 1}`}</p>
|
<p className="text-sm font-medium">{l.title || `Lesson ${i + 1}`}</p>
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
{(l.blocks?.length ?? 0)} block{(l.blocks?.length ?? 0) !== 1 ? "s" : ""}
|
{(l.blocks?.length ?? 0)} block{(l.blocks?.length ?? 0) !== 1 ? "s" : ""}
|
||||||
{(l.requirements?.length ?? 0) > 0 && ` · ${l.requirements.length} requirement${l.requirements.length !== 1 ? "s" : ""}`}
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
@@ -321,21 +316,6 @@ function StepPageBuilder({ control, setValue }) {
|
|||||||
</PreviewChrome>
|
</PreviewChrome>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mt-6 pt-4 border-t space-y-3">
|
|
||||||
<div>
|
|
||||||
<p className="text-sm font-medium">Completion Requirements — {activeLesson?.title || `Lesson ${activeIndex + 1}`}</p>
|
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
What this specific lesson's blocks unlock — e.g. a video block above makes "Finish Watching the Full Video" available.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<DraftRequirementsEditor
|
|
||||||
entityType="lesson"
|
|
||||||
items={requirements}
|
|
||||||
onChange={setRequirements}
|
|
||||||
blockTypes={blocks.map((b) => b.type)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DrawerFooter className="border-t flex-row justify-end">
|
<DrawerFooter className="border-t flex-row justify-end">
|
||||||
@@ -387,7 +367,7 @@ function StepReview({ data, tierCategories, requirements }) {
|
|||||||
<div key={i} className="flex items-center justify-between text-sm border-t border-border pt-2 first:border-t-0 first:pt-0">
|
<div key={i} className="flex items-center justify-between text-sm border-t border-border pt-2 first:border-t-0 first:pt-0">
|
||||||
<span>{i + 1}. {l.title}</span>
|
<span>{i + 1}. {l.title}</span>
|
||||||
<span className="text-muted-foreground text-xs">
|
<span className="text-muted-foreground text-xs">
|
||||||
{(l.objectives ?? []).filter((o) => o.value).length} objective(s) · {(l.blocks ?? []).length} block(s) · {(l.requirements ?? []).length} requirement(s)
|
{(l.objectives ?? []).filter((o) => o.value).length} objective(s) · {(l.blocks ?? []).length} block(s)
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@@ -468,7 +448,6 @@ export default function AddLibraryUnit() {
|
|||||||
description: l.description || null,
|
description: l.description || null,
|
||||||
objectives: (l.objectives ?? []).map((o) => o.value).filter(Boolean),
|
objectives: (l.objectives ?? []).map((o) => o.value).filter(Boolean),
|
||||||
blocks: l.blocks ?? [],
|
blocks: l.blocks ?? [],
|
||||||
requirements: (l.requirements ?? []).map(({ _key, ...r }) => r),
|
|
||||||
})),
|
})),
|
||||||
createdBy: user?.user_id,
|
createdBy: user?.user_id,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user