- fixed issue with number form field;

- fixed issue with datepicker form field;
- updated tables displaying submitted calls;
This commit is contained in:
Vitalii Kiiko
2024-11-18 15:13:20 +01:00
parent 0534b7cd0a
commit c698de622b
7 changed files with 26 additions and 21 deletions

View File

@@ -28,18 +28,17 @@ const Datepicker = ({
control={control}
defaultValue={defaultValue}
rules={config}
render={({ field, fieldState }) => (
<Calendar id={field.name}
disabled={disabled}
value={is(Date, field.value) ? field.value : null}
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 })}/>
render={({ field, fieldState }) => (<Calendar id={field.name}
disabled={disabled}
value={is(String, field.value) ? new Date(field.value) : field.value}
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 })}/>
)}/>
{infoText ? <small>{infoText}</small> : null}
</>)

View File

@@ -1,7 +1,7 @@
import React from 'react';
import { classNames } from 'primereact/utils';
import { Controller } from 'react-hook-form';
import { is } from 'ramda';
import { is, isEmpty } from 'ramda';
import { InputNumber } from 'primereact/inputnumber';
@@ -23,6 +23,8 @@ const NumberInput = ({
disabled = false,
useGrouping = true
}) => {
const minAttr = config.min ? config.min : min;
const maxAttr = config.max ? config.max : max;
const input = <Controller
name={fieldName}
control={control}
@@ -33,8 +35,8 @@ const NumberInput = ({
disabled={disabled}
value={field.value}
onValueChange={(e) => field.onChange(e.value)}
min={min}
max={max}
min={minAttr}
max={maxAttr}
locale={locale}
useGrouping={useGrouping}
maxFractionDigits={!isNaN(parseInt(maxFractionDigits)) ? parseInt(maxFractionDigits) : 0}
@@ -45,6 +47,8 @@ const NumberInput = ({
<>
<label htmlFor={fieldName} className={classNames({ 'p-error': errors[fieldName] })}>
{label}{config.required || config.isRequired ? <span className="appForm__field--required">*</span> : null}
{!isEmpty(minAttr) ? <span>(min. {minAttr})</span> : null}
{!isEmpty(maxAttr) ? <span>(max. {maxAttr})</span> : null}
</label>
{inputgroup
? <div className="p-inputgroup">