diff --git a/src/pages/DrillingProgram/CategoryAdder.jsx b/src/pages/DrillingProgram/CategoryAdder.jsx index c180457..390f8f9 100644 --- a/src/pages/DrillingProgram/CategoryAdder.jsx +++ b/src/pages/DrillingProgram/CategoryAdder.jsx @@ -1,12 +1,18 @@ -import { Button, Select } from 'antd' +import { Form, Select } from 'antd' import { FileAddOutlined } from '@ant-design/icons' import { memo, useCallback, useEffect, useState } from 'react' -import { DrillingProgramService } from '@api' +import Poprompt from '@components/Poprompt' import { invokeWebApiWrapperAsync } from '@components/factory' +import { DrillingProgramService } from '@api' import '@styles/drilling_program.less' +const catSelectorRules = [{ + required: true, + message: 'Пожалуйста, выберите категории' +}] + export const CategoryAdder = memo(({ categories, idWell, onUpdate, className, ...other }) => { const [options, setOptions] = useState([]) const [value, setValue] = useState([]) @@ -24,37 +30,47 @@ export const CategoryAdder = memo(({ categories, idWell, onUpdate, className, .. `Не удалось установить список доступных категорий для добавления` ), [categories]) - const onAddClick = useCallback(() => invokeWebApiWrapperAsync( + const onFinish = useCallback(({ categories }) => invokeWebApiWrapperAsync( async () => { - await DrillingProgramService.addParts(idWell, value) + if (!categories) return + await DrillingProgramService.addParts(idWell, categories) setValue([]) onUpdate?.() }, setShowLoader, `Не удалось добавить новые категорий программы бурения`, `Добавление категорий программы бурения` - ), [onUpdate, idWell, value]) + ), [onUpdate, idWell]) return ( -