Manuel Bustillo ec49fd01e7
All checks were successful
Check usage of free licenses / build-static-assets (pull_request) Successful in 1m39s
Add copyright notice / copyright_notice (pull_request) Successful in 2m21s
Playwright Tests / test (pull_request) Successful in 5m0s
Remove component that renders groups in a tree structure
2024-11-17 19:22:30 +01:00

61 lines
1.9 KiB
TypeScript

/* Copyright (C) 2024 Manuel Bustillo*/
'use client';
import { Group, Guest } from '@/app/lib/definitions';
import CreationDialog from '@/app/ui/components/creation-dialog';
import GroupsTable from '@/app/ui/groups/table';
import SkeletonTable from '@/app/ui/guests/skeleton-row';
import GuestsTable from '@/app/ui/guests/table';
import { TabPanel, TabView } from 'primereact/tabview';
import { Suspense, useState } from 'react';
import { loadGuests } from '@/app/api/guests';
import { loadGroups } from '@/app/api/groups';
export default function Page() {
function refreshGuests() {
loadGuests((guests) => {
setGuests(guests);
setGuestsLoaded(true);
});
}
function refreshGroups() {
loadGroups((groups) => {
setGroups(groups);
setGroupsLoaded(true);
});
}
const [groupsLoaded, setGroupsLoaded] = useState(false);
const [groups, setGroups] = useState<Array<Group>>([]);
const [guestsLoaded, setGuestsLoaded] = useState(false);
const [guests, setGuests] = useState<Array<Guest>>([]);
!groupsLoaded && refreshGroups();
!guestsLoaded && refreshGuests();
return (
<div className="w-full">
<TabView>
<TabPanel header="Guests" leftIcon="pi pi-users mx-2">
<div className="flex flex-col w-full items-center justify-between">
<CreationDialog groups={groups} onCreate={refreshGuests} />
<Suspense fallback={<SkeletonTable />}>
<GuestsTable guests={guests} onUpdate={refreshGuests} />
</Suspense>
</div>
</ TabPanel>
<TabPanel header="Groups" leftIcon="pi pi-sitemap mx-2">
<div className="flex w-full items-center justify-between">
<Suspense fallback={<SkeletonTable />}>
<GroupsTable groups={groups} />
</Suspense>
</div>
</ TabPanel>
</ TabView>
</div>
);
}