-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuestVisitActivityTab.tsx
More file actions
93 lines (86 loc) · 2.94 KB
/
GuestVisitActivityTab.tsx
File metadata and controls
93 lines (86 loc) · 2.94 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import { useState } from "react";
import { ChevronRight } from "lucide-react";
import { ActiveBookingCard } from "./ActiveBookingCard";
import { GuestBookingHistoryView } from "./GuestBookingHistoryView";
import { PastBookingCard } from "./PastBookingCard";
import { RequestCard } from "./RequestCard";
import type { GuestRequest, Stay } from "@shared";
type GuestVisitActivityTabProps = {
currentStays: Array<Stay>;
pastStays: Array<Stay>;
requests: Array<GuestRequest>;
};
export function GuestVisitActivityTab({
currentStays,
pastStays,
requests,
}: GuestVisitActivityTabProps) {
const [showHistory, setShowHistory] = useState(false);
if (showHistory) {
return (
<GuestBookingHistoryView
currentStays={currentStays}
pastStays={pastStays}
onBack={() => setShowHistory(false)}
/>
);
}
const hasActiveBookings = currentStays.length > 0;
return (
<div className="flex flex-col gap-6 p-6">
{/* Active Bookings or Previous Bookings */}
<section className="flex flex-col gap-4">
<div className="flex items-center justify-between">
<h3 className="text-base font-medium text-text-default">
{hasActiveBookings
? `Active Bookings (${currentStays.length})`
: "Previous Bookings"}
</h3>
<button
type="button"
aria-label="View all bookings"
onClick={() => setShowHistory(true)}
className="flex items-center gap-1 text-base text-text-default hover:underline"
>
View All Bookings
<ChevronRight className="size-3.5" strokeWidth={2} />
</button>
</div>
{hasActiveBookings ? (
currentStays.length === 1 ? (
<ActiveBookingCard stay={currentStays[0]} />
) : (
<div className="flex gap-5">
{currentStays.slice(0, 2).map((stay) => (
<ActiveBookingCard key={stay.room_number} stay={stay} compact />
))}
</div>
)
) : pastStays.length > 0 ? (
<div className="flex flex-col gap-2">
{pastStays.slice(0, 3).map((stay, i) => (
<PastBookingCard key={`past-${i}`} stay={stay} />
))}
</div>
) : (
<p className="text-sm text-text-subtle">No bookings.</p>
)}
</section>
{/* Requests */}
<section className="flex flex-col gap-4">
<h3 className="text-base font-medium text-text-default">
{requests.length > 0 ? `Requests (${requests.length})` : "Requests"}
</h3>
{requests.length > 0 ? (
<div className="flex flex-col gap-4">
{requests.map((req) => (
<RequestCard key={req.id ?? req.name} req={req} />
))}
</div>
) : (
<p className="text-base text-text-secondary">You're all caught up!</p>
)}
</section>
</div>
);
}