This commit is contained in:
Karol Wypchlo 2021-02-15 11:31:53 +01:00
parent e9958ce73e
commit 8902e24b12
3 changed files with 7 additions and 4 deletions

View File

@ -59,8 +59,11 @@ export default function Table({ items, count, headers, actions, offset, setOffse
<tbody>
{items.map((row, index) => (
<tr className={index % 2 ? "bg-white" : "bg-gray-50"} key={index}>
{headers.map(({ key, formatter }) => (
<td key={key} className="px-6 py-4 text-sm font-medium text-gray-900">
{headers.map(({ key, formatter, nowrap }) => (
<td
key={key}
className={`${nowrap ? "whitespace-nowrap" : ""} px-6 py-4 text-sm font-medium text-gray-900`}
>
{(formatter ? formatter(row[key]) : row[key]) || <>&mdash;</>}
</td>
))}

View File

@ -8,7 +8,7 @@ import Table from "../components/Table";
const apiPrefix = process.env.NODE_ENV === "development" ? "/api/stubs" : "";
const fetcher = (url) => fetch(url).then((r) => r.json());
const headers = [
{ key: "name", name: "Name" },
{ key: "name", name: "Name", nowrap: false },
{ key: "skylink", name: "Skylink" },
{ key: "size", name: "Size", formatter: prettyBytes },
{ key: "downloadedOn", name: "Accessed on", formatter: (date) => dayjs(date).format("YYYY-MM-DD HH:mm:ss") },

View File

@ -8,7 +8,7 @@ import Table from "../components/Table";
const apiPrefix = process.env.NODE_ENV === "development" ? "/api/stubs" : "";
const fetcher = (url) => fetch(url).then((r) => r.json());
const headers = [
{ key: "name", name: "Name" },
{ key: "name", name: "Name", nowrap: false },
{ key: "skylink", name: "Skylink" },
{ key: "size", name: "Size", formatter: prettyBytes },
{ key: "uploadedOn", name: "Uploaded on", formatter: (date) => dayjs(date).format("YYYY-MM-DD HH:mm:ss") },