Кнопка отправить заблокирована при отсутствии уставок

This commit is contained in:
avsirotkin 2022-04-05 11:25:57 +05:00
parent b94561aa62
commit fcb264b122

View File

@ -37,20 +37,19 @@ export const SetpointSender = memo(({ idWell, onClose, visible, setpointNames })
const onAdd = useCallback(async (sp) => setSetpoints((prevSp) => { const onAdd = useCallback(async (sp) => setSetpoints((prevSp) => {
sp.key = Date.now() sp.key = Date.now()
prevSp.push(sp) return [...prevSp, sp]
return prevSp
}), []) }), [])
const onEdit = useCallback(async (sp) => setSetpoints((prevSp) => { const onEdit = useCallback(async (sp) => setSetpoints((prevSp) => {
const idx = prevSp.findIndex((val) => val.key === sp.key) const idx = prevSp.findIndex((val) => val.key === sp.key)
prevSp[idx] = sp prevSp[idx] = sp
return prevSp return [...prevSp]
}), []) }), [])
const onDelete = useCallback(async (sp) => setSetpoints((prevSp) => { const onDelete = useCallback(async (sp) => setSetpoints((prevSp) => {
const idx = prevSp.findIndex((val) => val.key === sp.key) const idx = prevSp.findIndex((val) => val.key === sp.key)
prevSp.splice(idx, 1) prevSp.splice(idx, 1)
return prevSp return [...prevSp]
}), []) }), [])
const onModalOk = useCallback(() => invokeWebApiWrapperAsync( const onModalOk = useCallback(() => invokeWebApiWrapperAsync(
@ -81,6 +80,7 @@ export const SetpointSender = memo(({ idWell, onClose, visible, setpointNames })
onCancel={onClose} onCancel={onClose}
onOk={onModalOk} onOk={onModalOk}
okText={'Отправить'} okText={'Отправить'}
okButtonProps={{ disabled: setpoints.length <= 0 }}
> >
<LoaderPortal show={isLoading}> <LoaderPortal show={isLoading}>
<Grid> <Grid>