From 4904ec582f5a69e689965d91850e113bff11fff2 Mon Sep 17 00:00:00 2001 From: Nary Lozano <63013781+NaryLozano@users.noreply.github.com> Date: Mon, 25 Nov 2024 11:37:23 +0100 Subject: [PATCH 1/7] Dashboard - overview v0 (#18) * Add banner values from actual data * Fix style banner * Migration catalogue * Mock catalogue response * Clean up update * Delete dependency on package lock json * Add env for Batch size * Fix sidebar style * Fix pagination * Migrate updated publish form * Add Asset,PriceCard amd DatasetInfo components * Update tsconfig * Add review suggestions on style * Add asset credentials * Add provider card * Add mocked terms and conditions * Add recommender + fix styles * Update offerings to be clickable * First v of overview page * Fix style on transfer history * Fix style on transfer history * Add page and fix styles * hot fix * Add Recommender item and update styles * Update sidebar --- src/app/catalogue/components/ResultsPane.js | 2 +- src/app/dashboard/components/Dashboard.jsx | 14 ++++ .../dashboard/components/sidebar/Sidebar.jsx | 38 +++++++++ .../dashboard/components/sidebar/style.tsx | 80 +++++++++++++++++++ .../overview/components/BannerStats.jsx | 68 ++++++++++++++++ .../overview/components/Overview.jsx | 19 +++++ .../overview/components/TransferHistory.jsx | 70 ++++++++++++++++ src/app/dashboard/overview/page.js | 9 +++ src/app/dashboard/page.js | 7 ++ src/components/nav/NavItems.jsx | 2 +- src/utils/data/mockOverview.json | 8 ++ src/utils/data/mockTransfershistory.json | 52 ++++++++++++ 12 files changed, 367 insertions(+), 2 deletions(-) create mode 100644 src/app/dashboard/components/Dashboard.jsx create mode 100644 src/app/dashboard/components/sidebar/Sidebar.jsx create mode 100644 src/app/dashboard/components/sidebar/style.tsx create mode 100644 src/app/dashboard/overview/components/BannerStats.jsx create mode 100644 src/app/dashboard/overview/components/Overview.jsx create mode 100644 src/app/dashboard/overview/components/TransferHistory.jsx create mode 100644 src/app/dashboard/overview/page.js create mode 100644 src/app/dashboard/page.js create mode 100644 src/utils/data/mockOverview.json create mode 100644 src/utils/data/mockTransfershistory.json 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 + } + ] +} From 6ca6768638d3a9ddeb9f596d9bd98b1981c4c413 Mon Sep 17 00:00:00 2001 From: Nary Lozano <63013781+NaryLozano@users.noreply.github.com> Date: Mon, 25 Nov 2024 11:51:05 +0100 Subject: [PATCH 2/7] Feat/dashboard consumed contracts page v0 (#22) * Add banner values from actual data * Fix style banner * Migration catalogue * Mock catalogue response * Clean up update * Delete dependency on package lock json * Add env for Batch size * Fix sidebar style * Fix pagination * Migrate updated publish form * Add Asset,PriceCard amd DatasetInfo components * Update tsconfig * Add review suggestions on style * Add asset credentials * Add provider card * Add mocked terms and conditions * Add recommender + fix styles * Update offerings to be clickable * First v of overview page * Fix style on transfer history * Fix style on transfer history * Add page and fix styles * hot fix * Add Recommender item and update styles * Update sidebar * Contracting page v.0.0 * Update nav to show overview by default on dashboard * Unify icons in one object to avoid duplication * Delete bg red from contracts * Add filters to sideboard * Update Icons * Add creation date title * Fix styling --- next.config.js | 10 ++ package-lock.json | 10 +- package.json | 2 +- src/app/catalogue/asset/components/Asset.jsx | 13 +- .../catalogue/asset/components/PriceCard.jsx | 15 +- .../asset/components/ProviderCard.jsx | 14 +- .../asset/components/RecommenderItem.jsx | 45 +----- src/app/catalogue/asset/page.js | 12 +- src/app/catalogue/components/OfferingItem.jsx | 41 +----- src/app/catalogue/components/ResultsPane.js | 9 +- src/app/dashboard/components/Dashboard.jsx | 2 - .../components/sidebar/FilterDatePicker.jsx | 24 +++ .../dashboard/components/sidebar/Sidebar.jsx | 66 +++++++-- .../dashboard/components/sidebar/style.tsx | 1 + .../contracts/components/ButtonGroup.jsx | 23 +++ .../contracts/components/ContractItem.jsx | 86 +++++++++++ .../contracts/components/Contracts.jsx | 76 ++++++++++ src/app/dashboard/contracts/page.js | 11 ++ .../overview/components/Overview.jsx | 8 +- .../overview/components/TransferHistory.jsx | 18 +-- src/components/nav/NavItems.jsx | 2 +- src/utils/data/mockContract.json | 138 ++++++++++++++++++ src/utils/data/mockContractTransfers.json | 19 +++ 23 files changed, 499 insertions(+), 146 deletions(-) create mode 100644 src/app/dashboard/components/sidebar/FilterDatePicker.jsx create mode 100644 src/app/dashboard/contracts/components/ButtonGroup.jsx create mode 100644 src/app/dashboard/contracts/components/ContractItem.jsx create mode 100644 src/app/dashboard/contracts/components/Contracts.jsx create mode 100644 src/app/dashboard/contracts/page.js create mode 100644 src/utils/data/mockContract.json create mode 100644 src/utils/data/mockContractTransfers.json diff --git a/next.config.js b/next.config.js index da492d4..51e93a9 100644 --- a/next.config.js +++ b/next.config.js @@ -18,6 +18,16 @@ const nextConfig = { ] } ] + }, + images: { + remotePatterns: [ + { + protocol: 'https', + hostname: 'picsum.photos', + port: '', + pathname: '/200' + } + ] } } diff --git a/package-lock.json b/package-lock.json index 0ff028b..568721e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "name": "ws3-front-end", "version": "2.0.0", "dependencies": { - "@heroicons/react": "^2.0.18", + "@heroicons/react": "^2.2.0", "@metamask/sdk-react": "^0.27.0", "dayjs": "^1.11.13", "flowbite-react": "^0.7.2", @@ -2520,12 +2520,12 @@ "license": "MIT" }, "node_modules/@heroicons/react": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@heroicons/react/-/react-2.1.5.tgz", - "integrity": "sha512-FuzFN+BsHa+7OxbvAERtgBTNeZpUjgM/MIizfVkSCL2/edriN0Hx/DWRCR//aPYwO5QX/YlgLGXk+E3PcfZwjA==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@heroicons/react/-/react-2.2.0.tgz", + "integrity": "sha512-LMcepvRaS9LYHJGsF0zzmgKCUim/X3N/DQKc4jepAXJ7l8QxJ1PmxJzqplF2Z3FE4PqBAIGyJAQ/w4B5dsqbtQ==", "license": "MIT", "peerDependencies": { - "react": ">= 16" + "react": ">= 16 || ^19.0.0-rc" } }, "node_modules/@humanfs/core": { diff --git a/package.json b/package.json index b2438d7..753ef29 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "lint": "next lint" }, "dependencies": { - "@heroicons/react": "^2.0.18", + "@heroicons/react": "^2.2.0", "@metamask/sdk-react": "^0.27.0", "dayjs": "^1.11.13", "flowbite-react": "^0.7.2", diff --git a/src/app/catalogue/asset/components/Asset.jsx b/src/app/catalogue/asset/components/Asset.jsx index af1b792..5796ffc 100644 --- a/src/app/catalogue/asset/components/Asset.jsx +++ b/src/app/catalogue/asset/components/Asset.jsx @@ -1,5 +1,6 @@ import { Badge } from 'flowbite-react' import Image from 'next/image' +import { HiLocationMarker, HiCalendar, HiOutlineRefresh } from 'react-icons/hi' import Credentials from './Credentials' import ProviderCard from './ProviderCard' import mockProvider from '@/utils/data/mockProvider.json' @@ -22,21 +23,15 @@ function Asset ({ asset }) {
- +

{location}

- +

Published {createdAt.toISOString().split('T')[0]}

- +

Updated {updatedAt.toISOString().split('T')[0]}

diff --git a/src/app/catalogue/asset/components/PriceCard.jsx b/src/app/catalogue/asset/components/PriceCard.jsx index 871327d..dfe3dfd 100644 --- a/src/app/catalogue/asset/components/PriceCard.jsx +++ b/src/app/catalogue/asset/components/PriceCard.jsx @@ -1,5 +1,7 @@ import { Card } from 'flowbite-react' +import { HiClock, HiShoppingCart } from 'react-icons/hi' import { TermsNConditions } from './Terms&ConditionsModal' + function PriceCard ({ price }) { return ( @@ -8,9 +10,7 @@ function PriceCard ({ price }) { {price}
- + Accessible for three months
@@ -19,11 +19,10 @@ function PriceCard ({ price }) { type='button' className='inline-flex w-full justify-center rounded-lg bg-sedimark-deep-blue px-5 py-2.5 text-center text-sm font-medium text-white hover:bg-cyan-700 focus:outline-none focus:ring-4 focus:ring-cyan-200 dark:focus:ring-cyan-900' > - - Buy + + + Buy +
diff --git a/src/app/catalogue/asset/components/ProviderCard.jsx b/src/app/catalogue/asset/components/ProviderCard.jsx index 45b2179..cadfae0 100644 --- a/src/app/catalogue/asset/components/ProviderCard.jsx +++ b/src/app/catalogue/asset/components/ProviderCard.jsx @@ -1,4 +1,5 @@ import Image from 'next/image' +import { HiMail, HiGlobeAlt } from 'react-icons/hi' function ProviderCard ({ provider }) { return ( @@ -10,17 +11,12 @@ function ProviderCard ({ provider }) {

{provider.name}

-
- +
+

{provider.email}

-
- +
+

{provider.url}

diff --git a/src/app/catalogue/asset/components/RecommenderItem.jsx b/src/app/catalogue/asset/components/RecommenderItem.jsx index 15406ef..04a055b 100644 --- a/src/app/catalogue/asset/components/RecommenderItem.jsx +++ b/src/app/catalogue/asset/components/RecommenderItem.jsx @@ -1,7 +1,9 @@ +import { HiOutlineCurrencyEuro, HiCalendar, HiUser } from 'react-icons/hi' + function RecommenderItem ({ vc, providerName, price, color }) { const maxLengthTitle = 42 const maxLengthDescription = 60 - const name = vc.title.length > maxLengthTitle ? vc.title.substring( 0, maxLengthTitle ) + '...' : vc.title + const name = vc.title.length > maxLengthTitle ? vc.title.substring(0, maxLengthTitle) + '...' : vc.title const description = vc.short_description.length > maxLengthDescription ? vc.short_description.substring(0, maxLengthDescription) + '...' : vc.short_description const issuanceDate = vc.created_at ? new Date(vc.created_at) : new Date() const date = isNaN(issuanceDate.getTime()) ? new Date() : issuanceDate @@ -14,52 +16,19 @@ function RecommenderItem ({ vc, providerName, price, color }) {
{description}
- +

{validatedPrice} euros

- -

{date.toISOString().split('T')[0]}

+ +

{date.toISOString().split('T')[0]}

- +

{providedBy}

diff --git a/src/app/catalogue/asset/page.js b/src/app/catalogue/asset/page.js index 4137372..fc8675d 100644 --- a/src/app/catalogue/asset/page.js +++ b/src/app/catalogue/asset/page.js @@ -1,16 +1,18 @@ import { Button } from 'flowbite-react' +import { HiArrowLeft } from 'react-icons/hi' import DatasetInfoComponent from './components/DatasetInfoComponent' import Recommender from './components/Recommender' import mockRecommendations from '@/utils/data/mockRecommendations.json' + export default function Page () { return ( <>
- diff --git a/src/app/catalogue/components/OfferingItem.jsx b/src/app/catalogue/components/OfferingItem.jsx index 30a610b..6ce571a 100644 --- a/src/app/catalogue/components/OfferingItem.jsx +++ b/src/app/catalogue/components/OfferingItem.jsx @@ -1,3 +1,5 @@ +import { HiOutlineCurrencyEuro, HiCalendar, HiUser } from 'react-icons/hi' + function OfferingItem ({ vc, providerName, price, color }) { const name = vc.title const description = vc.short_description @@ -11,52 +13,19 @@ function OfferingItem ({ vc, providerName, price, color }) {
{description}
- +

{validatedPrice} euros

- +

{providedBy}

- +

{date.toISOString().split('T')[0]}

diff --git a/src/app/catalogue/components/ResultsPane.js b/src/app/catalogue/components/ResultsPane.js index dac6a8f..c3a4232 100644 --- a/src/app/catalogue/components/ResultsPane.js +++ b/src/app/catalogue/components/ResultsPane.js @@ -2,6 +2,7 @@ import { Button } from 'flowbite-react' import { useEffect, useState, useMemo } from 'react' import { useSearchParams } from 'next/navigation' +import { HiOutlineX } from 'react-icons/hi' import CustomPagination from '@/components/pagination/Pagination' import LoadingCard from '@/app/catalogue/components/LoadingCard' import CatalogueSideBar from './SideBar' @@ -109,10 +110,10 @@ export default function ResultsPane ({
{!loading && query && } {!loading && !results.length && data && (
diff --git a/src/app/dashboard/components/Dashboard.jsx b/src/app/dashboard/components/Dashboard.jsx index 4e89dc6..7160a24 100644 --- a/src/app/dashboard/components/Dashboard.jsx +++ b/src/app/dashboard/components/Dashboard.jsx @@ -1,13 +1,11 @@ 'use client' -// import Overview from '../overview/components/Overview' import SidebarDashboard from './sidebar/Sidebar' function Dashboard () { return (
- {/* */}
) } diff --git a/src/app/dashboard/components/sidebar/FilterDatePicker.jsx b/src/app/dashboard/components/sidebar/FilterDatePicker.jsx new file mode 100644 index 0000000..60d2911 --- /dev/null +++ b/src/app/dashboard/components/sidebar/FilterDatePicker.jsx @@ -0,0 +1,24 @@ +import Datepicker from 'react-tailwindcss-datepicker' +import { useState } from 'react' + +const FilterDatepicker = () => { + const [value, setValue] = useState() + const handleChange = (value) => { + setValue(value) + console.log('Filtering contracts by: date range - ', value) + } + + return ( + + ) +} + +export default FilterDatepicker diff --git a/src/app/dashboard/components/sidebar/Sidebar.jsx b/src/app/dashboard/components/sidebar/Sidebar.jsx index fa00356..4ee7d4c 100644 --- a/src/app/dashboard/components/sidebar/Sidebar.jsx +++ b/src/app/dashboard/components/sidebar/Sidebar.jsx @@ -1,12 +1,34 @@ -import { Sidebar } from 'flowbite-react' -import { useRouter } from 'next/navigation' +import { Checkbox, Label, ListGroup, Sidebar } from 'flowbite-react' +import { HiSwitchVertical, HiFilter, HiChartPie, HiShoppingBag } from 'react-icons/hi' +import { usePathname, useRouter } from 'next/navigation' import customTheme from './style' +import FilterDatepicker from './FilterDatePicker' +import { useEffect, useState } from 'react' function SidebarDashboard () { - const router = useRouter(); + const router = useRouter() + const pathname = usePathname() + const [isContracts, setContracts] = useState(false) + const [selectedCategory, setSelectedCategory] = useState(null) const handleItemClick = (path) => { - router.push(`/dashboard/${path}`); + if (path === 'contracts') { + setContracts(true) + } + router.push(`/dashboard/${path}`) } + + const handleCheckbox = (category) => { + setSelectedCategory(category === selectedCategory ? null : category) + console.log('Filtering contracts by:', category) + } + useEffect(() => { + if (pathname === '/dashboard/contracts') { + setContracts(true) + } + }, [pathname]) + + const sort = ['Creation date', 'Name', 'Price'] + return (
@@ -14,22 +36,44 @@ function SidebarDashboard () { handleItemClick('overview')}>
- + Overview
handleItemClick('contracts')} labelColor='dark'>
- + Contracts
+ {isContracts && + + +
+ + {sort.map((category, index) => ( +
+ handleCheckbox(category)} + /> + +
+ ))} +
+
+
+ +

Creation date

+ +
+
}
diff --git a/src/app/dashboard/components/sidebar/style.tsx b/src/app/dashboard/components/sidebar/style.tsx index adb58bc..40bfff4 100644 --- a/src/app/dashboard/components/sidebar/style.tsx +++ b/src/app/dashboard/components/sidebar/style.tsx @@ -1,4 +1,5 @@ import { FlowbiteSidebarTheme } from 'flowbite-react' + const customTheme: FlowbiteSidebarTheme = { "root": { "base": "h-full", diff --git a/src/app/dashboard/contracts/components/ButtonGroup.jsx b/src/app/dashboard/contracts/components/ButtonGroup.jsx new file mode 100644 index 0000000..91f67d8 --- /dev/null +++ b/src/app/dashboard/contracts/components/ButtonGroup.jsx @@ -0,0 +1,23 @@ +import { HiDownload, HiUpload } from 'react-icons/hi' +import { Button } from 'flowbite-react' + +function ButtonGroup () { + return ( +
+ + +
+ ) +} + +export default ButtonGroup diff --git a/src/app/dashboard/contracts/components/ContractItem.jsx b/src/app/dashboard/contracts/components/ContractItem.jsx new file mode 100644 index 0000000..0028543 --- /dev/null +++ b/src/app/dashboard/contracts/components/ContractItem.jsx @@ -0,0 +1,86 @@ +import Image from 'next/image' +import { Accordion, Table } from 'flowbite-react' +import { HiOutlineCurrencyEuro, HiCalendar, HiDotsHorizontal, HiCheck, HiExclamationCircle } from 'react-icons/hi' +import mockContractTransfer from '@/utils/data/mockContractTransfers.json' + +function ContractItem ({ vc, price }) { + const maxLengthTitle = 42 + const maxLengthDescription = 60 + const name = vc.title.length > maxLengthTitle ? vc.title.substring(0, maxLengthTitle) + '...' : vc.title + const description = vc.short_description.length > maxLengthDescription ? vc.short_description.substring(0, maxLengthDescription) + '...' : vc.short_description + const issuanceDate = vc.created_at ? new Date(vc.created_at) : new Date() + const date = isNaN(issuanceDate.getTime()) ? new Date() : issuanceDate + const provider = vc.provider + const providedBy = provider.name ?? 'OTHER' + const validatedPrice = price ?? '0' + const history = mockContractTransfer.transfer_history + const historyData = ['', 'Status', 'Date', 'Transfer ID'] + + return ( + + + +
+
+
{name}
+
+
{description}
+ {/* Price and date */} +
+
+ +

{date.toISOString().split('T')[0]}

+
+
+ +

{validatedPrice} euros

+
+
+
+
+
+ {provider.name} +

{providedBy}

+
+
+
+ +
+ + + {historyData.map((nameColumn, index) => { + return ({nameColumn}) + })} + + + {history.map((asset, index) => { + return ( + + {asset.status === 'Completed' && + + + } + {asset.status === 'In progress' && + + + } + {asset.status === 'Failed' && + + + } + {asset.status} + {asset.date} + {asset.transfer_id} + + ) + })} + +
+
+
+
+
+ ) +} + +export default ContractItem diff --git a/src/app/dashboard/contracts/components/Contracts.jsx b/src/app/dashboard/contracts/components/Contracts.jsx new file mode 100644 index 0000000..02680cd --- /dev/null +++ b/src/app/dashboard/contracts/components/Contracts.jsx @@ -0,0 +1,76 @@ +'use client' + +import { Pagination } from 'flowbite-react' +import { useState, useMemo, useEffect, useRef } from 'react' +import Link from 'next/link' +import { HiSearch } from 'react-icons/hi' +import { calculateTotalPages } from '@/app/catalogue/utils/paginationHelpers' +import SidebarDashboard from '../../components/sidebar/Sidebar' +import ButtonGroup from './ButtonGroup' +import ContractItem from './ContractItem' + +function calculateItemsPerPage (currentPage, size, data, setContracts) { + const startIndex = (currentPage - 1) * size + const endIndex = (currentPage * size) > data.total ? data.total : currentPage * size + setContracts(data.slice(startIndex, endIndex)) +} +function Contracts ({ data }) { + const [currentPage, setCurrentPage] = useState(1) + const [contracts, setContracts] = useState([]) + const ref = useRef(null) + + useEffect(() => { + if (data) { + setContracts(data) + } + }, [data]) + + useEffect(() => { + window.scrollTo(0, 0, 'smooth') + calculateItemsPerPage(currentPage, 2, data, setContracts) + }, [currentPage, data]) + + const handleSearch = (e) => { + console.log('Searching contracts by: ', e.target.value) + ref.current.value = '' + } + const totalPages = useMemo(() => calculateTotalPages(data.length, 2), [data.length]) + const totalPagesToDisplay = totalPages + const onPageChange = (page) => setCurrentPage(page) + return ( +
+ +
+ +
+
+ + { + if (e.key === 'Enter') { + handleSearch(e) + } + }} + /> +
+ +
+ {contracts.map((contract, index) => { + return ( + + + + ) + })} +
+
+ ) +} +export default Contracts diff --git a/src/app/dashboard/contracts/page.js b/src/app/dashboard/contracts/page.js new file mode 100644 index 0000000..e81ff87 --- /dev/null +++ b/src/app/dashboard/contracts/page.js @@ -0,0 +1,11 @@ +import Contracts from './components/Contracts' +import mockContract from '@/utils/data/mockContract.json' + +export default function Page () { + const contracts = mockContract + return ( +
+ +
+ ) +} diff --git a/src/app/dashboard/overview/components/Overview.jsx b/src/app/dashboard/overview/components/Overview.jsx index c286e23..e73c894 100644 --- a/src/app/dashboard/overview/components/Overview.jsx +++ b/src/app/dashboard/overview/components/Overview.jsx @@ -9,10 +9,10 @@ function Overview () { return (
-
- - -
+
+ + +
) } diff --git a/src/app/dashboard/overview/components/TransferHistory.jsx b/src/app/dashboard/overview/components/TransferHistory.jsx index d16346f..41dbd56 100644 --- a/src/app/dashboard/overview/components/TransferHistory.jsx +++ b/src/app/dashboard/overview/components/TransferHistory.jsx @@ -1,4 +1,5 @@ import { Table, Accordion } from 'flowbite-react' +import { HiDownload, HiUpload, HiDotsHorizontal, HiExclamationCircle } from 'react-icons/hi' function TransferHistory ({ history }) { const historyData = ['', 'Asset', 'Counterparty ID', 'Status', 'Date'] @@ -27,28 +28,19 @@ function TransferHistory ({ history }) { {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} diff --git a/src/components/nav/NavItems.jsx b/src/components/nav/NavItems.jsx index 862a2d9..ba3728a 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: '/dashboard', label: 'Dashboard' } + { href: '/dashboard/overview', label: 'Dashboard' } ] return ( diff --git a/src/utils/data/mockContract.json b/src/utils/data/mockContract.json new file mode 100644 index 0000000..278b61e --- /dev/null +++ b/src/utils/data/mockContract.json @@ -0,0 +1,138 @@ +[ + { + "title": "Breast cancer data (2022 update)", + "id": "did:web:example.com:dataset:climate-change-analysis-2022", + "short_description": "Breast cancer labelled data from 2020 to 2022 in France", + "provider": { + "name": "Care & Co SARL ", + "id": "did:web:example.com:provider:climate-change-analysis-2022", + "email": "example@noaa.com", + "url": "https://oceanservice.noaa.gov/", + "picture": "https://picsum.photos/200" + }, + "price": 50, + "picture": "/img/mock_asset_img.jpg", + "created_at": "2023-12-03T10:24:00", + "updated_at": "2023-10-05T14:30:00", + "keywords": [ + "cancer", + "health " + ], + "location": "London, UK", + "description": "This dataset provides comprehensive data on various climate metrics for the year 2022. It includes detailed information on temperature changes, precipitation patterns, and carbon emissions. The data is sourced from the National Oceanic and Atmospheric Administration (NOAA) and is designed to support research and policy-making efforts related to climate change. Users can analyze trends over time and compare data across different regions to gain insights into the impacts of climate change." + }, + { + "title": "Eviden HPC", + "id": "did:web:example.com:dataset:climate-change-analysis-2022", + "short_description": "Eviden HPC service to execute expensive computing tasks quickly and easily", + "provider": { + "name": "Bruxelloise des logiciels SRL", + "id": "did:web:example.com:provider:climate-change-analysis-2022", + "email": "example@noaa.com", + "url": "https://oceanservice.noaa.gov/", + "picture": "https://picsum.photos/200" + }, + "price": 6, + "picture": "/img/mock_asset_img.jpg", + "created_at": "2023-11-09T10:24:00", + "updated_at": "2023-10-05T14:30:00", + "keywords": [ + "cancer", + "health " + ], + "location": "London, UK", + "description": "This dataset provides comprehensive data on various climate metrics for the year 2022. It includes detailed information on temperature changes, precipitation patterns, and carbon emissions. The data is sourced from the National Oceanic and Atmospheric Administration (NOAA) and is designed to support research and policy-making efforts related to climate change. Users can analyze trends over time and compare data across different regions to gain insights into the impacts of climate change." + }, + { + "title": "Renewable Energy Trends", + "id": "did:web:example.com:dataset:renewable-energy-2023", + "short_description": "A dataset covering global renewable energy trends and statistics.", + "provider": { + "name": "Green Energy Analytics", + "id": "did:web:example.com:provider:renewable-energy", + "email": "contact@gea.com", + "url": "https://renewableanalytics.com", + "picture": "https://picsum.photos/200" + }, + "price": 25, + "picture": "/img/energy_asset_img.jpg", + "created_at": "2024-01-15T10:24:00", + "updated_at": "2024-02-05T14:30:00", + "keywords": [ + "renewable", + "energy", + "sustainability" + ], + "location": "Berlin, Germany", + "description": "Explore global renewable energy adoption trends, including solar, wind, and hydroelectric power data from 2023." + }, + { + "title": "Urban Mobility Insights", + "id": "did:web:example.com:dataset:urban-mobility", + "short_description": "Urban mobility statistics and insights from 2022.", + "provider": { + "name": "City Move Analytics", + "id": "did:web:example.com:provider:urban-mobility", + "email": "support@citymove.com", + "url": "https://citymoveanalytics.com", + "picture": "https://picsum.photos/200" + }, + "price": 15, + "picture": "/img/mobility_asset_img.jpg", + "created_at": "2023-10-12T12:24:00", + "updated_at": "2023-11-01T14:30:00", + "keywords": [ + "mobility", + "transportation", + "cities" + ], + "location": "Amsterdam, Netherlands", + "description": "Comprehensive data on urban transportation patterns, including ride-sharing, public transit, and traffic congestion metrics." + }, + { + "title": "AI Ethics Dataset", + "id": "did:web:example.com:dataset:ai-ethics", + "short_description": "AI ethics case studies and policy recommendations.", + "provider": { + "name": "EthicsAI", + "id": "did:web:example.com:provider:ai-ethics", + "email": "info@ethicsai.org", + "url": "https://ethicsai.org", + "picture": "https://picsum.photos/200" + }, + "price": 40, + "picture": "/img/ai_ethics_img.jpg", + "created_at": "2023-05-20T11:24:00", + "updated_at": "2023-06-15T16:30:00", + "keywords": [ + "AI", + "ethics", + "policy" + ], + "location": "San Francisco, USA", + "description": "Case studies and insights on the ethical implications of artificial intelligence in various domains." + }, + { + "title": "Wildlife Conservation Metrics", + "id": "did:web:example.com:dataset:wildlife-conservation", + "short_description": "Wildlife conservation data from 2021 to 2023.", + "provider": { + "name": "EcoData Foundation", + "id": "did:web:example.com:provider:wildlife-conservation", + "email": "contact@ecodata.org", + "url": "https://ecodata.org", + "picture": "https://picsum.photos/200" + }, + "price": 35, + "picture": "/img/wildlife_img.jpg", + "created_at": "2023-09-05T09:24:00", + "updated_at": "2023-12-01T10:30:00", + "keywords": [ + "wildlife", + "conservation", + "biodiversity" + ], + "location": "Nairobi, Kenya", + "description": "Data covering wildlife conservation efforts, including species population trends and protected area effectiveness." + } +] diff --git a/src/utils/data/mockContractTransfers.json b/src/utils/data/mockContractTransfers.json new file mode 100644 index 0000000..c95145b --- /dev/null +++ b/src/utils/data/mockContractTransfers.json @@ -0,0 +1,19 @@ +{ + "transfer_history": [ + { + "status": "In progress", + "date": "Yesterday at 6:31 pm", + "transfer_id": "kdjlsfjslf-156416" + }, + { + "status": "Completed", + "date": "2023-11-29 at 6:31 pm", + "transfer_id": "lsjflassfls-519861" + }, + { + "status": "Failed", + "date": "2023-11-21 at 5:24 am", + "transfer_id": "sldfkSƒFLie-56498" + } + ] +} From 93378f28b29721576c3dfdbfe76e04b1313b26c8 Mon Sep 17 00:00:00 2001 From: Nary Lozano Date: Mon, 25 Nov 2024 11:58:17 +0100 Subject: [PATCH 3/7] Fix formatting sidebar --- src/app/dashboard/components/sidebar/Sidebar.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/dashboard/components/sidebar/Sidebar.jsx b/src/app/dashboard/components/sidebar/Sidebar.jsx index 4ee7d4c..abb41bf 100644 --- a/src/app/dashboard/components/sidebar/Sidebar.jsx +++ b/src/app/dashboard/components/sidebar/Sidebar.jsx @@ -1,9 +1,10 @@ +import { useEffect, useState } from 'react' import { Checkbox, Label, ListGroup, Sidebar } from 'flowbite-react' import { HiSwitchVertical, HiFilter, HiChartPie, HiShoppingBag } from 'react-icons/hi' import { usePathname, useRouter } from 'next/navigation' -import customTheme from './style' import FilterDatepicker from './FilterDatePicker' -import { useEffect, useState } from 'react' +import customTheme from './style' + function SidebarDashboard () { const router = useRouter() const pathname = usePathname() From 28de090e71d8d07154d0d095d0b3d961dcfe3ebc Mon Sep 17 00:00:00 2001 From: Nary Lozano Date: Tue, 17 Dec 2024 15:58:20 +0100 Subject: [PATCH 4/7] Add Sugestions CR 1/2 --- .example.env | 3 ++ next.config.js | 4 +- .../dashboard/components/sidebar/Sidebar.jsx | 23 ++++++----- .../dashboard/components/sidebar/style.tsx | 1 + .../contracts/components/ButtonGroup.jsx | 2 +- .../contracts/components/ContractItem.jsx | 28 ++++++++----- .../contracts/components/Contracts.jsx | 41 +++++-------------- .../overview/components/TransferHistory.jsx | 2 +- src/app/dashboard/page.js | 7 ---- src/utils/settings.js | 1 + 10 files changed, 52 insertions(+), 60 deletions(-) delete mode 100644 src/app/dashboard/page.js diff --git a/.example.env b/.example.env index 016fa99..a83c0bb 100644 --- a/.example.env +++ b/.example.env @@ -6,3 +6,6 @@ export LOGOUT_REDIRECT_URL="" export NEXTAUTH_URL="" export NEXTAUTH_SECRET="" export FEDERATED_CATALOGUE_API="" +export CONTRACTS_PAGE_SIZE=5 +export BATCH_SIZE=40 + diff --git a/next.config.js b/next.config.js index 51e93a9..36451cb 100644 --- a/next.config.js +++ b/next.config.js @@ -4,6 +4,7 @@ const nextConfig = { output: 'standalone', env: { BATCH_SIZE: process.env.BATCH_SIZE ?? '40', + CONTRACTS_PAGE_SIZE: process.env.CONTRACTS_PAGE_SIZE ?? '5', FEDERATED_CATALOGUE_API: process.env.FEDERATED_CATALOGUE_API }, async headers () { @@ -19,7 +20,8 @@ const nextConfig = { } ] }, - images: { + // TODO: remove when integrating backend component + images: { remotePatterns: [ { protocol: 'https', diff --git a/src/app/dashboard/components/sidebar/Sidebar.jsx b/src/app/dashboard/components/sidebar/Sidebar.jsx index abb41bf..9d545e6 100644 --- a/src/app/dashboard/components/sidebar/Sidebar.jsx +++ b/src/app/dashboard/components/sidebar/Sidebar.jsx @@ -1,21 +1,23 @@ import { useEffect, useState } from 'react' -import { Checkbox, Label, ListGroup, Sidebar } from 'flowbite-react' +import { Label, ListGroup, Sidebar, Radio } from 'flowbite-react' import { HiSwitchVertical, HiFilter, HiChartPie, HiShoppingBag } from 'react-icons/hi' import { usePathname, useRouter } from 'next/navigation' import FilterDatepicker from './FilterDatePicker' import customTheme from './style' function SidebarDashboard () { + const router = useRouter() const pathname = usePathname() const [isContracts, setContracts] = useState(false) - const [selectedCategory, setSelectedCategory] = useState(null) + const [selectedCategory, setSelectedCategory] = useState( null ) - const handleItemClick = (path) => { - if (path === 'contracts') { + const handleItemClick = (item) => { + if (item === 'contracts') { setContracts(true) } - router.push(`/dashboard/${path}`) + + router.push(`/dashboard/${item}`) } const handleCheckbox = (category) => { @@ -35,13 +37,14 @@ function SidebarDashboard () { - handleItemClick('overview')}> + {/* //TODO:first do it, then do it right */} + handleItemClick('overview')}className={`${pathname === '/dashboard/overview' ? 'bg-gray-100' : ''}`} >
Overview
- handleItemClick('contracts')} labelColor='dark'> + handleItemClick('contracts')} className={`${isContracts ? 'bg-gray-100' : ''}`}>
Contracts @@ -50,7 +53,7 @@ function SidebarDashboard () { {isContracts && - +
{sort.map((category, index) => ( @@ -58,7 +61,7 @@ function SidebarDashboard () { key={`${category}-${index}`} className='flex items-center border-none focus:ring-0 m-2 ml-4' > -
- +

Creation date

diff --git a/src/app/dashboard/components/sidebar/style.tsx b/src/app/dashboard/components/sidebar/style.tsx index 40bfff4..63eafe3 100644 --- a/src/app/dashboard/components/sidebar/style.tsx +++ b/src/app/dashboard/components/sidebar/style.tsx @@ -1,5 +1,6 @@ import { FlowbiteSidebarTheme } from 'flowbite-react' +// Custom theme needed to override the root.inner property. const customTheme: FlowbiteSidebarTheme = { "root": { "base": "h-full", diff --git a/src/app/dashboard/contracts/components/ButtonGroup.jsx b/src/app/dashboard/contracts/components/ButtonGroup.jsx index 91f67d8..5719b01 100644 --- a/src/app/dashboard/contracts/components/ButtonGroup.jsx +++ b/src/app/dashboard/contracts/components/ButtonGroup.jsx @@ -4,7 +4,7 @@ import { Button } from 'flowbite-react' function ButtonGroup () { return (
- +
- +
{historyData.map((nameColumn, index) => { return ({nameColumn}) @@ -77,6 +84,7 @@ function ContractItem ({ vc, price }) {
+ diff --git a/src/app/dashboard/contracts/components/Contracts.jsx b/src/app/dashboard/contracts/components/Contracts.jsx index 02680cd..fe20c18 100644 --- a/src/app/dashboard/contracts/components/Contracts.jsx +++ b/src/app/dashboard/contracts/components/Contracts.jsx @@ -1,72 +1,53 @@ 'use client' import { Pagination } from 'flowbite-react' -import { useState, useMemo, useEffect, useRef } from 'react' -import Link from 'next/link' -import { HiSearch } from 'react-icons/hi' +import { useState, useMemo, useEffect } from 'react' import { calculateTotalPages } from '@/app/catalogue/utils/paginationHelpers' import SidebarDashboard from '../../components/sidebar/Sidebar' import ButtonGroup from './ButtonGroup' import ContractItem from './ContractItem' +import settings from '@/utils/settings' function calculateItemsPerPage (currentPage, size, data, setContracts) { const startIndex = (currentPage - 1) * size const endIndex = (currentPage * size) > data.total ? data.total : currentPage * size setContracts(data.slice(startIndex, endIndex)) } + function Contracts ({ data }) { const [currentPage, setCurrentPage] = useState(1) const [contracts, setContracts] = useState([]) - const ref = useRef(null) useEffect(() => { if (data) { - setContracts(data) + setContracts( data ) } - }, [data]) + }, [data] ) + useEffect(() => { - window.scrollTo(0, 0, 'smooth') - calculateItemsPerPage(currentPage, 2, data, setContracts) + calculateItemsPerPage(currentPage, settings.contractsPageSize , data, setContracts) }, [currentPage, data]) - const handleSearch = (e) => { - console.log('Searching contracts by: ', e.target.value) - ref.current.value = '' - } - const totalPages = useMemo(() => calculateTotalPages(data.length, 2), [data.length]) + const totalPages = useMemo(() => calculateTotalPages(data.length, settings.contractsPageSize), [data.length]) const totalPagesToDisplay = totalPages - const onPageChange = (page) => setCurrentPage(page) + const onPageChange = ( page ) => setCurrentPage( page ) + return (
-
- - { - if (e.key === 'Enter') { - handleSearch(e) - } - }} - /> -
{contracts.map((contract, index) => { return ( - - ) })}
diff --git a/src/app/dashboard/overview/components/TransferHistory.jsx b/src/app/dashboard/overview/components/TransferHistory.jsx index 41dbd56..998f8f8 100644 --- a/src/app/dashboard/overview/components/TransferHistory.jsx +++ b/src/app/dashboard/overview/components/TransferHistory.jsx @@ -13,7 +13,7 @@ function TransferHistory ({ history }) { Transfer history
- +
diff --git a/src/app/dashboard/page.js b/src/app/dashboard/page.js deleted file mode 100644 index 7fb897a..0000000 --- a/src/app/dashboard/page.js +++ /dev/null @@ -1,7 +0,0 @@ -import Dashboard from './components/Dashboard' - -export default function Page () { - return ( - - ) -} diff --git a/src/utils/settings.js b/src/utils/settings.js index 01c2776..35fc376 100644 --- a/src/utils/settings.js +++ b/src/utils/settings.js @@ -15,6 +15,7 @@ */ const settings = { batchSize: process.env.BATCH_SIZE ?? 40, + contractsPageSize : process.env.CONTRACTS_PAGE_SIZE ?? 5, federatedCatalogueApi: new URL('/query_page', process.env.FEDERATED_CATALOGUE_API), federatedCatalogueProviders: new URL('/api/providers', process.env.FEDERATED_CATALOGUE_API), federatedCatalogueFilters: new URL('/api/filters-data', process.env.FEDERATED_CATALOGUE_API) From 2dd1604c7b43a8c3305a16594a5fac323d86eb32 Mon Sep 17 00:00:00 2001 From: Nary Lozano Date: Wed, 18 Dec 2024 09:37:00 +0100 Subject: [PATCH 5/7] Refactor Bannerstats --- next.config.js | 2 +- .../components/sidebar/FilterDatePicker.jsx | 18 +-- .../dashboard/components/sidebar/Sidebar.jsx | 7 +- .../contracts/components/ButtonGroup.jsx | 2 +- .../contracts/components/ContractItem.jsx | 80 ++++++------ .../contracts/components/Contracts.jsx | 21 ++- .../overview/components/BannerStats.jsx | 120 +++++++++--------- src/utils/settings.js | 2 +- 8 files changed, 126 insertions(+), 126 deletions(-) diff --git a/next.config.js b/next.config.js index 36451cb..c893185 100644 --- a/next.config.js +++ b/next.config.js @@ -21,7 +21,7 @@ const nextConfig = { ] }, // TODO: remove when integrating backend component - images: { + images: { remotePatterns: [ { protocol: 'https', diff --git a/src/app/dashboard/components/sidebar/FilterDatePicker.jsx b/src/app/dashboard/components/sidebar/FilterDatePicker.jsx index 60d2911..a7688fa 100644 --- a/src/app/dashboard/components/sidebar/FilterDatePicker.jsx +++ b/src/app/dashboard/components/sidebar/FilterDatePicker.jsx @@ -9,15 +9,15 @@ const FilterDatepicker = () => { } return ( - + ) } diff --git a/src/app/dashboard/components/sidebar/Sidebar.jsx b/src/app/dashboard/components/sidebar/Sidebar.jsx index 9d545e6..4d4c5cc 100644 --- a/src/app/dashboard/components/sidebar/Sidebar.jsx +++ b/src/app/dashboard/components/sidebar/Sidebar.jsx @@ -6,17 +6,16 @@ import FilterDatepicker from './FilterDatePicker' import customTheme from './style' function SidebarDashboard () { - const router = useRouter() const pathname = usePathname() const [isContracts, setContracts] = useState(false) - const [selectedCategory, setSelectedCategory] = useState( null ) + const [selectedCategory, setSelectedCategory] = useState(null) const handleItemClick = (item) => { if (item === 'contracts') { setContracts(true) } - + router.push(`/dashboard/${item}`) } @@ -38,7 +37,7 @@ function SidebarDashboard () { {/* //TODO:first do it, then do it right */} - handleItemClick('overview')}className={`${pathname === '/dashboard/overview' ? 'bg-gray-100' : ''}`} > + handleItemClick('overview')} className={`${pathname === '/dashboard/overview' ? 'bg-gray-100' : ''}`}>
Overview diff --git a/src/app/dashboard/contracts/components/ButtonGroup.jsx b/src/app/dashboard/contracts/components/ButtonGroup.jsx index 5719b01..05ecba1 100644 --- a/src/app/dashboard/contracts/components/ButtonGroup.jsx +++ b/src/app/dashboard/contracts/components/ButtonGroup.jsx @@ -6,7 +6,7 @@ function ButtonGroup () {
diff --git a/src/app/dashboard/contracts/components/ContractItem.jsx b/src/app/dashboard/contracts/components/ContractItem.jsx index d12b687..f8f0fa8 100644 --- a/src/app/dashboard/contracts/components/ContractItem.jsx +++ b/src/app/dashboard/contracts/components/ContractItem.jsx @@ -1,6 +1,6 @@ import Image from 'next/image' import { Accordion, Table, Button } from 'flowbite-react' -import { HiOutlineCurrencyEuro, HiCalendar, HiDotsHorizontal, HiCheck, HiExclamationCircle, HiChevronDoubleRight, HiPlay } from 'react-icons/hi' +import { HiOutlineCurrencyEuro, HiCalendar, HiDotsHorizontal, HiCheck, HiExclamationCircle, HiPlay } from 'react-icons/hi' import mockContractTransfer from '@/utils/data/mockContractTransfers.json' function ContractItem ({ vc, price }) { @@ -44,46 +44,46 @@ function ContractItem ({ vc, price }) {
- +
    -
    - -
    -
    -
- - {historyData.map((nameColumn, index) => { - return ({nameColumn}) - })} - - - {history.map((asset, index) => { - return ( - - {asset.status === 'Completed' && - - - } - {asset.status === 'In progress' && - - - } - {asset.status === 'Failed' && - - - } - {asset.status} - {asset.date} - {asset.transfer_id} - - ) - })} - -
-
+
+ +
+
+ + + {historyData.map((nameColumn, index) => { + return ({nameColumn}) + })} + + + {history.map((asset, index) => { + return ( + + {asset.status === 'Completed' && + + + } + {asset.status === 'In progress' && + + + } + {asset.status === 'Failed' && + + + } + {asset.status} + {asset.date} + {asset.transfer_id} + + ) + })} + +
+
diff --git a/src/app/dashboard/contracts/components/Contracts.jsx b/src/app/dashboard/contracts/components/Contracts.jsx index fe20c18..987fed3 100644 --- a/src/app/dashboard/contracts/components/Contracts.jsx +++ b/src/app/dashboard/contracts/components/Contracts.jsx @@ -20,19 +20,18 @@ function Contracts ({ data }) { useEffect(() => { if (data) { - setContracts( data ) + setContracts(data) } - }, [data] ) - + }, [data]) useEffect(() => { - calculateItemsPerPage(currentPage, settings.contractsPageSize , data, setContracts) + calculateItemsPerPage(currentPage, settings.contractsPageSize, data, setContracts) }, [currentPage, data]) const totalPages = useMemo(() => calculateTotalPages(data.length, settings.contractsPageSize), [data.length]) const totalPagesToDisplay = totalPages - const onPageChange = ( page ) => setCurrentPage( page ) - + const onPageChange = (page) => setCurrentPage(page) + return (
@@ -43,11 +42,11 @@ function Contracts ({ data }) {
{contracts.map((contract, index) => { return ( - + ) })}
diff --git a/src/app/dashboard/overview/components/BannerStats.jsx b/src/app/dashboard/overview/components/BannerStats.jsx index c8c1843..e688ec8 100644 --- a/src/app/dashboard/overview/components/BannerStats.jsx +++ b/src/app/dashboard/overview/components/BannerStats.jsx @@ -1,66 +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)} - -
-
- ) - })} +
+
+ +
+
+ + {overview.assets_published} + + + Assets Published + +
+
+
+
+ +
+
+ + {overview.contracts_agreements} + + + Contracts Agreements + +
+
+
+
+ +
+
+ + {overview.datasets_downloaded} + + + Datasets Downloaded + +
+
+
+
+ +
+
+ + {overview.transfers_out} + + + Transfers Out + +
+
) diff --git a/src/utils/settings.js b/src/utils/settings.js index 35fc376..53669dd 100644 --- a/src/utils/settings.js +++ b/src/utils/settings.js @@ -15,7 +15,7 @@ */ const settings = { batchSize: process.env.BATCH_SIZE ?? 40, - contractsPageSize : process.env.CONTRACTS_PAGE_SIZE ?? 5, + contractsPageSize: process.env.CONTRACTS_PAGE_SIZE ?? 5, federatedCatalogueApi: new URL('/query_page', process.env.FEDERATED_CATALOGUE_API), federatedCatalogueProviders: new URL('/api/providers', process.env.FEDERATED_CATALOGUE_API), federatedCatalogueFilters: new URL('/api/filters-data', process.env.FEDERATED_CATALOGUE_API) From c3e5ac5ae62fdce83ce8e73bb4f272a809656934 Mon Sep 17 00:00:00 2001 From: Nary Lozano Date: Wed, 18 Dec 2024 13:40:30 +0100 Subject: [PATCH 6/7] Rafeactor SideBar --- .../dashboard/components/sidebar/Sidebar.jsx | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/app/dashboard/components/sidebar/Sidebar.jsx b/src/app/dashboard/components/sidebar/Sidebar.jsx index 4d4c5cc..2b9c2a9 100644 --- a/src/app/dashboard/components/sidebar/Sidebar.jsx +++ b/src/app/dashboard/components/sidebar/Sidebar.jsx @@ -6,28 +6,14 @@ import FilterDatepicker from './FilterDatePicker' import customTheme from './style' function SidebarDashboard () { - const router = useRouter() const pathname = usePathname() - const [isContracts, setContracts] = useState(false) - const [selectedCategory, setSelectedCategory] = useState(null) - - const handleItemClick = (item) => { - if (item === 'contracts') { - setContracts(true) - } - router.push(`/dashboard/${item}`) - } + const [selectedCategory, setSelectedCategory] = useState(null) const handleCheckbox = (category) => { setSelectedCategory(category === selectedCategory ? null : category) console.log('Filtering contracts by:', category) } - useEffect(() => { - if (pathname === '/dashboard/contracts') { - setContracts(true) - } - }, [pathname]) const sort = ['Creation date', 'Name', 'Price'] @@ -36,21 +22,20 @@ function SidebarDashboard () { - {/* //TODO:first do it, then do it right */} - handleItemClick('overview')} className={`${pathname === '/dashboard/overview' ? 'bg-gray-100' : ''}`}> +
Overview
- handleItemClick('contracts')} className={`${isContracts ? 'bg-gray-100' : ''}`}> +
Contracts
- {isContracts && + {pathname === '/dashboard/contracts' &&
From 017e3787991a3902616903238a938b5b92e04a23 Mon Sep 17 00:00:00 2001 From: Nary Lozano Date: Fri, 20 Dec 2024 09:54:36 +0100 Subject: [PATCH 7/7] Fix pagination position --- src/app/dashboard/contracts/components/Contracts.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/dashboard/contracts/components/Contracts.jsx b/src/app/dashboard/contracts/components/Contracts.jsx index 987fed3..253c4f4 100644 --- a/src/app/dashboard/contracts/components/Contracts.jsx +++ b/src/app/dashboard/contracts/components/Contracts.jsx @@ -37,7 +37,7 @@ function Contracts ({ data }) {
-
+
{contracts.map((contract, index) => {