- fixed freezing form;
This commit is contained in:
@@ -1,10 +1,30 @@
|
|||||||
import React from 'react';
|
import React, { useMemo } 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, isEmpty } from 'ramda';
|
import { is, isEmpty } from 'ramda';
|
||||||
|
|
||||||
import { Calendar } from 'primereact/calendar';
|
import { Calendar } from 'primereact/calendar';
|
||||||
|
|
||||||
|
const DatepickerField = ({ field, fieldState, disabled, timeOnly, minDate, maxDate }) => {
|
||||||
|
const dateValue = useMemo(
|
||||||
|
() => is(String, field.value) && !isEmpty(field.value) ? new Date(field.value) : field.value,
|
||||||
|
[field.value]
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<Calendar id={field.name}
|
||||||
|
disabled={disabled}
|
||||||
|
value={dateValue}
|
||||||
|
onChange={(e) => field.onChange(e.value)}
|
||||||
|
dateFormat="dd/mm/yy"
|
||||||
|
hourFormat="24"
|
||||||
|
timeOnly={timeOnly}
|
||||||
|
showIcon
|
||||||
|
minDate={minDate}
|
||||||
|
maxDate={maxDate}
|
||||||
|
className={classNames({ 'p-invalid': fieldState.invalid })}/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const Datepicker = ({
|
const Datepicker = ({
|
||||||
fieldName,
|
fieldName,
|
||||||
label,
|
label,
|
||||||
@@ -28,17 +48,15 @@ const Datepicker = ({
|
|||||||
control={control}
|
control={control}
|
||||||
defaultValue={defaultValue}
|
defaultValue={defaultValue}
|
||||||
rules={config}
|
rules={config}
|
||||||
render={({ field, fieldState }) => (<Calendar id={field.name}
|
render={({ field, fieldState }) => (
|
||||||
disabled={disabled}
|
<DatepickerField
|
||||||
value={is(String, field.value) && !isEmpty(field.value) ? new Date(field.value) : field.value}
|
field={field}
|
||||||
onChange={(e) => field.onChange(e.value)}
|
fieldState={fieldState}
|
||||||
dateFormat="dd/mm/yy"
|
disabled={disabled}
|
||||||
hourFormat="24"
|
timeOnly={timeOnly}
|
||||||
timeOnly={timeOnly}
|
minDate={minDate}
|
||||||
showIcon
|
maxDate={maxDate}
|
||||||
minDate={minDate}
|
/>
|
||||||
maxDate={maxDate}
|
|
||||||
className={classNames({ 'p-invalid': fieldState.invalid })}/>
|
|
||||||
)}/>
|
)}/>
|
||||||
{infoText ? <small>{infoText}</small> : null}
|
{infoText ? <small>{infoText}</small> : null}
|
||||||
</>)
|
</>)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { classNames } from 'primereact/utils';
|
import { classNames } from 'primereact/utils';
|
||||||
import { isNil } from 'ramda';
|
import { isNil } from 'ramda';
|
||||||
|
|
||||||
@@ -18,9 +18,12 @@ const DatepickerRange = ({
|
|||||||
maxDate = null,
|
maxDate = null,
|
||||||
disabled = false
|
disabled = false
|
||||||
}) => {
|
}) => {
|
||||||
const datesDefaultValue = !isNil(defaultValue) && defaultValue.length
|
const datesDefaultValue = useMemo(
|
||||||
? defaultValue.map(v => new Date(v))
|
() => !isNil(defaultValue) && defaultValue.length
|
||||||
: [];
|
? defaultValue.map(v => new Date(v))
|
||||||
|
: [],
|
||||||
|
[defaultValue]
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<label htmlFor={fieldName} className={classNames({ 'p-error': errors[fieldName] })}>
|
<label htmlFor={fieldName} className={classNames({ 'p-error': errors[fieldName] })}>
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ const NumberInput = ({
|
|||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
value={is(Number, field.value) || (!is(Number, field.value) && !isNaN(parseFloat(field.value))) ? field.value : ''}
|
value={is(Number, field.value) || (!is(Number, field.value) && !isNaN(parseFloat(field.value))) ? field.value : ''}
|
||||||
onValueChange={(e) => field.onChange(e.value)}
|
onValueChange={(e) => field.onChange(e.value)}
|
||||||
min={minAttr}
|
min={readOnly ? undefined : minAttr}
|
||||||
max={maxAttr}
|
max={readOnly ? undefined : maxAttr}
|
||||||
mode="decimal"
|
mode="decimal"
|
||||||
locale={locale}
|
locale={locale}
|
||||||
showButtons
|
showButtons
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ const BandoApplication = () => {
|
|||||||
const values = getValues();
|
const values = getValues();
|
||||||
const formValues = watch();
|
const formValues = watch();
|
||||||
|
|
||||||
|
|
||||||
const onValidate = () => {
|
const onValidate = () => {
|
||||||
saveDraft('VALIDATE');
|
saveDraft('VALIDATE');
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useCallback, useEffect, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { classNames } from 'primereact/utils';
|
import { classNames } from 'primereact/utils';
|
||||||
import { wrap } from 'object-path-immutable';
|
import { wrap } from 'object-path-immutable';
|
||||||
@@ -32,9 +32,11 @@ const DocumentsBeneficiary = () => {
|
|||||||
const [newFileData, setNewFileData] = useState({});
|
const [newFileData, setNewFileData] = useState({});
|
||||||
const [fileAttached, setFileAttached] = useState([]);
|
const [fileAttached, setFileAttached] = useState([]);
|
||||||
const [reloadHash, setReloadHash] = useState(0);
|
const [reloadHash, setReloadHash] = useState(0);
|
||||||
const today = new Date();
|
const tomorrow = useMemo(() => {
|
||||||
const tomorrow = new Date(today);
|
const d = new Date();
|
||||||
tomorrow.setDate(today.getDate() + 1);
|
d.setDate(d.getDate() + 1);
|
||||||
|
return d;
|
||||||
|
}, []);
|
||||||
const company = head(companies.filter(o => o.id === chosenCompanyId));
|
const company = head(companies.filter(o => o.id === chosenCompanyId));
|
||||||
|
|
||||||
const onCreateNew = useCallback((type) => {
|
const onCreateNew = useCallback((type) => {
|
||||||
|
|||||||
@@ -49,9 +49,11 @@ const EvaluationExtraFiles = ({
|
|||||||
const [addDocLoading, setAddDocLoading] = useState(false);
|
const [addDocLoading, setAddDocLoading] = useState(false);
|
||||||
const [reloadHash, setReloadHash] = useState(0);
|
const [reloadHash, setReloadHash] = useState(0);
|
||||||
const toast = useRef(null);
|
const toast = useRef(null);
|
||||||
const today = new Date();
|
const tomorrow = useMemo(() => {
|
||||||
const tomorrow = new Date(today);
|
const d = new Date();
|
||||||
tomorrow.setDate(today.getDate() + 1);
|
d.setDate(d.getDate() + 1);
|
||||||
|
return d;
|
||||||
|
}, []);
|
||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
|
|||||||
Reference in New Issue
Block a user