diff --git a/frontend/packages/volto-ploneconf/package.json b/frontend/packages/volto-ploneconf/package.json index 344c3e6..2d98ebc 100644 --- a/frontend/packages/volto-ploneconf/package.json +++ b/frontend/packages/volto-ploneconf/package.json @@ -42,7 +42,6 @@ "@eeacms/volto-matomo" ], "dependencies": { - "@plone/components": "workspace:*", "@eeacms/volto-accordion-block": "11.0.0", "@eeacms/volto-matomo": "^5.0.0", "@eeacms/volto-statistic-block": "4.1.0", @@ -54,19 +53,21 @@ "@mbarde/volto-image-crop-widget": "0.5.1", "@plone-collective/volto-authomatic": "2.0.1", "@plone-collective/volto-eventbrite-block": "^1.0.0-alpha.2", + "@plone/components": "workspace:*", "@plonegovbr/volto-network-block": "^1.0.0", "classnames": "2.2.6", "embla-carousel-autoplay": "^8.0.0", "embla-carousel-react": "^8.0.0", "react-lazy-load-image-component": "^1.6.2", + "react-stately": "^3.33.0", "volto-form-block": "^3.9.1", "volto-subblocks": "^2.1.0" }, "peerDependencies": { "react": "18.2.0", + "react-aria-components": "^1.4.1", "react-dom": "18.2.0", "react-intl": "^3.12.1", - "react-aria-components": "^1.4.1", "semantic-ui-react": "^2.1.5" }, "devDependencies": { diff --git a/frontend/packages/volto-ploneconf/src/components/Registrations/RegistrationsManagement.jsx b/frontend/packages/volto-ploneconf/src/components/Registrations/RegistrationsManagement.jsx index 6441d1e..729b93f 100644 --- a/frontend/packages/volto-ploneconf/src/components/Registrations/RegistrationsManagement.jsx +++ b/frontend/packages/volto-ploneconf/src/components/Registrations/RegistrationsManagement.jsx @@ -1,13 +1,14 @@ -import _ from 'lodash'; +import sortBy from 'lodash/sortBy'; +import cloneDeep from 'lodash/cloneDeep'; import React, { useEffect, useState } from 'react'; import { Container } from '@plone/components'; import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; import { useDispatch, useSelector } from 'react-redux'; import { useLocation } from 'react-router-dom'; import { - Table, - TableBody, - TableHeader, + Table as SemanticTable, + TableBody as SemanticTableBody, + TableHeader as SemanticTableHeader, TableRow, TableHeaderCell, Segment, @@ -17,12 +18,26 @@ import { Helmet } from '@plone/volto/helpers'; import backSVG from '@plone/volto/icons/back.svg'; import { Icon, Toolbar, UniversalLink } from '@plone/volto/components'; +import { + Cell, + Column, + ColumnResizer, + ResizableTableContainer, + Row, + Table, + TableBody, + TableHeader, +} from 'react-aria-components'; + import { getAllRegistrations, getRegistrations, } from '../../actions/registrations/registrations'; import RegistrationItem from './RegistrationItem'; +import { useListData, useAsyncList } from 'react-stately'; + +import '@plone/components/src/styles/basic/Table.css'; const messages = defineMessages({ back: { @@ -77,10 +92,9 @@ const sortReducer = (state, action) => { state.direction === 'ascending' ? 'descending' : 'ascending', }; } - return { column: action.column, - data: _.sortBy(state.data, [action.column]), + data: sortBy(state.data, [action.column]), direction: 'ascending', }; default: @@ -129,6 +143,44 @@ const RegistrationsManagement = () => { ? intl.formatMessage(messages.registrationManagementAll) : intl.formatMessage(messages.registrationManagement); + let list = useAsyncList({ + async load({ signal }) { + // let res = await fetch(`https://swapi.py4e.com/api/people/?search`, { + // signal, + // }); + // let json = await res.json(); + const func = + portal_type === 'Training' ? getRegistrations : getAllRegistrations; + + let registrations = await dispatch(func(pathname, uuid)); + const result = cloneDeep(registrations.registrations.items); + result.forEach((registration) => { + registration.training = registration.training.title; + }); + return { + items: result, + }; + }, + // async getKey(item) { + // debugger; + // return item.uid; + // }, + async sort({ items, sortDescriptor }) { + return { + items: items.sort((a, b) => { + let first = a[sortDescriptor.column]; + let second = b[sortDescriptor.column]; + let cmp = + (parseInt(first) || first) < (parseInt(second) || second) ? -1 : 1; + if (sortDescriptor.direction === 'descending') { + cmp *= -1; + } + return cmp; + }), + }; + }, + }); + return ( <> @@ -148,14 +200,48 @@ const RegistrationsManagement = () => { /> {pageTitle} - + {/* @sneridagh: Commenting the RAC alternative for now */} + {/*
+ + Training + + + Name + + + Date + + + State + + + + {(item) => ( + + {item.training} + {item.user_id} + {item.created} + {item.state} + + )} + +
*/} + + {allTrainings && ( - sortDispatch({ type: 'CHANGE_SORT', column: 'training' }) + sortDispatch({ + type: 'CHANGE_SORT', + column: 'training.title', + }) } > { - sortDispatch({ type: 'CHANGE_SORT', column: 'name' }) + sortDispatch({ type: 'CHANGE_SORT', column: 'user_id' }) } > @@ -189,8 +275,8 @@ const RegistrationsManagement = () => { )} - - + + {isClient && ( { allTrainings={allTrainings} /> )} - - + + {isClient && createPortal( diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index fd17729..7558a88 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -566,7 +566,7 @@ importers: version: 1.0.10 wait-on: specifier: ^7.2.0 - version: 7.2.0(debug@4.3.2) + version: 7.2.0(debug@4.3.4) devDependencies: release-it: specifier: ^16.1.3 @@ -1456,6 +1456,9 @@ importers: react-lazy-load-image-component: specifier: ^1.6.2 version: 1.6.2(react@18.2.0) + react-stately: + specifier: ^3.33.0 + version: 3.33.0(react@18.2.0) semantic-ui-react: specifier: ^2.1.5 version: 2.1.5(react-dom@18.2.0(react@18.2.0))(react@18.2.0) @@ -5587,6 +5590,7 @@ packages: acorn-import-assertions@1.9.0: resolution: {integrity: sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==} + deprecated: package has been renamed to acorn-import-attributes peerDependencies: acorn: ^8 @@ -7906,6 +7910,7 @@ packages: eslint@8.57.0: resolution: {integrity: sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options. hasBin: true esniff@2.0.1: @@ -13515,7 +13520,7 @@ packages: superagent@3.8.2: resolution: {integrity: sha512-gVH4QfYHcY3P0f/BZzavLreHW3T1v7hG9B+hpMQotGQqurOvhv87GcMCd6LWySmBuf+BDR44TQd0aISjVHLeNQ==} engines: {node: '>= 4.0'} - deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net supports-color@2.0.0: resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==} @@ -21098,6 +21103,12 @@ snapshots: axe-core@4.9.1: {} + axios@0.21.4: + dependencies: + follow-redirects: 1.15.6(debug@4.3.4) + transitivePeerDependencies: + - debug + axios@0.21.4(debug@4.3.2): dependencies: follow-redirects: 1.15.6(debug@4.3.2) @@ -24381,7 +24392,7 @@ snapshots: gitly@2.0.3: dependencies: - axios: 0.21.4(debug@4.3.2) + axios: 0.21.4 tar: 6.2.1 transitivePeerDependencies: - debug @@ -25617,7 +25628,11 @@ snapshots: pretty-format: 26.6.2 throat: 5.0.0 transitivePeerDependencies: + - bufferutil + - canvas - supports-color + - ts-node + - utf-8-validate jest-leak-detector@26.6.2: dependencies: @@ -32001,7 +32016,7 @@ snapshots: wait-on@7.2.0: dependencies: - axios: 1.7.2(debug@4.3.2) + axios: 1.7.2(debug@4.3.4) joi: 17.13.3 lodash: 4.17.21 minimist: 1.2.8