feat(frontend): ScheduleConfig V2 types, weekday schema, export update
This commit is contained in:
@@ -5,7 +5,7 @@ export function exportChannel(channel: ChannelResponse): void {
|
||||
name: channel.name,
|
||||
description: channel.description ?? undefined,
|
||||
timezone: channel.timezone,
|
||||
blocks: channel.schedule_config.blocks,
|
||||
day_blocks: channel.schedule_config.day_blocks,
|
||||
recycle_policy: channel.recycle_policy,
|
||||
};
|
||||
const blob = new Blob([JSON.stringify(payload, null, 2)], {
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { z } from "zod";
|
||||
import { WEEKDAYS } from "@/lib/types";
|
||||
import type { Weekday } from "@/lib/types";
|
||||
|
||||
const weekdaySchema = z.enum([
|
||||
'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday',
|
||||
]);
|
||||
|
||||
export const mediaFilterSchema = z.object({
|
||||
content_type: z.enum(["movie", "episode", "short"]).nullable().optional(),
|
||||
@@ -53,7 +59,10 @@ export const channelFormSchema = z.object({
|
||||
name: z.string().min(1, "Name is required"),
|
||||
timezone: z.string().min(1, "Timezone is required"),
|
||||
description: z.string().optional(),
|
||||
blocks: z.array(blockSchema),
|
||||
day_blocks: z.record(weekdaySchema, z.array(blockSchema))
|
||||
.default(() =>
|
||||
Object.fromEntries(WEEKDAYS.map(d => [d, []])) as unknown as Record<Weekday, z.infer<typeof blockSchema>[]>
|
||||
),
|
||||
recycle_policy: z.object({
|
||||
cooldown_days: z.number().int().min(0).nullable().optional(),
|
||||
cooldown_generations: z.number().int().min(0).nullable().optional(),
|
||||
|
||||
@@ -91,8 +91,35 @@ export interface ProgrammingBlock {
|
||||
access_password?: string;
|
||||
}
|
||||
|
||||
export type Weekday =
|
||||
| 'monday' | 'tuesday' | 'wednesday' | 'thursday'
|
||||
| 'friday' | 'saturday' | 'sunday'
|
||||
|
||||
export const WEEKDAYS: Weekday[] = [
|
||||
'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday',
|
||||
]
|
||||
|
||||
export const WEEKDAY_LABELS: Record<Weekday, string> = {
|
||||
monday: 'Mon', tuesday: 'Tue', wednesday: 'Wed', thursday: 'Thu',
|
||||
friday: 'Fri', saturday: 'Sat', sunday: 'Sun',
|
||||
}
|
||||
|
||||
export interface ScheduleConfig {
|
||||
blocks: ProgrammingBlock[];
|
||||
day_blocks: Record<Weekday, ProgrammingBlock[]>
|
||||
}
|
||||
|
||||
export interface ConfigSnapshot {
|
||||
id: string
|
||||
version_num: number
|
||||
label: string | null
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export interface ScheduleHistoryEntry {
|
||||
id: string
|
||||
generation: number
|
||||
valid_from: string
|
||||
valid_until: string
|
||||
}
|
||||
|
||||
// Config
|
||||
|
||||
Reference in New Issue
Block a user