2023-07-25 22:31:04 +00:00
|
|
|
|
import { useState } from "react";
|
2023-08-16 14:03:45 +00:00
|
|
|
|
import { Box, IconButton, Typography, useMediaQuery, useTheme } from "@mui/material";
|
2023-07-25 22:31:04 +00:00
|
|
|
|
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
|
|
|
|
|
|
|
|
|
|
import SectionWrapper from "@root/components/SectionWrapper";
|
|
|
|
|
import { Select } from "@root/components/Select";
|
|
|
|
|
import { Tabs } from "@root/components/Tabs";
|
|
|
|
|
|
|
|
|
|
import AccordionWrapper from "./AccordionWrapper";
|
|
|
|
|
import { HISTORY } from "./historyMocks";
|
2023-08-16 14:03:45 +00:00
|
|
|
|
import { useHistoryTracker } from "@root/utils/hooks/useHistoryTracker";
|
2023-07-25 22:31:04 +00:00
|
|
|
|
|
|
|
|
|
const subPages = ["Платежи", "Покупки тарифов", "Окончания тарифов"];
|
|
|
|
|
|
|
|
|
|
export default function History() {
|
|
|
|
|
const [selectedItem, setSelectedItem] = useState<number>(0);
|
2023-08-16 14:03:45 +00:00
|
|
|
|
|
2023-07-25 22:31:04 +00:00
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const upMd = useMediaQuery(theme.breakpoints.up("md"));
|
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(600));
|
|
|
|
|
|
2023-08-16 14:03:45 +00:00
|
|
|
|
const handleCustomBackNavigation = useHistoryTracker();
|
|
|
|
|
|
2023-07-25 22:31:04 +00:00
|
|
|
|
return (
|
|
|
|
|
<SectionWrapper
|
|
|
|
|
maxWidth="lg"
|
|
|
|
|
sx={{
|
|
|
|
|
mt: upMd ? "25px" : "20px",
|
|
|
|
|
mb: upMd ? "70px" : "37px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
mt: "20px",
|
2023-07-28 15:56:19 +00:00
|
|
|
|
mb: "20px",
|
2023-07-25 22:31:04 +00:00
|
|
|
|
display: "flex",
|
|
|
|
|
gap: "10px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{!upMd && (
|
2023-08-16 14:03:45 +00:00
|
|
|
|
<IconButton onClick={handleCustomBackNavigation} sx={{ p: 0, height: "28px", width: "28px", color: "black" }}>
|
2023-07-25 22:31:04 +00:00
|
|
|
|
<ArrowBackIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
)}
|
|
|
|
|
<Typography variant="h4">История</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
{isMobile ? (
|
2023-08-16 14:03:45 +00:00
|
|
|
|
<Select items={subPages} selectedItem={selectedItem} setSelectedItem={setSelectedItem} />
|
2023-07-25 22:31:04 +00:00
|
|
|
|
) : (
|
2023-08-16 14:03:45 +00:00
|
|
|
|
<Tabs items={subPages} selectedItem={selectedItem} setSelectedItem={setSelectedItem} />
|
2023-07-25 22:31:04 +00:00
|
|
|
|
)}
|
|
|
|
|
{HISTORY.map((history, index) => (
|
2023-08-16 14:03:45 +00:00
|
|
|
|
<Box hidden={selectedItem !== index} sx={{ mt: upMd ? "27px" : "10px" }}>
|
2023-07-25 22:31:04 +00:00
|
|
|
|
<AccordionWrapper content={history} />
|
|
|
|
|
</Box>
|
|
|
|
|
))}
|
|
|
|
|
</SectionWrapper>
|
|
|
|
|
);
|
|
|
|
|
}
|