diff --git a/app/dashboard/guests/page.tsx b/app/dashboard/guests/page.tsx index f829606..40214be 100644 --- a/app/dashboard/guests/page.tsx +++ b/app/dashboard/guests/page.tsx @@ -1,8 +1,8 @@ import { lusitana } from '@/app/ui/fonts'; import AffinityGroupsTree from '@/app/ui/guests/affinity-groups-tree'; import GuestsTable from '@/app/ui/guests/table'; -import { Tree } from 'primereact/tree'; -import React, { useState, useEffect } from 'react'; +import React, { Suspense } from 'react'; +import SkeletonTable from '@/app/ui/guests/skeleton-row'; @@ -10,10 +10,12 @@ export default function Page() { return (
- +

Guests

- + }> + +
); diff --git a/app/ui/guests/skeleton-row.tsx b/app/ui/guests/skeleton-row.tsx new file mode 100644 index 0000000..0b989e6 --- /dev/null +++ b/app/ui/guests/skeleton-row.tsx @@ -0,0 +1,34 @@ +import Skeleton from '@/app/ui/skeleton'; + +export function SkeletonRow() { + return ( + + {} + {} + {} + {} + + ); +} + +export default function SkeletonTable() { + return ( +
+ + + + + + {[...Array(20)].map((e, i) => )} + +
+ Guests +

+ Loading the list of guests... +

+
+
+ + ); +} + diff --git a/app/ui/guests/table.tsx b/app/ui/guests/table.tsx index 7cc49d5..0f31a0c 100644 --- a/app/ui/guests/table.tsx +++ b/app/ui/guests/table.tsx @@ -1,31 +1,31 @@ 'use client' import { Guest } from '@/app/lib/definitions'; -import { useState, Suspense, useEffect } from 'react'; +import SkeletonRow from './skeleton-row'; +import { Suspense } from 'react'; import clsx from 'clsx'; -export default function guestsTable() { +export function TableHeader() { + +} - const [guests, setGuests] = useState([]); +export default async function guestsTable() { - useEffect(() => { - if (guests.length > 0) { - return; - } - fetch("http://localhost:3001/guests.json") - .then((response) => response.json()) - .then((data) => { - setGuests(data.data.map((record: any) => { - return ({ - id: record.id, - name: record.attributes.name, - email: record.attributes.email, - group_name: record.attributes.group_name, - status: record.attributes.status - }); - })) + let guests: Guest[] = await fetch("http://localhost:3001/guests.json") + .then((response) => response.json()) + .then((data) => { + return data.data.map((record: any) => { + return ({ + id: record.id, + name: record.attributes.name, + email: record.attributes.email, + group_name: record.attributes.group_name, + status: record.attributes.status + }); }); - }); + }, (error) => { + return []; + }); return (
@@ -53,37 +53,34 @@ export default function guestsTable() { - - {guests.map((guest) => ( - - - {guest.name} - - - {guest.email} - - - {guest.group_name} - - - - - {/* */} - - {guest.status} + {guests.map((guest) => ( + + + {guest.name} + + + {guest.email} + + + {guest.group_name} + + + + - - - ))} - + {guest.status} + + + + ))}
diff --git a/app/ui/skeleton.tsx b/app/ui/skeleton.tsx new file mode 100644 index 0000000..590c507 --- /dev/null +++ b/app/ui/skeleton.tsx @@ -0,0 +1,3 @@ +export default function Skeleton({ className }: { className: string }) { + return
; +} \ No newline at end of file