From 61052805aeee284b3b3e15b944dbfbc0a5bdc3e3 Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Sat, 23 Nov 2024 14:25:41 +0100 Subject: [PATCH 1/2] invite base operations --- src/components/Header.vue | 6 +- .../admin/user/user/InviteListItem.vue | 46 +++++++ .../admin/user/user/InviteUserModal.vue | 93 ++++++++++++++ src/router/index.ts | 33 +++-- src/stores/admin/invite.ts | 34 +++++ src/viewmodels/admin/invite.models.ts | 7 ++ src/views/admin/user/Invite.vue | 39 ++++++ src/views/admin/user/User.vue | 10 +- src/views/invite/Verify.vue | 118 ++++++++++++++++++ 9 files changed, 375 insertions(+), 11 deletions(-) create mode 100644 src/components/admin/user/user/InviteListItem.vue create mode 100644 src/components/admin/user/user/InviteUserModal.vue create mode 100644 src/stores/admin/invite.ts create mode 100644 src/viewmodels/admin/invite.models.ts create mode 100644 src/views/admin/user/Invite.vue create mode 100644 src/views/invite/Verify.vue diff --git a/src/components/Header.vue b/src/components/Header.vue index 1c824c6..0512b4b 100644 --- a/src/components/Header.vue +++ b/src/components/Header.vue @@ -7,7 +7,11 @@
diff --git a/src/components/admin/user/user/InviteListItem.vue b/src/components/admin/user/user/InviteListItem.vue new file mode 100644 index 0000000..f1f9f87 --- /dev/null +++ b/src/components/admin/user/user/InviteListItem.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/src/components/admin/user/user/InviteUserModal.vue b/src/components/admin/user/user/InviteUserModal.vue new file mode 100644 index 0000000..fa57b2a --- /dev/null +++ b/src/components/admin/user/user/InviteUserModal.vue @@ -0,0 +1,93 @@ + + + + + diff --git a/src/router/index.ts b/src/router/index.ts index 967efe1..9377bdd 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -41,19 +41,33 @@ const router = createRouter({ ], }, { - path: "/reset", - name: "reset", + path: "/setup", + name: "setup", component: () => import("@/views/RouterView.vue"), + beforeEnter: [isSetup], children: [ { path: "", - name: "reset-start", - component: () => import("@/views/reset/Start.vue"), + name: "setup-create", + component: () => import("@/views/setup/Setup.vue"), }, { - path: "reset", - name: "reset-reset", - component: () => import("@/views/reset/Reset.vue"), + path: "verify", + name: "setup-verify", + component: () => import("@/views/setup/Verify.vue"), + props: (route) => ({ mail: route.query.mail, token: route.query.token }), + }, + ], + }, + { + path: "/invite", + name: "invite", + component: () => import("@/views/RouterView.vue"), + children: [ + { + path: "verify", + name: "invite-verify", + component: () => import("@/views/invite/Verify.vue"), props: (route) => ({ mail: route.query.mail, token: route.query.token }), }, ], @@ -403,6 +417,11 @@ const router = createRouter({ name: "admin-user-user", component: () => import("@/views/admin/user/User.vue"), }, + { + path: "invites", + name: "admin-user-user-invites", + component: () => import("@/views/admin/user/Invite.vue"), + }, { path: ":id/edit", name: "admin-user-user-edit", diff --git a/src/stores/admin/invite.ts b/src/stores/admin/invite.ts new file mode 100644 index 0000000..0600dc9 --- /dev/null +++ b/src/stores/admin/invite.ts @@ -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, + 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; + }); + }, + }, +}); diff --git a/src/viewmodels/admin/invite.models.ts b/src/viewmodels/admin/invite.models.ts new file mode 100644 index 0000000..c6c860f --- /dev/null +++ b/src/viewmodels/admin/invite.models.ts @@ -0,0 +1,7 @@ +export interface InviteViewModel { + id: number; + username: string; + mail: string; + firstname: string; + lastname: string; +} diff --git a/src/views/admin/user/Invite.vue b/src/views/admin/user/Invite.vue new file mode 100644 index 0000000..a1f6fb3 --- /dev/null +++ b/src/views/admin/user/Invite.vue @@ -0,0 +1,39 @@ + + + + + diff --git a/src/views/admin/user/User.vue b/src/views/admin/user/User.vue index 3b73671..6d1df32 100644 --- a/src/views/admin/user/User.vue +++ b/src/views/admin/user/User.vue @@ -11,8 +11,10 @@
- - + + + offene Einladungen +
@@ -20,10 +22,12 @@ diff --git a/src/views/invite/Verify.vue b/src/views/invite/Verify.vue new file mode 100644 index 0000000..2a74ef8 --- /dev/null +++ b/src/views/invite/Verify.vue @@ -0,0 +1,118 @@ + + + + + -- 2.45.2 From ed50d8e446aad1a551f0097549bef42f1f4dd7f5 Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Sun, 24 Nov 2024 12:36:03 +0100 Subject: [PATCH 2/2] invite management --- src/components/admin/user/user/InviteListItem.vue | 4 +++- src/stores/admin/invite.ts | 4 ++-- src/views/admin/user/User.vue | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/admin/user/user/InviteListItem.vue b/src/components/admin/user/user/InviteListItem.vue index f1f9f87..b7573d7 100644 --- a/src/components/admin/user/user/InviteListItem.vue +++ b/src/components/admin/user/user/InviteListItem.vue @@ -40,7 +40,9 @@ export default defineComponent({ }, methods: { ...mapActions(useInviteStore, ["deleteInvite"]), - triggerDeleteInvite() {}, + triggerDeleteInvite() { + this.deleteInvite(this.invite.mail); + }, }, }); diff --git a/src/stores/admin/invite.ts b/src/stores/admin/invite.ts index 0600dc9..80526b4 100644 --- a/src/stores/admin/invite.ts +++ b/src/stores/admin/invite.ts @@ -24,8 +24,8 @@ export const useInviteStore = defineStore("invite", { this.loading = "failed"; }); }, - deleteInvite(invite: number): Promise> { - return http.delete(`/admin/invite/${invite}`).then((result) => { + deleteInvite(mail: string): Promise> { + return http.delete(`/admin/invite/${mail}`).then((result) => { this.fetchInvites(); return result; }); diff --git a/src/views/admin/user/User.vue b/src/views/admin/user/User.vue index 6d1df32..9650cfd 100644 --- a/src/views/admin/user/User.vue +++ b/src/views/admin/user/User.vue @@ -41,6 +41,10 @@ export default defineComponent({ }, methods: { ...mapActions(useUserStore, ["fetchUsers"]), + ...mapActions(useModalStore, ["openModal"]), + inviteUser() { + this.openModal(markRaw(defineAsyncComponent(() => import("@/components/admin/user/user/InviteUserModal.vue")))); + }, }, }); -- 2.45.2