feat: Open Day class duration + max participants, UI fixes
- Class duration: editable end time (was hardcoded +1h), shown as range - Max participants per class (0 = unlimited), shown as "3/10 чел." - New DB migration 14: max_participants column on open_day_classes - Min bookings moved to separate row with hint text - "Скидка" renamed to "Цена со скидкой" for clarity - Cancel/recover icon: Ban for cancel, RotateCcw for recover
This commit is contained in:
@@ -255,6 +255,16 @@ const migrations: Migration[] = [
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
version: 14,
|
||||
name: "add_max_participants_to_open_day_classes",
|
||||
up: (db) => {
|
||||
const cols = db.prepare("PRAGMA table_info(open_day_classes)").all() as { name: string }[];
|
||||
if (!cols.some((c) => c.name === "max_participants")) {
|
||||
db.exec("ALTER TABLE open_day_classes ADD COLUMN max_participants INTEGER NOT NULL DEFAULT 0");
|
||||
}
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
function runMigrations(db: Database.Database) {
|
||||
@@ -975,6 +985,7 @@ interface OpenDayClassRow {
|
||||
style: string;
|
||||
cancelled: number;
|
||||
sort_order: number;
|
||||
max_participants: number;
|
||||
booking_count?: number;
|
||||
}
|
||||
|
||||
@@ -988,6 +999,7 @@ export interface OpenDayClass {
|
||||
style: string;
|
||||
cancelled: boolean;
|
||||
sortOrder: number;
|
||||
maxParticipants: number;
|
||||
bookingCount: number;
|
||||
}
|
||||
|
||||
@@ -1054,6 +1066,7 @@ function mapClassRow(r: OpenDayClassRow): OpenDayClass {
|
||||
style: r.style,
|
||||
cancelled: !!r.cancelled,
|
||||
sortOrder: r.sort_order,
|
||||
maxParticipants: r.max_participants ?? 0,
|
||||
bookingCount: r.booking_count ?? 0,
|
||||
};
|
||||
}
|
||||
@@ -1207,7 +1220,7 @@ export function getOpenDayClasses(eventId: number): OpenDayClass[] {
|
||||
|
||||
export function updateOpenDayClass(
|
||||
id: number,
|
||||
data: Partial<{ hall: string; startTime: string; endTime: string; trainer: string; style: string; cancelled: boolean; sortOrder: number }>
|
||||
data: Partial<{ hall: string; startTime: string; endTime: string; trainer: string; style: string; cancelled: boolean; sortOrder: number; maxParticipants: number }>
|
||||
): void {
|
||||
const db = getDb();
|
||||
const sets: string[] = [];
|
||||
@@ -1219,6 +1232,7 @@ export function updateOpenDayClass(
|
||||
if (data.style !== undefined) { sets.push("style = ?"); vals.push(data.style); }
|
||||
if (data.cancelled !== undefined) { sets.push("cancelled = ?"); vals.push(data.cancelled ? 1 : 0); }
|
||||
if (data.sortOrder !== undefined) { sets.push("sort_order = ?"); vals.push(data.sortOrder); }
|
||||
if (data.maxParticipants !== undefined) { sets.push("max_participants = ?"); vals.push(data.maxParticipants); }
|
||||
if (sets.length === 0) return;
|
||||
vals.push(id);
|
||||
db.prepare(`UPDATE open_day_classes SET ${sets.join(", ")} WHERE id = ?`).run(...vals);
|
||||
|
||||
Reference in New Issue
Block a user