import { useCommunicationStore } from "@/stores/admin/communication";
import { useMemberStore } from "@/stores/admin/member";
import { useMemberAwardStore } from "@/stores/admin/memberAward";
import { useMemberExecutivePositionStore } from "@/stores/admin/memberExecutivePosition";
import { useMemberQualificationStore } from "@/stores/admin/memberQualification";
import { useMembershipStore } from "@/stores/admin/membership";

export async function setMemberId(to: any, from: any, next: any) {
  const member = useMemberStore();
  member.activeMember = to.params?.memberId ?? null;

  useMembershipStore().$reset();
  useCommunicationStore().$reset();
  useMemberAwardStore().$reset();
  useMemberExecutivePositionStore().$reset();
  useMemberQualificationStore().$reset();

  next();
}

export async function resetMemberStores(to: any, from: any, next: any) {
  const member = useMemberStore();
  member.activeMember = null;
  member.activeMemberObj = null;

  useMembershipStore().$reset();
  useCommunicationStore().$reset();
  useMemberAwardStore().$reset();
  useMemberExecutivePositionStore().$reset();
  useMemberQualificationStore().$reset();

  next();
}
