2022-12-21 11:26:07 +00:00
|
|
|
|
import { Box, Typography, useMediaQuery, useTheme } from "@mui/material";
|
|
|
|
|
import { useState } from "react";
|
|
|
|
|
import ExpandIcon from "./icons/ExpandIcon";
|
2023-07-25 22:31:04 +00:00
|
|
|
|
import type { ReactNode } from "react";
|
2022-12-21 11:26:07 +00:00
|
|
|
|
|
|
|
|
|
interface Props {
|
2023-07-25 22:31:04 +00:00
|
|
|
|
header: ReactNode;
|
|
|
|
|
text: string;
|
|
|
|
|
divide?: boolean;
|
2023-08-18 16:39:29 +00:00
|
|
|
|
price?: number;
|
2023-09-16 12:24:19 +00:00
|
|
|
|
last?: boolean;
|
|
|
|
|
first?: boolean;
|
2022-12-21 11:26:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-16 12:24:19 +00:00
|
|
|
|
export default function CustomAccordion({ header, text, divide = false, price, last, first }: Props) {
|
2023-07-25 22:31:04 +00:00
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const upMd = useMediaQuery(theme.breakpoints.up("md"));
|
|
|
|
|
const upXs = useMediaQuery(theme.breakpoints.up("xs"));
|
|
|
|
|
const [isExpanded, setIsExpanded] = useState<boolean>(false);
|
2022-12-21 11:26:07 +00:00
|
|
|
|
|
2023-07-25 22:31:04 +00:00
|
|
|
|
return (
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
backgroundColor: "white",
|
2023-09-16 12:24:19 +00:00
|
|
|
|
borderTopLeftRadius: first ? "12px" : "0",
|
|
|
|
|
borderTopRightRadius: first ? "12px" : "0",
|
|
|
|
|
borderBottomLeftRadius: last ? "12px" : "0",
|
|
|
|
|
borderBottomRightRadius: last ? "12px" : "0",
|
|
|
|
|
borderBottom: `1px solid ${theme.palette.gray.main}`,
|
|
|
|
|
|
|
|
|
|
...(last && { borderBottom: "none" }),
|
2023-07-25 22:31:04 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
onClick={() => setIsExpanded((prev) => !prev)}
|
|
|
|
|
sx={{
|
|
|
|
|
minHeight: "72px",
|
|
|
|
|
px: "20px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "stretch",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
cursor: "pointer",
|
|
|
|
|
userSelect: "none",
|
|
|
|
|
rowGap: "10px",
|
|
|
|
|
flexDirection: upXs ? undefined : "column",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
width: "100%",
|
|
|
|
|
fontSize: upMd ? undefined : "16px",
|
|
|
|
|
lineHeight: upMd ? undefined : "19px",
|
|
|
|
|
fontWeight: 500,
|
2023-08-22 10:28:22 +00:00
|
|
|
|
color: theme.palette.gray.dark,
|
2023-07-25 22:31:04 +00:00
|
|
|
|
px: 0,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{header}
|
|
|
|
|
</Box>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
pl: "20px",
|
|
|
|
|
width: "52px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
borderLeft: divide ? "1px solid #000000" : "none",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<ExpandIcon isExpanded={isExpanded} />
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
{isExpanded && (
|
2022-12-21 11:26:07 +00:00
|
|
|
|
<Box
|
2023-07-25 22:31:04 +00:00
|
|
|
|
sx={{
|
2023-08-18 16:39:29 +00:00
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "space-between",
|
2023-07-25 22:31:04 +00:00
|
|
|
|
px: "20px",
|
|
|
|
|
py: upMd ? "25px" : undefined,
|
|
|
|
|
pt: upMd ? undefined : "15px",
|
|
|
|
|
pb: upMd ? undefined : "25px",
|
|
|
|
|
backgroundColor: "#F1F2F6",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography
|
2022-12-21 11:26:07 +00:00
|
|
|
|
sx={{
|
2023-07-25 22:31:04 +00:00
|
|
|
|
fontSize: upMd ? undefined : "16px",
|
|
|
|
|
lineHeight: upMd ? undefined : "19px",
|
2023-08-22 10:28:22 +00:00
|
|
|
|
color: theme.palette.gray.dark,
|
2022-12-21 11:26:07 +00:00
|
|
|
|
}}
|
2023-07-25 22:31:04 +00:00
|
|
|
|
>
|
|
|
|
|
{text}
|
|
|
|
|
</Typography>
|
2023-08-18 16:39:29 +00:00
|
|
|
|
<Typography sx={{ display: price ? "block" : "none", fontSize: "18px", mr: "120px" }}>
|
|
|
|
|
{price} руб.
|
|
|
|
|
</Typography>
|
2022-12-21 11:26:07 +00:00
|
|
|
|
</Box>
|
2023-07-25 22:31:04 +00:00
|
|
|
|
)}
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
}
|