модалка редактирования открывается более раза подряд

This commit is contained in:
Nastya 2023-07-26 04:28:00 +03:00
parent 5b2a0a55dc
commit 1f060fc5e8
2 changed files with 4 additions and 3 deletions

@ -45,9 +45,10 @@ const editTariff = ({ tarifIid, tariffName, tariffPrice, privilege }: EditProps)
}; };
interface Props { interface Props {
tariff: Tariff; tariff: Tariff;
closeModal: () => void
} }
export default function EditModal({ tariff = undefined }: Props) { export default function EditModal({ tariff = undefined, closeModal }: Props) {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [name, setName] = useState(""); const [name, setName] = useState("");
const [price, setPrice] = useState(""); const [price, setPrice] = useState("");
@ -61,7 +62,7 @@ export default function EditModal({ tariff = undefined }: Props) {
return ( return (
<Modal <Modal
open={open} open={open}
onClose={() => setOpen(false)} onClose={() => closeModal(undefined)}
aria-labelledby="modal-modal-title" aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description" aria-describedby="modal-modal-description"
> >

@ -145,7 +145,7 @@ export default function TariffsDG({ selectedTariffs, handleSelectionChange }: Pr
}} }}
selectedTariffs={selectedTariffs} selectedTariffs={selectedTariffs}
/> />
<EditModal tariff={changingTariff} /> <EditModal tariff={changingTariff} closeModal={setChangingTariff} />
</> </>
); );
} }