2024-11-23 14:25:41 +01:00
|
|
|
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<InviteViewModel>,
|
|
|
|
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";
|
|
|
|
});
|
|
|
|
},
|
2024-11-24 12:36:03 +01:00
|
|
|
deleteInvite(mail: string): Promise<AxiosResponse<any, any>> {
|
|
|
|
return http.delete(`/admin/invite/${mail}`).then((result) => {
|
2024-11-23 14:25:41 +01:00
|
|
|
this.fetchInvites();
|
|
|
|
return result;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|