From 924a6bf647919f73a89cadc1d7450ffdd421b9ed Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Wed, 22 Jan 2025 08:56:52 +0100 Subject: [PATCH 1/2] get statistics --- src/stores/admin/club/member/member.ts | 18 +++++++++++++++++- src/stores/admin/club/member/membership.ts | 11 +++++++++++ .../admin/club/member/member.models.ts | 12 ++++++++++++ .../admin/club/member/membership.models.ts | 15 +++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/stores/admin/club/member/member.ts b/src/stores/admin/club/member/member.ts index c7892c2..1d96dc7 100644 --- a/src/stores/admin/club/member/member.ts +++ b/src/stores/admin/club/member/member.ts @@ -1,5 +1,9 @@ import { defineStore } from "pinia"; -import type { CreateMemberViewModel, UpdateMemberViewModel } from "@/viewmodels/admin/club/member/member.models"; +import type { + CreateMemberViewModel, + MemberStatisticsViewModel, + UpdateMemberViewModel, +} from "@/viewmodels/admin/club/member/member.models"; import { http } from "@/serverCom"; import type { AxiosResponse } from "axios"; import type { MemberViewModel } from "@/viewmodels/admin/club/member/member.models"; @@ -12,6 +16,7 @@ export const useMemberStore = defineStore("member", { loading: "loading" as "loading" | "fetched" | "failed", activeMember: null as number | null, activeMemberObj: null as MemberViewModel | null, + activeMemberStatistics: null as MemberStatisticsViewModel | null, loadingActive: "loading" as "loading" | "fetched" | "failed", }; }, @@ -70,6 +75,17 @@ export const useMemberStore = defineStore("member", { fetchMemberById(id: number) { return http.get(`/admin/member/${id}`); }, + fetchMemberStatisticsByActiveId() { + http + .get(`/admin/member/${this.activeMember}/statistics`) + .then((res) => { + this.activeMemberStatistics = res.data; + }) + .catch((err) => {}); + }, + fetchMemberStatisticsById(id: number) { + return http.get(`/admin/member/${id}/statistics`); + }, async createMember(member: CreateMemberViewModel): Promise> { const result = await http.post(`/admin/member`, { salutation: member.salutation, diff --git a/src/stores/admin/club/member/membership.ts b/src/stores/admin/club/member/membership.ts index a430bf4..fd2aaf8 100644 --- a/src/stores/admin/club/member/membership.ts +++ b/src/stores/admin/club/member/membership.ts @@ -6,6 +6,7 @@ import type { MemberViewModel } from "@/viewmodels/admin/club/member/member.mode import { useMemberStore } from "./member"; import type { CreateMembershipViewModel, + MembershipStatisticsViewModel, MembershipViewModel, UpdateMembershipViewModel, } from "@/viewmodels/admin/club/member/membership.models"; @@ -14,6 +15,7 @@ export const useMembershipStore = defineStore("membership", { state: () => { return { memberships: [] as Array, + membershipStatistics: [] as Array, loading: "loading" as "loading" | "fetched" | "failed", }; }, @@ -31,6 +33,15 @@ export const useMembershipStore = defineStore("membership", { this.loading = "failed"; }); }, + fetchMembershipStatisticsForMember() { + const memberId = useMemberStore().activeMember; + http + .get(`/admin/member/${memberId}/memberships/statistics`) + .then((result) => { + this.membershipStatistics = result.data; + }) + .catch((err) => {}); + }, fetchMembershipById(id: number) { const memberId = useMemberStore().activeMember; return http.get(`/admin/member/${memberId}/membership/${id}`); diff --git a/src/viewmodels/admin/club/member/member.models.ts b/src/viewmodels/admin/club/member/member.models.ts index ca5fcc1..0283545 100644 --- a/src/viewmodels/admin/club/member/member.models.ts +++ b/src/viewmodels/admin/club/member/member.models.ts @@ -17,6 +17,18 @@ export interface MemberViewModel { preferredCommunication?: Array; } +export interface MemberStatisticsViewModel { + id: number; + salutation: Salutation; + firstname: string; + lastname: string; + nameaffix: string; + birthdate: Date; + todayAge: number; + ageThisYear: number; + exactAge: string; +} + export interface CreateMemberViewModel { salutation: Salutation; firstname: string; diff --git a/src/viewmodels/admin/club/member/membership.models.ts b/src/viewmodels/admin/club/member/membership.models.ts index 82ede06..b2114c0 100644 --- a/src/viewmodels/admin/club/member/membership.models.ts +++ b/src/viewmodels/admin/club/member/membership.models.ts @@ -1,3 +1,5 @@ +import type { Salutation } from "../../../../enums/salutation"; + export interface MembershipViewModel { id: number; start: Date; @@ -7,6 +9,19 @@ export interface MembershipViewModel { statusId: number; } +export interface MembershipStatisticsViewModel { + durationInDays: number; + durationInYears: string; + status: string; + statusId: number; + memberId: number; + memberSalutation: Salutation; + memberFirstname: string; + memberLastname: string; + memberNameaffix: string; + memberBirthdate: Date; +} + export interface CreateMembershipViewModel { start: Date; statusId: number; -- 2.45.2 From ab3e2b9dc4b7bf48b85990fce6faaeb1c81775b7 Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Wed, 22 Jan 2025 08:57:28 +0100 Subject: [PATCH 2/2] display membership stats in member overview --- .../admin/club/members/MemberOverview.vue | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/views/admin/club/members/MemberOverview.vue b/src/views/admin/club/members/MemberOverview.vue index 6cc0ed2..6716daf 100644 --- a/src/views/admin/club/members/MemberOverview.vue +++ b/src/views/admin/club/members/MemberOverview.vue @@ -25,6 +25,20 @@ +
+

Statistiken zur Mitgliedschaft

+
+
+

+ {{ stat.status }} für gesamt {{ stat.durationInDays }} Tage + ~> {{ stat.durationInYears.replace("_", "") }} Jahre +

+
+
+

Erster Eintrag Mitgliedschaft

@@ -125,6 +139,7 @@ import { defineComponent } from "vue"; import { mapActions, mapState } from "pinia"; import Spinner from "@/components/Spinner.vue"; import { useMemberStore } from "@/stores/admin/club/member/member"; +import { useMembershipStore } from "@/stores/admin/club/member/membership"; -- 2.45.2