move build to cmd

This commit is contained in:
Karol Wypchlo 2021-02-20 17:06:21 +01:00
parent 734cf55122
commit 14f06a4ddb
1 changed files with 15 additions and 11 deletions

View File

@ -7,22 +7,26 @@ import Table from "../components/Table";
import authServerSideProps from "../services/authServerSideProps"; import authServerSideProps from "../services/authServerSideProps";
import { SkynetClient } from "skynet-js"; import { SkynetClient } from "skynet-js";
const skynetClient = new SkynetClient(process.env.SKYNET_PORTAL_API);
const apiPrefix = process.env.NODE_ENV === "development" ? "/api/stubs" : ""; const apiPrefix = process.env.NODE_ENV === "development" ? "/api/stubs" : "";
const fetcher = (url) => fetch(url).then((r) => r.json()); 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"); export const getServerSideProps = authServerSideProps();
const headers = [ 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: "name", name: "Name", nowrap: false, href: getSkylinkLink },
{ key: "skylink", name: "Skylink" }, { key: "skylink", name: "Skylink" },
{ key: "size", name: "Size", formatter: ({ size }) => prettyBytes(size) }, { key: "size", name: "Size", formatter: ({ size }) => prettyBytes(size) },
{ key: "uploadedOn", name: "Uploaded on", formatter: getRelativeDate }, { key: "uploadedOn", name: "Uploaded on", formatter: getRelativeDate },
]; ];
const actions = []; const actions = [];
export const getServerSideProps = authServerSideProps(); return { props: { headers, actions } };
};
export default function Uploads() { export default function Uploads({ headers, actions }) {
const [offset, setOffset] = useState(0); const [offset, setOffset] = useState(0);
const { data, error } = useSWR(`${apiPrefix}/user/uploads?pageSize=10&offset=${offset}`, fetcher); const { data, error } = useSWR(`${apiPrefix}/user/uploads?pageSize=10&offset=${offset}`, fetcher);