import { useCommunicationStore } from "@/stores/admin/club/member/communication";
import { useMemberStore } from "@/stores/admin/club/member/member";
import { useMemberAwardStore } from "@/stores/admin/club/member/memberAward";
import { useMemberExecutivePositionStore } from "@/stores/admin/club/member/memberExecutivePosition";
import { useMemberQualificationStore } from "@/stores/admin/club/member/memberQualification";
import { useMembershipStore } from "@/stores/admin/club/member/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();
}
