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;
}| Option | Type | Required | Description |
|---|---|---|---|
roomId | string | Yes | The room ID to fetch |
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 | RoomDetail | null | Room with equipment and accessibility |
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}/rooms/{roomId}