invite base operations
This commit is contained in:
parent
51e9452901
commit
61052805ae
9 changed files with 375 additions and 11 deletions
34
src/stores/admin/invite.ts
Normal file
34
src/stores/admin/invite.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
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";
|
||||
});
|
||||
},
|
||||
deleteInvite(invite: number): Promise<AxiosResponse<any, any>> {
|
||||
return http.delete(`/admin/invite/${invite}`).then((result) => {
|
||||
this.fetchInvites();
|
||||
return result;
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue