69 lines
No EOL
2 KiB
TypeScript
69 lines
No EOL
2 KiB
TypeScript
import {VTextarea, VTextField} from "vuetify/components";
|
|
import axios, {type AxiosResponse} from "axios";
|
|
import type {Show} from "@models/show/show.ts";
|
|
import {cleanOptions} from "@/helpers/AxiosHelper.ts";
|
|
|
|
export function playlist(item) {
|
|
const visibleFields = {
|
|
name: {
|
|
title: 'Nome',
|
|
required: true,
|
|
},
|
|
description: {
|
|
title: 'Descrizione',
|
|
required: false
|
|
},
|
|
}
|
|
|
|
return () => {
|
|
const fields = {}
|
|
Object.keys(visibleFields).forEach((key) => {
|
|
fields[key] = {
|
|
label: visibleFields[key].title,
|
|
value: item !== null ? item[key] : '',
|
|
required: visibleFields[key].required,
|
|
component: VTextField
|
|
}
|
|
// console.log(fields)
|
|
switch (key) {
|
|
case 'name':
|
|
fields[key].component = VTextField
|
|
break
|
|
case 'description':
|
|
fields[key].component = VTextarea
|
|
break;
|
|
}
|
|
})
|
|
// console.log(fields)
|
|
return fields
|
|
}
|
|
}
|
|
|
|
// TODO playlist interface
|
|
export const getPlaylist = 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<any> => {
|
|
const filteredParams = cleanOptions(options);
|
|
return await axios.get(`/playlist`, {params: filteredParams})
|
|
.then((response: AxiosResponse) => {
|
|
return response.data.data
|
|
}).catch((error: Error) => {
|
|
console.log("Error: " + error);
|
|
})
|
|
}
|
|
|
|
// TODO playlist interface
|
|
export const getPlaylistContent = async (playlistId: Number): Promise<any> => {
|
|
return await axios.get(`/playlist/${playlistId}`)
|
|
.then((response: AxiosResponse) => {
|
|
return response.data
|
|
}).catch((error: Error) => {
|
|
console.log("Error: " + error);
|
|
})
|
|
} |