Files
baya-monorepo/client/src/services/payouts/hooks/usePreviewPayoutBatch.ts
T
2026-07-10 20:28:06 +03:30

16 lines
776 B
TypeScript

import { useMutation } from '@tanstack/react-query';
import { payoutsApi } from '../apis';
import type { PayoutBatchPreview } from '../types';
/**
* The eligibility dry-run for a window — a **mutation**, not an auto-fetching query: it runs only when the
* admin explicitly asks to preview (never on mount), and its result (the eligible/skipped breakdown + the
* server's holiday-shifted processing date) is read from the mutation's `data`. The client renders it; it
* never computes eligibility or the shifted date.
*/
export function usePreviewPayoutBatch() {
return useMutation<PayoutBatchPreview, unknown, { periodStart: string; periodEnd: string }>({
mutationFn: ({ periodStart, periodEnd }) => payoutsApi.previewPayoutBatch(periodStart, periodEnd),
});
}