2023-07-25 22:31:04 +00:00
|
|
|
|
import { Box, Typography, useMediaQuery, useTheme } from "@mui/material";
|
|
|
|
|
import CustomAccordion from "@components/CustomAccordion";
|
|
|
|
|
|
|
|
|
|
export type History = {
|
|
|
|
|
title: string;
|
|
|
|
|
date: string;
|
|
|
|
|
info: string;
|
|
|
|
|
description: string;
|
|
|
|
|
payMethod?: string;
|
|
|
|
|
expired?: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
2023-09-16 12:24:19 +00:00
|
|
|
|
type KeyValue = { Key: string; Value: string | number };
|
2023-07-25 22:31:04 +00:00
|
|
|
|
interface AccordionWrapperProps {
|
2023-09-16 12:24:19 +00:00
|
|
|
|
content: KeyValue[];
|
|
|
|
|
last?: boolean;
|
|
|
|
|
first?: boolean;
|
2023-10-16 11:37:54 +00:00
|
|
|
|
createdAt: string
|
2023-07-25 22:31:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-10-16 11:37:54 +00:00
|
|
|
|
export default function AccordionWrapper({ content, last, first, createdAt }: AccordionWrapperProps) {
|
2023-07-25 22:31:04 +00:00
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const upMd = useMediaQuery(theme.breakpoints.up("md"));
|
|
|
|
|
const upSm = useMediaQuery(theme.breakpoints.up("sm"));
|
|
|
|
|
const isTablet = useMediaQuery(theme.breakpoints.down(900));
|
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(560));
|
|
|
|
|
|
2023-09-16 12:24:19 +00:00
|
|
|
|
const valuesByKey: any = {};
|
2023-10-16 11:37:54 +00:00
|
|
|
|
console.log(content)
|
2023-09-16 12:24:19 +00:00
|
|
|
|
content.forEach((item) => {
|
|
|
|
|
valuesByKey[item.Key] = item.Value;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const extractDateFromString = (tariffName: string) => {
|
|
|
|
|
const dateMatch = tariffName.match(/\d{4}-\d{2}-\d{2}/);
|
|
|
|
|
return dateMatch ? dateMatch[0] : null;
|
|
|
|
|
};
|
|
|
|
|
|
2023-07-25 22:31:04 +00:00
|
|
|
|
return (
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
borderRadius: "12px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-09-16 12:24:19 +00:00
|
|
|
|
<CustomAccordion
|
|
|
|
|
last={last}
|
|
|
|
|
first={first}
|
|
|
|
|
divide
|
|
|
|
|
text={"Дата действия приобретенной лицензии (в формате дд.мм.гггг-дд.мм.гггг) Или же объем"}
|
|
|
|
|
header={
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
width: "100%",
|
|
|
|
|
height: upMd ? "72px" : undefined,
|
|
|
|
|
padding: "20px 20px 20px 0",
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
cursor: "pointer",
|
|
|
|
|
userSelect: "none",
|
|
|
|
|
gap: "20px",
|
|
|
|
|
alignItems: upSm ? "center" : undefined,
|
|
|
|
|
flexDirection: upSm ? undefined : "column",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-07-25 22:31:04 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: upSm ? "center" : undefined,
|
2023-09-16 12:24:19 +00:00
|
|
|
|
justifyContent: "space-between",
|
2023-07-25 22:31:04 +00:00
|
|
|
|
flexDirection: upSm ? undefined : "column",
|
2023-09-16 12:24:19 +00:00
|
|
|
|
gap: upMd ? "40px" : "10px",
|
2023-07-25 22:31:04 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2023-09-16 12:24:19 +00:00
|
|
|
|
<Typography
|
2023-07-25 22:31:04 +00:00
|
|
|
|
sx={{
|
2023-09-16 12:24:19 +00:00
|
|
|
|
width: "110px",
|
|
|
|
|
fontSize: upMd ? "20px" : "18px",
|
|
|
|
|
lineHeight: upMd ? undefined : "19px",
|
|
|
|
|
fontWeight: 500,
|
|
|
|
|
color: valuesByKey.expired ? theme.palette.text.disabled : theme.palette.text.secondary,
|
|
|
|
|
px: 0,
|
|
|
|
|
whiteSpace: "nowrap",
|
2023-07-25 22:31:04 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2023-10-16 11:37:54 +00:00
|
|
|
|
{extractDateFromString(createdAt)}
|
2023-09-16 12:24:19 +00:00
|
|
|
|
</Typography>
|
2023-07-25 22:31:04 +00:00
|
|
|
|
|
2023-09-16 12:24:19 +00:00
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontSize: upMd ? "18px" : "16px",
|
|
|
|
|
lineHeight: upMd ? undefined : "19px",
|
|
|
|
|
fontWeight: 500,
|
|
|
|
|
color: valuesByKey.expired ? theme.palette.text.disabled : theme.palette.gray.dark,
|
|
|
|
|
px: 0,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{valuesByKey.name}
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
flexFlow: "1",
|
|
|
|
|
flexBasis: "60%",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
display: upMd ? undefined : "none",
|
|
|
|
|
fontSize: upMd ? "18px" : "16px",
|
|
|
|
|
lineHeight: upMd ? undefined : "19px",
|
|
|
|
|
fontWeight: 400,
|
|
|
|
|
color: valuesByKey.expired ? theme.palette.text.disabled : theme.palette.gray.dark,
|
|
|
|
|
px: 0,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{valuesByKey.payMethod && <Typography>Способ оплаты: {valuesByKey.payMethod}</Typography>}
|
|
|
|
|
</Typography>
|
2023-07-25 22:31:04 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
2023-09-16 12:24:19 +00:00
|
|
|
|
height: "100%",
|
2023-07-25 22:31:04 +00:00
|
|
|
|
alignItems: "center",
|
2023-09-16 12:24:19 +00:00
|
|
|
|
gap: upSm ? "111px" : "17px",
|
|
|
|
|
width: "100%",
|
|
|
|
|
maxWidth: isTablet ? null : "160px",
|
2023-07-25 22:31:04 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
2023-09-16 12:24:19 +00:00
|
|
|
|
marginLeft: isTablet ? (isMobile ? null : "auto") : null,
|
|
|
|
|
color: valuesByKey.expired ? theme.palette.text.disabled : theme.palette.gray.dark,
|
|
|
|
|
fontSize: upSm ? "20px" : "16px",
|
|
|
|
|
fontWeight: 500,
|
|
|
|
|
textAlign: "left",
|
2023-07-25 22:31:04 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2023-09-16 12:24:19 +00:00
|
|
|
|
{valuesByKey.price} руб.
|
2023-07-25 22:31:04 +00:00
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
2023-09-16 12:24:19 +00:00
|
|
|
|
</Box>
|
|
|
|
|
}
|
|
|
|
|
/>
|
2023-07-25 22:31:04 +00:00
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
}
|