diff --git a/src/pages/Setting/CustomWrapper.tsx b/src/pages/Setting/CustomWrapper.tsx deleted file mode 100644 index a2325b3..0000000 --- a/src/pages/Setting/CustomWrapper.tsx +++ /dev/null @@ -1,250 +0,0 @@ -import { useState } from "react"; -import axios from "axios"; -import { - Box, - IconButton, - SxProps, - TextField, - Theme, - Tooltip, - Typography, - useMediaQuery, - useTheme, -} from "@mui/material"; -import ModeEditOutlineOutlinedIcon from "@mui/icons-material/ModeEditOutlineOutlined"; - -import { usePrivilegies } from "@root/hooks/privilege.hook"; - -interface CustomWrapperProps { - text: string; - sx?: SxProps; - result?: boolean; -} - -interface СardChildren { - name: string; - type: string; - price: string; - description: string; -} - -const СardChildren = ({ name, type, price, description }: СardChildren) => { - const [inputOpen, setInputOpen] = useState(false); - const [inputValue, setInputValue] = useState(""); - - const PutPrivilegies = () => { - axios({ - method: "put", - url: "https://admin.pena.digital/strator/privilege/service", - data: { - price: inputValue, - }, - }); - }; - - if (!inputOpen && inputValue !== "") { - PutPrivilegies(); - setInputValue(""); - } - - 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} - - - ); -}; - -export const PrivilegiesWrapper = ({ text, sx, result }: CustomWrapperProps) => { - const theme = useTheme(); - const upMd = useMediaQuery(theme.breakpoints.up("md")); - const upSm = useMediaQuery(theme.breakpoints.up("sm")); - const [isExpanded, setIsExpanded] = useState(false); - - const { privilegies, isError, isLoading, errorMessage } = usePrivilegies(); - - return ( - - - setIsExpanded((prev) => !prev)} - sx={{ - height: "88px", - px: "20px", - display: "flex", - alignItems: "center", - justifyContent: "space-between", - cursor: "pointer", - userSelect: "none", - }} - > - - {text} - - - - {result ? ( - <> - - - - - - - - ) : ( - - - - - )} - - - {isExpanded && - (isError ? ( - errorMessage - ) : ( - privilegies?.Шаблонизатор.map(({ name, type, price, description }) => ( - <СardChildren key={type} name={name} type={type} price={price} description={description} /> - )) - ))} - - - ); -}; diff --git a/src/pages/Setting/SettingRoles.tsx b/src/pages/Setting/SettingRoles.tsx index 9304f64..9a1b854 100644 --- a/src/pages/Setting/SettingRoles.tsx +++ b/src/pages/Setting/SettingRoles.tsx @@ -2,7 +2,7 @@ import { AccordionDetails, Table, TableBody, TableCell, TableHead, TableRow, Typ import FormDeleteRoles from "./FormDeleteRoles"; import FormCreateRoles from "./FormCreateRoles"; -import { PrivilegiesWrapper } from "./CustomWrapper"; +import { PrivilegiesWrapper } from "./PrivilegiesWrapper"; import theme from "../../theme";