Restore usage of client component and remove explicit async
All checks were successful
Check usage of free licenses / build-static-assets (pull_request) Successful in 22s
Playwright Tests / test (pull_request) Successful in 2m37s
Build Nginx-based docker image / build-static-assets (pull_request) Successful in 4m29s

This commit is contained in:
Manuel Bustillo 2024-10-27 11:52:42 +01:00
parent de595bbf51
commit 63d4420806

View File

@ -1,12 +1,15 @@
import { Guest } from '@/app/lib/definitions';
'use client';
import clsx from 'clsx';
import React, { useState, useEffect } from 'react';
import { Guest } from '@/app/lib/definitions';
export default async function guestsTable() {
let guests: Guest[] = await fetch("http://localhost:3001/guests.json")
export default function guestsTable() {
function loadGuests() {
fetch("http://localhost:3001/guests.json")
.then((response) => response.json())
.then((data) => {
return data.data.map((record: any) => {
setGuests(data.data.map((record: any) => {
return ({
id: record.id,
name: record.attributes.name,
@ -14,10 +17,15 @@ export default async function guestsTable() {
group_name: record.attributes.group_name,
status: record.attributes.status
});
});
}));
}, (error) => {
return [];
});
}
const [guests, setGuests] = useState<Array<Guest>>([]);
guests.length === 0 && loadGuests();
return (
<div className="w-full relative overflow-x-auto shadow-md sm:rounded-lg">