Newsletter base views and Data display

This commit is contained in:
Julian Krauser 2024-12-26 13:57:45 +01:00
parent 9ef171b913
commit be2bd5e6e3
14 changed files with 941 additions and 14 deletions

View file

@ -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";

View file

@ -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";