From eddfaaf0d7146cad0fbb5fe4518a79bfe4b2ee83 Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Wed, 16 Oct 2024 13:50:47 +0200 Subject: [PATCH] - progress with cerating users form; --- src/helpers/getBandoLabel.js | 3 ++ src/helpers/getBandoSeverity.js | 3 ++ .../components/AppSidebar/index.js | 3 +- src/pages/Registration/index.js | 4 +- .../Users/components/AllUsersTable/index.js | 49 +++++++++++++------ src/pages/Users/index.js | 9 +++- 6 files changed, 50 insertions(+), 21 deletions(-) diff --git a/src/helpers/getBandoLabel.js b/src/helpers/getBandoLabel.js index 585def9..0986759 100644 --- a/src/helpers/getBandoLabel.js +++ b/src/helpers/getBandoLabel.js @@ -2,6 +2,9 @@ import { __ } from '@wordpress/i18n'; const getBandoLabel = (status) => { switch (status) { + case 'ACTIVE': + return __('Attivo', 'gepafin'); + case 'SUBMIT': return __('Inviato', 'gepafin'); diff --git a/src/helpers/getBandoSeverity.js b/src/helpers/getBandoSeverity.js index f0b2dad..72c8421 100644 --- a/src/helpers/getBandoSeverity.js +++ b/src/helpers/getBandoSeverity.js @@ -2,6 +2,9 @@ import { __ } from '@wordpress/i18n'; const getBandoSeverity = (status) => { switch (status) { + case 'ACTIVE': + return 'success'; + case 'SUBMIT': return 'success'; diff --git a/src/layouts/DefaultLayout/components/AppSidebar/index.js b/src/layouts/DefaultLayout/components/AppSidebar/index.js index c7672cf..005dc21 100644 --- a/src/layouts/DefaultLayout/components/AppSidebar/index.js +++ b/src/layouts/DefaultLayout/components/AppSidebar/index.js @@ -52,8 +52,7 @@ const AppSidebar = () => { icon: 'pi pi-users', href: '/utenti', id: 5, - enable: false - //enable: intersection(permissions, ['VIEW_USERS', 'MANAGE_USERS']).length + enable: intersection(permissions, ['VIEW_USERS', 'MANAGE_USERS']).length }, { label: __('Configurazione', 'gepafin'), diff --git a/src/pages/Registration/index.js b/src/pages/Registration/index.js index 8cd123e..eefc3d8 100644 --- a/src/pages/Registration/index.js +++ b/src/pages/Registration/index.js @@ -85,7 +85,7 @@ const Registration = () => { setValue('codiceFiscale', codiceFiscale); setValue('firstName', firstName); setValue('lastName', lastName); - setValue('birthDate', dateOfBirthObj); + setValue('dateOfBirth', dateOfBirthObj); } else { errorMsgs.current.show([ { @@ -199,7 +199,7 @@ const Registration = () => { { const sample = [ { id: 11, - name: 'Mario Rossi', + firstName: 'Mario', + lastName: 'Rossi', email: 'mario.rossi@example.com', - role: 'Beneficiario', - status: 'active', - last_access: '2024-08-01 10:30' + role: { + roleName: 'Beneficiario' + }, + status: 'ACTIVE', + lastLogin: '2024-08-01 10:30' }, { id: 12, - name: 'Mario Rossi2', - email: 'mario.rossi@example.com', - role: 'Beneficiario', - status: 'active', - last_access: '2024-08-01 10:30' + firstName: 'John', + lastName: 'Doe', + email: 'john.doe@example.com', + role: { + roleName: 'Beneficiario' + }, + status: 'ACTIVE', + lastLogin: '2024-08-01 10:30' } ]; setItems(sample); @@ -75,7 +81,7 @@ const AllUsersTable = () => { const getFormattedData = (data) => { return data.map((d) => { - d.last_access = is(String, d.last_access) ? new Date(d.last_access) : (d.last_access ? d.last_access : ''); + d.lastLogin = is(String, d.lastLogin) ? new Date(d.lastLogin) : (d.lastLogin ? d.lastLogin : ''); return d; }); }; @@ -98,7 +104,7 @@ const AllUsersTable = () => { setFilters({ global: { value: null, matchMode: FilterMatchMode.CONTAINS }, name: { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.STARTS_WITH }] }, - last_access: { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }] }, + lastLogin: { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }] }, status: { operator: FilterOperator.OR, constraints: [{ value: null, matchMode: FilterMatchMode.EQUALS }] }, }); setGlobalFilterValue(''); @@ -117,13 +123,21 @@ const AllUsersTable = () => { }; const dateLastAccessBodyTemplate = (rowData) => { - return getDateFromISOstring(rowData.last_access); + return getDateFromISOstring(rowData.lastLogin); }; const dateFilterTemplate = (options) => { return options.filterCallback(e.value, options.index)} dateFormat="mm/dd/yy" placeholder="mm/dd/yyyy" mask="99/99/9999" />; }; + const nameBodyTemplate = (rowData) => { + return `${rowData.firstName} ${rowData.lastName}` + } + + const roleBodyTemplate = (rowData) => { + return rowData.role.roleName; + } + const statusBodyTemplate = (rowData) => { return ; }; @@ -152,16 +166,21 @@ const AllUsersTable = () => { header={header} emptyMessage={__('Nessun dato disponibile', 'gepafin')} onFilter={(e) => setFilters(e.filters)}> - - - { const [isVisibleEditDialog, setIsVisibleEditDialog] = useState(false); @@ -45,7 +46,10 @@ const Users = () => { } const saveEditDialog = () => { - + const emptyValues = Object.values(newUserData).filter(v => isEmpty(v)); + if (isEmpty(emptyValues)) { + console.log(newUserData) + } } const onChangeEditItem = (value, key) => { @@ -129,12 +133,13 @@ const Users = () => {
onChangeEditItem(e.target.value, 'email')}/>
onChangeEditItem(e.target.value, 'phoneNumber')}/>