-
Notifications
You must be signed in to change notification settings - Fork 0
feat: guests activity history #336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6a4e07b
feat: redesign guest list table and extract filter popover
zaydaanjahangir 9453e0b
feat: add guest details drawer with profile tab
zaydaanjahangir e6609de
feat: add visit activity tab and booking history view
zaydaanjahangir ac3c055
Merge branch 'main' into feat/guests-activity-history
zaydaanjahangir bc946a7
feat: fix bad merge
zaydaanjahangir 7ed88aa
feat: Break to components
zaydaanjahangir 9e0c576
feat: Consolidate RequestPriority
zaydaanjahangir 5faaae3
style: fix styling
zaydaanjahangir cc2fc55
style: formatting mobile
zaydaanjahangir File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { CalendarDays, UsersRound } from "lucide-react"; | ||
| import type { Stay } from "@shared"; | ||
| import { cn } from "@/lib/utils"; | ||
| import { formatDate } from "@/utils/dates"; | ||
|
|
||
| type ActiveBookingCardProps = { | ||
| stay: Stay; | ||
| compact?: boolean; | ||
| }; | ||
|
|
||
| export function ActiveBookingCard({ stay, compact }: ActiveBookingCardProps) { | ||
| return ( | ||
| <div | ||
| className={cn( | ||
| "flex flex-col gap-2 rounded-lg border border-primary bg-bg-selected p-4", | ||
| compact && "w-[231px] shrink-0", | ||
| )} | ||
| > | ||
| <div className="flex items-start justify-between"> | ||
| <span className="text-xl font-bold text-primary"> | ||
| Suite {stay.room_number} | ||
| </span> | ||
| {stay.group_size != null && ( | ||
| <div className="flex items-center gap-1 text-primary"> | ||
| <UsersRound className="size-[19px]" strokeWidth={1.5} /> | ||
| <span className="text-xl font-bold">{stay.group_size}</span> | ||
| </div> | ||
| )} | ||
| </div> | ||
| {compact ? ( | ||
| <div className="flex flex-col gap-1"> | ||
| <div className="flex flex-col gap-1"> | ||
| <span className="text-sm font-medium text-primary">Arrival:</span> | ||
| <div className="flex items-center gap-2 text-sm text-primary"> | ||
| <CalendarDays className="size-3 shrink-0" strokeWidth={1.5} /> | ||
| <span>{formatDate(stay.arrival_date)}</span> | ||
| </div> | ||
| </div> | ||
| <div className="flex flex-col gap-1"> | ||
| <span className="text-sm font-medium text-primary">Departure:</span> | ||
| <div className="flex items-center gap-2 text-sm text-primary"> | ||
| <CalendarDays className="size-3 shrink-0" strokeWidth={1.5} /> | ||
| <span>{formatDate(stay.departure_date)}</span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ) : ( | ||
| <div className="flex gap-[72px]"> | ||
| <div className="flex flex-1 flex-col gap-1"> | ||
| <span className="text-sm font-medium text-primary">Arrival:</span> | ||
| <div className="flex items-center gap-2 text-sm text-primary"> | ||
| <CalendarDays className="size-3 shrink-0" strokeWidth={1.5} /> | ||
| <span>{formatDate(stay.arrival_date)}</span> | ||
| </div> | ||
| </div> | ||
| <div className="flex flex-1 flex-col gap-1"> | ||
| <span className="text-sm font-medium text-primary">Departure:</span> | ||
| <div className="flex items-center gap-2 text-sm text-primary"> | ||
| <CalendarDays className="size-3 shrink-0" strokeWidth={1.5} /> | ||
| <span>{formatDate(stay.departure_date)}</span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| } |
74 changes: 74 additions & 0 deletions
74
clients/web/src/components/guests/GuestBookingHistoryView.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import { ChevronRight } from "lucide-react"; | ||
| import { ActiveBookingCard } from "./ActiveBookingCard"; | ||
| import { PastBookingCard } from "./PastBookingCard"; | ||
| import type { Stay } from "@shared"; | ||
|
|
||
| type GuestBookingHistoryViewProps = { | ||
| currentStays: Array<Stay>; | ||
| pastStays: Array<Stay>; | ||
| onBack: () => void; | ||
| }; | ||
|
|
||
| export function GuestBookingHistoryView({ | ||
| currentStays, | ||
| pastStays, | ||
| onBack, | ||
| }: GuestBookingHistoryViewProps) { | ||
| const byYear = pastStays.reduce<Record<string, Array<Stay>>>((acc, stay) => { | ||
| const year = stay.arrival_date.slice(0, 4); | ||
| (acc[year] ??= []).push(stay); | ||
| return acc; | ||
| }, {}); | ||
| const years = Object.keys(byYear).sort((a, b) => Number(b) - Number(a)); | ||
|
|
||
| return ( | ||
| <div className="flex flex-col gap-6 p-6"> | ||
| {/* Breadcrumb */} | ||
| <div className="flex items-center gap-1 text-base"> | ||
| <button | ||
| type="button" | ||
| aria-label="Visit Activity" | ||
| onClick={onBack} | ||
| className="text-text-default hover:underline" | ||
| > | ||
| Visit Activity | ||
| </button> | ||
| <ChevronRight className="size-3.5 text-text-default" strokeWidth={2} /> | ||
| <span className="text-text-default">Booking History</span> | ||
| </div> | ||
|
|
||
| {/* Active stays */} | ||
| {currentStays.length > 0 && ( | ||
| <section className="flex flex-col gap-4"> | ||
| <h3 className="text-base font-medium text-text-default"> | ||
| Active Bookings ({currentStays.length}) | ||
| </h3> | ||
| <div className="flex flex-col gap-3"> | ||
| {currentStays.map((stay) => ( | ||
| <ActiveBookingCard | ||
| key={`active-${stay.room_number}`} | ||
| stay={stay} | ||
| /> | ||
| ))} | ||
| </div> | ||
| </section> | ||
| )} | ||
|
|
||
| {/* Past stays by year */} | ||
| {years.length > 0 ? ( | ||
| years.map((year) => ( | ||
| <section key={year} className="flex flex-col gap-2"> | ||
| <h3 className="text-sm font-medium text-text-default">{year}</h3> | ||
| <div className="flex flex-col gap-2"> | ||
| {byYear[year].map((stay, i) => ( | ||
| <PastBookingCard key={`${year}-${i}`} stay={stay} /> | ||
| ))} | ||
| </div> | ||
| </section> | ||
| )) | ||
| ) : ( | ||
| <p className="text-sm text-text-subtle">No booking history.</p> | ||
| )} | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
clients/web/src/components/guests/GuestVisitActivityTab.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,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> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { UsersRound } from "lucide-react"; | ||
| import type { Stay } from "@shared"; | ||
| import { formatDate } from "@/utils/dates"; | ||
|
|
||
| type PastBookingCardProps = { | ||
| stay: Stay; | ||
| }; | ||
|
|
||
| export function PastBookingCard({ stay }: PastBookingCardProps) { | ||
| return ( | ||
| <div className="flex items-center rounded-lg border border-text-subtle bg-bg-container p-4"> | ||
| <div className="flex flex-1 flex-col gap-1"> | ||
| <div className="flex items-center gap-2"> | ||
| <span className="text-sm font-medium text-text-subtle"> | ||
| Suite {stay.room_number} | ||
| </span> | ||
| {stay.group_size != null && ( | ||
| <div className="flex items-center gap-0.5 text-text-subtle"> | ||
| <UsersRound className="size-3" strokeWidth={1.5} /> | ||
| <span className="text-sm font-medium">{stay.group_size}</span> | ||
| </div> | ||
| )} | ||
| </div> | ||
| <span className="text-sm text-text-subtle"> | ||
| {formatDate(stay.arrival_date)} - {formatDate(stay.departure_date)} | ||
| </span> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.