diff --git a/src/components/admin/club/newsletter/CreateNewsletterModal.vue b/src/components/admin/club/newsletter/CreateNewsletterModal.vue new file mode 100644 index 0000000..301b436 --- /dev/null +++ b/src/components/admin/club/newsletter/CreateNewsletterModal.vue @@ -0,0 +1,78 @@ + + + + + diff --git a/src/components/admin/club/newsletter/CurrentlySyncingModal.vue b/src/components/admin/club/newsletter/CurrentlySyncingModal.vue new file mode 100644 index 0000000..5d14c37 --- /dev/null +++ b/src/components/admin/club/newsletter/CurrentlySyncingModal.vue @@ -0,0 +1,26 @@ + + + + + diff --git a/src/components/admin/club/newsletter/NewsletterListItem.vue b/src/components/admin/club/newsletter/NewsletterListItem.vue new file mode 100644 index 0000000..bbc488a --- /dev/null +++ b/src/components/admin/club/newsletter/NewsletterListItem.vue @@ -0,0 +1,29 @@ + + + + + diff --git a/src/components/admin/club/newsletter/NewsletterSyncing.vue b/src/components/admin/club/newsletter/NewsletterSyncing.vue new file mode 100644 index 0000000..1e60b0f --- /dev/null +++ b/src/components/admin/club/newsletter/NewsletterSyncing.vue @@ -0,0 +1,123 @@ + + + + + diff --git a/src/router/index.ts b/src/router/index.ts index 6320b22..f34bb3d 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -8,6 +8,7 @@ import { abilityAndNavUpdate } from "./adminGuard"; import type { PermissionType, PermissionSection, PermissionModule } from "@/types/permissionTypes"; import { resetMemberStores, setMemberId } from "./memberGuard"; import { resetProtocolStores, setProtocolId } from "./protocolGuard"; +import { resetNewsletterStores, setNewsletterId } from "./newsletterGuard"; const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), @@ -174,10 +175,51 @@ const router = createRouter({ }, { path: "newsletter", - name: "admin-club-newsletter", - component: () => import("@/views/admin/ViewSelect.vue"), + name: "admin-club-newsletter-route", + component: () => import("@/views/RouterView.vue"), meta: { type: "read", section: "club", module: "newsletter" }, beforeEnter: [abilityAndNavUpdate], + children: [ + { + path: "", + name: "admin-club-newsletter", + component: () => import("@/views/admin/club/newsletter/Newsletter.vue"), + beforeEnter: [resetNewsletterStores], + }, + { + path: ":newsletterId", + name: "admin-club-newsletter-routing", + component: () => import("@/views/admin/club/newsletter/NewsletterRouting.vue"), + beforeEnter: [setNewsletterId], + props: true, + children: [ + { + path: "overview", + name: "admin-club-newsletter-overview", + component: () => import("@/views/admin/club/newsletter/NewsletterOverview.vue"), + props: true, + }, + { + path: "recipients", + name: "admin-club-newsletter-recipients", + component: () => import("@/views/admin/club/newsletter/NewsletterRecipients.vue"), + props: true, + }, + { + path: "dates", + name: "admin-club-newsletter-dates", + component: () => import("@/views/admin/club/newsletter/NewsletterDates.vue"), + props: true, + }, + { + path: "printout", + name: "admin-club-newsletter-printout", + component: () => import("@/views/admin/club/newsletter/NewsletterPrintout.vue"), + props: true, + }, + ], + }, + ], }, { path: "protocol", diff --git a/src/router/newsletterGuard.ts b/src/router/newsletterGuard.ts new file mode 100644 index 0000000..1f64164 --- /dev/null +++ b/src/router/newsletterGuard.ts @@ -0,0 +1,24 @@ +import { useNewsletterStore } from "@/stores/admin/newsletter"; +import { useNewsletterDatesStore } from "@/stores/admin/newsletterDates"; +import { useNewsletterRecipientsStore } from "@/stores/admin/newsletterRecipients"; + +export async function setNewsletterId(to: any, from: any, next: any) { + const newsletter = useNewsletterStore(); + newsletter.activeNewsletter = to.params?.newsletterId ?? null; + + useNewsletterDatesStore().$reset(); + useNewsletterRecipientsStore().$reset(); + + next(); +} + +export async function resetNewsletterStores(to: any, from: any, next: any) { + const newsletter = useNewsletterStore(); + newsletter.activeNewsletter = null; + newsletter.activeNewsletterObj = null; + + useNewsletterDatesStore().$reset(); + useNewsletterRecipientsStore().$reset(); + + next(); +} diff --git a/src/stores/admin/newsletterDates.ts b/src/stores/admin/newsletterDates.ts index 9040554..9e1e23f 100644 --- a/src/stores/admin/newsletterDates.ts +++ b/src/stores/admin/newsletterDates.ts @@ -1,7 +1,7 @@ import { defineStore } from "pinia"; import { http } from "@/serverCom"; import type { NewsletterDatesViewModel, SyncNewsletterDatesViewModel } from "@/viewmodels/admin/newsletterDates.models"; -import { useProtocolStore } from "./protocol"; +import { useNewsletterStore } from "./newsletter"; import cloneDeep from "lodash.clonedeep"; import isEqual from "lodash.isequal"; import differenceWith from "lodash.differencewith"; @@ -36,16 +36,16 @@ export const useNewsletterDatesStore = defineStore("newsletterDates", { }); }, fetchNewsletterDatesPromise() { - const protocolId = useProtocolStore().activeProtocol; - return http.get(`/admin/protocol/${protocolId}/agenda`); + const newsletterId = useNewsletterStore().activeNewsletter; + return http.get(`/admin/newsletter/${newsletterId}/dates`); }, async synchronizeActiveNewsletterDates() { this.syncingNewsletterDates = "syncing"; - const protocolId = useProtocolStore().activeProtocol; + const newsletterId = useNewsletterStore().activeNewsletter; await http - .patch(`/admin/protocol/${protocolId}/synchronize/agenda`, { - agenda: differenceWith(this.dates, this.origin, isEqual), + .patch(`/admin/newsletter/${newsletterId}/synchronize/dates`, { + dates: differenceWith(this.dates, this.origin, isEqual), }) .then((res) => { this.syncingNewsletterDates = "synced"; diff --git a/src/stores/admin/newsletterRecipients.ts b/src/stores/admin/newsletterRecipients.ts index 3d44265..3f4991d 100644 --- a/src/stores/admin/newsletterRecipients.ts +++ b/src/stores/admin/newsletterRecipients.ts @@ -4,7 +4,7 @@ import type { NewsletterRecipientsViewModel, SyncNewsletterRecipientsViewModel, } from "@/viewmodels/admin/newsletterRecipients.models"; -import { useProtocolStore } from "./protocol"; +import { useNewsletterStore } from "./newsletter"; import cloneDeep from "lodash.clonedeep"; import isEqual from "lodash.isequal"; @@ -38,15 +38,15 @@ export const useNewsletterRecipientsStore = defineStore("newsletterRecipients", }); }, fetchNewsletterRecipientsPromise() { - const protocolId = useProtocolStore().activeProtocol; - return http.get(`/admin/protocol/${protocolId}/presence`); + const newsletterId = useNewsletterStore().activeNewsletter; + return http.get(`/admin/newsletter/${newsletterId}/recipients`); }, async synchronizeActiveNewsletterRecipients() { this.syncingNewsletterRecipients = "syncing"; - const protocolId = useProtocolStore().activeProtocol; + const newsletterId = useNewsletterStore().activeNewsletter; await http - .put(`/admin/protocol/${protocolId}/synchronize/presence`, { - presence: this.recipients, + .patch(`/admin/newsletter/${newsletterId}/synchronize/recipients`, { + recipients: this.recipients, }) .then((res) => { this.syncingNewsletterRecipients = "synced"; diff --git a/src/views/admin/club/newsletter/Newsletter.vue b/src/views/admin/club/newsletter/Newsletter.vue new file mode 100644 index 0000000..4541051 --- /dev/null +++ b/src/views/admin/club/newsletter/Newsletter.vue @@ -0,0 +1,69 @@ + + + + + diff --git a/src/views/admin/club/newsletter/NewsletterDates.vue b/src/views/admin/club/newsletter/NewsletterDates.vue new file mode 100644 index 0000000..9879f42 --- /dev/null +++ b/src/views/admin/club/newsletter/NewsletterDates.vue @@ -0,0 +1,84 @@ + + + + + diff --git a/src/views/admin/club/newsletter/NewsletterOverview.vue b/src/views/admin/club/newsletter/NewsletterOverview.vue new file mode 100644 index 0000000..0d7b004 --- /dev/null +++ b/src/views/admin/club/newsletter/NewsletterOverview.vue @@ -0,0 +1,63 @@ + + + + + diff --git a/src/views/admin/club/newsletter/NewsletterPrintout.vue b/src/views/admin/club/newsletter/NewsletterPrintout.vue new file mode 100644 index 0000000..b328242 --- /dev/null +++ b/src/views/admin/club/newsletter/NewsletterPrintout.vue @@ -0,0 +1,102 @@ + + + + + diff --git a/src/views/admin/club/newsletter/NewsletterRecipients.vue b/src/views/admin/club/newsletter/NewsletterRecipients.vue new file mode 100644 index 0000000..b282456 --- /dev/null +++ b/src/views/admin/club/newsletter/NewsletterRecipients.vue @@ -0,0 +1,164 @@ + + + + + diff --git a/src/views/admin/club/newsletter/NewsletterRouting.vue b/src/views/admin/club/newsletter/NewsletterRouting.vue new file mode 100644 index 0000000..f9e9299 --- /dev/null +++ b/src/views/admin/club/newsletter/NewsletterRouting.vue @@ -0,0 +1,123 @@ + + + + +