import { ref, computed } from "vue";
import { defineStore } from "pinia";
import type { DataOptionInsignia } from "@/modules/04_registryPerson/interface/index/Main";
import type { ResponseObject as Insignia } from "@/modules/07_insignia/interface/response/Main";

export const useInsigniaDataStore = defineStore("insigniaDataStore", () => {
  const insigniaOption = ref<DataOptionInsignia[]>([]);

  function mapInsigniaOption(resData: any) {
    insigniaOption.value = [];
    resData.map((r: Insignia) => {
      insigniaOption.value.push({
        id: r.id.toString(),
        name: r.name.toString() + ` (${r.shortName})`,
        typeName: r.insigniaTypeName.toString(),
      });
    });
  }

  return { insigniaOption, mapInsigniaOption };
});
