import * as React from 'react';
import Request from '../utils/request';
export const useAccessControllerList = () => {
	const [state, setState] = React.useState({
		loading: false,
		dataSource: [],
		total: 0,
		page: 1,
	});
	const request = (params: { page?: number }) => {
		setState((preState) => ({ ...preState, loading: true }));
		Request.sendRequest({
			url: '/v1/device/attendance_list',
			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;
};
