import { useState } from "react"; import axios from "axios"; import { Box, IconButton, TextField, Tooltip, Typography } from "@mui/material"; import ModeEditOutlineOutlinedIcon from "@mui/icons-material/ModeEditOutlineOutlined"; interface CardPrivilegie { name: string; type: string; price: string; description: string; value: string; privilegeId: string; serviceKey: string; } export const СardPrivilegie = ({ name, type, price, description, value, privilegeId, serviceKey }: CardPrivilegie) => { const [inputOpen, setInputOpen] = useState(false); const [inputValue, setInputValue] = useState(""); const PutPrivilegies = () => { axios({ method: "put", url: "https://admin.pena.digital/strator/privilege/", data: { name: name, privilegeId: privilegeId, serviceKey: serviceKey, description: description, type: type, value: value, price: inputValue, }, }); }; const requestOnclickEnter = (event: any) => { if (event.key === "Enter" && inputValue !== "") { PutPrivilegies(); setInputValue(""); setInputOpen(false); } }; const onCloseInput = (event: any) => { if (event.key === "Escape") { setInputOpen(false); } }; return ( {name} setInputOpen(!inputOpen)}> {inputOpen ? ( setInputValue(event.target.value)} sx={{ alignItems: "center", width: "400px", "& .MuiInputBase-root": { backgroundColor: "#F2F3F7", height: "48px", }, }} inputProps={{ sx: { borderRadius: "10px", fontSize: "18px", lineHeight: "21px", py: 0, }, }} /> ) : ( price: {price} )} {type} ); };