From 2d85850d5e6ca9f78490583ed1a4ed02f78c8dec Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Tue, 9 Feb 2021 16:55:56 +0100 Subject: [PATCH] uploads --- packages/dashboard/src/components/Table.js | 34 ++++---- .../src/pages/api/stubs/user/downloads.json | 81 ++++++++++--------- .../src/pages/api/stubs/user/uploads.json | 81 ++++++++++--------- packages/dashboard/src/pages/downloads.js | 6 +- packages/dashboard/src/pages/uploads.js | 8 +- 5 files changed, 112 insertions(+), 98 deletions(-) diff --git a/packages/dashboard/src/components/Table.js b/packages/dashboard/src/components/Table.js index 9c65bdc5..3ac0d55a 100644 --- a/packages/dashboard/src/components/Table.js +++ b/packages/dashboard/src/components/Table.js @@ -1,8 +1,6 @@ import { useEffect } from "react"; import classnames from "classnames"; -const pageSize = 2; - function Button({ children, disabled, className, ...props }) { return ( - diff --git a/packages/dashboard/src/pages/api/stubs/user/downloads.json b/packages/dashboard/src/pages/api/stubs/user/downloads.json index 929caede..e38e37c0 100644 --- a/packages/dashboard/src/pages/api/stubs/user/downloads.json +++ b/packages/dashboard/src/pages/api/stubs/user/downloads.json @@ -1,38 +1,43 @@ -[ - { - "skylink": "PAL0w4SdA5rFCDGEutgpeQ50Om-YkBabtXVOJAkmedslKw", - "name": "ugabuga.pdf", - "size": 123123, - "uploadedOn": "2020-04-02T08:02:17-05:00" - }, - { - "skylink": "XABvi7JtJbQSMAcDwnUnmp2FKDPjg8_tTTFP4BwMSxVdEg", - "name": "ugabuga.pdf", - "size": 8912739812, - "uploadedOn": "2020-04-02T08:02:17-05:00" - }, - { - "skylink": "IADUs8d9CQjUO34LmdaaNPK_STuZo24rpKVfYW3wPPM2uQ", - "name": "ugabuga.pdf", - "size": 123123, - "uploadedOn": "2020-04-02T08:02:17-05:00" - }, - { - "skylink": "_A2zt5SKoqwnnZU4cBF8uBycSKULXMyeg1c5ZISBr2Q3dA", - "name": "ugabuga.pdf", - "size": 83943, - "uploadedOn": "2020-04-02T08:02:17-05:00" - }, - { - "skylink": "AAC0uO43g64ULpyrW0zO3bjEknSFbAhm8c-RFP21EQlmSQ", - "name": "ugabuga.pdf", - "size": 3290489120, - "uploadedOn": "2020-04-02T08:02:17-05:00" - }, - { - "skylink": "CACqf4NlIMlA0CCCieYGjpViPGyfyJ4v1x3bmuCKZX8FKA", - "name": "ugabuga.pdf", - "size": 1290389, - "uploadedOn": "2020-04-02T08:02:17-05:00" - } -] +{ + "items": [ + { + "skylink": "PAL0w4SdA5rFCDGEutgpeQ50Om-YkBabtXVOJAkmedslKw", + "name": "ugabuga.pdf", + "size": 123123, + "uploadedOn": "2020-04-02T08:02:17-05:00" + }, + { + "skylink": "XABvi7JtJbQSMAcDwnUnmp2FKDPjg8_tTTFP4BwMSxVdEg", + "name": "ugabuga.pdf", + "size": 8912739812, + "uploadedOn": "2020-04-02T08:02:17-05:00" + }, + { + "skylink": "IADUs8d9CQjUO34LmdaaNPK_STuZo24rpKVfYW3wPPM2uQ", + "name": "ugabuga.pdf", + "size": 123123, + "uploadedOn": "2020-04-02T08:02:17-05:00" + }, + { + "skylink": "_A2zt5SKoqwnnZU4cBF8uBycSKULXMyeg1c5ZISBr2Q3dA", + "name": "ugabuga.pdf", + "size": 83943, + "uploadedOn": "2020-04-02T08:02:17-05:00" + }, + { + "skylink": "AAC0uO43g64ULpyrW0zO3bjEknSFbAhm8c-RFP21EQlmSQ", + "name": "ugabuga.pdf", + "size": 3290489120, + "uploadedOn": "2020-04-02T08:02:17-05:00" + }, + { + "skylink": "CACqf4NlIMlA0CCCieYGjpViPGyfyJ4v1x3bmuCKZX8FKA", + "name": "ugabuga.pdf", + "size": 1290389, + "uploadedOn": "2020-04-02T08:02:17-05:00" + } + ], + "offset": 0, + "pageSize": 10, + "count": 6 +} diff --git a/packages/dashboard/src/pages/api/stubs/user/uploads.json b/packages/dashboard/src/pages/api/stubs/user/uploads.json index 929caede..e38e37c0 100644 --- a/packages/dashboard/src/pages/api/stubs/user/uploads.json +++ b/packages/dashboard/src/pages/api/stubs/user/uploads.json @@ -1,38 +1,43 @@ -[ - { - "skylink": "PAL0w4SdA5rFCDGEutgpeQ50Om-YkBabtXVOJAkmedslKw", - "name": "ugabuga.pdf", - "size": 123123, - "uploadedOn": "2020-04-02T08:02:17-05:00" - }, - { - "skylink": "XABvi7JtJbQSMAcDwnUnmp2FKDPjg8_tTTFP4BwMSxVdEg", - "name": "ugabuga.pdf", - "size": 8912739812, - "uploadedOn": "2020-04-02T08:02:17-05:00" - }, - { - "skylink": "IADUs8d9CQjUO34LmdaaNPK_STuZo24rpKVfYW3wPPM2uQ", - "name": "ugabuga.pdf", - "size": 123123, - "uploadedOn": "2020-04-02T08:02:17-05:00" - }, - { - "skylink": "_A2zt5SKoqwnnZU4cBF8uBycSKULXMyeg1c5ZISBr2Q3dA", - "name": "ugabuga.pdf", - "size": 83943, - "uploadedOn": "2020-04-02T08:02:17-05:00" - }, - { - "skylink": "AAC0uO43g64ULpyrW0zO3bjEknSFbAhm8c-RFP21EQlmSQ", - "name": "ugabuga.pdf", - "size": 3290489120, - "uploadedOn": "2020-04-02T08:02:17-05:00" - }, - { - "skylink": "CACqf4NlIMlA0CCCieYGjpViPGyfyJ4v1x3bmuCKZX8FKA", - "name": "ugabuga.pdf", - "size": 1290389, - "uploadedOn": "2020-04-02T08:02:17-05:00" - } -] +{ + "items": [ + { + "skylink": "PAL0w4SdA5rFCDGEutgpeQ50Om-YkBabtXVOJAkmedslKw", + "name": "ugabuga.pdf", + "size": 123123, + "uploadedOn": "2020-04-02T08:02:17-05:00" + }, + { + "skylink": "XABvi7JtJbQSMAcDwnUnmp2FKDPjg8_tTTFP4BwMSxVdEg", + "name": "ugabuga.pdf", + "size": 8912739812, + "uploadedOn": "2020-04-02T08:02:17-05:00" + }, + { + "skylink": "IADUs8d9CQjUO34LmdaaNPK_STuZo24rpKVfYW3wPPM2uQ", + "name": "ugabuga.pdf", + "size": 123123, + "uploadedOn": "2020-04-02T08:02:17-05:00" + }, + { + "skylink": "_A2zt5SKoqwnnZU4cBF8uBycSKULXMyeg1c5ZISBr2Q3dA", + "name": "ugabuga.pdf", + "size": 83943, + "uploadedOn": "2020-04-02T08:02:17-05:00" + }, + { + "skylink": "AAC0uO43g64ULpyrW0zO3bjEknSFbAhm8c-RFP21EQlmSQ", + "name": "ugabuga.pdf", + "size": 3290489120, + "uploadedOn": "2020-04-02T08:02:17-05:00" + }, + { + "skylink": "CACqf4NlIMlA0CCCieYGjpViPGyfyJ4v1x3bmuCKZX8FKA", + "name": "ugabuga.pdf", + "size": 1290389, + "uploadedOn": "2020-04-02T08:02:17-05:00" + } + ], + "offset": 0, + "pageSize": 10, + "count": 6 +} diff --git a/packages/dashboard/src/pages/downloads.js b/packages/dashboard/src/pages/downloads.js index 5194b42d..0b45fa84 100644 --- a/packages/dashboard/src/pages/downloads.js +++ b/packages/dashboard/src/pages/downloads.js @@ -16,12 +16,12 @@ const headers = [ const actions = []; export default function Downloads() { - const [page, setPage] = useState(1); - const { data, error } = useSWR(`${apiPrefix}/user/downloads`, fetcher); + const [offset, setOffset] = useState(0); + const { data, error } = useSWR(`${apiPrefix}/user/downloads?pageSize=10&offset=${offset}`, fetcher); return ( - {data && } +
); } diff --git a/packages/dashboard/src/pages/uploads.js b/packages/dashboard/src/pages/uploads.js index be743c51..dc2756c8 100644 --- a/packages/dashboard/src/pages/uploads.js +++ b/packages/dashboard/src/pages/uploads.js @@ -15,13 +15,13 @@ const headers = [ ]; const actions = []; -export default function Downloads() { - const [page, setPage] = useState(1); - const { data, error } = useSWR(`${apiPrefix}/user/uploads`, fetcher); +export default function Uploads() { + const [offset, setOffset] = useState(0); + const { data, error } = useSWR(`${apiPrefix}/user/uploads?pageSize=10&offset=${offset}`, fetcher); return ( - {data &&
} +
); }