From 17a0fd8bc5853133deb62ed8b99ca8d4aebab72e Mon Sep 17 00:00:00 2001 From: aleksandr-raw <104529174+aleksandr-raw@users.noreply.github.com> Date: Tue, 9 Apr 2024 19:38:38 +0400 Subject: [PATCH] WIP step 5 --- .../CustomFileUploader/CustomFileUploader.tsx | 92 +++++++++++++++++++ .../IntegrationStep4/IntegrationStep4.tsx | 37 ++++++-- .../IntegrationStep5/IntegrationStep5.tsx | 20 ++-- .../IntegrationStep6/IntegrationStep6.tsx | 27 ++++-- .../IntegrationsModal/IntegrationsModal.tsx | 75 ++++++++++----- 5 files changed, 203 insertions(+), 48 deletions(-) create mode 100644 src/components/CustomFileUploader/CustomFileUploader.tsx diff --git a/src/components/CustomFileUploader/CustomFileUploader.tsx b/src/components/CustomFileUploader/CustomFileUploader.tsx new file mode 100644 index 00000000..ffe8a804 --- /dev/null +++ b/src/components/CustomFileUploader/CustomFileUploader.tsx @@ -0,0 +1,92 @@ +import { + Box, + ButtonBase, + Typography, + useMediaQuery, + useTheme, +} from "@mui/material"; +import UploadIcon from "@icons/UploadIcon"; +import { type DragEvent, FC, useRef, useState } from "react"; + +type TextFormat = "txt" | "docx"; + +interface CustomFileUploaderProps { + description?: string; + accept?: TextFormat[]; + handleImageChange: (file: File) => void; +} + +export const CustomFileUploader: FC = ({ + accept, + description, + handleImageChange, +}) => { + const theme = useTheme(); + const dropZone = useRef(null); + const [ready, setReady] = useState(false); + const isMobile = useMediaQuery(theme.breakpoints.down(600)); + + const handleDragEnter = (event: DragEvent) => { + event.preventDefault(); + setReady(true); + }; + + const handleDrop = (event: DragEvent) => { + event.preventDefault(); + event.stopPropagation(); + + const file = event.dataTransfer.files[0]; + if (!file) return; + + handleImageChange(file); + }; + + const acceptedFormats = accept + ? accept.map((format) => "." + format).join(", ") + : ""; + + return ( + + { + const file = event.target.files?.[0]; + if (file) handleImageChange(file); + }} + hidden + accept={acceptedFormats || ".jpg, .jpeg, .png , .gif"} + multiple + type="file" + data-cy="upload-image-input" + /> + ) => + event.preventDefault() + } + onDrop={handleDrop} + ref={dropZone} + sx={{ + width: "580px", + padding: isMobile ? "33px" : "33px 10px 33px 55px", + display: "flex", + alignItems: "center", + backgroundColor: theme.palette.background.default, + border: `1px solid ${ready ? "red" : theme.palette.grey2.main}`, + borderRadius: "8px", + gap: "55px", + flexDirection: isMobile ? "column" : undefined, + }} + onDragEnter={handleDragEnter} + > + + + + Добавить файл + + + {description || "Принимает JPG, PNG, и GIF формат — максимум 5mb"} + + + + + ); +}; diff --git a/src/pages/IntegrationsPage/IntegrationsModal/IntegrationStep4/IntegrationStep4.tsx b/src/pages/IntegrationsPage/IntegrationsModal/IntegrationStep4/IntegrationStep4.tsx index be02f918..fef9bccb 100644 --- a/src/pages/IntegrationsPage/IntegrationsModal/IntegrationStep4/IntegrationStep4.tsx +++ b/src/pages/IntegrationsPage/IntegrationsModal/IntegrationStep4/IntegrationStep4.tsx @@ -1,18 +1,26 @@ -import { Box, Typography, useMediaQuery, useTheme } from "@mui/material"; +import { Box, useMediaQuery, useTheme } from "@mui/material"; import { FC } from "react"; import { StepButtonsBlock } from "../StepButtonsBlock/StepButtonsBlock"; +import { CustomSelect } from "../../../../components/CustomSelect/CustomSelect"; type IntegrationStep4Props = { handlePrevStep: () => void; handleNextStep: () => void; + selectedDealPerformer: string | null; + setSelectedDealPerformer: (value: string | null) => void; + performers: string[]; }; export const IntegrationStep4: FC = ({ handlePrevStep, handleNextStep, + selectedDealPerformer, + setSelectedDealPerformer, + performers, }) => { const theme = useTheme(); - const upMd = useMediaQuery(theme.breakpoints.up("md")); + const isMobile = useMediaQuery(theme.breakpoints.down(600)); + const isTablet = useMediaQuery(theme.breakpoints.down(1000)); return ( = ({ flexGrow: 1, }} > - + + + - step 4 - - + + ); }; diff --git a/src/pages/IntegrationsPage/IntegrationsModal/IntegrationStep5/IntegrationStep5.tsx b/src/pages/IntegrationsPage/IntegrationsModal/IntegrationStep5/IntegrationStep5.tsx index 133aedf4..8be5edbd 100644 --- a/src/pages/IntegrationsPage/IntegrationsModal/IntegrationStep5/IntegrationStep5.tsx +++ b/src/pages/IntegrationsPage/IntegrationsModal/IntegrationStep5/IntegrationStep5.tsx @@ -1,15 +1,21 @@ -import { Box, Typography, useMediaQuery, useTheme } from "@mui/material"; +import { Box, useMediaQuery, useTheme } from "@mui/material"; import { FC } from "react"; import { StepButtonsBlock } from "../StepButtonsBlock/StepButtonsBlock"; +import File from "@ui_kit/QuizPreview/QuizPreviewQuestionTypes/File"; +import { CustomFileUploader } from "../../../../components/CustomFileUploader/CustomFileUploader"; type IntegrationStep5Props = { handlePrevStep: () => void; handleNextStep: () => void; + setUtmFile: (file: File | null) => void; + utmFile: File | null; }; export const IntegrationStep5: FC = ({ handlePrevStep, handleNextStep, + utmFile, + setUtmFile, }) => { const theme = useTheme(); const upMd = useMediaQuery(theme.breakpoints.up("md")); @@ -24,11 +30,13 @@ export const IntegrationStep5: FC = ({ flexGrow: 1, }} > - - step 5 - + + + void; @@ -9,8 +10,8 @@ export const IntegrationStep6: FC = ({ handlePrevStep, }) => { const theme = useTheme(); - const upMd = useMediaQuery(theme.breakpoints.up("md")); - + const isMobile = useMediaQuery(theme.breakpoints.down(600)); + const isTablet = useMediaQuery(theme.breakpoints.down(1000)); return ( = ({ flexGrow: 1, }} > - - step 6 - + + ); }; diff --git a/src/pages/IntegrationsPage/IntegrationsModal/IntegrationsModal.tsx b/src/pages/IntegrationsPage/IntegrationsModal/IntegrationsModal.tsx index 67287442..8efae901 100644 --- a/src/pages/IntegrationsPage/IntegrationsModal/IntegrationsModal.tsx +++ b/src/pages/IntegrationsPage/IntegrationsModal/IntegrationsModal.tsx @@ -17,6 +17,7 @@ import { IntegrationStep5 } from "./IntegrationStep5/IntegrationStep5"; import { IntegrationStep6 } from "./IntegrationStep6/IntegrationStep6"; import GearIcon from "@icons/GearIcon"; import { funnelsMock, performersMock, stagesMock } from "../mocks/MockData"; +import File from "@ui_kit/QuizPreview/QuizPreviewQuestionTypes/File"; type IntegrationsModalProps = { isModalOpen: boolean; @@ -42,6 +43,10 @@ export const IntegrationsModal: FC = ({ string | null >(null); const [selectedStage, setSelectedStage] = useState(null); + const [selectedDealPerformer, setSelectedDealPerformer] = useState< + string | null + >(null); + const [utmFile, setUtmFile] = useState(null); const handleNextStep = () => { setStep((prevState) => prevState + 1); @@ -54,10 +59,12 @@ export const IntegrationsModal: FC = ({ () => [ { title: "Авторизация в аккаунте", + isSettingsAvailable: false, component: , }, { title: "Выбор воронки", + isSettingsAvailable: true, component: ( = ({ }, { title: "Выбор этапа воронки", + isSettingsAvailable: true, component: ( = ({ }, { title: "Сделка", + isSettingsAvailable: true, component: ( ), }, { - title: "Название шага", + title: "Добавление utm-меток", + isSettingsAvailable: false, component: ( ), }, { title: "Добавление тегов", + isSettingsAvailable: true, component: , }, ], - [], + [ + utmFile, + selectedFunnelPerformer, + selectedFunnel, + selectedStagePerformer, + selectedStage, + selectedDealPerformer, + ], ); return ( @@ -191,29 +214,31 @@ export const IntegrationsModal: FC = ({ Шаг {step + 1} - + {steps[step].isSettingsAvailable && ( + + )} {steps[step].component}