[events] Sync route names
This commit is contained in:
parent
6da4f67d68
commit
b15ff0f5e3
|
@ -33,7 +33,7 @@ export const useScheduleStore = defineStore({
|
|||
async getJobTypes(force = false) {
|
||||
if (force || this.jobTypes.length == 0)
|
||||
try {
|
||||
const { data } = await api.get<FG.JobType[]>('/schedule/job-types');
|
||||
const { data } = await api.get<FG.JobType[]>('/events/job-types');
|
||||
this.jobTypes = data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
@ -42,24 +42,24 @@ export const useScheduleStore = defineStore({
|
|||
},
|
||||
|
||||
async addJobType(name: string) {
|
||||
await api.post<FG.JobType>('/schedule/job-types', { name: name });
|
||||
await api.post<FG.JobType>('/events/job-types', { name: name });
|
||||
//TODO: HAndle new JT
|
||||
},
|
||||
|
||||
async removeJobType(id: number) {
|
||||
await api.delete(`/schedule/job-types/${id}`);
|
||||
await api.delete(`/events/job-types/${id}`);
|
||||
//Todo Handle delete JT
|
||||
},
|
||||
|
||||
async renameJobType(id: number, newName: string) {
|
||||
await api.put(`/schedule/job-types/${id}`, { name: newName });
|
||||
await api.put(`/events/job-types/${id}`, { name: newName });
|
||||
// TODO handle rename
|
||||
},
|
||||
|
||||
async getEventTypes(force = false) {
|
||||
if (force || this.eventTypes.length == 0)
|
||||
try {
|
||||
const { data } = await api.get<FG.EventType[]>('/schedule/event-types');
|
||||
const { data } = await api.get<FG.EventType[]>('/events/event-types');
|
||||
this.eventTypes = data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
@ -75,7 +75,7 @@ export const useScheduleStore = defineStore({
|
|||
*/
|
||||
async addEventType(name: string) {
|
||||
try {
|
||||
const { data } = await api.post<FG.EventType>('/schedule/event-types', { name: name });
|
||||
const { data } = await api.post<FG.EventType>('/events/event-types', { name: name });
|
||||
return data;
|
||||
} catch (error) {
|
||||
if ('response' in error) {
|
||||
|
@ -87,7 +87,9 @@ export const useScheduleStore = defineStore({
|
|||
},
|
||||
async removeEvent(id: number) {
|
||||
try {
|
||||
await api.delete(`/schedule/events/${id}`);
|
||||
await api.delete(`/events/${id}`);
|
||||
const idx = this.templates.findIndex((v) => v.id === id);
|
||||
if (idx !== -1) this.templates.splice(idx, 1);
|
||||
} catch (e) {
|
||||
const error = <AxiosError>e;
|
||||
if (error.response && error.response.status === 404) return false;
|
||||
|
@ -97,13 +99,13 @@ export const useScheduleStore = defineStore({
|
|||
},
|
||||
|
||||
async removeEventType(id: number) {
|
||||
await api.delete(`/schedule/event-types/${id}`);
|
||||
await api.delete(`/events/event-types/${id}`);
|
||||
// TODO handle delete
|
||||
},
|
||||
|
||||
async renameEventType(id: number, newName: string) {
|
||||
try {
|
||||
await api.put(`/schedule/event-types/${id}`, { name: newName });
|
||||
await api.put(`/events/event-types/${id}`, { name: newName });
|
||||
// TODO handle rename
|
||||
return true;
|
||||
} catch (error) {
|
||||
|
@ -117,7 +119,7 @@ export const useScheduleStore = defineStore({
|
|||
|
||||
async getTemplates(force = false) {
|
||||
if (force || this.templates.length == 0) {
|
||||
const { data } = await api.get<FG.Event[]>('/schedule/templates');
|
||||
const { data } = await api.get<FG.Event[]>('/events/templates');
|
||||
data.forEach((element) => fixEvent(element));
|
||||
this.templates = data;
|
||||
}
|
||||
|
@ -126,19 +128,27 @@ export const useScheduleStore = defineStore({
|
|||
|
||||
async getEvents(filter: { from?: Date; to?: Date } | undefined = undefined) {
|
||||
try {
|
||||
const { data } = await api.get<FG.Event[]>('/schedule/events', { params: filter });
|
||||
const { data } = await api.get<FG.Event[]>('/events', { params: filter });
|
||||
data.forEach((element) => fixEvent(element));
|
||||
return data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
async getEvent(id: number) {
|
||||
try {
|
||||
const { data } = await api.get<FG.Event>(`/events/${id}`);
|
||||
fixEvent(data);
|
||||
return data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
async updateJob(eventId: number, jobId: number, service: FG.Service | UserService) {
|
||||
try {
|
||||
const { data } = await api.put<FG.Job>(
|
||||
`/schedule/events/${eventId}/jobs/${jobId}`,
|
||||
service
|
||||
);
|
||||
const { data } = await api.put<FG.Job>(`/events/${eventId}/jobs/${jobId}`, service);
|
||||
fixJob(data);
|
||||
return data;
|
||||
} catch (error) {
|
||||
|
@ -147,7 +157,7 @@ export const useScheduleStore = defineStore({
|
|||
},
|
||||
|
||||
async addEvent(event: FG.Event) {
|
||||
const { data } = await api.post<FG.Event>('/schedule/events', event);
|
||||
const { data } = await api.post<FG.Event>('/events', event);
|
||||
if (data.is_template) this.templates.push(data);
|
||||
return data;
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue