2024-08-11 12:03:11 +02:00
|
|
|
import Image from 'next/image';
|
2024-08-11 12:34:16 +02:00
|
|
|
import { UpdateInvoice, DeleteInvoice } from '@/app/ui/guests/buttons';
|
|
|
|
import gueststatus from '@/app/ui/guests/status';
|
2024-08-11 12:03:11 +02:00
|
|
|
import { formatDateToLocal, formatCurrency } from '@/app/lib/utils';
|
2024-08-11 12:34:16 +02:00
|
|
|
import { fetchFilteredguests } from '@/app/lib/data';
|
2024-08-11 12:03:11 +02:00
|
|
|
|
2024-08-11 12:34:16 +02:00
|
|
|
export default async function guestsTable({
|
2024-08-11 12:03:11 +02:00
|
|
|
query,
|
|
|
|
currentPage,
|
|
|
|
}: {
|
|
|
|
query: string;
|
|
|
|
currentPage: number;
|
|
|
|
}) {
|
2024-08-11 12:34:16 +02:00
|
|
|
const guests = await fetchFilteredguests(query, currentPage);
|
2024-08-11 12:03:11 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="mt-6 flow-root">
|
|
|
|
<div className="inline-block min-w-full align-middle">
|
|
|
|
<div className="rounded-lg bg-gray-50 p-2 md:pt-0">
|
|
|
|
<div className="md:hidden">
|
2024-08-11 12:34:16 +02:00
|
|
|
{guests?.map((invoice) => (
|
2024-08-11 12:03:11 +02:00
|
|
|
<div
|
|
|
|
key={invoice.id}
|
|
|
|
className="mb-2 w-full rounded-md bg-white p-4"
|
|
|
|
>
|
|
|
|
<div className="flex items-center justify-between border-b pb-4">
|
|
|
|
<div>
|
|
|
|
<div className="mb-2 flex items-center">
|
|
|
|
<Image
|
|
|
|
src={invoice.image_url}
|
|
|
|
className="mr-2 rounded-full"
|
|
|
|
width={28}
|
|
|
|
height={28}
|
|
|
|
alt={`${invoice.name}'s profile picture`}
|
|
|
|
/>
|
|
|
|
<p>{invoice.name}</p>
|
|
|
|
</div>
|
|
|
|
<p className="text-sm text-gray-500">{invoice.email}</p>
|
|
|
|
</div>
|
2024-08-11 12:34:16 +02:00
|
|
|
<gueststatus status={invoice.status} />
|
2024-08-11 12:03:11 +02:00
|
|
|
</div>
|
|
|
|
<div className="flex w-full items-center justify-between pt-4">
|
|
|
|
<div>
|
|
|
|
<p className="text-xl font-medium">
|
|
|
|
{formatCurrency(invoice.amount)}
|
|
|
|
</p>
|
|
|
|
<p>{formatDateToLocal(invoice.date)}</p>
|
|
|
|
</div>
|
|
|
|
<div className="flex justify-end gap-2">
|
|
|
|
<UpdateInvoice id={invoice.id} />
|
|
|
|
<DeleteInvoice id={invoice.id} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
<table className="hidden min-w-full text-gray-900 md:table">
|
|
|
|
<thead className="rounded-lg text-left text-sm font-normal">
|
|
|
|
<tr>
|
|
|
|
<th scope="col" className="px-4 py-5 font-medium sm:pl-6">
|
|
|
|
Customer
|
|
|
|
</th>
|
|
|
|
<th scope="col" className="px-3 py-5 font-medium">
|
|
|
|
Email
|
|
|
|
</th>
|
|
|
|
<th scope="col" className="px-3 py-5 font-medium">
|
|
|
|
Amount
|
|
|
|
</th>
|
|
|
|
<th scope="col" className="px-3 py-5 font-medium">
|
|
|
|
Date
|
|
|
|
</th>
|
|
|
|
<th scope="col" className="px-3 py-5 font-medium">
|
|
|
|
Status
|
|
|
|
</th>
|
|
|
|
<th scope="col" className="relative py-3 pl-6 pr-3">
|
|
|
|
<span className="sr-only">Edit</span>
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody className="bg-white">
|
2024-08-11 12:34:16 +02:00
|
|
|
{guests?.map((invoice) => (
|
2024-08-11 12:03:11 +02:00
|
|
|
<tr
|
|
|
|
key={invoice.id}
|
|
|
|
className="w-full border-b py-3 text-sm last-of-type:border-none [&:first-child>td:first-child]:rounded-tl-lg [&:first-child>td:last-child]:rounded-tr-lg [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg"
|
|
|
|
>
|
|
|
|
<td className="whitespace-nowrap py-3 pl-6 pr-3">
|
|
|
|
<div className="flex items-center gap-3">
|
|
|
|
<Image
|
|
|
|
src={invoice.image_url}
|
|
|
|
className="rounded-full"
|
|
|
|
width={28}
|
|
|
|
height={28}
|
|
|
|
alt={`${invoice.name}'s profile picture`}
|
|
|
|
/>
|
|
|
|
<p>{invoice.name}</p>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
<td className="whitespace-nowrap px-3 py-3">
|
|
|
|
{invoice.email}
|
|
|
|
</td>
|
|
|
|
<td className="whitespace-nowrap px-3 py-3">
|
|
|
|
{formatCurrency(invoice.amount)}
|
|
|
|
</td>
|
|
|
|
<td className="whitespace-nowrap px-3 py-3">
|
|
|
|
{formatDateToLocal(invoice.date)}
|
|
|
|
</td>
|
|
|
|
<td className="whitespace-nowrap px-3 py-3">
|
2024-08-11 12:34:16 +02:00
|
|
|
<gueststatus status={invoice.status} />
|
2024-08-11 12:03:11 +02:00
|
|
|
</td>
|
|
|
|
<td className="whitespace-nowrap py-3 pl-6 pr-3">
|
|
|
|
<div className="flex justify-end gap-3">
|
|
|
|
<UpdateInvoice id={invoice.id} />
|
|
|
|
<DeleteInvoice id={invoice.id} />
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
))}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|