- saving;
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { classNames } from 'primereact/utils';
|
||||
|
||||
// components
|
||||
@@ -15,43 +15,96 @@ const FileSelect = ({
|
||||
config = {},
|
||||
infoText = null,
|
||||
disabled = false,
|
||||
|
||||
options = []
|
||||
}) => {
|
||||
const [stateFieldData, setStateFieldData] = useState([]);
|
||||
const [selectedUnconfirmed, setSelectedUnconfirmed] = useState(null);
|
||||
const cities = [
|
||||
{
|
||||
label: 'Germany',
|
||||
code: 'DE',
|
||||
label: 'Company files',
|
||||
code: 'company-files',
|
||||
items: [
|
||||
{ label: 'Berlin', value: 'berlin' },
|
||||
{ label: 'Frankfurt', value: 'frankfurt' },
|
||||
{ label: 'Hamburg', value: 'hamburg' },
|
||||
{ label: 'Munich', value: 'munich' }
|
||||
{
|
||||
'id': 589,
|
||||
'name': 'pdf-3-test.pdf',
|
||||
'filePath': 'https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/staging/call/%2Fapplication/%2Fpdf-1-test_8432561.pdf',
|
||||
'type': 'DOCUMENT',
|
||||
'source': 'APPLICATION',
|
||||
'sourceId': 0,
|
||||
'createdDate': '2025-02-21T15:33:52.767089176',
|
||||
'updatedDate': '2025-02-21T15:33:52.767109885',
|
||||
'documentAttachmentId': null
|
||||
},
|
||||
{
|
||||
'id': 569,
|
||||
'name': 'pdf-2-test.pdf',
|
||||
'filePath': 'https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/staging/call/%2Fapplication/%2Fpdf-1-test_8432561.pdf',
|
||||
'type': 'DOCUMENT',
|
||||
'source': 'APPLICATION',
|
||||
'sourceId': 0,
|
||||
'createdDate': '2025-02-21T15:33:52.767089176',
|
||||
'updatedDate': '2025-02-21T15:33:52.767109885',
|
||||
'documentAttachmentId': null
|
||||
},
|
||||
{
|
||||
'id': 519,
|
||||
'name': 'pdf-1-test.pdf',
|
||||
'filePath': 'https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/staging/call/%2Fapplication/%2Fpdf-1-test_8432561.pdf',
|
||||
'type': 'DOCUMENT',
|
||||
'source': 'APPLICATION',
|
||||
'sourceId': 0,
|
||||
'createdDate': '2025-02-21T15:33:52.767089176',
|
||||
'updatedDate': '2025-02-21T15:33:52.767109885',
|
||||
'documentAttachmentId': null
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'USA',
|
||||
code: 'US',
|
||||
label: 'Personal files',
|
||||
code: 'personal-files',
|
||||
items: [
|
||||
{ label: 'Chicago', value: 'chicago' },
|
||||
{ label: 'Los Angeles', value: 'los Angeles' },
|
||||
{ label: 'New York', value: 'New York' },
|
||||
{ label: 'San Francisco', value: 'San Francisco' }
|
||||
]
|
||||
{
|
||||
'id': 179,
|
||||
'name': 'pdf-13-test.pdf',
|
||||
'filePath': 'https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/staging/call/%2Fapplication/%2Fpdf-1-test_8432561.pdf',
|
||||
'type': 'DOCUMENT',
|
||||
'source': 'APPLICATION',
|
||||
'sourceId': 0,
|
||||
'createdDate': '2025-02-21T15:33:52.767089176',
|
||||
'updatedDate': '2025-02-21T15:33:52.767109885',
|
||||
'documentAttachmentId': null
|
||||
},
|
||||
{
|
||||
label: 'Japan',
|
||||
code: 'JP',
|
||||
items: [
|
||||
{ label: 'Kyoto', value: 'Kyoto' },
|
||||
{ label: 'Osaka', value: 'Osaka' },
|
||||
{ label: 'Tokyo', value: 'Tokyo' },
|
||||
{ label: 'Yokohama', value: 'Yokohama' }
|
||||
'id': 169,
|
||||
'name': 'pdf-12-test.pdf',
|
||||
'filePath': 'https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/staging/call/%2Fapplication/%2Fpdf-1-test_8432561.pdf',
|
||||
'type': 'DOCUMENT',
|
||||
'source': 'APPLICATION',
|
||||
'sourceId': 0,
|
||||
'createdDate': '2025-02-21T15:33:52.767089176',
|
||||
'updatedDate': '2025-02-21T15:33:52.767109885',
|
||||
'documentAttachmentId': null
|
||||
},
|
||||
{
|
||||
'id': 129,
|
||||
'name': 'pdf-11-test.pdf',
|
||||
'filePath': 'https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/staging/call/%2Fapplication/%2Fpdf-1-test_8432561.pdf',
|
||||
'type': 'DOCUMENT',
|
||||
'source': 'APPLICATION',
|
||||
'sourceId': 0,
|
||||
'createdDate': '2025-02-21T15:33:52.767089176',
|
||||
'updatedDate': '2025-02-21T15:33:52.767109885',
|
||||
'documentAttachmentId': null
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
const attachSelectedFiles = useCallback(() => {
|
||||
setStateFieldData([...stateFieldData, ...selectedUnconfirmed]);
|
||||
setSelectedUnconfirmed([]);
|
||||
}, [selectedUnconfirmed, stateFieldData])
|
||||
|
||||
useEffect(() => {
|
||||
console.log('selectedUnconfirmed', selectedUnconfirmed)
|
||||
}, [selectedUnconfirmed]);
|
||||
@@ -68,25 +121,30 @@ const FileSelect = ({
|
||||
return (
|
||||
<>
|
||||
<label htmlFor={fieldName} className={classNames({ 'p-error': errors[fieldName] })}>
|
||||
{label}{config.required || config.isRequired ? <span className="appForm__field--required">*</span> : null}
|
||||
{label}{config.required || config.isRequired ?
|
||||
<span className="appForm__field--required">*</span> : null}
|
||||
</label>
|
||||
<div className="fileselectInner">
|
||||
<ListBox multiple
|
||||
value={selectedUnconfirmed}
|
||||
onChange={(e) => setSelectedUnconfirmed(e.value)}
|
||||
options={cities}
|
||||
optionLabel="label"
|
||||
optionLabel="name"
|
||||
optionGroupLabel="label"
|
||||
optionGroupChildren="items"
|
||||
className="w-full md:w-14rem"
|
||||
listStyle={{ maxHeight: '130px' }} />
|
||||
listStyle={{ maxHeight: '130px' }}/>
|
||||
<div className="fileselectInner__selectedFiles">
|
||||
<Button
|
||||
severity="success"
|
||||
label={__('Conferma selezionati', 'gepafin')} icon="pi pi-plus" size="small" iconPos="right" />
|
||||
onClick={attachSelectedFiles}
|
||||
label={__('Conferma selezionati', 'gepafin')}
|
||||
icon="pi pi-plus" size="small" iconPos="right"/>
|
||||
<p>{__('Selezionati')}</p>
|
||||
<ul>
|
||||
|
||||
{[...stateFieldData].map(o => <li key={o.id}>
|
||||
{o.name}
|
||||
</li>)}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user