From 0f65ae53af5583073efe80f18aa0986871e80dce Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 22 Dec 2021 01:08:48 +0100 Subject: [PATCH] feat(ui): Add functions for getting a job and invitations to the events store --- src/store/index.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/store/index.ts b/src/store/index.ts index 0b0cf73..8a69d83 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -28,6 +28,7 @@ export const useEventStore = defineStore({ jobTypes: [] as FG.JobType[], eventTypes: [] as FG.EventType[], templates: [] as FG.Event[], + invitations: [] as FG.Invitation[], }), getters: {}, @@ -168,6 +169,10 @@ export const useEventStore = defineStore({ .then(({ data }) => fixJob(data)); }, + async getJob(id: number) { + return api.get(`/events/jobs/${id}`).then(({ data }) => fixJob(data)); + }, + async getJobs(filter?: FG.PaginationFilter) { return api .get>('/events/jobs', { params: filter }) @@ -191,6 +196,14 @@ export const useEventStore = defineStore({ }); }, + async getInvitations(force = false) { + if (this.invitations.length == 0 || force) { + const { data } = await api.get('/events/invitations'); + this.invitations = data; + } + return this.invitations; + }, + async rejectInvitation(invite: FG.Invitation | number) { return api.delete(`/events/invitations/${typeof invite === 'number' ? invite : invite.id}`); },