import { useNewsletterStore } from "@/stores/admin/club/newsletter/newsletter";
import { useNewsletterDatesStore } from "@/stores/admin/club/newsletter/newsletterDates";
import { useNewsletterRecipientsStore } from "@/stores/admin/club/newsletter/newsletterRecipients";
import { useNewsletterPrintoutStore } from "../stores/admin/club/newsletter/newsletterPrintout";

export async function setNewsletterId(to: any, from: any, next: any) {
  const newsletter = useNewsletterStore();
  newsletter.activeNewsletter = to.params?.newsletterId ?? null;

  useNewsletterDatesStore().$reset();
  useNewsletterRecipientsStore().$reset();
  useNewsletterPrintoutStore().$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();
  useNewsletterPrintoutStore().$reset();

  next();
}
