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

export const useOrganizationalDataStore = defineStore("organizational", () => {
  interface organizational {
    mappingPosition: { columns: String[] };
  }

  const organizationalData = ref<organizational>({
    mappingPosition: { columns: [] },
  });

  const changeOrganizationalColumns = (system: String, val: String[]) => {
    if (system == "mappingPosition")
      organizationalData.value.mappingPosition.columns = val;
    localStorage.setItem(
      "organizational",
      JSON.stringify(organizationalData.value)
    );
  };

  if (localStorage.getItem("organizational") !== null) {
    organizationalData.value = JSON.parse(
      localStorage.getItem("organizational") || "{}"
    );
  }

  return {
    organizationalData,
    changeOrganizationalColumns,
  };
});
