-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoomCard.tsx
More file actions
58 lines (53 loc) · 1.86 KB
/
RoomCard.tsx
File metadata and controls
58 lines (53 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import {
BrushCleaning,
CircleAlert,
CircleUserRound,
UserRoundCheck,
} from "lucide-react";
import { Tag } from "../ui/Tag";
import type { RoomWithOptionalGuestBooking } from "@shared";
import { cn } from "@/lib/utils";
type RoomCardProps = {
room: RoomWithOptionalGuestBooking;
isSelected?: boolean;
onClick: () => void;
};
function getGuestDisplay(room: RoomWithOptionalGuestBooking) {
const hasGuests = (room.guests?.length ?? 0) > 0;
const guestLabel = room.guests
?.map((guest) => `${guest.first_name} ${guest.last_name}`)
.join(", ");
return { hasGuests, guestLabel };
}
export function RoomCard({ room, isSelected = false, onClick }: RoomCardProps) {
const { hasGuests, guestLabel } = getGuestDisplay(room);
return (
<button
type="button"
onClick={onClick}
className={cn(
"flex flex-col items-start flex-1 min-w-0 w-full min-h-36.25 text-left rounded-md border gap-2 px-5 py-4 transition-colors",
isSelected
? "border-stroke-subtle bg-bg-selected shadow-sm"
: "border-stroke-subtle hover:bg-bg-selected cursor-pointer",
)}
>
<span className="text-xl font-bold text-text-default ">
Room {room.room_number}
</span>
<span className="text-sm text-text-subtle">{room.suite_type}</span>
{hasGuests && (
<div className="flex items-center gap-1 text-sm text-text-subtle pb-3">
<CircleUserRound className="h-4.5 w-4.5 shrink-0" />
<span className="truncate">{guestLabel}</span>
</div>
)}
{/* Hardcoded tag for now */}
<div className="flex flex-row gap-3 pt-1">
<Tag icon={CircleAlert} label="Urgent Task" variant="danger" />
<Tag icon={UserRoundCheck} label="Occupied" variant="default" />
<Tag icon={BrushCleaning} label="Needs Cleaning" variant="default" />
</div>
</button>
);
}