frontPanel/src/pages/Result/SettingForm.tsx

132 lines
4.4 KiB
TypeScript
Raw Normal View History

2023-04-23 08:39:34 +00:00
import { useState } from "react";
2023-04-15 09:10:59 +00:00
import { Box, Button, IconButton, SxProps, Theme, Typography } from "@mui/material";
import CustomButton from "../../components/CustomButton";
import { SwitchSetting } from "./SwichResult";
2023-04-23 08:39:34 +00:00
import Info from "@icons/Info";
2023-04-15 09:10:59 +00:00
import listChecks from "@icons/listChecks.svg";
import ShareNetwork from "@icons/ShareNetwork.svg";
import ArrowCounterClockWise from "@icons/ArrowCounterClockWise.svg";
2023-04-15 09:10:59 +00:00
const buttonSetting: { title: string; sx: SxProps<Theme>; type: string }[] = [
{
2023-04-23 08:39:34 +00:00
sx: { backgroundColor: "#7E2AEA", color: "white", width: "237px", height: "44px", border: "1px solid #9A9AAF" },
2023-04-15 09:10:59 +00:00
title: "До формы контактов",
type: "toContactForm",
},
{
sx: { backgroundColor: "#F2F3F7", color: "#9A9AAF", width: "266px", height: "44px", border: "1px solid #9A9AAF" },
title: "После формы контактов",
type: "afterСontactForm",
},
{
sx: { color: "#9A9AAF", backgroundColor: "#F2F3F7", width: "233px", height: "44px", border: "1px solid #9A9AAF" },
title: "Отправить на E-mail",
type: "e-mail",
},
];
2023-04-23 08:39:34 +00:00
export const SettingForm = () => {
const [activeIndex, setActiveIndex] = useState<number>(0);
const [typeActive, setTypeActive] = useState<string>("toContactForm");
2023-04-15 09:10:59 +00:00
const active = (index: number, type: string) => {
setActiveIndex(index);
setTypeActive(type);
};
return (
2023-04-23 08:39:34 +00:00
<Box component="section" sx={{ width: "796px" }}>
2023-04-15 09:10:59 +00:00
<Box sx={{ display: "flex", alignItems: "center", mb: "40px" }}>
<Typography sx={{ pr: "10px" }} variant="h5">
Настройки результатов
</Typography>
<Info />
</Box>
<Box
sx={{
height: "100%",
bgcolor: "#FFFFFF",
borderRadius: "12px",
p: "30px 20px",
}}
>
<Box
sx={{
display: "flex",
alignItems: "center",
justifyContent: "space-between",
mb: "20px",
}}
>
2023-04-23 08:39:34 +00:00
<Typography component="p" sx={{ color: "#9A9AAF" }}>
Показывать результат
</Typography>
2023-04-15 09:10:59 +00:00
<IconButton>
<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="30" height="30" rx="6" fill="#EEE4FC" />
<path
d="M22.5 11.25L15 18.75L7.5 11.25"
stroke="#7E2AEA"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
2023-04-15 09:10:59 +00:00
/>
</svg>
</IconButton>
</Box>
<Box sx={{ display: "flex", justifyContent: "space-between", mb: "20px" }}>
{buttonSetting.map(({ sx, title, type }, index) => (
<CustomButton
disableRipple
onClick={() => active(index, type)}
key={title}
sx={{
...sx,
bgcolor: activeIndex === index ? " #7E2AEA" : "#F2F3F7",
color: activeIndex === index ? " white" : "#9A9AAF",
}}
>
{title}
</CustomButton>
))}
</Box>
{typeActive === "e-mail" ? (
2023-04-23 08:39:34 +00:00
<SwitchSetting icon={listChecks} text="Показывать несколько результатов" />
2023-04-15 09:10:59 +00:00
) : (
<>
2023-04-23 08:39:34 +00:00
<SwitchSetting icon={listChecks} text="Показывать несколько результатов" />
<SwitchSetting icon={ShareNetwork} text="Поделиться результатами" />
<SwitchSetting icon={ArrowCounterClockWise} text="Кнопка `Пройти тест заново`" />
2023-04-15 09:10:59 +00:00
</>
)}
</Box>
<Box sx={{ display: "flex", alignItems: "center", mb: "15px", mt: "15px" }}>
<Typography variant="p1" sx={{ color: "#4D4D4D", fontSize: "14px" }}>
Создайте результат
</Typography>
<Button
disableRipple
sx={{
ml: "auto",
height: "19px",
color: "#7E2AEA",
textDecoration: "underline",
fontSize: "16px",
"&:hover": {
background: "none",
textDecoration: "underline",
},
}}
variant="text"
>
Свернуть всё
</Button>
</Box>
</Box>
);
2023-04-23 08:39:34 +00:00
};