- updated copies;
- test for spid login;
This commit is contained in:
@@ -2,6 +2,10 @@ import React, { useState, useCallback } from 'react';
|
||||
import { classNames } from 'primereact/utils';
|
||||
import { Controller } from 'react-hook-form';
|
||||
import { Checkbox } from 'primereact/checkbox';
|
||||
import { klona } from 'klona';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
|
||||
import { maxChecks, minChecks } from '../../../../helpers/validators';
|
||||
|
||||
const Checkboxes = ({
|
||||
fieldName,
|
||||
@@ -29,11 +33,23 @@ const Checkboxes = ({
|
||||
updateFn(data);
|
||||
}, [fieldVal]);
|
||||
|
||||
const properConfig = (config) => {
|
||||
let newConfig = klona(config);
|
||||
if (config.minLength) {
|
||||
newConfig = wrap(newConfig).set(['validate', 'minChecks'], (v) => minChecks(v, config.minLength)).value();
|
||||
}
|
||||
if (config.maxLength) {
|
||||
newConfig = wrap(newConfig).set(['validate', 'maxChecks'], (v) => maxChecks(v, config.maxLength)).value();
|
||||
}
|
||||
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
const input = <Controller
|
||||
name={fieldName}
|
||||
control={control}
|
||||
defaultValue={fieldVal}
|
||||
rules={config}
|
||||
rules={properConfig(config)}
|
||||
render={({ field, fieldState }) =>
|
||||
options.map(o => <div className="appForm__fieldItem" key={o.name}>
|
||||
<Checkbox
|
||||
|
||||
Reference in New Issue
Block a user