date editing

This commit is contained in:
Julian Krauser 2024-12-26 19:36:00 +01:00
parent be2bd5e6e3
commit ec477b7d72
9 changed files with 139 additions and 44 deletions

View file

@ -17,7 +17,16 @@ export const useNewsletterDatesStore = defineStore("newsletterDates", {
},
getters: {
detectedChangeNewsletterDates: (state) =>
!isEqual(state.origin, state.dates) && state.syncingNewsletterDates != "syncing",
!isEqual(
state.origin.sort(
(a: NewsletterDatesViewModel, b: NewsletterDatesViewModel) =>
new Date(a.calendar.starttime).getTime() - new Date(b.calendar.starttime).getTime()
),
state.dates.sort(
(a: NewsletterDatesViewModel, b: NewsletterDatesViewModel) =>
new Date(a.calendar.starttime).getTime() - new Date(b.calendar.starttime).getTime()
)
) && state.syncingNewsletterDates != "syncing",
},
actions: {
setNewsletterDatesSyncingState(state: "synced" | "syncing" | "detectedChanges" | "failed") {
@ -45,7 +54,7 @@ export const useNewsletterDatesStore = defineStore("newsletterDates", {
await http
.patch(`/admin/newsletter/${newsletterId}/synchronize/dates`, {
dates: differenceWith(this.dates, this.origin, isEqual),
dates: this.dates,
})
.then((res) => {
this.syncingNewsletterDates = "synced";