RoomKitFrontend
useBlackouts
List blackout windows with location and time filters
Overview
useBlackouts fetches a paginated list of blackout windows. It calls GET {apiUrl}/blackouts.
import { useBlackouts } from '@roomkit/react';Usage
function BlackoutList({ locationScope }: { locationScope: string }) {
const { data, isLoading } = useBlackouts({
filters: {
locationScope,
startsAt: new Date('2026-03-01'),
endsAt: new Date('2026-06-30'),
},
pagination: { limit: 20 },
});
if (isLoading) return <div>Loading blackouts...</div>;
return (
<ul>
{data?.items.map((blackout) => (
<li key={blackout.id}>
{blackout.title} ({blackout.scope}) — {blackout.startsAt} to {blackout.endsAt}
</li>
))}
</ul>
);
}UseBlackoutsOptions
interface UseBlackoutsFilters {
locationScope?: string;
startsAt?: Date;
endsAt?: Date;
}
interface UseBlackoutsOptions {
filters?: UseBlackoutsFilters;
pagination?: Pagination;
enabled?: boolean;
onSuccess?: (data: PaginatedResult<BlackoutWindow>) => void;
onError?: (error: Error) => void;
}| Option | Type | Required | Description |
|---|---|---|---|
filters | UseBlackoutsFilters | No | Filter by location scope and time range |
pagination | Pagination | No | { cursor?, limit } |
enabled | boolean | No | Set to false to skip the request |
onSuccess | (data) => void | No | Called when the request succeeds |
onError | (error) => void | No | Called when the request fails |
Return Value
| Field | Type | Description |
|---|---|---|
data | PaginatedResult<BlackoutWindow> | null | Paginated blackout windows |
isLoading | boolean | true while the request is in flight |
error | Error | null | The error if the request failed |
refetch | () => Promise<void> | Manually re-fetch the data |
API Endpoint
GET {apiUrl}/blackouts?locationScope=...&startsAt=...&endsAt=...