|
|
@ -5,6 +5,7 @@ import INPUT_TYPES from '../../lib/consts/INPUT_TYPES'; |
|
|
|
import api from '../../lib/api'; |
|
|
|
import api from '../../lib/api'; |
|
|
|
import buildMapToMessageSetter from '../../lib/buildMapToMessageSetter'; |
|
|
|
import buildMapToMessageSetter from '../../lib/buildMapToMessageSetter'; |
|
|
|
import buildNumberTestBatch from '../../lib/test_input/buildNumberTestBatch'; |
|
|
|
import buildNumberTestBatch from '../../lib/test_input/buildNumberTestBatch'; |
|
|
|
|
|
|
|
import buildObjectStateSetterCallback from '../../lib/buildObjectStateSetterCallback'; |
|
|
|
import CheckboxWithLabel from '../CheckboxWithLabel'; |
|
|
|
import CheckboxWithLabel from '../CheckboxWithLabel'; |
|
|
|
import ConfirmDialog from '../ConfirmDialog'; |
|
|
|
import ConfirmDialog from '../ConfirmDialog'; |
|
|
|
import FlexBox from '../FlexBox'; |
|
|
|
import FlexBox from '../FlexBox'; |
|
|
@ -58,26 +59,18 @@ const AddPeerDialog = forwardRef< |
|
|
|
const [isSubmittingAddPeer, setIsSubmittingAddPeer] = |
|
|
|
const [isSubmittingAddPeer, setIsSubmittingAddPeer] = |
|
|
|
useProtectedState<boolean>(false, protect); |
|
|
|
useProtectedState<boolean>(false, protect); |
|
|
|
|
|
|
|
|
|
|
|
const buildFormValiditySetterCallback = useCallback( |
|
|
|
|
|
|
|
(key: string, value: boolean) => |
|
|
|
|
|
|
|
({ [key]: toReplace, ...restPrevious }) => ({ |
|
|
|
|
|
|
|
...restPrevious, |
|
|
|
|
|
|
|
[key]: value, |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
[], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
const buildInputFirstRenderFunction = useCallback( |
|
|
|
const buildInputFirstRenderFunction = useCallback( |
|
|
|
(key: string) => |
|
|
|
(key: string) => |
|
|
|
({ isRequired }: { isRequired: boolean }) => { |
|
|
|
({ isRequired }: { isRequired: boolean }) => { |
|
|
|
setFormValidity(buildFormValiditySetterCallback(key, !isRequired)); |
|
|
|
setFormValidity(buildObjectStateSetterCallback(key, !isRequired)); |
|
|
|
}, |
|
|
|
}, |
|
|
|
[buildFormValiditySetterCallback], |
|
|
|
[], |
|
|
|
); |
|
|
|
); |
|
|
|
const buildFinishInputTestBatchFunction = useCallback( |
|
|
|
const buildFinishInputTestBatchFunction = useCallback( |
|
|
|
(key: string) => (result: boolean) => { |
|
|
|
(key: string) => (result: boolean) => { |
|
|
|
setFormValidity(buildFormValiditySetterCallback(key, result)); |
|
|
|
setFormValidity(buildObjectStateSetterCallback(key, result)); |
|
|
|
}, |
|
|
|
}, |
|
|
|
[buildFormValiditySetterCallback], |
|
|
|
[], |
|
|
|
); |
|
|
|
); |
|
|
|
const setAPIMessage = useCallback((message?: Message) => { |
|
|
|
const setAPIMessage = useCallback((message?: Message) => { |
|
|
|
messageGroupRef.current.setMessage?.call(null, 'api', message); |
|
|
|
messageGroupRef.current.setMessage?.call(null, 'api', message); |
|
|
|