feat(FE): axios helper func

This commit is contained in:
Michael 2025-03-31 19:21:20 +02:00
parent bba0f09389
commit a2630e8d4d

View file

@ -1,7 +1,5 @@
import { VSelect, VTextField } from "vuetify/components";
import type {Show} from "@models/show/show";
import axios, {type AxiosResponse} from "axios"; import axios, {type AxiosResponse} from "axios";
import {dateFormatter} from "@/helpers/DateFormatter.ts"; import {cleanOptions} from "@/helpers/AxiosHelper.ts";
export interface ShowDays { export interface ShowDays {
id?: number; id?: number;
@ -20,7 +18,7 @@ export interface ShowDays {
export const baseShowDays = ():ShowDays => { export const baseShowDays = ():ShowDays => {
return { return {
firstShow: new Date(), firstShow: new Date(),
lastShow: new Date(), lastShow: null,
startTime: '08:00', startTime: '08:00',
timezone: '', timezone: '',
duration: '01:00', duration: '01:00',
@ -36,9 +34,8 @@ export const getShowDays = async (options: {
showId?: number | null; showId?: number | null;
flattenShowDays?: boolean; flattenShowDays?: boolean;
}): Promise<ShowDays> => { }): Promise<ShowDays> => {
const filteredParams = Object.fromEntries( const filteredParams = cleanOptions(options);
Object.entries(options).filter(([_, value]) => value !== undefined && value !== null)
);
return await axios.get(`/showDays`, {params: filteredParams}) return await axios.get(`/showDays`, {params: filteredParams})
.then((response: AxiosResponse) => { .then((response: AxiosResponse) => {
return response.data return response.data