feat(FE): show create api call
This commit is contained in:
parent
15e7606e45
commit
d376414729
1 changed files with 40 additions and 14 deletions
|
@ -1,6 +1,9 @@
|
|||
import { defineStore } from 'pinia'
|
||||
import { type Show } from '@models/show/show'
|
||||
import {defineStore} from 'pinia'
|
||||
import {type Show} from '@models/show/show'
|
||||
import type {ShowDays} from "@models/show/showDays";
|
||||
import axios, {type AxiosResponse} from "axios";
|
||||
import {camelToSnake} from "@/helpers/AxiosHelper.ts";
|
||||
import {extractTime} from "@/helpers/DateFormatter.ts";
|
||||
|
||||
export const useShowStore = defineStore('show', {
|
||||
state: () => ({
|
||||
|
@ -9,23 +12,46 @@ export const useShowStore = defineStore('show', {
|
|||
}),
|
||||
actions: {
|
||||
async loadShow(showData: Show) {
|
||||
this.currentShow = { ...showData }
|
||||
this.currentShow = {...showData}
|
||||
},
|
||||
updateField(payload: { key: string; value: any }) {
|
||||
this.currentShow[payload.key] = payload.value
|
||||
},
|
||||
async saveShow() {
|
||||
// Implement API call to save this.currentShow
|
||||
},
|
||||
async saveSchedule() {
|
||||
// Implement schedule saving logic
|
||||
},
|
||||
resetShowDays() {
|
||||
this.currentShow.showDays = { ...this.baseShowDays };
|
||||
},
|
||||
|
||||
updateShowDaysField(payload: { key: string; value: any }) {
|
||||
this.currentShow.showDays[payload.key] = payload.value;
|
||||
}
|
||||
},
|
||||
async createShow() {
|
||||
let showData = {...this.currentShow};
|
||||
showData.showDays.firstShow = extractTime(showData.showDays.firstShow);
|
||||
if (showData.showDays.lastShow) {
|
||||
showData.showDays.lastShow = extractTime(showData.showDays.lastShow);
|
||||
}
|
||||
showData = camelToSnake(showData);
|
||||
return await axios.post(`/show`, showData)
|
||||
.then((response: AxiosResponse) => {
|
||||
return response.data
|
||||
}).catch((error: Error) => {
|
||||
console.log("Error: " + error);
|
||||
})
|
||||
},
|
||||
async updateShow() {
|
||||
return await axios.post(`/show`, this.currentShow)
|
||||
.then((response: AxiosResponse) => {
|
||||
return response.data
|
||||
}).catch((error: Error) => {
|
||||
console.log("Error: " + error.message);
|
||||
})
|
||||
},
|
||||
async updateShowDays() {
|
||||
return await axios.post(`/showDays`, this.currentShow.showDays)
|
||||
.then((response: AxiosResponse) => {
|
||||
return response.data
|
||||
}).catch((error: Error) => {
|
||||
console.log("Error: " + error);
|
||||
})
|
||||
},
|
||||
resetShowDays() {
|
||||
this.currentShow.showDays = {...this.baseShowDays};
|
||||
},
|
||||
}
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue