My App
CourseKitFrontend

useRoomSearch

Search for rooms by capacity, building, campus, and availability

Overview

useRoomSearch provides a search function for finding rooms that match specific criteria.

import { useRoomSearch } from '@hfu.digital/coursekit-react';

Usage

function RoomFinder() {
    const { rooms, loading, error, search } = useRoomSearch();

    const handleSearch = async () => {
        await search({
            minCapacity: 50,
            building: 'Main Building',
            availableAt: { start: '2026-03-02T09:00:00', end: '2026-03-02T10:30:00' },
        });
    };

    return (
        <div>
            <button onClick={handleSearch} disabled={loading}>Find Rooms</button>
            {rooms.map(room => (
                <div key={room.id}>
                    {room.name} — {room.building} (capacity: {room.capacity})
                </div>
            ))}
        </div>
    );
}

You can also pass an initial query to trigger a search on mount:

const { rooms, loading } = useRoomSearch({ minCapacity: 30 });

RoomSearchQuery

interface RoomSearchQuery {
    building?: string;
    campus?: string;
    minCapacity?: number;
    availableAt?: { start: string; end: string };
}

All fields are optional. When availableAt is provided, only rooms that are free during that time window are returned.

RoomResult

interface RoomResult {
    id: string;
    name: string;
    building: string | null;
    campus: string | null;
    capacity: number;
    tags: Record<string, unknown> | null;
}

UseRoomSearchResult

interface UseRoomSearchResult {
    rooms: RoomResult[];
    loading: boolean;
    error: Error | null;
    search: (query: RoomSearchQuery) => Promise<void>;
}
FieldTypeDescription
roomsRoomResult[]Matching rooms (empty until search is called)
loadingbooleantrue while the search is in flight
errorError | nullThe error if the search failed
searchfunctionTrigger a new search

API Endpoint

The hook calls:

GET {apiUrl}/rooms?building=...&campus=...&minCapacity=...&availableStart=...&availableEnd=...

On this page