import { defineStore } from "pinia"; import type { InviteViewModel } from "@/viewmodels/admin/invite.models"; import { http } from "@/serverCom"; import type { PermissionObject } from "@/types/permissionTypes"; import type { AxiosResponse } from "axios"; export const useInviteStore = defineStore("invite", { state: () => { return { invites: [] as Array, loading: "loading" as "loading" | "fetched" | "failed", }; }, actions: { fetchInvites() { this.loading = "loading"; http .get("/admin/invite") .then((result) => { this.invites = result.data; this.loading = "fetched"; }) .catch((err) => { this.loading = "failed"; }); }, deleteInvite(invite: number): Promise> { return http.delete(`/admin/invite/${invite}`).then((result) => { this.fetchInvites(); return result; }); }, }, });