Stage 1.5: categories, enrollment expiry, access log, bulk grant, user page
This commit is contained in:
@@ -14,11 +14,18 @@ interface Course {
|
||||
description: string | null;
|
||||
coverImage: string | null;
|
||||
published: boolean;
|
||||
categoryId: string | null;
|
||||
}
|
||||
|
||||
export function CourseEditForm({ course }: { course: Course }) {
|
||||
interface Category {
|
||||
id: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
export function CourseEditForm({ course, categories = [] }: { course: Course; categories?: Category[] }) {
|
||||
const [published, setPublished] = useState(course.published);
|
||||
const [coverImage, setCoverImage] = useState(course.coverImage ?? "");
|
||||
const [categoryId, setCategoryId] = useState(course.categoryId ?? "");
|
||||
const [uploading, setUploading] = useState(false);
|
||||
const [pending, startTransition] = useTransition();
|
||||
|
||||
@@ -39,6 +46,7 @@ export function CourseEditForm({ course }: { course: Course }) {
|
||||
const fd = new FormData(e.currentTarget);
|
||||
fd.set("published", String(published));
|
||||
fd.set("coverImage", coverImage);
|
||||
fd.set("categoryId", categoryId);
|
||||
startTransition(() => updateCourse(course.id, fd));
|
||||
}
|
||||
|
||||
@@ -63,6 +71,23 @@ export function CourseEditForm({ course }: { course: Course }) {
|
||||
<Label htmlFor="description">Описание</Label>
|
||||
<Textarea id="description" name="description" defaultValue={course.description ?? ""} rows={3} />
|
||||
</div>
|
||||
{categories.length > 0 && (
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="categoryId">Категория</Label>
|
||||
<select
|
||||
id="categoryId"
|
||||
value={categoryId}
|
||||
onChange={(e) => setCategoryId(e.target.value)}
|
||||
className="w-full px-3 py-2 text-sm bg-transparent"
|
||||
style={{ border: "2px solid var(--border)", color: "var(--foreground)", fontFamily: "var(--font-sans)" }}
|
||||
>
|
||||
<option value="">Без категории</option>
|
||||
{categories.map((c) => (
|
||||
<option key={c.id} value={c.id}>{c.title}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
<div className="space-y-1.5">
|
||||
<Label>Обложка</Label>
|
||||
<div className="flex items-center gap-3">
|
||||
|
||||
Reference in New Issue
Block a user