import { ref, computed } from "vue";
import { TRenderData } from "../../type";
const useStack = () => {
  const stack = ref<TRenderData[][]>([]);

  //栈最后一条数据，也就是当前最新的数据
  const lastStackData = computed(() => stack.value[stack.value.length - 1]);

  //是否是首次进入的员工列表
  const isFirstEmployeePage = computed(() => stack.value.length === 1);

  const onAddStack = (data: TRenderData[]) => {
    stack.value.push(data);
  };

  const onPopStack = () => {
    return stack.value.pop();
  };

  return {
    stack,
    lastStackData,
    isFirstEmployeePage,
    onAddStack,
    onPopStack,
  };
};

export default useStack;
