Fix race condition updating guests
This commit is contained in:
parent
01bce277a8
commit
1fdac88c75
@ -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 } }),
|
||||
|
@ -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>
|
||||
|
@ -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 (
|
||||
|
Loading…
x
Reference in New Issue
Block a user