import { useProtocolStore } from "@/stores/admin/protocol";
import { useProtocolAgendaStore } from "@/stores/admin/protocolAgenda";
import { useProtocolDecisionStore } from "@/stores/admin/protocolDecision";
import { useProtocolPresenceStore } from "@/stores/admin/protocolPresence";
import { useProtocolVotingStore } from "@/stores/admin/protocolVoting";
import { useProtocolPrintoutStore } from "../stores/admin/protocolPrintout";

export async function setProtocolId(to: any, from: any, next: any) {
  const protocol = useProtocolStore();
  protocol.activeProtocol = to.params?.protocolId ?? null;

  useProtocolAgendaStore().$reset();
  useProtocolDecisionStore().$reset();
  useProtocolPresenceStore().$reset();
  useProtocolVotingStore().$reset();
  useProtocolPrintoutStore().$reset();

  next();
}

export async function resetProtocolStores(to: any, from: any, next: any) {
  const protocol = useProtocolStore();
  protocol.activeProtocol = null;
  protocol.activeProtocolObj = null;

  useProtocolAgendaStore().$reset();
  useProtocolDecisionStore().$reset();
  useProtocolPresenceStore().$reset();
  useProtocolVotingStore().$reset();
  useProtocolPrintoutStore().$reset();

  next();
}
