feat(ui): Add functions for getting a job and invitations to the events store

This commit is contained in:
Ferdinand Thiessen 2021-12-22 01:08:48 +01:00
parent 2ef9fd023a
commit 0f65ae53af
1 changed files with 13 additions and 0 deletions

View File

@ -28,6 +28,7 @@ export const useEventStore = defineStore({
jobTypes: [] as FG.JobType[], jobTypes: [] as FG.JobType[],
eventTypes: [] as FG.EventType[], eventTypes: [] as FG.EventType[],
templates: [] as FG.Event[], templates: [] as FG.Event[],
invitations: [] as FG.Invitation[],
}), }),
getters: {}, getters: {},
@ -168,6 +169,10 @@ export const useEventStore = defineStore({
.then(({ data }) => fixJob(data)); .then(({ data }) => fixJob(data));
}, },
async getJob(id: number) {
return api.get<FG.Job>(`/events/jobs/${id}`).then(({ data }) => fixJob(data));
},
async getJobs(filter?: FG.PaginationFilter) { async getJobs(filter?: FG.PaginationFilter) {
return api return api
.get<FG.PaginationResponse<FG.Job>>('/events/jobs', { params: <unknown>filter }) .get<FG.PaginationResponse<FG.Job>>('/events/jobs', { params: <unknown>filter })
@ -191,6 +196,14 @@ export const useEventStore = defineStore({
}); });
}, },
async getInvitations(force = false) {
if (this.invitations.length == 0 || force) {
const { data } = await api.get<FG.Invitation[]>('/events/invitations');
this.invitations = data;
}
return this.invitations;
},
async rejectInvitation(invite: FG.Invitation | number) { async rejectInvitation(invite: FG.Invitation | number) {
return api.delete(`/events/invitations/${typeof invite === 'number' ? invite : invite.id}`); return api.delete(`/events/invitations/${typeof invite === 'number' ? invite : invite.id}`);
}, },