- updates;
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React from 'react';
|
||||||
import { classNames } from 'primereact/utils';
|
import { classNames } from 'primereact/utils';
|
||||||
import { Controller } from 'react-hook-form';
|
import { Controller } from 'react-hook-form';
|
||||||
import { is } from 'ramda';
|
import { is } from 'ramda';
|
||||||
@@ -18,6 +18,7 @@ const Datepicker = ({
|
|||||||
disabled = false,
|
disabled = false,
|
||||||
timeOnly = false
|
timeOnly = false
|
||||||
}) => {
|
}) => {
|
||||||
|
console.log('defaultValue', defaultValue)
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<label htmlFor={fieldName} className={classNames({ 'p-error': errors[fieldName] })}>
|
<label htmlFor={fieldName} className={classNames({ 'p-error': errors[fieldName] })}>
|
||||||
@@ -31,7 +32,7 @@ const Datepicker = ({
|
|||||||
render={({ field, fieldState }) => (
|
render={({ field, fieldState }) => (
|
||||||
<Calendar id={field.name}
|
<Calendar id={field.name}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
value={is(String, field.value) ? new Date(field.value) : field.value}
|
value={is(Date, field.value) ? field.value : null}
|
||||||
onChange={(e) => field.onChange(e.value)}
|
onChange={(e) => field.onChange(e.value)}
|
||||||
dateFormat="dd/mm/yy"
|
dateFormat="dd/mm/yy"
|
||||||
hourFormat="24"
|
hourFormat="24"
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
||||||
import { __, sprintf } from '@wordpress/i18n';
|
import { __, sprintf } from '@wordpress/i18n';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { head, is, pluck, isEmpty } from 'ramda';
|
import { head, is, pluck, isEmpty, pathOr } from 'ramda';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { TZDate } from '@date-fns/tz';
|
import { TZDate } from '@date-fns/tz';
|
||||||
|
import { klona } from 'klona';
|
||||||
|
|
||||||
// store
|
// store
|
||||||
import { storeSet, useStore } from '../../store';
|
import { storeSet, storeGet, useStore } from '../../store';
|
||||||
|
|
||||||
// api
|
// api
|
||||||
import ApplicationService from '../../service/application-service';
|
import ApplicationService from '../../service/application-service';
|
||||||
@@ -266,18 +267,62 @@ const BandoApplication = () => {
|
|||||||
setApplicationStatus(data.data.applicationStatus)
|
setApplicationStatus(data.data.applicationStatus)
|
||||||
setActiveStep(data.data.currentStep);
|
setActiveStep(data.data.currentStep);
|
||||||
|
|
||||||
|
const chosenCompanyId = storeGet.main.chosenCompanyId();
|
||||||
|
const companies = storeGet.main.companies();
|
||||||
|
const company = head(companies.filter(o => o.id === chosenCompanyId));
|
||||||
|
let formDataInitial = {};
|
||||||
|
let dynamicData = {
|
||||||
|
company: {},
|
||||||
|
user: {}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (company) {
|
||||||
|
dynamicData = Object.keys(company).reduce((acc, cur) => {
|
||||||
|
if ([
|
||||||
|
'companyName', 'vatNumber', 'codiceFiscale', 'address', 'phoneNumber',
|
||||||
|
'city', 'province', 'cap', 'country', 'pec', 'email', 'contactName', 'contactEmail'
|
||||||
|
].includes(cur)) {
|
||||||
|
acc.company[cur] = company[cur];
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, dynamicData);
|
||||||
|
}
|
||||||
|
|
||||||
|
const userData = storeGet.main.userData();
|
||||||
|
Object.keys(userData).reduce((acc, cur) => {
|
||||||
|
if ([
|
||||||
|
'email', 'firstName', 'lastName', 'phoneNumber', 'codiceFiscale'
|
||||||
|
].includes(cur)) {
|
||||||
|
acc.user[cur] = userData[cur];
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, dynamicData);
|
||||||
|
|
||||||
|
if (data.data.applicationFormResponse.content) {
|
||||||
|
data.data.applicationFormResponse.content.map((o) => {
|
||||||
|
if (o.dynamicData && !isEmpty(o.dynamicData)) {
|
||||||
|
formDataInitial[o.id] = pathOr('', o.dynamicData.split('.'), dynamicData);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
console.log('formDataInitial1', klona(formDataInitial));
|
||||||
|
|
||||||
if (data.data.applicationFormResponse.formFields) {
|
if (data.data.applicationFormResponse.formFields) {
|
||||||
const submitData = data.data.applicationFormResponse.formFields.map((o) => ({
|
const submitData = data.data.applicationFormResponse.formFields.map((o) => ({
|
||||||
fieldId: o.fieldId,
|
fieldId: o.fieldId,
|
||||||
fieldValue: o.fieldValue
|
fieldValue: o.fieldValue
|
||||||
}));
|
}));
|
||||||
const formDataInitial = submitData.reduce((acc, cur) => {
|
formDataInitial = submitData.reduce((acc, cur) => {
|
||||||
acc[cur.fieldId] = cur.fieldValue;
|
if (cur.fieldValue) {
|
||||||
|
acc[cur.fieldId] = cur.fieldValue;
|
||||||
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, formDataInitial);
|
||||||
reset();
|
|
||||||
setFormInitialData(formDataInitial);
|
|
||||||
}
|
}
|
||||||
|
console.log('formDataInitial2', klona(formDataInitial));
|
||||||
|
|
||||||
|
reset();
|
||||||
|
setFormInitialData(formDataInitial);
|
||||||
}
|
}
|
||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
@@ -369,8 +414,7 @@ const BandoApplication = () => {
|
|||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
const errSignedPdfCallbacks = (data) => {
|
const errSignedPdfCallbacks = () => {
|
||||||
//set404FromErrorResponse(data);
|
|
||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,9 +114,9 @@ const LoginAdmin = () => {
|
|||||||
label={__('Accedi', 'gepafin')}
|
label={__('Accedi', 'gepafin')}
|
||||||
disabled={loading}/>
|
disabled={loading}/>
|
||||||
|
|
||||||
{/*<Button
|
<Button
|
||||||
label={__('Password dimenticata?', 'gepafin')}
|
label={__('Password dimenticata?', 'gepafin')}
|
||||||
link onClick={gotToResetPassword}/>*/}
|
link onClick={gotToResetPassword}/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user