- components/overlay.tsx: first Dialog/ConfirmDialog (portal, esc/backdrop close, scroll lock, aria wiring, reduced-motion aware) + 7 tests - api: libraryBrowse, channelTemplates (default 404->null), artwork upload (multipart /api/artwork/uploads), pickers (client-sorted lists incl. /api/ffmpeg/profiles), createChannelFromLineup in channels.ts - schedules.ts now sources filler/watermark fetchers from pickers.ts (avoids duplicate barrel exports) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { ApiError, request } from './client';
|
|
import type { components } from './generated/v1';
|
|
|
|
export type ChannelTemplate = components['schemas']['ChannelTemplateResponseModel'];
|
|
export type CreateChannelTemplateRequest = components['schemas']['CreateChannelTemplateRequest'];
|
|
|
|
export function getChannelTemplates(): Promise<ChannelTemplate[]> {
|
|
return request<ChannelTemplate[]>('/api/channel-templates');
|
|
}
|
|
|
|
export async function getDefaultChannelTemplate(): Promise<ChannelTemplate | null> {
|
|
try {
|
|
return await request<ChannelTemplate>('/api/channel-templates/default');
|
|
} catch (error) {
|
|
if (error instanceof ApiError && error.status === 404) {
|
|
return null;
|
|
}
|
|
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
export function createChannelTemplate(body: CreateChannelTemplateRequest): Promise<ChannelTemplate> {
|
|
return request<ChannelTemplate>('/api/channel-templates', {
|
|
body,
|
|
method: 'POST'
|
|
});
|
|
}
|
|
|
|
export function messageFromChannelTemplateError(error: unknown, fallback = 'Unable to load channel templates'): string {
|
|
if (error instanceof ApiError) {
|
|
return error.detail ?? error.message;
|
|
}
|
|
|
|
if (error instanceof Error) {
|
|
return error.message;
|
|
}
|
|
|
|
return fallback;
|
|
}
|