My App
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;
}
OptionTypeRequiredDescription
filtersUseBlackoutsFiltersNoFilter by location scope and time range
paginationPaginationNo{ cursor?, limit }
enabledbooleanNoSet to false to skip the request
onSuccess(data) => voidNoCalled when the request succeeds
onError(error) => voidNoCalled when the request fails

Return Value

FieldTypeDescription
dataPaginatedResult<BlackoutWindow> | nullPaginated blackout windows
isLoadingbooleantrue while the request is in flight
errorError | nullThe error if the request failed
refetch() => Promise<void>Manually re-fetch the data

API Endpoint

GET {apiUrl}/blackouts?locationScope=...&startsAt=...&endsAt=...

On this page