diff --git a/src/app/catalogue/components/ResultsPane.js b/src/app/catalogue/components/ResultsPane.js index 77a6246..dac6a8f 100644 --- a/src/app/catalogue/components/ResultsPane.js +++ b/src/app/catalogue/components/ResultsPane.js @@ -81,7 +81,7 @@ export default function ResultsPane ({ useEffect(() => { window.scrollTo(0, 0, 'smooth') calculateItemsPerPage(currentPage, settings, data, setVcs) - }, [currentPage]) + }, [currentPage, data]) const totalPages = useMemo(() => calculateTotalPages(totalVcs, settings.batchSize), [totalVcs]) const totalPagesToDisplay = totalPages diff --git a/src/app/dashboard/components/Dashboard.jsx b/src/app/dashboard/components/Dashboard.jsx new file mode 100644 index 0000000..4e89dc6 --- /dev/null +++ b/src/app/dashboard/components/Dashboard.jsx @@ -0,0 +1,14 @@ +'use client' + +// import Overview from '../overview/components/Overview' +import SidebarDashboard from './sidebar/Sidebar' + +function Dashboard () { + return ( +
+ + {/* */} +
+ ) +} +export default Dashboard diff --git a/src/app/dashboard/components/sidebar/Sidebar.jsx b/src/app/dashboard/components/sidebar/Sidebar.jsx new file mode 100644 index 0000000..fa00356 --- /dev/null +++ b/src/app/dashboard/components/sidebar/Sidebar.jsx @@ -0,0 +1,38 @@ +import { Sidebar } from 'flowbite-react' +import { useRouter } from 'next/navigation' +import customTheme from './style' +function SidebarDashboard () { + const router = useRouter(); + + const handleItemClick = (path) => { + router.push(`/dashboard/${path}`); + } + return ( +
+ + + + handleItemClick('overview')}> +
+ + Overview +
+
+ handleItemClick('contracts')} labelColor='dark'> +
+ + Contracts +
+
+
+
+
+
+ ) +} +export default SidebarDashboard diff --git a/src/app/dashboard/components/sidebar/style.tsx b/src/app/dashboard/components/sidebar/style.tsx new file mode 100644 index 0000000..adb58bc --- /dev/null +++ b/src/app/dashboard/components/sidebar/style.tsx @@ -0,0 +1,80 @@ +import { FlowbiteSidebarTheme } from 'flowbite-react' +const customTheme: FlowbiteSidebarTheme = { + "root": { + "base": "h-full", + "collapsed": { + "on": "w-16", + "off": "w-64" + }, + "inner": "h-full overflow-y-auto overflow-x-hidden rounded bg-white px-3 py-4" + }, + "collapse": { + "button": "group flex w-full items-center rounded-lg p-2 text-base font-normal text-gray-900 transition duration-75 hover:bg-gray-100 dark:text-white dark:hover:bg-gray-700", + "icon": { + "base": "h-6 w-6 text-gray-500 transition duration-75 group-hover:text-gray-900 dark:text-gray-400 dark:group-hover:text-white", + "open": { + "off": "", + "on": "text-gray-900" + } + }, + "label": { + "base": "ml-3 flex-1 whitespace-nowrap text-left", + "icon": { + "base": "h-6 w-6 transition delay-0 ease-in-out", + "open": { + "on": "rotate-180", + "off": "" + } + } + }, + "list": "space-y-2 py-2" + }, + "cta": { + "base": "mt-6 rounded-lg bg-gray-100 p-4 dark:bg-gray-700", + "color": { + "blue": "bg-cyan-50 dark:bg-cyan-900", + "dark": "bg-dark-50 dark:bg-dark-900", + "failure": "bg-red-50 dark:bg-red-900", + "gray": "bg-alternative-50 dark:bg-alternative-900", + "green": "bg-green-50 dark:bg-green-900", + "light": "bg-light-50 dark:bg-light-900", + "red": "bg-red-50 dark:bg-red-900", + "purple": "bg-purple-50 dark:bg-purple-900", + "success": "bg-green-50 dark:bg-green-900", + "yellow": "bg-yellow-50 dark:bg-yellow-900", + "warning": "bg-yellow-50 dark:bg-yellow-900" + } + }, + "item": { + "base": "flex items-center justify-center rounded-lg p-2 text-base font-normal text-gray-900 hover:bg-gray-100 dark:text-white dark:hover:bg-gray-700", + "active": "bg-gray-100 dark:bg-gray-700", + "collapsed": { + "insideCollapse": "group w-full pl-8 transition duration-75", + "noIcon": "font-bold" + }, + "content": { + "base": "flex-1 whitespace-nowrap px-3" + }, + "icon": { + "base": "h-6 w-6 flex-shrink-0 text-gray-500 transition duration-75 group-hover:text-gray-900 dark:text-gray-400 dark:group-hover:text-white", + "active": "text-gray-700 dark:text-gray-100" + }, + "label": "", + "listItem": "" + }, + "items": { + "base": "" + }, + "itemGroup": { + "base": "mt-4 space-y-2 border-t border-gray-200 pt-4 first:mt-0 first:border-t-0 first:pt-0 dark:border-gray-700" + }, + "logo": { + "base": "mb-5 flex items-center pl-2.5", + "collapsed": { + "on": "hidden", + "off": "self-center whitespace-nowrap text-xl font-semibold dark:text-white" + }, + "img": "mr-3 h-6 sm:h-7" + } +} +export default customTheme diff --git a/src/app/dashboard/overview/components/BannerStats.jsx b/src/app/dashboard/overview/components/BannerStats.jsx new file mode 100644 index 0000000..c8c1843 --- /dev/null +++ b/src/app/dashboard/overview/components/BannerStats.jsx @@ -0,0 +1,68 @@ +function BannerStats ({ overview }) { + const transformKey = (key) => { + return key + .replace(/_/g, ' ') + .split(' ') + .map(word => word.charAt(0).toUpperCase() + word.slice(1)) + .join(' ') + } + const icon = (key) => { + switch (key) { + case 'assets_published': + return ( + + ) + case 'contracts_agreements': + return ( + + ) + case 'datasets_downloaded': + return ( + + ) + case 'transfers_out': + return ( + + ) + default: + return ( + + ) + } + } + return ( +
+
+ {Object.keys(overview).map((key, index) => { + return ( +
+
+ {icon(key)} +
+
+ + {overview[key]} + + + {transformKey(key)} + +
+
+ ) + })} +
+
+ ) +} +export default BannerStats diff --git a/src/app/dashboard/overview/components/Overview.jsx b/src/app/dashboard/overview/components/Overview.jsx new file mode 100644 index 0000000..c286e23 --- /dev/null +++ b/src/app/dashboard/overview/components/Overview.jsx @@ -0,0 +1,19 @@ +'use client' +import BannerStats from './BannerStats' +import TransferHistory from './TransferHistory' +import SidebarDashboard from '../../components/sidebar/Sidebar' +import mockTransferHistory from '@/utils/data/mockTransfershistory.json' +import mockOverview from '@/utils/data/mockOverview.json' + +function Overview () { + return ( +
+ +
+ + +
+
+ ) +} +export default Overview diff --git a/src/app/dashboard/overview/components/TransferHistory.jsx b/src/app/dashboard/overview/components/TransferHistory.jsx new file mode 100644 index 0000000..d16346f --- /dev/null +++ b/src/app/dashboard/overview/components/TransferHistory.jsx @@ -0,0 +1,70 @@ +import { Table, Accordion } from 'flowbite-react' + +function TransferHistory ({ history }) { + const historyData = ['', 'Asset', 'Counterparty ID', 'Status', 'Date'] + return ( + + + +
+ Transfer history +
+
+ +
+ + + {historyData.map((nameColumn, index) => { + return ({nameColumn}) + })} + + + {history.map((asset, index) => { + return ( + // Icons + + {asset.transfer_in && + + + } + {asset.transfer_out && + + + } + {!asset.transfer_out && !asset.transfer_in && asset.status === 'Pending' && + + + } + {!asset.transfer_out && !asset.transfer_in && asset.status === 'Failed' && + + + } + + {asset.asset} + + {asset.counterpart_id} + {asset.status} + {asset.date} + + ) + })} + +
+
+
+
+
+ ) +} +export default TransferHistory diff --git a/src/app/dashboard/overview/page.js b/src/app/dashboard/overview/page.js new file mode 100644 index 0000000..9980d3d --- /dev/null +++ b/src/app/dashboard/overview/page.js @@ -0,0 +1,9 @@ +import Overview from './components/Overview' + +export default function Page () { + return ( +
+ +
+ ) +} diff --git a/src/app/dashboard/page.js b/src/app/dashboard/page.js new file mode 100644 index 0000000..7fb897a --- /dev/null +++ b/src/app/dashboard/page.js @@ -0,0 +1,7 @@ +import Dashboard from './components/Dashboard' + +export default function Page () { + return ( + + ) +} diff --git a/src/components/nav/NavItems.jsx b/src/components/nav/NavItems.jsx index aefba7e..862a2d9 100644 --- a/src/components/nav/NavItems.jsx +++ b/src/components/nav/NavItems.jsx @@ -7,7 +7,7 @@ export const NavItems = () => { // THESE TWO SHOULD BE PROTECTED, ONLY ACCESSED BY REGISTERED USERS // @TODO: Implement Metamask plugin + a session provider to show only if logged in. { href: '/publish', label: 'Publish' }, - { href: '/', label: 'Dashboard' } + { href: '/dashboard', label: 'Dashboard' } ] return ( diff --git a/src/utils/data/mockOverview.json b/src/utils/data/mockOverview.json new file mode 100644 index 0000000..3297dab --- /dev/null +++ b/src/utils/data/mockOverview.json @@ -0,0 +1,8 @@ +{ + "overview": { + "assets_published": 3, + "contracts_agreements": 7, + "datasets_downloaded": 5, + "transfers_out": 3 + } +} diff --git a/src/utils/data/mockTransfershistory.json b/src/utils/data/mockTransfershistory.json new file mode 100644 index 0000000..607287d --- /dev/null +++ b/src/utils/data/mockTransfershistory.json @@ -0,0 +1,52 @@ +{ + "transfer_history": [ + { + "asset": "2022 EU EV charging data", + "counterpart_id": "University of Cantabria", + "status": "Completed", + "date": "Yesterday at 6:31 pm", + "transfer_in": true, + "transfer_out": false + }, + { + "asset": "Helsinki EV stations metering", + "counterpart_id": "Forum Virium Helsinki", + "status": "Completed", + "date": "2023-11-29 at 6:31 pm", + "transfer_in": false, + "transfer_out": true + }, + { + "asset": "Paris Water Purity", + "counterpart_id": "EGM ", + "status": "In progress", + "date": "2023-11-21 at 5:24 am", + "transfer_in": true, + "transfer_out": false + }, + { + "asset": "Berlin Air Quality Data", + "counterpart_id": "Technische Universität Berlin", + "status": "Pending", + "date": "2023-11-30 at 10:00 am", + "transfer_in": false, + "transfer_out": false + }, + { + "asset": "London Traffic Flow Data", + "counterpart_id": "Transport for London", + "status": "Completed", + "date": "2023-11-28 at 3:45 pm", + "transfer_in": true, + "transfer_out": false + }, + { + "asset": "Madrid Energy Consumption", + "counterpart_id": "Universidad Politécnica de Madrid", + "status": "Failed", + "date": "2023-11-25 at 8:15 am", + "transfer_in": false, + "transfer_out": false + } + ] +}