import * as React from 'react';
import Request from '../utils/request';
export const useAddtendanceList = () => {
  const [state, setState] = React.useState({
    loading: false,
    dataSource: [],
    total: 0,
    page: 1,
  });
  const request = (params: {
    page?: number;
    start?: number;
    end?: number;
    filter?: string;
  }) => {
    setState((preState) => ({ ...preState, loading: true }));
    Request.sendRequest({
      url: '/v1/staff/attendance',
      params,
    })
      .then((data: any) => {
        setState((preState) => ({
          ...preState,
          ...data,
          loading: false,
          dataSource: data.list,
        }));
      })
      .catch((error) => {
        setState((preState) => ({ ...preState, loading: false }));
      });
  };
  return { state, request } as const;
};
