Include transitions to confirmed and declined
All checks were successful
Check usage of free licenses / build-static-assets (pull_request) Successful in 1m59s
Playwright Tests / test (pull_request) Successful in 8m48s
Build Nginx-based docker image / build-static-assets (pull_request) Successful in 14m59s

This commit is contained in:
Manuel Bustillo 2024-10-27 19:24:21 +01:00
parent 58c8f51510
commit 60ad1d127d

View File

@ -26,12 +26,15 @@ export default function guestsTable() {
});
};
const handleInviteGuest = (e: React.MouseEvent<HTMLElement>) => handleGuestChange(e, 'invited');
const handleConfirmGuest = (e: React.MouseEvent<HTMLElement>) => handleGuestChange(e, 'confirmed');
const handleDeclineGuest = (e: React.MouseEvent<HTMLElement>) => handleGuestChange(e, 'declined');
const handleInviteGuest = (e: React.MouseEvent<HTMLElement>) => {
const handleGuestChange = (e: React.MouseEvent<HTMLElement>, status:string) => {
fetch("/api/guests/bulk_update.json",
{
method: 'POST',
body: JSON.stringify({ properties: { status: "invited" }, guest_ids: [e.currentTarget.getAttribute('data-guest-id')] }),
body: JSON.stringify({ properties: { status: status }, guest_ids: [e.currentTarget.getAttribute('data-guest-id')] }),
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': getCsrfToken(),
@ -42,6 +45,7 @@ export default function guestsTable() {
}
guests.length === 0 && loadGuests();
const ctaClassName = "text-white py-1 px-2 mx-1 rounded";
return (
<div className="w-full relative overflow-x-auto shadow-md sm:rounded-lg">
@ -97,9 +101,15 @@ export default function guestsTable() {
</span>
</td>
<td>
{guest.status === 'Considered' && (<button data-guest-id={guest.id} onClick={handleInviteGuest} className="bg-blue-300 hover:bg-blue-500 text-white py-1 px-2 rounded">
{guest.status === 'Considered' && (<button data-guest-id={guest.id} onClick={handleInviteGuest} className={`${ctaClassName} bg-blue-400 hover:bg-blue-600`}>
Invite
</button>)}
{guest.status === 'Invited' && (<button data-guest-id={guest.id} onClick={handleConfirmGuest} className={`${ctaClassName} bg-green-500 hover:bg-green-600`}>
Confirm
</button>)}
{guest.status === 'Invited' && (<button data-guest-id={guest.id} onClick={handleDeclineGuest} className={`${ctaClassName} bg-red-500 hover:bg-red-600`}>
Decline
</button>)}
</td>
</tr>
))}