- progress with cerating users form;
This commit is contained in:
@@ -2,6 +2,9 @@ import { __ } from '@wordpress/i18n';
|
|||||||
|
|
||||||
const getBandoLabel = (status) => {
|
const getBandoLabel = (status) => {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
|
case 'ACTIVE':
|
||||||
|
return __('Attivo', 'gepafin');
|
||||||
|
|
||||||
case 'SUBMIT':
|
case 'SUBMIT':
|
||||||
return __('Inviato', 'gepafin');
|
return __('Inviato', 'gepafin');
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ import { __ } from '@wordpress/i18n';
|
|||||||
|
|
||||||
const getBandoSeverity = (status) => {
|
const getBandoSeverity = (status) => {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
|
case 'ACTIVE':
|
||||||
|
return 'success';
|
||||||
|
|
||||||
case 'SUBMIT':
|
case 'SUBMIT':
|
||||||
return 'success';
|
return 'success';
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,7 @@ const AppSidebar = () => {
|
|||||||
icon: 'pi pi-users',
|
icon: 'pi pi-users',
|
||||||
href: '/utenti',
|
href: '/utenti',
|
||||||
id: 5,
|
id: 5,
|
||||||
enable: false
|
enable: intersection(permissions, ['VIEW_USERS', 'MANAGE_USERS']).length
|
||||||
//enable: intersection(permissions, ['VIEW_USERS', 'MANAGE_USERS']).length
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: __('Configurazione', 'gepafin'),
|
label: __('Configurazione', 'gepafin'),
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ const Registration = () => {
|
|||||||
setValue('codiceFiscale', codiceFiscale);
|
setValue('codiceFiscale', codiceFiscale);
|
||||||
setValue('firstName', firstName);
|
setValue('firstName', firstName);
|
||||||
setValue('lastName', lastName);
|
setValue('lastName', lastName);
|
||||||
setValue('birthDate', dateOfBirthObj);
|
setValue('dateOfBirth', dateOfBirthObj);
|
||||||
} else {
|
} else {
|
||||||
errorMsgs.current.show([
|
errorMsgs.current.show([
|
||||||
{
|
{
|
||||||
@@ -199,7 +199,7 @@ const Registration = () => {
|
|||||||
<FormField
|
<FormField
|
||||||
type="datepicker"
|
type="datepicker"
|
||||||
disabled={true}
|
disabled={true}
|
||||||
fieldName="birthDate"
|
fieldName="dateOfBirth"
|
||||||
label={__('Data di nascita', 'gepafin')}
|
label={__('Data di nascita', 'gepafin')}
|
||||||
control={control}
|
control={control}
|
||||||
errors={errors}
|
errors={errors}
|
||||||
|
|||||||
@@ -40,19 +40,25 @@ const AllUsersTable = () => {
|
|||||||
const sample = [
|
const sample = [
|
||||||
{
|
{
|
||||||
id: 11,
|
id: 11,
|
||||||
name: 'Mario Rossi',
|
firstName: 'Mario',
|
||||||
|
lastName: 'Rossi',
|
||||||
email: 'mario.rossi@example.com',
|
email: 'mario.rossi@example.com',
|
||||||
role: 'Beneficiario',
|
role: {
|
||||||
status: 'active',
|
roleName: 'Beneficiario'
|
||||||
last_access: '2024-08-01 10:30'
|
},
|
||||||
|
status: 'ACTIVE',
|
||||||
|
lastLogin: '2024-08-01 10:30'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 12,
|
id: 12,
|
||||||
name: 'Mario Rossi2',
|
firstName: 'John',
|
||||||
email: 'mario.rossi@example.com',
|
lastName: 'Doe',
|
||||||
role: 'Beneficiario',
|
email: 'john.doe@example.com',
|
||||||
status: 'active',
|
role: {
|
||||||
last_access: '2024-08-01 10:30'
|
roleName: 'Beneficiario'
|
||||||
|
},
|
||||||
|
status: 'ACTIVE',
|
||||||
|
lastLogin: '2024-08-01 10:30'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
setItems(sample);
|
setItems(sample);
|
||||||
@@ -75,7 +81,7 @@ const AllUsersTable = () => {
|
|||||||
|
|
||||||
const getFormattedData = (data) => {
|
const getFormattedData = (data) => {
|
||||||
return data.map((d) => {
|
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;
|
return d;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -98,7 +104,7 @@ const AllUsersTable = () => {
|
|||||||
setFilters({
|
setFilters({
|
||||||
global: { value: null, matchMode: FilterMatchMode.CONTAINS },
|
global: { value: null, matchMode: FilterMatchMode.CONTAINS },
|
||||||
name: { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.STARTS_WITH }] },
|
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 }] },
|
status: { operator: FilterOperator.OR, constraints: [{ value: null, matchMode: FilterMatchMode.EQUALS }] },
|
||||||
});
|
});
|
||||||
setGlobalFilterValue('');
|
setGlobalFilterValue('');
|
||||||
@@ -117,13 +123,21 @@ const AllUsersTable = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const dateLastAccessBodyTemplate = (rowData) => {
|
const dateLastAccessBodyTemplate = (rowData) => {
|
||||||
return getDateFromISOstring(rowData.last_access);
|
return getDateFromISOstring(rowData.lastLogin);
|
||||||
};
|
};
|
||||||
|
|
||||||
const dateFilterTemplate = (options) => {
|
const dateFilterTemplate = (options) => {
|
||||||
return <Calendar value={options.value} onChange={(e) => options.filterCallback(e.value, options.index)} dateFormat="mm/dd/yy" placeholder="mm/dd/yyyy" mask="99/99/9999" />;
|
return <Calendar value={options.value} onChange={(e) => 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) => {
|
const statusBodyTemplate = (rowData) => {
|
||||||
return <ProperBandoLabel status={rowData.status}/>;
|
return <ProperBandoLabel status={rowData.status}/>;
|
||||||
};
|
};
|
||||||
@@ -152,16 +166,21 @@ const AllUsersTable = () => {
|
|||||||
header={header}
|
header={header}
|
||||||
emptyMessage={__('Nessun dato disponibile', 'gepafin')}
|
emptyMessage={__('Nessun dato disponibile', 'gepafin')}
|
||||||
onFilter={(e) => setFilters(e.filters)}>
|
onFilter={(e) => setFilters(e.filters)}>
|
||||||
<Column field="name" header={__('Nome utente', 'gepafin')} filter filterPlaceholder={__('Cerca il nome', 'gepafin')}
|
<Column field="name" header={__('Nome utente', 'gepafin')}
|
||||||
|
body={nameBodyTemplate}
|
||||||
|
filter filterPlaceholder={__('Cerca il nome', 'gepafin')}
|
||||||
style={{ minWidth: '12rem' }}/>
|
style={{ minWidth: '12rem' }}/>
|
||||||
<Column field="email" header={__('Email', 'gepafin')} filter filterPlaceholder="Search by email"
|
<Column field="email" header={__('Email', 'gepafin')}
|
||||||
|
filter filterPlaceholder="Search by email"
|
||||||
style={{ minWidth: '12rem' }}/>
|
style={{ minWidth: '12rem' }}/>
|
||||||
<Column field="role" header={__('Ruolo', 'gepafin')}
|
<Column field="role" header={__('Ruolo', 'gepafin')}
|
||||||
|
body={roleBodyTemplate}
|
||||||
style={{ minWidth: '12rem' }}/>
|
style={{ minWidth: '12rem' }}/>
|
||||||
<Column field="status" header={__('Stato', 'gepafin')} filterMenuStyle={{ width: '14rem' }}
|
<Column field="status" header={__('Stato', 'gepafin')} filterMenuStyle={{ width: '14rem' }}
|
||||||
style={{ width: '120px' }} body={statusBodyTemplate} filter
|
style={{ width: '120px' }} body={statusBodyTemplate} filter
|
||||||
filterElement={statusFilterTemplate}/>
|
filterElement={statusFilterTemplate}/>
|
||||||
<Column header={__('Ultimo accesso', 'gepafin')} filterField="last_access" dataType="date"
|
<Column header={__('Ultimo accesso', 'gepafin')} filterField="lastLogin"
|
||||||
|
dataType="date"
|
||||||
style={{ minWidth: '10rem' }}
|
style={{ minWidth: '10rem' }}
|
||||||
body={dateLastAccessBodyTemplate} filter filterElement={dateFilterTemplate}/>
|
body={dateLastAccessBodyTemplate} filter filterElement={dateFilterTemplate}/>
|
||||||
<Column header={__('Azioni', 'gepafin')}
|
<Column header={__('Azioni', 'gepafin')}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
|||||||
import { storeSet } from '../../store';
|
import { storeSet } from '../../store';
|
||||||
import { klona } from 'klona';
|
import { klona } from 'klona';
|
||||||
import { classNames } from 'primereact/utils';
|
import { classNames } from 'primereact/utils';
|
||||||
|
import { isEmail } from '../../helpers/validators';
|
||||||
|
|
||||||
const Users = () => {
|
const Users = () => {
|
||||||
const [isVisibleEditDialog, setIsVisibleEditDialog] = useState(false);
|
const [isVisibleEditDialog, setIsVisibleEditDialog] = useState(false);
|
||||||
@@ -45,7 +46,10 @@ const Users = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const saveEditDialog = () => {
|
const saveEditDialog = () => {
|
||||||
|
const emptyValues = Object.values(newUserData).filter(v => isEmpty(v));
|
||||||
|
if (isEmpty(emptyValues)) {
|
||||||
|
console.log(newUserData)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onChangeEditItem = (value, key) => {
|
const onChangeEditItem = (value, key) => {
|
||||||
@@ -129,12 +133,13 @@ const Users = () => {
|
|||||||
<div className="appForm__field">
|
<div className="appForm__field">
|
||||||
<label className={classNames({ 'p-error': isEmpty(newUserData.email) || isNil(newUserData.email) })}>{__('Email', 'gepafin')}*</label>
|
<label className={classNames({ 'p-error': isEmpty(newUserData.email) || isNil(newUserData.email) })}>{__('Email', 'gepafin')}*</label>
|
||||||
<InputText value={newUserData.email}
|
<InputText value={newUserData.email}
|
||||||
invalid={isEmpty(newUserData.email) || isNil(newUserData.email)}
|
invalid={isEmpty(newUserData.email) || isNil(newUserData.email) || !isEmail(newUserData.email)}
|
||||||
onChange={(e) => onChangeEditItem(e.target.value, 'email')}/>
|
onChange={(e) => onChangeEditItem(e.target.value, 'email')}/>
|
||||||
</div>
|
</div>
|
||||||
<div className="appForm__field">
|
<div className="appForm__field">
|
||||||
<label className={classNames({ 'p-error': isEmpty(newUserData.phoneNumber) || isNil(newUserData.phoneNumber) })}>{__('Telefono', 'gepafin')}</label>
|
<label className={classNames({ 'p-error': isEmpty(newUserData.phoneNumber) || isNil(newUserData.phoneNumber) })}>{__('Telefono', 'gepafin')}</label>
|
||||||
<InputText value={newUserData.phoneNumber}
|
<InputText value={newUserData.phoneNumber}
|
||||||
|
keyfilter="int"
|
||||||
invalid={isEmpty(newUserData.phoneNumber) || isNil(newUserData.phoneNumber)}
|
invalid={isEmpty(newUserData.phoneNumber) || isNil(newUserData.phoneNumber)}
|
||||||
onChange={(e) => onChangeEditItem(e.target.value, 'phoneNumber')}/>
|
onChange={(e) => onChangeEditItem(e.target.value, 'phoneNumber')}/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user