import { defineStore } from "pinia";
import { ref } from "vue";

export const useroleUserDataStore = defineStore("roleusers", () => {
  const insignia1Role = ref<boolean>(false);
  const insignia2Role = ref<boolean>(false);
  const caregiverRole = ref<boolean>(false);
  const chairmanRole = ref<boolean>(false);
  const commanderRole = ref<boolean>(false);
  const admin2Role = ref<boolean>(false);
  const adminRole = ref<boolean>(false);
  const oligarchRole = ref<boolean>(false);

  const fetchroleUser = async (roles: string[]) => {
    if (roles) {
      insignia1Role.value = await roles.includes("insignia1");
      insignia2Role.value = await roles.includes("insignia2");
      caregiverRole.value = await roles.includes("caregiver");
      chairmanRole.value = await roles.includes("chairman");
      commanderRole.value = await roles.includes("commander");
      admin2Role.value = await roles.includes("admin2");
      adminRole.value = await roles.includes("admin");
      oligarchRole.value = await roles.includes("oligarch");
    }
  };

  return {
    fetchroleUser,
    insignia1Role,
    insignia2Role,
    caregiverRole,
    chairmanRole,
    commanderRole,
    admin2Role,
    adminRole,
  };
});
