import { postScheduleList } from "../schedules/serve.js";
import { useEffect, useState } from "react";
import { useRequest } from "ahooks";
//#region src/components/schedules/hooks/useSchedulesDataSource.ts
const useSchedulesDataSource = (params) => {
	const { scheduleIds } = params || {};
	const [dataSource, setDataSource] = useState([]);
	const { loading, run, refresh } = useRequest(postScheduleList, {
		manual: true,
		onSuccess: (result, params) => {
			if (result.status) setDataSource(result.data.list);
		}
	});
	useEffect(() => {
		run({
			ids: scheduleIds,
			skip: 1,
			num: 500,
			with: ["relation", "timeSlot"],
			with_count: ["relation", "order"]
		});
	}, [scheduleIds]);
	return {
		loading,
		dataSource,
		refresh
	};
};
//#endregion
export { useSchedulesDataSource as default };
