sintonia_webapp/resources/js/composables/content/models/show/showDays.ts

47 lines
No EOL
1.2 KiB
TypeScript

import axios, {type AxiosResponse} from "axios";
import {cleanOptions, snakeToCamel} from "@/helpers/AxiosHelper.ts";
import type {ShowRepetitionType} from "@models/show/ShowRepetition.ts";
//TODO RepeatType should use the interface ShowRepetitionType
export interface ShowDays {
id?: number;
firstShow: Date;
lastShow: Date;
startTime: string;
timezone: string;
duration: string;
day: number[];
repeatType: string;
nextPopDate?: string;
showId?: number;
record?: number;
}
export const baseShowDays = ():ShowDays => {
return {
firstShow: new Date(),
lastShow: null,
startTime: '08:00',
timezone: '',
duration: '01:00',
day: [],
repeatType: 'noRepeat',
nextPopDate: '',
showId: 0,
record: 0
};
}
export const getShowDays = async (options: {
show_id?: number | null;
flattenShowDays?: boolean;
}): Promise<ShowDays> => {
const filteredParams = cleanOptions(options);
return await axios.get(`/showDays`, {params: filteredParams})
.then((response: AxiosResponse) => {
return snakeToCamel(response.data);
}).catch((error: Error) => {
console.log("Error: " + error);
})
}