From 14f06a4ddb6e2b49a4d5b0fb37f261d3638bed42 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Sat, 20 Feb 2021 17:06:21 +0100 Subject: [PATCH] move build to cmd --- packages/dashboard/src/pages/uploads.js | 26 ++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/dashboard/src/pages/uploads.js b/packages/dashboard/src/pages/uploads.js index 6bcf7a45..a942d863 100644 --- a/packages/dashboard/src/pages/uploads.js +++ b/packages/dashboard/src/pages/uploads.js @@ -7,22 +7,26 @@ import Table from "../components/Table"; import authServerSideProps from "../services/authServerSideProps"; import { SkynetClient } from "skynet-js"; -const skynetClient = new SkynetClient(process.env.SKYNET_PORTAL_API); const apiPrefix = process.env.NODE_ENV === "development" ? "/api/stubs" : ""; const fetcher = (url) => fetch(url).then((r) => r.json()); -const getSkylinkLink = ({ skylink }) => skynetClient.getSkylinkUrl(skylink); -const getRelativeDate = ({ uploadedOn }) => dayjs(uploadedOn).format("YYYY-MM-DD HH:mm:ss"); -const headers = [ - { key: "name", name: "Name", nowrap: false, href: getSkylinkLink }, - { key: "skylink", name: "Skylink" }, - { key: "size", name: "Size", formatter: ({ size }) => prettyBytes(size) }, - { key: "uploadedOn", name: "Uploaded on", formatter: getRelativeDate }, -]; -const actions = []; export const getServerSideProps = authServerSideProps(); +export const getStaticProps = () => { + const skynetClient = new SkynetClient(process.env.SKYNET_PORTAL_API); + const getSkylinkLink = ({ skylink }) => skynetClient.getSkylinkUrl(skylink); + const getRelativeDate = ({ uploadedOn }) => dayjs(uploadedOn).format("YYYY-MM-DD HH:mm:ss"); + const headers = [ + { key: "name", name: "Name", nowrap: false, href: getSkylinkLink }, + { key: "skylink", name: "Skylink" }, + { key: "size", name: "Size", formatter: ({ size }) => prettyBytes(size) }, + { key: "uploadedOn", name: "Uploaded on", formatter: getRelativeDate }, + ]; + const actions = []; -export default function Uploads() { + return { props: { headers, actions } }; +}; + +export default function Uploads({ headers, actions }) { const [offset, setOffset] = useState(0); const { data, error } = useSWR(`${apiPrefix}/user/uploads?pageSize=10&offset=${offset}`, fetcher);