48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import { PERMS } from "@/lib/permission-slugs";
|
|
import type { HousekeepingPageInput } from "../../../route-handlers";
|
|
import { hotelQuery } from "../queries/rooms";
|
|
import { HotelCommandForm } from "./hotel-command-form";
|
|
import {
|
|
HotelPageFrame,
|
|
type HotelPageProps,
|
|
parseHotelListInput,
|
|
} from "./hotel-page-frame";
|
|
|
|
export function HotelRoomsPage(props: HotelPageProps) {
|
|
return (
|
|
<HotelPageFrame
|
|
title="Rooms"
|
|
description="Search and operate hotel rooms."
|
|
result={props.result}
|
|
forms={
|
|
props.context.has(PERMS.ROOMS_EDIT) ? (
|
|
<HotelCommandForm
|
|
commandId="hotel.rooms.update"
|
|
buttonLabel="Save room"
|
|
input={{}}
|
|
fields={[
|
|
{ name: "id", label: "Room ID", type: "number", required: true },
|
|
{ name: "name", label: "Name", type: "text", required: true },
|
|
]}
|
|
/>
|
|
) : null
|
|
}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export async function renderHotelRoomsPage(input: HousekeepingPageInput) {
|
|
const result = await hotelQuery.run(input.context, {
|
|
routeId: "hotel.rooms",
|
|
params: input.match.params,
|
|
list: parseHotelListInput(input.searchParams ?? {}),
|
|
});
|
|
return (
|
|
<HotelRoomsPage
|
|
context={input.context}
|
|
result={result}
|
|
routeId="hotel.rooms"
|
|
/>
|
|
);
|
|
}
|