амо 5-6 шаги поменяны местами, добавлено удаление аккаунта, убраны юзеры
This commit is contained in:
parent
c8f33e8e69
commit
25f055cb8e
@ -256,7 +256,7 @@ export const getIntegrationRules = async (
|
|||||||
method: "GET",
|
method: "GET",
|
||||||
url: `${API_URL}/rules/${quizID}`,
|
url: `${API_URL}/rules/${quizID}`,
|
||||||
});
|
});
|
||||||
return [settingsResponse];
|
return [settingsResponse || null];
|
||||||
} catch (nativeError) {
|
} catch (nativeError) {
|
||||||
const [error] = parseAxiosError(nativeError);
|
const [error] = parseAxiosError(nativeError);
|
||||||
return [null, `Не удалось получить настройки интеграции. ${error}`];
|
return [null, `Не удалось получить настройки интеграции. ${error}`];
|
||||||
@ -331,3 +331,18 @@ export const getCustomFields = async (
|
|||||||
return [null, `Не удалось получить список кастомных полей. ${error}`];
|
return [null, `Не удалось получить список кастомных полей. ${error}`];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Отвязать аккаунт амо от публикации
|
||||||
|
|
||||||
|
export const removeAmoAccount = async (): Promise<[void | null, string?]> => {
|
||||||
|
try {
|
||||||
|
await makeRequest<void>({
|
||||||
|
method: "DELETE",
|
||||||
|
url: `${API_URL}/delete`,
|
||||||
|
});
|
||||||
|
return [null, ""];
|
||||||
|
} catch (nativeError) {
|
||||||
|
const [error] = parseAxiosError(nativeError);
|
||||||
|
return [null, `Не удалось отвязать аккаунт. ${error}`];
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -96,6 +96,10 @@ export type AnyTypedQuizQuestion =
|
|||||||
| QuizQuestionRating
|
| QuizQuestionRating
|
||||||
| QuizQuestionResult;
|
| QuizQuestionResult;
|
||||||
|
|
||||||
|
export type AllTypesQuestion =
|
||||||
|
| AnyTypedQuizQuestion
|
||||||
|
| UntypedQuizQuestion;
|
||||||
|
|
||||||
type FilterQuestionsWithVariants<T> = T extends {
|
type FilterQuestionsWithVariants<T> = T extends {
|
||||||
content: { variants: QuestionVariant[] };
|
content: { variants: QuestionVariant[] };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,24 +8,29 @@ import {
|
|||||||
import React, { FC, useEffect, useMemo, useState } from "react";
|
import React, { FC, useEffect, useMemo, useState } from "react";
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import CloseIcon from "@mui/icons-material/Close";
|
import CloseIcon from "@mui/icons-material/Close";
|
||||||
|
import { AmoRemoveAccount } from "./AmoRemoveAccount/AmoRemoveAccount";
|
||||||
import { AmoLogin } from "./AmoLogin/AmoLogin";
|
import { AmoLogin } from "./AmoLogin/AmoLogin";
|
||||||
import { AmoStep2 } from "./AmoStep2/AmoStep2";
|
import { AmoStep2 } from "./AmoStep2/AmoStep2";
|
||||||
import { AmoStep3 } from "./AmoStep3/AmoStep3";
|
import { AmoStep3 } from "./AmoStep3/AmoStep3";
|
||||||
import { AmoStep4 } from "./AmoStep4/AmoStep4";
|
import { AmoStep4 } from "./AmoStep4/AmoStep4";
|
||||||
import { AmoStep6 } from "./IntegrationStep6/AmoStep6";
|
import { AmoStep6 } from "./IntegrationStep6/AmoStep6";
|
||||||
|
import { AmoStep7 } from "./IntegrationStep7/AmoStep7";
|
||||||
import { AmoModalTitle } from "./AmoModalTitle/AmoModalTitle";
|
import { AmoModalTitle } from "./AmoModalTitle/AmoModalTitle";
|
||||||
import { AmoSettingsBlock } from "./SettingsBlock/AmoSettingsBlock";
|
import { AmoSettingsBlock } from "./SettingsBlock/AmoSettingsBlock";
|
||||||
import { AmoStep7 } from "./IntegrationStep7/AmoStep7";
|
|
||||||
import { AmoAccountInfo } from "./AmoAccountInfo/AmoAccountInfo";
|
import { AmoAccountInfo } from "./AmoAccountInfo/AmoAccountInfo";
|
||||||
import { AccountResponse, getAccount } from "@api/integration";
|
import { AccountResponse, IntegrationRules, getAccount, getIntegrationRules } from "@api/integration";
|
||||||
|
import { useQuestions } from "@/stores/questions/hooks";
|
||||||
|
import { redirect } from "react-router-dom";
|
||||||
|
import { enqueueSnackbar } from "notistack";
|
||||||
|
|
||||||
export type TitleKeys = "contacts" | "company" | "deal" | "users" | "buyers";
|
export type TitleKeys = "contacts" | "company" | "deal" | "buyers";
|
||||||
|
|
||||||
export type TQuestionEntity = Record<TitleKeys, string[] | []>;
|
export type TQuestionEntity = Record<TitleKeys, string[] | []>;
|
||||||
type IntegrationsModalProps = {
|
type IntegrationsModalProps = {
|
||||||
isModalOpen: boolean;
|
isModalOpen: boolean;
|
||||||
handleCloseModal: () => void;
|
handleCloseModal: () => void;
|
||||||
companyName: string | null;
|
companyName: string | null;
|
||||||
|
quizID: number | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TagKeys = "contact" | "company" | "deal" | "buyer";
|
export type TagKeys = "contact" | "company" | "deal" | "buyer";
|
||||||
@ -35,15 +40,20 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
|||||||
isModalOpen,
|
isModalOpen,
|
||||||
handleCloseModal,
|
handleCloseModal,
|
||||||
companyName,
|
companyName,
|
||||||
|
quizID,
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isMobile = useMediaQuery(theme.breakpoints.down(600));
|
const isMobile = useMediaQuery(theme.breakpoints.down(600));
|
||||||
const isTablet = useMediaQuery(theme.breakpoints.down(1000));
|
const isTablet = useMediaQuery(theme.breakpoints.down(1000));
|
||||||
|
|
||||||
|
const { questions } = useQuestions();
|
||||||
|
|
||||||
const [step, setStep] = useState<number>(0);
|
const [step, setStep] = useState<number>(0);
|
||||||
const [isSettingsBlock, setIsSettingsBlock] = useState<boolean>(false);
|
const [isSettingsBlock, setIsSettingsBlock] = useState<boolean>(false);
|
||||||
|
const [isRemoveAccount, setIsRemoveAccount] = useState<boolean>(false);
|
||||||
|
|
||||||
const [accountInfo, setAccountInfo] = useState<AccountResponse | null>(null);
|
const [accountInfo, setAccountInfo] = useState<AccountResponse | null>(null);
|
||||||
|
const [integrationRules, setIntegrationRules] = useState<IntegrationRules | null>(null);
|
||||||
const [selectedPipelinePerformer, setSelectedPipelinePerformer] = useState<
|
const [selectedPipelinePerformer, setSelectedPipelinePerformer] = useState<
|
||||||
string | null
|
string | null
|
||||||
>(null);
|
>(null);
|
||||||
@ -56,10 +66,9 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
|||||||
string | null
|
string | null
|
||||||
>(null);
|
>(null);
|
||||||
const [questionEntity, setQuestionEntity] = useState<TQuestionEntity>({
|
const [questionEntity, setQuestionEntity] = useState<TQuestionEntity>({
|
||||||
|
deal: [],
|
||||||
contacts: [],
|
contacts: [],
|
||||||
company: [],
|
company: [],
|
||||||
deal: [],
|
|
||||||
users: [],
|
|
||||||
buyers: [],
|
buyers: [],
|
||||||
});
|
});
|
||||||
const [tags, setTags] = useState<TTags>({
|
const [tags, setTags] = useState<TTags>({
|
||||||
@ -68,21 +77,38 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
|||||||
company: [],
|
company: [],
|
||||||
buyer: [],
|
buyer: [],
|
||||||
});
|
});
|
||||||
console.log(accountInfo)
|
console.log(questionEntity)
|
||||||
|
console.log(tags)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isModalOpen) {
|
if (isModalOpen && quizID !== undefined && !isRemoveAccount) {
|
||||||
const fetchAccount = async () => {
|
const fetchAccount = async () => {
|
||||||
const [account, error] = await getAccount();
|
const [account, error] = await getAccount();
|
||||||
if (account && !error) {
|
|
||||||
setAccountInfo(account);
|
if (error) {
|
||||||
} else {
|
enqueueSnackbar(error)
|
||||||
setAccountInfo(null);
|
setAccountInfo(null);
|
||||||
}
|
}
|
||||||
|
if (account) {
|
||||||
|
setAccountInfo(account);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
const fetchRules = async () => {
|
||||||
|
const [settingsResponse, error] = await getIntegrationRules(quizID.toString());
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
enqueueSnackbar(error)
|
||||||
|
setIntegrationRules(null);
|
||||||
|
}
|
||||||
|
if (settingsResponse) {
|
||||||
|
setIntegrationRules(settingsResponse);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
fetchAccount();
|
fetchAccount();
|
||||||
|
fetchRules();
|
||||||
}
|
}
|
||||||
}, [isModalOpen]);
|
}, [isModalOpen, isRemoveAccount]);
|
||||||
|
|
||||||
const handleNextStep = () => {
|
const handleNextStep = () => {
|
||||||
setStep((prevState) => prevState + 1);
|
setStep((prevState) => prevState + 1);
|
||||||
@ -152,26 +178,27 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Соотнесение вопросов и сущностей",
|
title: "Добавление тегов",
|
||||||
isSettingsAvailable: true,
|
isSettingsAvailable: true,
|
||||||
component: (
|
component: (
|
||||||
<AmoStep6
|
<AmoStep6
|
||||||
questionEntity={questionEntity}
|
tags={tags}
|
||||||
setQuestionEntity={setQuestionEntity}
|
|
||||||
handlePrevStep={handlePrevStep}
|
handlePrevStep={handlePrevStep}
|
||||||
handleNextStep={handleNextStep}
|
handleNextStep={handleNextStep}
|
||||||
|
setTags={setTags}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Добавление тегов",
|
title: "Соотнесение вопросов и сущностей",
|
||||||
isSettingsAvailable: true,
|
isSettingsAvailable: true,
|
||||||
component: (
|
component: (
|
||||||
<AmoStep7
|
<AmoStep7
|
||||||
handleSmallBtn={handlePrevStep}
|
questionEntity={questionEntity}
|
||||||
handleLargeBtn={handleSave}
|
setQuestionEntity={setQuestionEntity}
|
||||||
tags={tags}
|
handlePrevStep={handlePrevStep}
|
||||||
setTags={setTags}
|
handleNextStep={handleSave}
|
||||||
|
questions={questions}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@ -190,6 +217,9 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
|||||||
|
|
||||||
const stepTitles = steps.map((step) => step.title);
|
const stepTitles = steps.map((step) => step.title);
|
||||||
|
|
||||||
|
//Если нет контекста квиза, то и делать на этой страничке нечего
|
||||||
|
if (quizID === undefined) redirect("/list")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
open={isModalOpen}
|
open={isModalOpen}
|
||||||
@ -252,8 +282,14 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
|||||||
isSettingsBlock={isSettingsBlock}
|
isSettingsBlock={isSettingsBlock}
|
||||||
setIsSettingsBlock={setIsSettingsBlock}
|
setIsSettingsBlock={setIsSettingsBlock}
|
||||||
setStep={setStep}
|
setStep={setStep}
|
||||||
|
startRemoveAccount={() => setIsRemoveAccount(true)}
|
||||||
/>
|
/>
|
||||||
{isSettingsBlock ? (
|
{isRemoveAccount && (
|
||||||
|
<AmoRemoveAccount
|
||||||
|
stopThisPage={() => setIsRemoveAccount(false)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{isSettingsBlock && (
|
||||||
<Box sx={{ flexGrow: 1, width: "100%" }}>
|
<Box sx={{ flexGrow: 1, width: "100%" }}>
|
||||||
<AmoSettingsBlock
|
<AmoSettingsBlock
|
||||||
stepTitles={stepTitles}
|
stepTitles={stepTitles}
|
||||||
@ -268,7 +304,8 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
|||||||
tags={tags}
|
tags={tags}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
) : (
|
)}
|
||||||
|
{!isSettingsBlock && !isRemoveAccount && (
|
||||||
<Box sx={{ flexGrow: 1, width: "100%" }}>{steps[step].component}</Box>
|
<Box sx={{ flexGrow: 1, width: "100%" }}>{steps[step].component}</Box>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@ -10,6 +10,7 @@ type AmoModalTitleProps = {
|
|||||||
isSettingsBlock?: boolean;
|
isSettingsBlock?: boolean;
|
||||||
setIsSettingsBlock: (value: boolean) => void;
|
setIsSettingsBlock: (value: boolean) => void;
|
||||||
setStep: (value: number) => void;
|
setStep: (value: number) => void;
|
||||||
|
startRemoveAccount: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AmoModalTitle: FC<AmoModalTitleProps> = ({
|
export const AmoModalTitle: FC<AmoModalTitleProps> = ({
|
||||||
@ -18,13 +19,16 @@ export const AmoModalTitle: FC<AmoModalTitleProps> = ({
|
|||||||
setIsSettingsBlock,
|
setIsSettingsBlock,
|
||||||
isSettingsBlock,
|
isSettingsBlock,
|
||||||
setStep,
|
setStep,
|
||||||
|
startRemoveAccount
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isMobile = useMediaQuery(theme.breakpoints.down(600));
|
const isMobile = useMediaQuery(theme.breakpoints.down(600));
|
||||||
|
|
||||||
const handleClick = useCallback(() => {
|
console.log(isSettingsBlock)
|
||||||
|
const handleClick = useCallback(async () => {
|
||||||
if (isSettingsBlock) {
|
if (isSettingsBlock) {
|
||||||
setIsSettingsBlock(false);
|
startRemoveAccount();
|
||||||
|
setIsSettingsBlock(false)
|
||||||
setStep(0);
|
setStep(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,61 @@
|
|||||||
|
import { FC } from "react"
|
||||||
|
import { Button, Typography, useTheme, Box } from "@mui/material"
|
||||||
|
import { removeAmoAccount } from "@/api/integration";
|
||||||
|
import { enqueueSnackbar } from "notistack";
|
||||||
|
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
stopThisPage: () => void;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export const AmoRemoveAccount: FC<Props> = ({
|
||||||
|
stopThisPage,
|
||||||
|
|
||||||
|
}: Props) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
const removeAccount = async () => {
|
||||||
|
const [, error] = await removeAmoAccount()
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
enqueueSnackbar(error)
|
||||||
|
} else {
|
||||||
|
stopThisPage()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
mt: "30px"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography textAlign="center">
|
||||||
|
Вы хотите сменить аккаунт?
|
||||||
|
</Typography>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "space-evenly",
|
||||||
|
flexWrap: "wrap",
|
||||||
|
margin: "30px auto",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
sx={{
|
||||||
|
width: "150px",
|
||||||
|
}}
|
||||||
|
onClick={stopThisPage}
|
||||||
|
>отмена</Button>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
sx={{
|
||||||
|
width: "150px",
|
||||||
|
}}
|
||||||
|
onClick={removeAccount}
|
||||||
|
>сменить</Button>
|
||||||
|
</Box>
|
||||||
|
</Box >
|
||||||
|
)
|
||||||
|
}
|
||||||
@ -7,23 +7,24 @@ import {
|
|||||||
useMemo,
|
useMemo,
|
||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { ItemsSelectionView } from "./ItemsSelectionView/ItemsSelectionView";
|
|
||||||
import { ItemDetailsView } from "./ItemDetailsView/ItemDetailsView";
|
|
||||||
import { TitleKeys, TQuestionEntity } from "../AmoCRMModal";
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
|
|
||||||
type AmoStep6Props = {
|
import { TagKeys, TTags } from "../AmoCRMModal";
|
||||||
handlePrevStep: () => void;
|
import Box from "@mui/material/Box";
|
||||||
|
import { ItemsSelectionView } from "../IntegrationStep7/ItemsSelectionView/ItemsSelectionView";
|
||||||
|
import { TagsDetailsView } from "./TagsDetailsView/TagsDetailsView";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
handleNextStep: () => void;
|
handleNextStep: () => void;
|
||||||
questionEntity: TQuestionEntity;
|
handlePrevStep: () => void;
|
||||||
setQuestionEntity: Dispatch<SetStateAction<TQuestionEntity>>;
|
tags: TTags;
|
||||||
|
setTags: Dispatch<SetStateAction<TTags>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AmoStep6: FC<AmoStep6Props> = ({
|
export const AmoStep6: FC<Props> = ({
|
||||||
handlePrevStep,
|
|
||||||
handleNextStep,
|
handleNextStep,
|
||||||
questionEntity,
|
handlePrevStep,
|
||||||
setQuestionEntity,
|
tags,
|
||||||
|
setTags,
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const [isSelection, setIsSelection] = useState<boolean>(false);
|
const [isSelection, setIsSelection] = useState<boolean>(false);
|
||||||
@ -33,14 +34,14 @@ export const AmoStep6: FC<AmoStep6Props> = ({
|
|||||||
const handleAdd = useCallback(() => {
|
const handleAdd = useCallback(() => {
|
||||||
if (!activeItem || !selectedValue) return;
|
if (!activeItem || !selectedValue) return;
|
||||||
|
|
||||||
setQuestionEntity((prevState) => ({
|
setTags((prevState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
[activeItem]: [...prevState[activeItem as TitleKeys], selectedValue],
|
[activeItem]: [...prevState[activeItem as TagKeys], selectedValue],
|
||||||
}));
|
}));
|
||||||
}, [activeItem, setQuestionEntity, selectedValue]);
|
}, [activeItem, setTags, selectedValue]);
|
||||||
|
|
||||||
const items = useMemo(
|
const items = useMemo(
|
||||||
() => ["Город", "Имя", "Фамилия", "Отчество", "Контрагент"],
|
() => ["#тег с результатом 1", "#еще один тег с результатом 2", "#тег"],
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -58,6 +59,7 @@ export const AmoStep6: FC<AmoStep6Props> = ({
|
|||||||
items={items}
|
items={items}
|
||||||
selectedValue={selectedValue}
|
selectedValue={selectedValue}
|
||||||
setSelectedValue={setSelectedValue}
|
setSelectedValue={setSelectedValue}
|
||||||
|
type={"typeTags"}
|
||||||
onSmallBtnClick={() => {
|
onSmallBtnClick={() => {
|
||||||
setActiveItem(null);
|
setActiveItem(null);
|
||||||
setIsSelection(false);
|
setIsSelection(false);
|
||||||
@ -69,11 +71,11 @@ export const AmoStep6: FC<AmoStep6Props> = ({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<ItemDetailsView
|
<TagsDetailsView
|
||||||
setIsSelection={setIsSelection}
|
setIsSelection={setIsSelection}
|
||||||
handleNextStep={handleNextStep}
|
|
||||||
handlePrevStep={handlePrevStep}
|
handlePrevStep={handlePrevStep}
|
||||||
questionEntity={questionEntity}
|
handleNextStep={handleNextStep}
|
||||||
|
tags={tags}
|
||||||
setActiveItem={setActiveItem}
|
setActiveItem={setActiveItem}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -2,19 +2,19 @@ import { Box, Typography, useTheme } from "@mui/material";
|
|||||||
import { StepButtonsBlock } from "../../StepButtonsBlock/StepButtonsBlock";
|
import { StepButtonsBlock } from "../../StepButtonsBlock/StepButtonsBlock";
|
||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
import { TagKeys, TTags } from "../../AmoCRMModal";
|
import { TagKeys, TTags } from "../../AmoCRMModal";
|
||||||
import { Item } from "../../IntegrationStep6/Item/Item";
|
import { Item } from "../../IntegrationStep7/Item/Item";
|
||||||
|
|
||||||
type TagsDetailsViewProps = {
|
type TagsDetailsViewProps = {
|
||||||
setIsSelection: (value: boolean) => void;
|
setIsSelection: (value: boolean) => void;
|
||||||
handleSmallBtn: () => void;
|
handlePrevStep: () => void;
|
||||||
handleLargeBtn: () => void;
|
handleNextStep: () => void;
|
||||||
tags: TTags;
|
tags: TTags;
|
||||||
setActiveItem: (value: string | null) => void;
|
setActiveItem: (value: string | null) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const TagsDetailsView: FC<TagsDetailsViewProps> = ({
|
export const TagsDetailsView: FC<TagsDetailsViewProps> = ({
|
||||||
handleSmallBtn,
|
handlePrevStep,
|
||||||
handleLargeBtn,
|
handleNextStep,
|
||||||
tags,
|
tags,
|
||||||
setActiveItem,
|
setActiveItem,
|
||||||
setIsSelection,
|
setIsSelection,
|
||||||
@ -89,9 +89,8 @@ export const TagsDetailsView: FC<TagsDetailsViewProps> = ({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<StepButtonsBlock
|
<StepButtonsBlock
|
||||||
onSmallBtnClick={handleSmallBtn}
|
onSmallBtnClick={handlePrevStep}
|
||||||
onLargeBtnClick={handleLargeBtn}
|
onLargeBtnClick={handleNextStep}
|
||||||
largeBtnText={"Сохранить"}
|
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@ -7,24 +7,26 @@ import {
|
|||||||
useMemo,
|
useMemo,
|
||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
|
import { ItemsSelectionView } from "./ItemsSelectionView/ItemsSelectionView";
|
||||||
import { TagKeys, TTags } from "../AmoCRMModal";
|
import { ItemDetailsView } from "./ItemDetailsView/ItemDetailsView";
|
||||||
|
import { TitleKeys, TQuestionEntity } from "../AmoCRMModal";
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import { ItemsSelectionView } from "../IntegrationStep6/ItemsSelectionView/ItemsSelectionView";
|
import type { AllTypesQuestion } from "@model/questionTypes/shared"
|
||||||
import { TagsDetailsView } from "./TagsDetailsView/TagsDetailsView";
|
|
||||||
|
|
||||||
type AmoStep7Props = {
|
type Props = {
|
||||||
handleSmallBtn: () => void;
|
handlePrevStep: () => void;
|
||||||
handleLargeBtn: () => void;
|
handleNextStep: () => void;
|
||||||
tags: TTags;
|
questionEntity: TQuestionEntity;
|
||||||
setTags: Dispatch<SetStateAction<TTags>>;
|
setQuestionEntity: Dispatch<SetStateAction<TQuestionEntity>>;
|
||||||
|
questions: AllTypesQuestion[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AmoStep7: FC<AmoStep7Props> = ({
|
export const AmoStep7: FC<Props> = ({
|
||||||
handleSmallBtn,
|
handlePrevStep,
|
||||||
handleLargeBtn,
|
handleNextStep,
|
||||||
tags,
|
questionEntity,
|
||||||
setTags,
|
setQuestionEntity,
|
||||||
|
questions,
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const [isSelection, setIsSelection] = useState<boolean>(false);
|
const [isSelection, setIsSelection] = useState<boolean>(false);
|
||||||
@ -34,14 +36,14 @@ export const AmoStep7: FC<AmoStep7Props> = ({
|
|||||||
const handleAdd = useCallback(() => {
|
const handleAdd = useCallback(() => {
|
||||||
if (!activeItem || !selectedValue) return;
|
if (!activeItem || !selectedValue) return;
|
||||||
|
|
||||||
setTags((prevState) => ({
|
setQuestionEntity((prevState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
[activeItem]: [...prevState[activeItem as TagKeys], selectedValue],
|
[activeItem]: [...prevState[activeItem as TitleKeys], selectedValue],
|
||||||
}));
|
}));
|
||||||
}, [activeItem, setTags, selectedValue]);
|
}, [activeItem, setQuestionEntity, selectedValue]);
|
||||||
|
|
||||||
const items = useMemo(
|
const items = useMemo(
|
||||||
() => ["#тег с результатом 1", "#еще один тег с результатом 2", "#тег"],
|
() => ["Город", "Имя", "Фамилия", "Отчество", "Контрагент"],
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -59,7 +61,6 @@ export const AmoStep7: FC<AmoStep7Props> = ({
|
|||||||
items={items}
|
items={items}
|
||||||
selectedValue={selectedValue}
|
selectedValue={selectedValue}
|
||||||
setSelectedValue={setSelectedValue}
|
setSelectedValue={setSelectedValue}
|
||||||
type={"typeTags"}
|
|
||||||
onSmallBtnClick={() => {
|
onSmallBtnClick={() => {
|
||||||
setActiveItem(null);
|
setActiveItem(null);
|
||||||
setIsSelection(false);
|
setIsSelection(false);
|
||||||
@ -69,13 +70,14 @@ export const AmoStep7: FC<AmoStep7Props> = ({
|
|||||||
setActiveItem(null);
|
setActiveItem(null);
|
||||||
setIsSelection(false);
|
setIsSelection(false);
|
||||||
}}
|
}}
|
||||||
|
questions={questions}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<TagsDetailsView
|
<ItemDetailsView
|
||||||
setIsSelection={setIsSelection}
|
setIsSelection={setIsSelection}
|
||||||
handleLargeBtn={handleLargeBtn}
|
handleLargeBtn={handleNextStep}
|
||||||
handleSmallBtn={handleSmallBtn}
|
handleSmallBtn={handlePrevStep}
|
||||||
tags={tags}
|
questionEntity={questionEntity}
|
||||||
setActiveItem={setActiveItem}
|
setActiveItem={setActiveItem}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -4,19 +4,19 @@ import { StepButtonsBlock } from "../../StepButtonsBlock/StepButtonsBlock";
|
|||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
import { TQuestionEntity } from "../../AmoCRMModal";
|
import { TQuestionEntity } from "../../AmoCRMModal";
|
||||||
|
|
||||||
type TitleKeys = "contacts" | "company" | "deal" | "users" | "buyers";
|
type TitleKeys = "contacts" | "company" | "deal" | "buyers";
|
||||||
|
|
||||||
type ItemDetailsViewProps = {
|
type ItemDetailsViewProps = {
|
||||||
setIsSelection: (value: boolean) => void;
|
setIsSelection: (value: boolean) => void;
|
||||||
handlePrevStep: () => void;
|
handleSmallBtn: () => void;
|
||||||
handleNextStep: () => void;
|
handleLargeBtn: () => void;
|
||||||
questionEntity: TQuestionEntity;
|
questionEntity: TQuestionEntity;
|
||||||
setActiveItem: (value: string | null) => void;
|
setActiveItem: (value: string | null) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ItemDetailsView: FC<ItemDetailsViewProps> = ({
|
export const ItemDetailsView: FC<ItemDetailsViewProps> = ({
|
||||||
handlePrevStep,
|
handleSmallBtn,
|
||||||
handleNextStep,
|
handleLargeBtn,
|
||||||
questionEntity,
|
questionEntity,
|
||||||
setActiveItem,
|
setActiveItem,
|
||||||
setIsSelection,
|
setIsSelection,
|
||||||
@ -69,8 +69,9 @@ export const ItemDetailsView: FC<ItemDetailsViewProps> = ({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<StepButtonsBlock
|
<StepButtonsBlock
|
||||||
onSmallBtnClick={handlePrevStep}
|
onSmallBtnClick={handleSmallBtn}
|
||||||
onLargeBtnClick={handleNextStep}
|
onLargeBtnClick={handleLargeBtn}
|
||||||
|
largeBtnText={"Сохранить"}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
@ -2,6 +2,7 @@ import { Box } from "@mui/material";
|
|||||||
import { CustomRadioGroup } from "../../../../../components/CustomRadioGroup/CustomRadioGroup";
|
import { CustomRadioGroup } from "../../../../../components/CustomRadioGroup/CustomRadioGroup";
|
||||||
import { StepButtonsBlock } from "../../StepButtonsBlock/StepButtonsBlock";
|
import { StepButtonsBlock } from "../../StepButtonsBlock/StepButtonsBlock";
|
||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
|
import { AllTypesQuestion } from "@/model/questionTypes/shared";
|
||||||
|
|
||||||
type ItemsSelectionViewProps = {
|
type ItemsSelectionViewProps = {
|
||||||
type?: string;
|
type?: string;
|
||||||
@ -6,6 +6,7 @@ import { YandexMetricaLogo } from "../mocks/YandexMetricaLogo";
|
|||||||
import { VKPixelLogo } from "../mocks/VKPixelLogo";
|
import { VKPixelLogo } from "../mocks/VKPixelLogo";
|
||||||
import { QuizMetricType } from "@model/quizSettings";
|
import { QuizMetricType } from "@model/quizSettings";
|
||||||
import { AmoCRMLogo } from "../mocks/AmoCRMLogo";
|
import { AmoCRMLogo } from "../mocks/AmoCRMLogo";
|
||||||
|
import { useCurrentQuiz } from "@/stores/quizes/hooks";
|
||||||
|
|
||||||
const AnalyticsModal = lazy(() =>
|
const AnalyticsModal = lazy(() =>
|
||||||
import("./AnalyticsModal/AnalyticsModal").then((module) => ({
|
import("./AnalyticsModal/AnalyticsModal").then((module) => ({
|
||||||
@ -43,6 +44,8 @@ export const PartnersBoard: FC<PartnersBoardProps> = ({
|
|||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isMobile = useMediaQuery(theme.breakpoints.down(600));
|
const isMobile = useMediaQuery(theme.breakpoints.down(600));
|
||||||
|
|
||||||
|
const quiz = useCurrentQuiz();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@ -125,6 +128,7 @@ export const PartnersBoard: FC<PartnersBoardProps> = ({
|
|||||||
isModalOpen={isAmoCrmModalOpen}
|
isModalOpen={isAmoCrmModalOpen}
|
||||||
handleCloseModal={handleCloseAmoSRMModal}
|
handleCloseModal={handleCloseAmoSRMModal}
|
||||||
companyName={companyName}
|
companyName={companyName}
|
||||||
|
quizID={quiz?.backendId}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -25,7 +25,7 @@ const translateMessage: Record<string, string> = {
|
|||||||
|
|
||||||
export const parseAxiosError = (nativeError: unknown): [string, number?] => {
|
export const parseAxiosError = (nativeError: unknown): [string, number?] => {
|
||||||
const error = nativeError as AxiosError;
|
const error = nativeError as AxiosError;
|
||||||
|
console.log(error)
|
||||||
if (process.env.NODE_ENV !== "production") console.error(error);
|
if (process.env.NODE_ENV !== "production") console.error(error);
|
||||||
if (error.message === "Failed to fetch") return ["Ошибка сети"];
|
if (error.message === "Failed to fetch") return ["Ошибка сети"];
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user