Extract APIs to their own files #108
@ -21,7 +21,7 @@ export function loadGuests(onLoad?: (guests: Guest[]) => void) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function updateGuest(guest: Guest) {
|
export function updateGuest(guest: Guest) {
|
||||||
fetch(`/api/guests/${guest.id}`,
|
return fetch(`/api/guests/${guest.id}`,
|
||||||
{
|
{
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: JSON.stringify({ guest: { name: guest.name, status: guest.status } }),
|
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">
|
<div className="flex flex-col w-full items-center justify-between">
|
||||||
<CreationDialog groups={groups} onCreate={refreshGuests} />
|
<CreationDialog groups={groups} onCreate={refreshGuests} />
|
||||||
<Suspense fallback={<SkeletonTable />}>
|
<Suspense fallback={<SkeletonTable />}>
|
||||||
<GuestsTable guests={guests} />
|
<GuestsTable guests={guests} onUpdate={refreshGuests} />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</div>
|
||||||
</ TabPanel>
|
</ TabPanel>
|
||||||
|
@ -9,10 +9,10 @@ import clsx from 'clsx';
|
|||||||
import InlineTextField from '../components/form/inlineTextField';
|
import InlineTextField from '../components/form/inlineTextField';
|
||||||
import TableOfContents from '../components/table-of-contents';
|
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) => {
|
const handleGuestChange = (guest: Guest, status: GuestStatus) => {
|
||||||
guest.status = status;
|
guest.status = status;
|
||||||
updateGuest(guest);
|
updateGuest(guest).then(() => onUpdate());
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user