import type {ShowInstance} from "@models/show/showInstance.ts"; import type {ShowDays} from "@models/show/showDays"; import type {ShowDjs} from "@models/show/showDjs"; import axios, {type AxiosResponse} from "axios"; export interface Show { id?: number; name: string; url: string; genre: string; description: string; color?: string; backgroundColor: string; liveStreamUsingAirtimeAuth?: boolean; liveStreamUsingCustomAuth?: boolean; liveStreamUser?: string; liveStreamPass?: string; imagePath?: string; hasAutoplaylist: boolean; autoplaylistId?: number; autoplaylistRepeat: boolean; // Relationships block?: any; showDays?: ShowDays; showDjs?: ShowDjs[]; showInstances?: ShowInstance[]; playlist?: any; } export const baseShow = (): Show => { return { id: null, name: '', url: '', genre: '', description: '', backgroundColor: '', liveStreamUsingAirtimeAuth: false, liveStreamUser: '', liveStreamPass: '', imagePath: '', hasAutoplaylist: false, autoplaylistId: 0, autoplaylistRepeat: false, showDjs: null, showDays: null, } } export const showTableHeader = [ {title: 'Nome', value: 'name'}, {title: 'dj', value: 'dj'}, {title: 'Durata', value: 'length'}, {title: 'Schedulata', value: 'scheduled'}, {title: 'Azioni', value: 'actions'} ] export const getShow = async (options: { id?: number | null; scheduled?: number | null; withDjs?: boolean | null; isScheduled?: boolean | null; page?: Number | null; per_page?: Number | null; all?: string | null; }): Promise => { const filteredParams = Object.fromEntries( Object.entries(options).filter(([_, value]) => value !== undefined && value !== null) ); return await axios.get(`/show`, {params: filteredParams}) .then((response: AxiosResponse) => { return response.data }).catch((error: Error) => { console.log("Error: " + error); }) } export const deleteShow = async (showIds: Number[]) => { return axios.delete(`show`, {data: {'showIds': showIds}}) }