HFU Digital Docs
RoomKitFrontend

useRoomDetail

Fetch a room with its equipment and accessibility attributes

Overview

useRoomDetail fetches a room along with its equipment tags and accessibility attributes. It calls GET {apiUrl}/rooms/{roomId}.

import { useRoomDetail } from '@hfu.digital/roomkit-react';

Usage

function RoomInfo({ roomId }: { roomId: string }) {
    const { data, isLoading, error } = useRoomDetail({ roomId });

    if (isLoading) return <div>Loading...</div>;
    if (!data) return <div>Room not found</div>;

    return (
        <div>
            <h2>{data.locationNodeId}</h2>
            <p>Seated: {data.seatedCapacity} | Exam: {data.examCapacity}</p>
            <h3>Equipment</h3>
            <ul>
                {data.equipment.map((e) => (
                    <li key={e.id}>{e.tag}</li>
                ))}
            </ul>
            <h3>Accessibility</h3>
            <ul>
                {data.accessibility.map((a) => (
                    <li key={a.id}>{a.attribute}</li>
                ))}
            </ul>
        </div>
    );
}

UseRoomDetailOptions

interface RoomDetail extends Room {
    equipment: RoomEquipment[];
    accessibility: RoomAccessibility[];
}

interface UseRoomDetailOptions {
    roomId: string;
    enabled?: boolean;
    onSuccess?: (data: RoomDetail) => void;
    onError?: (error: Error) => void;
}
OptionTypeRequiredDescription
roomIdstringYesThe room ID to fetch
enabledbooleanNoSet to false to skip the request
onSuccess(data) => voidNoCalled when the request succeeds
onError(error) => voidNoCalled when the request fails

Return Value

FieldTypeDescription
dataRoomDetail | nullRoom with equipment and accessibility
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}/rooms/{roomId}

On this page