:
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import React from 'react';
|
||||
import { classNames } from 'primereact/utils';
|
||||
import { isEmpty, isNil } from 'ramda';
|
||||
|
||||
// components
|
||||
import { Controller } from 'react-hook-form';
|
||||
import { isNil } from 'ramda';
|
||||
import { Calendar } from 'primereact/calendar';
|
||||
|
||||
const DatepickerRange = ({
|
||||
@@ -15,6 +17,7 @@ const DatepickerRange = ({
|
||||
minDate = null,
|
||||
maxDate = null
|
||||
}) => {
|
||||
const datesDefaultValue = !isNil(defaultValue) && !isEmpty(defaultValue) && defaultValue.length ? defaultValue.map(v => new Date(v)) : [];
|
||||
return (
|
||||
<>
|
||||
<label htmlFor={fieldName} className={classNames({ 'p-error': errors[fieldName] })}>
|
||||
@@ -23,16 +26,24 @@ const DatepickerRange = ({
|
||||
<Controller
|
||||
name={fieldName}
|
||||
control={control}
|
||||
defaultValue={defaultValue}
|
||||
defaultValue={datesDefaultValue}
|
||||
rules={config}
|
||||
render={({ field, fieldState }) => (
|
||||
<Calendar id={field.name}
|
||||
value={field.value}
|
||||
onChange={(e) => field.onChange(e.value)}
|
||||
dateFormat="dd/mm/yy" mask="99/99/9999"
|
||||
onChange={(e) => {
|
||||
const formattedValues = e.value.map(d => d ? d.toISOString() : d);
|
||||
console.log('formattedValues', formattedValues);
|
||||
field.onChange(formattedValues)
|
||||
}}
|
||||
dateFormat="dd/mm/yy"
|
||||
mask="99/99/9999"
|
||||
showIcon
|
||||
minDate={minDate} maxDate={maxDate}
|
||||
selectionMode="range" readOnlyInput hideOnRangeSelection
|
||||
minDate={minDate}
|
||||
maxDate={maxDate}
|
||||
selectionMode="range"
|
||||
readOnlyInput
|
||||
hideOnRangeSelection
|
||||
className={classNames({ 'p-invalid': fieldState.invalid })}/>
|
||||
)}/>
|
||||
{infoText ? <small>{infoText}</small> : null}
|
||||
|
||||
@@ -15,7 +15,8 @@ const Fileupload = ({
|
||||
accept = 'image/*',
|
||||
api = '/api/upload',
|
||||
emptyText = __('Trascina qui il tuo file', 'gepafin'),
|
||||
chooseLabel = __('Aggiungi immagine', 'gepafin')
|
||||
chooseLabel = __('Aggiungi immagine', 'gepafin'),
|
||||
multiple = false
|
||||
}) => {
|
||||
return (
|
||||
<>
|
||||
@@ -32,7 +33,7 @@ const Fileupload = ({
|
||||
id={field.name}
|
||||
name={`${field.name}[]`}
|
||||
url={api}
|
||||
multiple
|
||||
multiple={multiple}
|
||||
accept={accept}
|
||||
maxFileSize={1000000}
|
||||
emptyTemplate={<p>{emptyText}</p>}
|
||||
|
||||
Reference in New Issue
Block a user