diff --git a/src/pages/Analytics/Answers/AnswersStatistics.tsx b/src/pages/Analytics/Answers/AnswersStatistics.tsx index c522891e..1a9ff469 100644 --- a/src/pages/Analytics/Answers/AnswersStatistics.tsx +++ b/src/pages/Analytics/Answers/AnswersStatistics.tsx @@ -3,7 +3,7 @@ import { Box, Typography, useMediaQuery, useTheme } from "@mui/material"; import { Answers } from "./Answers"; import { QuestionsResponse } from "@api/statistic"; import { FC } from "react"; -import { Funnel } from "./Funnel"; +import { Funnel } from "./FunnelAnswers/Funnel"; import { Results } from "./Results"; type AnswersStatisticsProps = { diff --git a/src/pages/Analytics/Answers/Funnel.tsx b/src/pages/Analytics/Answers/Funnel.tsx deleted file mode 100644 index e0d41caa..00000000 --- a/src/pages/Analytics/Answers/Funnel.tsx +++ /dev/null @@ -1,145 +0,0 @@ -import { - Box, - LinearProgress, - Paper, - Typography, - useMediaQuery, - useTheme, -} from "@mui/material"; - -import type { FC } from "react"; - -type FunnelItemProps = { - title: string; - percent: number; - index: number; - funnel: number; -}; - -type FunnelProps = { - data: number[]; - funnelData: number[]; -}; - -const FUNNEL_MOCK: Record = { - "Стартовая страница": 100, - "Воронка квиза": 0, - Заявки: 0, - Результаты: 0, -}; - -const FunnelItem = ({ title, percent, index, funnel }: FunnelItemProps) => { - const theme = useTheme(); - - return ( - - - {title} - - - - {funnel} - - - 100 ? 100 : percent * 100} - sx={{ - width: "100%", - marginRight: "15px", - - height: "12px", - background: theme.palette.background.default, - borderRadius: "6px", - border: - percent >= 100 - ? `1px solid ${theme.palette.brightPurple.main}` - : null, - "& > span": { background: "#D9C0F9" }, - }} - /> - - - {index === 0 ? "100%" : `${(percent * 100).toFixed(1)}%`} - - - - - - ); -}; - -export const Funnel: FC = ({ data, funnelData }) => { - const theme = useTheme(); - const isSmallMonitor = useMediaQuery(theme.breakpoints.down(1150)); - const isMobile = useMediaQuery(theme.breakpoints.down(850)); - - if (!data) - return ( - - нет данных о разделах - - ); - - return ( - - {Object.entries(FUNNEL_MOCK).map(([title, percent], index) => ( - 0 ? data[index - 1] : percent} - funnel={funnelData[index]} - /> - ))} - - ); -}; diff --git a/src/pages/Analytics/Answers/FunnelAnswers/Funnel.tsx b/src/pages/Analytics/Answers/FunnelAnswers/Funnel.tsx new file mode 100644 index 00000000..9ffe5aa6 --- /dev/null +++ b/src/pages/Analytics/Answers/FunnelAnswers/Funnel.tsx @@ -0,0 +1,191 @@ +import { + Box, IconButton, + LinearProgress, + Paper, + Typography, + useMediaQuery, + useTheme, +} from "@mui/material"; + +import type { FC } from "react"; +import {ArrowDownIcon} from "@icons/questionsPage/ArrowDownIcon"; +import ExpandLessIcon from "@mui/icons-material/ExpandLess"; +import {useState} from "react"; +import FunnelDetals from "@/pages/Analytics/Answers/FunnelAnswers/funnelDetals"; + +type FunnelItemProps = { + title: string; + percent: number; + index: number; + funnel: number; +}; + +type FunnelProps = { + data: number[]; + funnelData: number[]; +}; + +const FUNNEL_MOCK: Record = { + "Стартовая страница": 100, + "Воронка квиза": 0, + Заявки: 0, + Результаты: 0, +}; + +const FunnelItem = ({ title, percent, index, funnel }: FunnelItemProps) => { + const theme = useTheme(); + const [isExpanded, setIsExpanded] = useState(false); + const expandedHC = (bool: boolean) => { + setIsExpanded(bool); + }; + + return ( + <> + + + {title} + + + expandedHC(!isExpanded)} + > + + + + {funnel} + + + 100 ? 100 : percent * 100} + sx={{ + width: "100%", + marginRight: "15px", + + height: "12px", + background: theme.palette.background.default, + borderRadius: "6px", + border: + percent >= 100 + ? `1px solid ${theme.palette.brightPurple.main}` + : null, + "& > span": { background: "#D9C0F9" }, + }} + /> + + + {index === 0 ? "100%" : `${(percent * 100).toFixed(1)}%`} + + + + + + {isExpanded && + <> + + Воронки + Дошли до этапа + + + + + + + } + + + ); +}; + +export const Funnel: FC = ({ data, funnelData }) => { + const theme = useTheme(); + const isSmallMonitor = useMediaQuery(theme.breakpoints.down(1150)); + const isMobile = useMediaQuery(theme.breakpoints.down(850)); + + if (!data) + return ( + + нет данных о разделах + + ); + + return ( + + {Object.entries(FUNNEL_MOCK).map(([title, percent], index) => ( + 0 ? data[index - 1] : percent} + funnel={funnelData[index]} + /> + ))} + + ); +}; diff --git a/src/pages/Analytics/Answers/FunnelAnswers/funnelDetals.tsx b/src/pages/Analytics/Answers/FunnelAnswers/funnelDetals.tsx new file mode 100644 index 00000000..71f18a0c --- /dev/null +++ b/src/pages/Analytics/Answers/FunnelAnswers/funnelDetals.tsx @@ -0,0 +1,87 @@ +import {Box, IconButton, Typography, useTheme} from "@mui/material"; +import {ArrowDownIcon} from "@icons/questionsPage/ArrowDownIcon"; +import {useState} from "react"; + +export default function FunnelDetals () { + const theme = useTheme(); + const [isExpanded, setIsExpanded] = useState(false); + const expandedHC = (bool: boolean) => { + setIsExpanded(bool); + }; + return( + + + Воронка 1 + expandedHC(!isExpanded)} + > + + + + {isExpanded && + + + + + + + } + + + ) +} + +const DetalItem = () => { + return( + + + + 1. + Вы немного опоздали, как поступите? + + 20% + + + + ) +} \ No newline at end of file