20 lines
976 B
TypeScript
20 lines
976 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { bookingsApi } from '../apis';
|
|
import { bookingKeys } from '../keys';
|
|
import { SESSION_EVV_STALE_TIME } from '../constants';
|
|
|
|
/**
|
|
* Per-session EVV detail (`booking_sessions/evv/{id}`) — the `checkInAt` + advisory `checkInAddressMatch`
|
|
* the EVV banner renders on the nurse's day surface (the booking-detail card reads these from the
|
|
* embedded session instead, so it doesn't need this). `enabled` lets the day surface fetch it only for
|
|
* sessions that already have EVV activity. EVV mutations `setQueryData` this key so the banner is instant.
|
|
*/
|
|
export function useSessionEvv(sessionId: number | undefined, options?: { enabled?: boolean }) {
|
|
return useQuery({
|
|
queryKey: bookingKeys.sessionEvv(sessionId ?? -1),
|
|
queryFn: () => bookingsApi.getSessionEvv(sessionId as number),
|
|
enabled: (options?.enabled ?? true) && sessionId != null && sessionId > 0,
|
|
staleTime: SESSION_EVV_STALE_TIME,
|
|
});
|
|
}
|