Extract APIs to their own files #108

Merged
bustikiller merged 8 commits from extract-apis into main 2024-11-17 17:02:08 +00:00
3 changed files with 4 additions and 4 deletions
Showing only changes of commit 1fdac88c75 - Show all commits

View File

@ -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 } }),

View File

@ -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>

View File

@ -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 (