From fb42ac7ce9658a0210fd9253f76c32ad403fa60d Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Fri, 12 Feb 2021 00:31:52 +0100 Subject: [PATCH] main page --- packages/dashboard/src/components/Table.js | 10 +- packages/dashboard/src/config.js | 2 + .../src/pages/api/stubs/user/downloads.js | 8 +- .../src/pages/api/stubs/user/downloads.json | 87 ++--- .../src/pages/api/stubs/user/uploads.js | 8 +- packages/dashboard/src/pages/index.js | 307 ++++-------------- packages/dashboard/src/pages/payments.js | 2 +- packages/dashboard/src/pages/plans.js | 4 +- 8 files changed, 132 insertions(+), 296 deletions(-) diff --git a/packages/dashboard/src/components/Table.js b/packages/dashboard/src/components/Table.js index 8c52c116..d3ef61bb 100644 --- a/packages/dashboard/src/components/Table.js +++ b/packages/dashboard/src/components/Table.js @@ -8,7 +8,7 @@ function Button({ children, disabled, className, ...props }) { className={classnames( "inline-flex items-center px-3 py-2 border border-gray-300 shadow-sm text-sm leading-4 font-medium rounded-md text-gray-700 bg-white", { - "hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500": !disabled, + "hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500": !disabled, "cursor-auto opacity-50": disabled, }, className @@ -24,7 +24,7 @@ function Button({ children, disabled, className, ...props }) { export default function Table({ items, count, headers, actions, offset, setOffset, pageSize = 10 }) { useEffect(() => { if (offset < 0) setOffset(0); - else if (offset >= count) setOffset(count - (count % pageSize)); + else if (offset >= count) setOffset(Math.floor(count / pageSize - 1) * pageSize); else if (offset % pageSize) setOffset(offset - (offset % pageSize)); }, [offset, pageSize, setOffset]); @@ -66,7 +66,7 @@ export default function Table({ items, count, headers, actions, offset, setOffse ))} {actions.map(({ key, name, action }) => ( - + {name} @@ -82,7 +82,7 @@ export default function Table({ items, count, headers, actions, offset, setOffse >

- Showing {offset ? offset + 1 : 0} to{" "} + Showing {count ? offset + 1 : 0} to{" "} {offset + pageSize > count ? count : offset + pageSize} of{" "} {count} results

@@ -93,7 +93,7 @@ export default function Table({ items, count, headers, actions, offset, setOffse
diff --git a/packages/dashboard/src/pages/plans.js b/packages/dashboard/src/pages/plans.js index c6287beb..ee319e69 100644 --- a/packages/dashboard/src/pages/plans.js +++ b/packages/dashboard/src/pages/plans.js @@ -13,13 +13,13 @@ export default function Payments() {