import { defineStore } from "pinia";
import { tenantSelect } from "@/api/subPlatform/tenant";

const useDataStore = defineStore("data", {
  state: () => ({
    siteList: [],
  }),
  getters: {
    getSiteName: (state) => {
      return (siteId) =>
        state.siteList.find((el) => el.id === siteId)?.name || "无";
    },
  },
  actions: {
    async setSiteList() {
      console.log(this.siteList);
      if (this.siteList.length !== 0) {
        return;
      }
      const { rows } = await tenantSelect();
      this.siteList = rows;
    },
  },
});

export default useDataStore;
