import {
  WorkspaceAddDatas,
  SceneListType,
  GetListWorkshop,
  getSceneList,
  LabelModuleListType,
} from '@/api/scene/sceneOperate';
import { WorkShopTempleteType } from '@/api/scene/secene-templet';
import { defineStore } from 'pinia';
import { ref } from 'vue';
import { dataSourceWithParent } from './use-method';

export const useScene = defineStore('scene-data', () => {
  //场景数据
  const tableData = ref<
    SceneListType<GetListWorkshop<WorkspaceAddDatas, WorkShopTempleteType>, LabelModuleListType>[]
  >([]);

  const getSceneDetail = () => {
    getSceneList().then((res) => {
      tableData.value = res;
      //添加父级，主要用于排序功能
      tableData.value = dataSourceWithParent(tableData.value, null);
    });
  };

  return { tableData, getSceneDetail };
});

export default useScene;
