// import { useQuery } from "@tanstack/react-query";
// import {
//   dispatchedRecords,
//   OutgoingRecordQueryParams,
// } from "@/record-management/services/api/recordOfficerService";
// import { getReportRO } from "@/record-management/services/api/reportService";

// const getDateRanges = () => {
//   // helpers
//   const pad2 = (n: number) => String(n).padStart(2, "0");
//   const ymdLocal = (d: Date) =>
//     `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;

//   // now (local)
//   const now = new Date();

//   // daily: start of today -> start of tomorrow (exclusive end)
//   const startOfToday = new Date(
//     now.getFullYear(),
//     now.getMonth(),
//     now.getDate()
//   );
//   const startOfTomorrow = new Date(
//     now.getFullYear(),
//     now.getMonth(),
//     now.getDate() + 1
//   );
//   const dailyFrom = ymdLocal(startOfToday);
//   const dailyTo = ymdLocal(startOfTomorrow);

//   // weekly (Monday..next Monday exclusive)
//   const tmp = new Date(now.getFullYear(), now.getMonth(), now.getDate()); // copy
//   const dow = tmp.getDay(); // 0 = Sun, 1 = Mon, ...
//   const diffToMonday = (dow + 6) % 7; // days back to Monday
//   const startOfWeek = new Date(
//     tmp.getFullYear(),
//     tmp.getMonth(),
//     tmp.getDate() - diffToMonday
//   );
//   const startOfNextWeek = new Date(
//     startOfWeek.getFullYear(),
//     startOfWeek.getMonth(),
//     startOfWeek.getDate() + 7
//   );
//   const weeklyFrom = ymdLocal(startOfWeek);
//   const weeklyTo = ymdLocal(startOfNextWeek);

//   // monthly: first of month -> first of next month (exclusive end)
//   const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
//   const startOfNextMonth = new Date(now.getFullYear(), now.getMonth() + 1, 1);
//   const monthlyFrom = ymdLocal(startOfMonth);
//   const monthlyTo = ymdLocal(startOfNextMonth);

//   return {
//     daily: { fromDate: dailyFrom, toDate: dailyTo },
//     weekly: { fromDate: weeklyFrom, toDate: weeklyTo },
//     monthly: { fromDate: monthlyFrom, toDate: monthlyTo },
//   };
// };

// export const useOutgoingRecordCounts = () => {
//   const ranges = getDateRanges();
//   // daily
//   const { data: daily } = useQuery({
//     queryKey: ["outgoingRecords", "daily"],
//     queryFn: () => getReportRO(ranges.daily as OutgoingRecordQueryParams),
//   });

//   // weekly
//   const { data: weekly } = useQuery({
//     queryKey: ["outgoingRecords", "weekly"],
//     queryFn: () => getReportRO(ranges.weekly as OutgoingRecordQueryParams),
//   });

//   // monthly
//   const { data: monthly } = useQuery({
//     queryKey: ["outgoingRecords", "monthly"],
//     queryFn: () => getReportRO(ranges.monthly as OutgoingRecordQueryParams),
//   });
//   const monthlytotalOutgoing = monthly?.outgoingInstanceCount?.Dispatched || 0;
//   const weeklytotalOutgoing = weekly?.outgoingInstanceCount?.Dispatched || 0;
//   const dailytotalOutgoing = daily?.outgoingInstanceCount?.Dispatched || 0;

//   return {
//     dailyCountOutgoing: dailytotalOutgoing,
//     weeklyCountOutgoing: weeklytotalOutgoing,
//     monthlyCountOutgoing: monthlytotalOutgoing,
//   };
// };
