Update max additional guests logic and refine guest counts display
Set default max additional guests to 10 and renamed related labels for clarity. Improved guest count calculation by adding total confirmed guests and refining additional guest computations. Updated the UI to reflect these changes concisely and consistently.
This commit is contained in:
@@ -101,7 +101,7 @@ const GuestListTable = ({ event }: GuestListTableProps) => {
|
|||||||
full_name: "",
|
full_name: "",
|
||||||
email: "",
|
email: "",
|
||||||
phone: "",
|
phone: "",
|
||||||
max_additional_guests: 0,
|
max_additional_guests: 10,
|
||||||
dietary_restrictions: "",
|
dietary_restrictions: "",
|
||||||
notes: "",
|
notes: "",
|
||||||
can_bring_guests: true,
|
can_bring_guests: true,
|
||||||
@@ -293,7 +293,7 @@ const GuestListTable = ({ event }: GuestListTableProps) => {
|
|||||||
"Phone",
|
"Phone",
|
||||||
"Invitation Code",
|
"Invitation Code",
|
||||||
"Status",
|
"Status",
|
||||||
"Additional Guests",
|
"Max Additional Guests",
|
||||||
];
|
];
|
||||||
const csvContent = [
|
const csvContent = [
|
||||||
headers.join(","),
|
headers.join(","),
|
||||||
@@ -348,6 +348,12 @@ const GuestListTable = ({ event }: GuestListTableProps) => {
|
|||||||
}
|
}
|
||||||
}, [addGuestOpen, editGuestOpen, currentGuest]);
|
}, [addGuestOpen, editGuestOpen, currentGuest]);
|
||||||
|
|
||||||
|
const confirmedGuestCount =
|
||||||
|
guests?.filter((g) => g.status === GuestStatus.CONFIRMED).length || 0;
|
||||||
|
const confirmedAdditionalGuestsCount =
|
||||||
|
guests?.reduce((acc, g) => acc + (g.actual_additional_guests || 0), 0) || 0;
|
||||||
|
const totalConfirmedGuestsCount =
|
||||||
|
confirmedGuestCount + confirmedAdditionalGuestsCount;
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4 w-full">
|
<div className="space-y-4 w-full">
|
||||||
{error && (
|
{error && (
|
||||||
@@ -414,14 +420,14 @@ const GuestListTable = ({ event }: GuestListTableProps) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-4 items-center gap-4">
|
<div className="grid grid-cols-4 items-center gap-4">
|
||||||
<Label htmlFor="max_additional_guests" className="text-right">
|
<Label htmlFor="max_additional_guests" className="text-right">
|
||||||
Additional Guests
|
Max Add. Guests
|
||||||
</Label>
|
</Label>
|
||||||
<Input
|
<Input
|
||||||
id="max_additional_guests"
|
id="max_additional_guests"
|
||||||
name="max_additional_guests"
|
name="max_additional_guests"
|
||||||
type="number"
|
type="number"
|
||||||
min="0"
|
min="0"
|
||||||
value={formData.max_additional_guests || 0}
|
value={formData.max_additional_guests || 10}
|
||||||
onChange={handleInputChange}
|
onChange={handleInputChange}
|
||||||
className="col-span-3"
|
className="col-span-3"
|
||||||
/>
|
/>
|
||||||
@@ -685,14 +691,9 @@ const GuestListTable = ({ event }: GuestListTableProps) => {
|
|||||||
Showing {filteredGuests.length} of {guests?.length || 0} guests
|
Showing {filteredGuests.length} of {guests?.length || 0} guests
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
Total Confirmed:{" "}
|
Guests Confirmed: {confirmedGuestCount} | Additional Guests:{" "}
|
||||||
{guests?.filter((g) => g.status === GuestStatus.CONFIRMED).length ||
|
{confirmedAdditionalGuestsCount} | Total Guests:{" "}
|
||||||
0}{" "}
|
{totalConfirmedGuestsCount}
|
||||||
| Total Additional Guests:{" "}
|
|
||||||
{guests?.reduce(
|
|
||||||
(acc, g) => acc + (g.max_additional_guests || 0),
|
|
||||||
0,
|
|
||||||
) || 0}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -746,7 +747,7 @@ const GuestListTable = ({ event }: GuestListTableProps) => {
|
|||||||
htmlFor="edit_max_additional_guests"
|
htmlFor="edit_max_additional_guests"
|
||||||
className="text-right"
|
className="text-right"
|
||||||
>
|
>
|
||||||
Additional Guests
|
Max Add. Guests
|
||||||
</Label>
|
</Label>
|
||||||
<Input
|
<Input
|
||||||
id="edit_max_additional_guests"
|
id="edit_max_additional_guests"
|
||||||
|
|||||||
Reference in New Issue
Block a user