Fix race condition updating guests
Some checks failed
Check usage of free licenses / build-static-assets (pull_request) Successful in 44s
Add copyright notice / copyright_notice (pull_request) Successful in 59s
Playwright Tests / test (pull_request) Failing after 3m42s

This commit is contained in:
Manuel Bustillo 2024-11-17 17:50:06 +01:00
parent 01bce277a8
commit 1fdac88c75
3 changed files with 4 additions and 4 deletions

View File

@ -21,7 +21,7 @@ export function loadGuests(onLoad?: (guests: Guest[]) => void) {
};
export function updateGuest(guest: Guest) {
fetch(`/api/guests/${guest.id}`,
return fetch(`/api/guests/${guest.id}`,
{
method: 'PUT',
body: JSON.stringify({ guest: { name: guest.name, status: guest.status } }),

View File

@ -46,7 +46,7 @@ export default function Page() {
<div className="flex flex-col w-full items-center justify-between">
<CreationDialog groups={groups} onCreate={refreshGuests} />
<Suspense fallback={<SkeletonTable />}>
<GuestsTable guests={guests} />
<GuestsTable guests={guests} onUpdate={refreshGuests} />
</Suspense>
</div>
</ TabPanel>

View File

@ -9,10 +9,10 @@ import clsx from 'clsx';
import InlineTextField from '../components/form/inlineTextField';
import TableOfContents from '../components/table-of-contents';
export default function guestsTable({ guests }: { guests: Guest[] }) {
export default function guestsTable({ guests, onUpdate }: { guests: Guest[], onUpdate: () => void }) {
const handleGuestChange = (guest: Guest, status: GuestStatus) => {
guest.status = status;
updateGuest(guest);
updateGuest(guest).then(() => onUpdate());
}
return (