- fixed displaying data in table form field;

- updated labels for fileupload fields;
This commit is contained in:
Vitalii Kiiko
2024-10-10 17:26:29 +02:00
parent f23de10ab8
commit 8fb1551880
6 changed files with 26 additions and 13 deletions

View File

@@ -4,11 +4,13 @@ import Routes from './routes';
import { createI18n, setLocaleData } from '@wordpress/i18n';
import { I18nProvider } from '@wordpress/react-i18n';
import './assets/scss/theme.scss';
import AuthenticationService from './service/authentication-service';
import { isEmpty } from 'ramda'
// store
import { useStore, storeSet, storeGet } from './store';
import CompanyService from './service/company-service';
// api
import AuthenticationService from './service/authentication-service';
const i18n = createI18n({}, 'gepafin');
@@ -32,7 +34,7 @@ function App() {
useEffect(() => {
if (role === 'ROLE_BENEFICIARY') {
const userData = storeGet.main.userData();
if (userData.companies) {
if (userData.companies && !isEmpty(userData.companies)) {
storeSet.main.companies(userData.companies);
}
}

View File

@@ -17,6 +17,8 @@ const FileuploadDelega = ({
maxSize = 100000000,
emptyText = __('Trascina qui il tuo file', 'gepafin'),
chooseLabel = __('Aggiungi delega', 'gepafin'),
uploadLabel = __('Salva documento', 'gepafin'),
cancelLabel = __('Cancella documento', 'gepafin'),
multiple = false,
companyId = 0,
disabled = false
@@ -163,8 +165,8 @@ const FileuploadDelega = ({
maxFileSize={maxSize}
emptyTemplate={<p>{emptyText}</p>}
chooseLabel={chooseLabel}
cancelLabel={__('Cancella', 'gepafin')}
uploadLabel={__('Carica', 'gepafin')}
cancelLabel={cancelLabel}
uploadLabel={uploadLabel}
itemTemplate={itemTemplate}
customUpload
onBeforeDrop={onBeforeDrop}

View File

@@ -26,11 +26,14 @@ const Fileupload = ({
maxSize = 100000000,
emptyText = __('Trascina qui il tuo file', 'gepafin'),
chooseLabel = __('Aggiungi file', 'gepafin'),
uploadLabel = __('Salva documento', 'gepafin'),
cancelLabel = __('Cancella documento', 'gepafin'),
multiple = false,
sourceId = 0,
source = 'application',
disabled = false,
saveFormCallback = () => {}
saveFormCallback = () => {
}
}) => {
const [stateFieldData, setStateFieldData] = useState([]);
const [acceptFormats, setAcceptFormats] = useState('');
@@ -191,8 +194,8 @@ const Fileupload = ({
maxFileSize={maxSize}
emptyTemplate={<p>{emptyText}</p>}
chooseLabel={chooseLabel}
cancelLabel={__('Cancella', 'gepafin')}
uploadLabel={__('Carica', 'gepafin')}
cancelLabel={cancelLabel}
uploadLabel={uploadLabel}
className={classNames({ 'p-invalid': errors[fieldName] })}
itemTemplate={itemTemplate}
customUpload

View File

@@ -40,6 +40,11 @@ const Table = ({
rowRowIndexToDelete(index);
}
const updateRows = (data) => {
setRows(data);
setDataFn(fieldName, data, { shouldValidate: true });
}
useEffect(() => {
if (!isNil(rowIndexToDelete)) {
const newRowsData = wrap(rows).del([rowIndexToDelete]).value();
@@ -49,11 +54,6 @@ const Table = ({
rowRowIndexToDelete(null);
}, [rowIndexToDelete]);
const updateRows = (data) => {
setRows(data);
setDataFn(fieldName, data, { shouldValidate: true });
}
useEffect(() => {
let shouldDisableNewRows = false;
@@ -110,6 +110,10 @@ const Table = ({
setRowsCfg(rowsData);
}, [tableColumns]);
useEffect(() => {
setRows(defaultValue)
}, [defaultValue]);
useEffect(() => {
register(fieldName, config);
}, []);

View File

@@ -5,6 +5,7 @@ import { Navigate, Outlet } from 'react-router-dom';
import AuthenticationService from '../../service/authentication-service';
const ProtectedRoute = () => {
if (!AuthenticationService.wasLoggedIn()) {
return (<Navigate to={'/login'} replace/>);
}

View File

@@ -460,6 +460,7 @@ const ProfileCompany = () => {
<label htmlFor="delega">
{__('Carica documento Delega Firmato', 'gepafin')}
<span className="appForm__field--required">*</span>
(.p7m)
</label>
<FileuploadDelega
setDataFn={setDelegaFile}