import { ApprovalWorkflow } from "@/interfaces/approval.workflow";
import axios from "axios";
import { useCallback, useEffect, useState } from "react";

import approvalWorkflowsData from '../demo/approval_workflows.json' // to test locally

export default function useApprovalWorkflows() {
  const [approvalWorkflows, setApprovalWorkflows] = useState<ApprovalWorkflow[]>(approvalWorkflowsData);
  const [isLoading, setIsLoading] = useState(false);
  const [isError, setIsError] = useState(false);

  /* const getData = useCallback(() => {
    setIsLoading(true);
    axios
      .get<ApprovalWorkflow[]>(`/api/approvalWorkflows`)
      .then((response) => setApprovalWorkflows(response.data))
      .catch((error) => {
        setIsError(true); 
      })
      .finally(() => setIsLoading(false));
  }, []);

  useEffect(getData, [getData]); */

  return { approvalWorkflows, isLoading, isError/* , reload: getData */ };
}
