import { Autocomplete, Box, Divider, FormControl, IconButton, Stack, TextField } from '@mui/material'; import { useEffect, useState } from 'react'; import { toast } from 'react-toastify'; import { ExpenseItemApi } from '../../../api/expense-item'; import { DangerOutlinedButton, PrimaryButton } from '../../common/Buttons/Buttons'; import { HeaderContainer, ModalBackdrop, ModalContainer, ModalTitle } from '../../common/Modal/ModalStyled'; import { Cancel } from '../../common/icons/icons'; export const SelectExpenseItemModal = ({ isOpen, onClose, onSelect, formId, title = '', isSaving = false, sheet }) => { const [selectedValue, setSelectedValue] = useState(''); const [expenseItemOptions, setExpenseItemOption] = useState([]); useEffect(() => { if (formId === null) return; ExpenseItemApi.getAll({ r_start: true, sheet: sheet }).then((data) => { if (data.success) { setExpenseItemOption(data.result); return; } toast.error('Ошибка получения статья расходов'); }); }, [formId]); useEffect(() => { if (!isOpen) { setSelectedValue(''); } }, [isOpen]); const handleCancel = () => { setSelectedValue(''); onClose(); }; const handleBackdropClick = (e) => { if (e.target === e.currentTarget) { handleCancel(); } }; const handleSave = () => { onSelect?.(selectedValue); onClose(); }; const isFormValid = selectedValue; if (!isOpen) return null; return ( {title} {/* Выбор ВСП */} option.name || ''} getOptionKey={(option) => option.id} value={selectedValue} onChange={(event, newValue) => { setSelectedValue(newValue); }} slotProps={{ popper: { style: { zIndex: 60 }, }, }} renderInput={(params) => ( )} /> Отмена Выбрать ); };