Merge branch 'dev' into 'staging'
Dev See merge request frontend/squiz!342
This commit is contained in:
commit
2cb1aff63a
@ -11,19 +11,20 @@ const API_URL = `${process.env.REACT_APP_DOMAIN}/squiz/amocrm`;
|
||||
// получение информации об аккаунте
|
||||
|
||||
export type AccountResponse = {
|
||||
ID: number;
|
||||
AmoUserID: number;
|
||||
AccountID: string;
|
||||
AmoID: number;
|
||||
Name: string;
|
||||
Email: string;
|
||||
Role: string;
|
||||
Group: number;
|
||||
Deleted: boolean;
|
||||
CreatedAt: number;
|
||||
Subdomain: string;
|
||||
Amoiserid: number;
|
||||
Country: string;
|
||||
id: number;
|
||||
accountID: string;
|
||||
amoID: number;
|
||||
name: string;
|
||||
deleted: boolean;
|
||||
createdAt: string;
|
||||
subdomain: string;
|
||||
country: string;
|
||||
driveURL: string;
|
||||
// AmoUiserid: number;
|
||||
// Email: string;
|
||||
// Role: string;
|
||||
// Group: number;
|
||||
// AmoUserID: number;
|
||||
};
|
||||
|
||||
export const getAccount = async (): Promise<
|
||||
@ -117,18 +118,18 @@ export const getTags = async ({
|
||||
//получение списка пользователей
|
||||
|
||||
export type User = {
|
||||
ID: number;
|
||||
AccountID: string;
|
||||
AmoID: number;
|
||||
Name: string;
|
||||
Email: string;
|
||||
Role: string;
|
||||
Group: number;
|
||||
Deleted: boolean;
|
||||
CreatedAt: number;
|
||||
Subdomain: string;
|
||||
Amoiserid: number;
|
||||
Country: string;
|
||||
id: number;
|
||||
amoID: number;
|
||||
name: string;
|
||||
email: string;
|
||||
role: number;
|
||||
group: number;
|
||||
deleted: boolean;
|
||||
createdAt: string;
|
||||
amoUserID: number;
|
||||
|
||||
// Subdomain: string;
|
||||
// AccountID: string;
|
||||
};
|
||||
|
||||
export type UsersResponse = {
|
||||
@ -229,23 +230,35 @@ export const getPipelines = async ({
|
||||
};
|
||||
|
||||
//получение настроек интеграции
|
||||
type QuestionID = Record<string, number>
|
||||
|
||||
export type IntegrationRules = {
|
||||
ID: number;
|
||||
AccountID: number;
|
||||
QuizID: number;
|
||||
PerformerID: number;
|
||||
PipelineID: number;
|
||||
StepID: number;
|
||||
UTMs: number[];
|
||||
PerformerID?: number;
|
||||
FieldsRule: {
|
||||
Lead: { QuestionID: number }[];
|
||||
Contact: { ContactRuleMap: string }[];
|
||||
Company: { QuestionID: number }[];
|
||||
Customer: { QuestionID: number }[];
|
||||
Lead: [
|
||||
{
|
||||
QuestionID: QuestionID;
|
||||
}
|
||||
] | null,
|
||||
Company: [
|
||||
{
|
||||
QuestionID: QuestionID;
|
||||
}
|
||||
] | null,
|
||||
Customer: [
|
||||
{
|
||||
QuestionID: QuestionID;
|
||||
}
|
||||
] | null,
|
||||
};
|
||||
Deleted: boolean;
|
||||
CreatedAt: number;
|
||||
TagsToAdd: {
|
||||
Lead: number[] | null;
|
||||
Contact: number[] | null;
|
||||
Company: number[] | null;
|
||||
Customer: number[] | null;
|
||||
}
|
||||
};
|
||||
|
||||
export const getIntegrationRules = async (
|
||||
|
@ -54,8 +54,6 @@ export const CustomRadioGroup: FC<CustomRadioGroupProps> = ({
|
||||
const boxRef = useRef(null);
|
||||
|
||||
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
console.log("применился хенделчейндж")
|
||||
console.log((event.target as HTMLInputElement).value)
|
||||
setSelectedValue((event.target as HTMLInputElement).value);
|
||||
setCurrentValue((event.target as HTMLInputElement).value);
|
||||
};
|
||||
@ -70,9 +68,6 @@ export const CustomRadioGroup: FC<CustomRadioGroupProps> = ({
|
||||
setPage((prevPage) => prevPage + 1);
|
||||
}
|
||||
};
|
||||
console.log(type)
|
||||
console.log(items)
|
||||
console.log(type === "typeQuestions" && items && items.length !== 0)
|
||||
|
||||
useEffect(() => {
|
||||
if (type === "typeTags" && hasMoreItems && setTags !== undefined) {
|
||||
@ -315,9 +310,6 @@ export const CustomRadioGroup: FC<CustomRadioGroupProps> = ({
|
||||
name="controlled-radio-buttons-group"
|
||||
value={currentValue}
|
||||
onChange={(e) => {
|
||||
console.log("klick")
|
||||
console.log(e.target.value)
|
||||
console.log(typeof e.target.value)
|
||||
handleChange(e)
|
||||
}}
|
||||
>
|
||||
|
@ -39,14 +39,16 @@ export const CustomSelect: FC<CustomSelectProps> = ({
|
||||
const selectWidth = ref.current ? ref.current.offsetWidth : undefined;
|
||||
|
||||
const [savedValue, setSavedValue] = useState<number | null>(null);
|
||||
const [userName, setUserName] = useState<string>("");
|
||||
|
||||
const onSelectItem = useCallback(
|
||||
(event: SelectChangeEvent<HTMLDivElement>) => {
|
||||
const newValue = event.target.value.toString();
|
||||
const selectedUser = users.find((user) => user.Name === newValue);
|
||||
const selectedUser = users.find((user) => user.amoUserID == Number(newValue));
|
||||
setUserName(selectedUser.name)
|
||||
if (selectedUser) {
|
||||
//для сохранения ID выбранного пользователя в стейт или конфиг...
|
||||
setSavedValue(selectedUser.ID);
|
||||
setSavedValue(selectedUser.id);
|
||||
}
|
||||
setCurrentValue(newValue);
|
||||
setSelectedItem(newValue);
|
||||
@ -90,12 +92,10 @@ export const CustomSelect: FC<CustomSelectProps> = ({
|
||||
|
||||
const menuItems = useMemo(() => {
|
||||
if (type === "typeUsers" && users && users.length !== 0) {
|
||||
console.log(type)
|
||||
console.log(users)
|
||||
return users.map((user) => (
|
||||
<MenuItem
|
||||
key={user.ID}
|
||||
value={user.AmocrmID}
|
||||
key={user.amoUserID}
|
||||
value={user.amoUserID}
|
||||
sx={{
|
||||
padding: "6px 0",
|
||||
zIndex: 2,
|
||||
@ -122,7 +122,7 @@ export const CustomSelect: FC<CustomSelectProps> = ({
|
||||
padding: isMobile ? "5px 0 5px 20px" : "10px 0 10px 20px",
|
||||
}}
|
||||
>
|
||||
{user.Name}
|
||||
{user.name}
|
||||
</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
@ -134,7 +134,7 @@ export const CustomSelect: FC<CustomSelectProps> = ({
|
||||
color: isMobile ? "#9A9AAF" : "#4D4D4D",
|
||||
}}
|
||||
>
|
||||
{user.Email}
|
||||
{user.email}
|
||||
</Typography>
|
||||
<Typography
|
||||
sx={{
|
||||
@ -143,7 +143,7 @@ export const CustomSelect: FC<CustomSelectProps> = ({
|
||||
color: isMobile ? "#9A9AAF" : "#4D4D4D",
|
||||
}}
|
||||
>
|
||||
{user.Role}
|
||||
{user.role}
|
||||
</Typography>
|
||||
</Box>
|
||||
</MenuItem>
|
||||
@ -190,7 +190,7 @@ export const CustomSelect: FC<CustomSelectProps> = ({
|
||||
flexGrow: 1,
|
||||
}}
|
||||
>
|
||||
{currentValue || "Выберите ответственного за сделку"}
|
||||
{userName || "Выберите ответственного за сделку"}
|
||||
</Typography>
|
||||
<img
|
||||
src={arrow_down}
|
||||
|
@ -71,12 +71,12 @@ export const AmoAccountInfo: FC<AmoAccountInfoProps> = ({
|
||||
gap: isMobile ? "10px" : "20px",
|
||||
}}
|
||||
>
|
||||
{infoItem("Amo ID", accountInfo.AmoUserID)}
|
||||
{infoItem("Имя аккаунта", accountInfo.Name)}
|
||||
{infoItem("Email аккаунта", accountInfo.Email)}
|
||||
{infoItemLink("ЛК в amo", `https://${accountInfo.Subdomain}.amocrm.ru/dashboard/`)}
|
||||
{infoItemLink("Профиль пользователя в amo", `https://${accountInfo.Subdomain}.amocrm.ru/settings/users/`)}
|
||||
{infoItem("Страна пользователя", accountInfo.Country)}
|
||||
{infoItem("Amo ID", accountInfo.amoUserID)}
|
||||
{infoItem("Имя аккаунта", accountInfo.name)}
|
||||
{infoItem("Email аккаунта", accountInfo.email)}
|
||||
{infoItemLink("ЛК в amo", `https://${accountInfo.subdomain}.amocrm.ru/dashboard/`)}
|
||||
{infoItemLink("Профиль пользователя в amo", `https://${accountInfo.subdomain}.amocrm.ru/settings/users/`)}
|
||||
{infoItem("Страна пользователя", accountInfo.country)}
|
||||
</Box>
|
||||
<StepButtonsBlock
|
||||
isSmallBtnDisabled={true}
|
||||
|
@ -1,29 +1,32 @@
|
||||
import React, { FC, useEffect, useMemo, useState } from "react";
|
||||
import {
|
||||
Dialog,
|
||||
IconButton,
|
||||
Typography,
|
||||
useMediaQuery,
|
||||
useTheme,
|
||||
Box,
|
||||
} from "@mui/material";
|
||||
import React, { FC, useEffect, useMemo, useState } from "react";
|
||||
import Box from "@mui/material/Box";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import { AmoRemoveAccount } from "./AmoRemoveAccount/AmoRemoveAccount";
|
||||
import { AmoLogin } from "./AmoLogin/AmoLogin";
|
||||
import { AmoStep2 } from "./AmoStep2/AmoStep2";
|
||||
import { AmoStep3 } from "./AmoStep3/AmoStep3";
|
||||
import { AmoStep4 } from "./AmoStep4/AmoStep4";
|
||||
import { AmoStep6 } from "./IntegrationStep6/AmoStep6";
|
||||
import { AmoStep7 } from "./IntegrationStep7/AmoStep7";
|
||||
import { AmoModalTitle } from "./AmoModalTitle/AmoModalTitle";
|
||||
import { AmoSettingsBlock } from "./SettingsBlock/AmoSettingsBlock";
|
||||
import { AmoAccountInfo } from "./AmoAccountInfo/AmoAccountInfo";
|
||||
import { AccountResponse, IntegrationRules, getAccount, getIntegrationRules, setIntegrationRules, updateIntegrationRules } from "@api/integration";
|
||||
import { useQuestions } from "@/stores/questions/hooks";
|
||||
import { redirect } from "react-router-dom";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
|
||||
export type TitleKeys = "Contact" | "Company" | "Lead" | "Customer";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
|
||||
import { AmoRemoveAccount } from "./AmoRemoveAccount/AmoRemoveAccount";
|
||||
import { AmoLogin } from "./AmoLogin/AmoLogin";
|
||||
import { Pipelines } from "./Pipelines/Pipelines";
|
||||
import { PipelineSteps } from "./PipelineSteps/PipelineSteps";
|
||||
import { DealPerformers } from "./DealPerformers/DealPerformers";
|
||||
import { AmoTags } from "./AmoTags/AmoTags";
|
||||
import { AmoQuestions } from "./AmoQuestions/AmoQuestions";
|
||||
import { AmoModalTitle } from "./AmoModalTitle/AmoModalTitle";
|
||||
import { AmoSettingsBlock } from "./SettingsBlock/AmoSettingsBlock";
|
||||
import { AmoAccountInfo } from "./AmoAccountInfo/AmoAccountInfo";
|
||||
import { AccountResponse, IntegrationRules, Pipeline, Step, User, getAccount, getIntegrationRules, getPipelines, getSteps, getTags, getUsers, setIntegrationRules, updateIntegrationRules } from "@api/integration";
|
||||
|
||||
|
||||
export type TitleKeys = "Company" | "Lead" | "Customer";
|
||||
export type TagQuestionObject = {
|
||||
backendId: string;
|
||||
title: string;
|
||||
@ -57,22 +60,20 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
||||
const [isRemoveAccount, setIsRemoveAccount] = useState<boolean>(false);
|
||||
|
||||
const [firstRules, setFirstRules] = useState<boolean>(false);
|
||||
|
||||
const [accountInfo, setAccountInfo] = useState<AccountResponse | null>(null);
|
||||
const [selectedPipelinePerformer, setSelectedPipelinePerformer] = useState<
|
||||
string | null
|
||||
>(null);
|
||||
const [selectedPipeline, setSelectedPipeline] = useState<string | null>(null);
|
||||
const [selectedStepsPerformer, setSelectedStepsPerformer] = useState<
|
||||
string | null
|
||||
>(null);
|
||||
const [selectedStep, setSelectedStep] = useState<string | null>(null);
|
||||
const [selectedDealPerformer, setSelectedDealPerformer] = useState<
|
||||
string | null
|
||||
>(null);
|
||||
|
||||
const [arrayOfPipelines, setArrayOfPipelines] = useState<Pipeline[]>([]);
|
||||
const [arrayOfPipelinesSteps, setArrayOfPipelinesSteps] = useState<Step[]>([]);
|
||||
const [arrayOfUsers, setArrayOfUsers] = useState<User[]>([]);
|
||||
const [arrayOfTags, setArrayOfTags] = useState<TTags[]>([]);
|
||||
|
||||
const [selectedPipeline, setSelectedPipeline] = useState<number | null>(null);
|
||||
const [selectedPipelineStep, setSelectedPipelineStep] = useState<number | null>(null);
|
||||
const [selectedDealPerformer, setSelectedDealPerformer] = useState<number | null>(null);
|
||||
|
||||
const [questionEntityBackend, setQuestionEntityBackend] = useState<TQuestionEntity>({});
|
||||
const [questionEntity, setQuestionEntity] = useState<TQuestionEntity>({
|
||||
Lead: [],
|
||||
Contact: [],
|
||||
Company: [],
|
||||
Customer: [],
|
||||
});
|
||||
@ -82,8 +83,6 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
||||
Company: [],
|
||||
Customer: [],
|
||||
});
|
||||
console.log(questionEntity)
|
||||
console.log(tags)
|
||||
|
||||
useEffect(() => {
|
||||
if (isModalOpen && quizID !== undefined && !isRemoveAccount) {
|
||||
@ -106,16 +105,78 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
||||
if (!error.includes("Not Found") && !error.includes("first")) enqueueSnackbar(error);
|
||||
}
|
||||
if (settingsResponse) {
|
||||
console.log(settingsResponse);
|
||||
setFirstRules(false);
|
||||
if (settingsResponse.PipelineID) setSelectedPipeline(settingsResponse.PipelineID)
|
||||
if (settingsResponse.StepID) setSelectedPipelineStep(settingsResponse.StepID)
|
||||
if (settingsResponse.PerformerID) setSelectedDealPerformer(settingsResponse.PerformerID)
|
||||
if (Boolean(settingsResponse.FieldsRule) &&
|
||||
Object.keys(settingsResponse.FieldsRule).length > 0) {
|
||||
const newRules = { ...questionEntity }
|
||||
setQuestionEntityBackend(settingsResponse.FieldsRule)
|
||||
for (let key in settingsResponse.FieldsRule) {
|
||||
if (settingsResponse.FieldsRule[key] !== null && Array.isArray(settingsResponse.FieldsRule[key])) {
|
||||
const gottenList = Object.keys(settingsResponse.FieldsRule[key][0].QuestionID)
|
||||
newRules[key] = gottenList
|
||||
}
|
||||
}
|
||||
setQuestionEntity(newRules)
|
||||
}
|
||||
if (Boolean(settingsResponse.TagsToAdd) &&
|
||||
Object.keys(settingsResponse.TagsToAdd).length > 0) {
|
||||
const newRules = { ...tags }
|
||||
for (let key in settingsResponse.TagsToAdd) {
|
||||
const gottenList = settingsResponse.TagsToAdd[key]
|
||||
if (gottenList !== null && Array.isArray(gottenList)) {
|
||||
newRules[key] = gottenList
|
||||
}
|
||||
}
|
||||
setTags(newRules)
|
||||
}
|
||||
setFirstRules(false);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
getTags({
|
||||
page: 1,
|
||||
size: 9999,
|
||||
}).then(([response]) => {
|
||||
if (response && response.items !== null) {
|
||||
setArrayOfTags(response.items);
|
||||
}
|
||||
});
|
||||
getUsers({
|
||||
page: 1,
|
||||
size: 9999,
|
||||
}).then(([response]) => {
|
||||
if (response && response.items !== null) {
|
||||
setArrayOfUsers(response.items);
|
||||
}
|
||||
});
|
||||
getPipelines({
|
||||
page: 1,
|
||||
size: 9999,
|
||||
}).then(([response]) => {
|
||||
if (response && response.items !== null) {
|
||||
setArrayOfPipelines(response.items);
|
||||
}
|
||||
})
|
||||
|
||||
fetchAccount();
|
||||
fetchRules();
|
||||
}
|
||||
}, [isModalOpen, isRemoveAccount]);
|
||||
useEffect(() => {
|
||||
if (selectedPipeline !== null)
|
||||
getSteps({
|
||||
page: 1,
|
||||
size: 9999,
|
||||
pipelineId: selectedPipeline,
|
||||
}).then(([response]) => {
|
||||
if (response && response.items !== null) {
|
||||
setArrayOfPipelinesSteps(response.items);
|
||||
}
|
||||
});
|
||||
}, [selectedPipeline])
|
||||
|
||||
const handleNextStep = () => {
|
||||
setStep((prevState) => prevState + 1);
|
||||
@ -126,51 +187,47 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
||||
const handleSave = () => {
|
||||
console.log("На отправку")
|
||||
console.log({
|
||||
PerformerID: selectedDealPerformer,
|
||||
PipelineID: selectedPipeline,
|
||||
StepID: selectedStep,
|
||||
Fieldsrule: {
|
||||
...questionEntity
|
||||
},
|
||||
TagsToAdd: {
|
||||
...tags
|
||||
}
|
||||
})
|
||||
if (quizID === undefined) return
|
||||
if (selectedPipeline?.toString().length === 0) return enqueueSnackbar("Выберите воронку")
|
||||
if (selectedPipeline?.toString().length === 0) return enqueueSnackbar("Выберите этап воронки")
|
||||
PipelineID: Number(selectedPipeline),
|
||||
StepID: Number(selectedPipelineStep),
|
||||
PerformerID: Number(selectedDealPerformer),
|
||||
FieldsRule: questionEntity,
|
||||
TagsToAdd: tags
|
||||
})
|
||||
if (quizID === undefined) return
|
||||
if (selectedPipeline === null) return enqueueSnackbar("Выберите воронку")
|
||||
if (selectedPipeline === null) return enqueueSnackbar("Выберите этап воронки")
|
||||
|
||||
if (firstRules) {
|
||||
setIntegrationRules(quizID.toString(), {
|
||||
PerformerID: Number(selectedDealPerformer),
|
||||
PipelineID: Number(selectedPipeline),
|
||||
StepID: Number(selectedStep),
|
||||
Fieldsrule: {
|
||||
...questionEntity
|
||||
},
|
||||
TagsToAdd: {
|
||||
...tags
|
||||
}
|
||||
})
|
||||
} else {
|
||||
const body = {
|
||||
|
||||
Fieldsrule: {
|
||||
...questionEntity
|
||||
},
|
||||
TagsToAdd: {
|
||||
...tags
|
||||
}
|
||||
};
|
||||
if (selectedDealPerformer?.toString() > 0) body.PerformerID = Number(selectedDealPerformer)
|
||||
if (selectedPipeline?.toString() > 0) body.PipelineID = Number(selectedPipeline)
|
||||
if (selectedStep?.toString() > 0) body.StepID = Number(selectedStep)
|
||||
|
||||
updateIntegrationRules(quizID.toString(), body)
|
||||
const body = {
|
||||
PipelineID: Number(selectedPipeline),
|
||||
StepID: Number(selectedPipelineStep),
|
||||
PerformerID: Number(selectedDealPerformer),
|
||||
FieldsRule: questionEntityBackend,
|
||||
TagsToAdd: tags
|
||||
}
|
||||
|
||||
// handleCloseModal();
|
||||
// setStep(1);
|
||||
|
||||
for (let key in questionEntityBackend) {
|
||||
if (key !== "Contact") {
|
||||
|
||||
if (body.FieldsRule[key] === null) body.FieldsRule[key] = [{ "QuestionID": {} }]
|
||||
console.log(key)
|
||||
console.log(questionEntity)
|
||||
questionEntity[key].forEach((id) => {
|
||||
body.FieldsRule[key][0].QuestionID[id] = 0
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
console.log(body)
|
||||
|
||||
if (firstRules) {
|
||||
setIntegrationRules(quizID.toString(), body)
|
||||
} else {
|
||||
updateIntegrationRules(quizID.toString(), body)
|
||||
}
|
||||
|
||||
handleCloseModal();
|
||||
setStep(1);
|
||||
};
|
||||
const steps = useMemo(
|
||||
() => [
|
||||
@ -192,12 +249,11 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
||||
title: "Выбор воронки",
|
||||
isSettingsAvailable: true,
|
||||
component: (
|
||||
<AmoStep2
|
||||
<Pipelines
|
||||
handlePrevStep={handlePrevStep}
|
||||
handleNextStep={handleNextStep}
|
||||
selectedPipelinePerformer={selectedDealPerformer}
|
||||
setSelectedPipelinePerformer={setSelectedDealPerformer}
|
||||
setSelectedDealPerformer={setSelectedDealPerformer}
|
||||
selectedPipeline={selectedPipeline}
|
||||
setSelectedPipeline={setSelectedPipeline}
|
||||
/>
|
||||
@ -207,13 +263,13 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
||||
title: "Выбор этапа воронки",
|
||||
isSettingsAvailable: true,
|
||||
component: (
|
||||
<AmoStep3
|
||||
<PipelineSteps
|
||||
handlePrevStep={handlePrevStep}
|
||||
handleNextStep={handleNextStep}
|
||||
selectedStepsPerformer={selectedDealPerformer}
|
||||
setSelectedStepsPerformer={setSelectedDealPerformer}
|
||||
selectedStep={selectedStep}
|
||||
setSelectedStep={setSelectedStep}
|
||||
selectedStep={selectedPipelineStep}
|
||||
setSelectedStep={setSelectedPipelineStep}
|
||||
pipelineId={selectedPipeline}
|
||||
/>
|
||||
),
|
||||
@ -222,7 +278,7 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
||||
title: "Сделка",
|
||||
isSettingsAvailable: true,
|
||||
component: (
|
||||
<AmoStep4
|
||||
<DealPerformers
|
||||
handlePrevStep={handlePrevStep}
|
||||
handleNextStep={handleNextStep}
|
||||
selectedDealPerformer={selectedDealPerformer}
|
||||
@ -234,11 +290,12 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
||||
title: "Добавление тегов",
|
||||
isSettingsAvailable: true,
|
||||
component: (
|
||||
<AmoStep6
|
||||
<AmoTags
|
||||
tagsNames={tags}
|
||||
handlePrevStep={handlePrevStep}
|
||||
handleNextStep={handleNextStep}
|
||||
setTagsNames={setTags}
|
||||
setIdTags={setTags}
|
||||
arrayOfTags={arrayOfTags}
|
||||
/>
|
||||
),
|
||||
},
|
||||
@ -246,7 +303,7 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
||||
title: "Соотнесение вопросов и сущностей",
|
||||
isSettingsAvailable: true,
|
||||
component: (
|
||||
<AmoStep7
|
||||
<AmoQuestions
|
||||
questionEntity={questionEntity}
|
||||
setQuestionEntity={setQuestionEntity}
|
||||
handlePrevStep={handlePrevStep}
|
||||
@ -259,10 +316,8 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
||||
[
|
||||
accountInfo,
|
||||
questionEntity,
|
||||
selectedPipelinePerformer,
|
||||
selectedPipeline,
|
||||
selectedStepsPerformer,
|
||||
selectedStep,
|
||||
selectedPipelineStep,
|
||||
selectedDealPerformer,
|
||||
tags,
|
||||
],
|
||||
@ -271,7 +326,7 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
||||
const stepTitles = steps.map((step) => step.title);
|
||||
|
||||
//Если нет контекста квиза, то и делать на этой страничке нечего
|
||||
if (quizID === undefined) redirect("/list")
|
||||
if (quizID === undefined) return redirect("/list")
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
@ -348,11 +403,9 @@ export const AmoCRMModal: FC<IntegrationsModalProps> = ({
|
||||
stepTitles={stepTitles}
|
||||
setIsSettingsBlock={setIsSettingsBlock}
|
||||
setStep={setStep}
|
||||
selectedDealPerformer={selectedDealPerformer}
|
||||
selectedFunnelPerformer={selectedPipelinePerformer}
|
||||
selectedFunnel={selectedPipeline}
|
||||
selectedStagePerformer={selectedStepsPerformer}
|
||||
selectedStage={selectedStep}
|
||||
selectedDealPerformer={arrayOfUsers.find(p => p.amoUserID == selectedDealPerformer)?.name || null}
|
||||
selectedFunnel={arrayOfPipelines.find(p => selectedPipeline)?.Name || null}
|
||||
selectedStage={arrayOfPipelinesSteps.find(p => selectedPipelineStep)?.Name || null}
|
||||
questionEntity={questionEntity}
|
||||
tags={tags}
|
||||
/>
|
||||
|
@ -27,7 +27,6 @@ export const AmoLogin: FC<IntegrationStep1Props> = ({ handleNextStep }) => {
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down(600));
|
||||
|
||||
const onAmoClick = async () => {
|
||||
console.log("Amo click");
|
||||
const [url, error] = await connectAmo();
|
||||
if (url && !error) {
|
||||
window.open(url, "_blank");
|
||||
|
@ -24,7 +24,6 @@ export const AmoModalTitle: FC<AmoModalTitleProps> = ({
|
||||
const theme = useTheme();
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down(600));
|
||||
|
||||
console.log(isSettingsBlock)
|
||||
const handleClick = useCallback(async () => {
|
||||
if (isSettingsBlock) {
|
||||
startRemoveAccount();
|
||||
|
@ -23,7 +23,7 @@ type Props = {
|
||||
questions: AllTypesQuestion[];
|
||||
};
|
||||
|
||||
export const AmoStep7: FC<Props> = ({
|
||||
export const AmoQuestions: FC<Props> = ({
|
||||
handlePrevStep,
|
||||
handleNextStep,
|
||||
questionEntity,
|
||||
@ -56,16 +56,20 @@ export const AmoStep7: FC<Props> = ({
|
||||
[],
|
||||
);
|
||||
const translatedQuestionEntity = useMemo(() => {
|
||||
const translated = {} as TQuestionEntity;
|
||||
const translated = {
|
||||
|
||||
} as TQuestionEntity;
|
||||
|
||||
for (let key in questionEntity) {
|
||||
translated[key] = questionEntity[key].map((id) =>
|
||||
questions.find((q) => q.backendId === Number(id))?.title || id
|
||||
)
|
||||
if (questionEntity[key] !== "Contact") {
|
||||
console.log(translated)
|
||||
console.log(translated[key])
|
||||
console.log(questionEntity)
|
||||
translated[key] = questionEntity[key].map((id) =>
|
||||
questions.find((q) => q.backendId === Number(id))?.title || id)
|
||||
}
|
||||
}
|
||||
|
||||
console.log("questionEntity", questionEntity)
|
||||
console.log("translated", translated)
|
||||
return translated
|
||||
},
|
||||
[questionEntity],
|
@ -21,6 +21,8 @@ export const AnswerItem: FC<AnswerItemProps> = ({ fieldName, fieldValue }) => {
|
||||
fontSize: "14px",
|
||||
fontWeight: 500,
|
||||
color: theme.palette.grey3.main,
|
||||
textOverflow: "ellipsis",
|
||||
overflow: "hidden"
|
||||
}}
|
||||
>
|
||||
{fieldName}
|
||||
@ -30,6 +32,8 @@ export const AnswerItem: FC<AnswerItemProps> = ({ fieldName, fieldValue }) => {
|
||||
fontSize: "14px",
|
||||
fontWeight: 400,
|
||||
color: theme.palette.grey3.main,
|
||||
textOverflow: "ellipsis",
|
||||
overflow: "hidden"
|
||||
}}
|
||||
>
|
||||
{fieldValue}
|
@ -9,11 +9,9 @@ type ItemProps = {
|
||||
onAddBtnClick: () => void;
|
||||
data: TQuestionEntity | TTags;
|
||||
};
|
||||
export const Item: FC<ItemProps> = ({ title, onAddBtnClick, data }) => {
|
||||
export const Item: FC<ItemProps> = ({ title, onAddBtnClick, data, tagsNamesList }) => {
|
||||
const theme = useTheme();
|
||||
|
||||
console.log("title")
|
||||
console.log(data)
|
||||
const titleDictionary = {
|
||||
Company: "Компания",
|
||||
Lead: "Сделка",
|
||||
@ -53,7 +51,7 @@ export const Item: FC<ItemProps> = ({ title, onAddBtnClick, data }) => {
|
||||
<AnswerItem
|
||||
key={text + index}
|
||||
fieldValue={"Значение поля"}
|
||||
fieldName={text}
|
||||
fieldName={tagsNamesList?.[title][index] || text}
|
||||
/>
|
||||
))}
|
||||
|
@ -27,8 +27,6 @@ export const ItemsSelectionView: FC<ItemsSelectionViewProps> = ({
|
||||
parentTags,
|
||||
setTags
|
||||
}) => {
|
||||
console.log("items тегов")
|
||||
console.log(items)
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
@ -9,9 +9,9 @@ import {
|
||||
useState,
|
||||
} from "react";
|
||||
|
||||
import { TagKeys, TTags } from "../AmoCRMModal";
|
||||
import { TagKeys, TagQuestionObject, TTags } from "../AmoCRMModal";
|
||||
import Box from "@mui/material/Box";
|
||||
import { ItemsSelectionView } from "../IntegrationStep7/ItemsSelectionView/ItemsSelectionView";
|
||||
import { ItemsSelectionView } from "../AmoQuestions/ItemsSelectionView/ItemsSelectionView";
|
||||
import { TagsDetailsView } from "./TagsDetailsView/TagsDetailsView";
|
||||
import { Tag } from "@api/integration";
|
||||
|
||||
@ -19,33 +19,40 @@ type Props = {
|
||||
handleNextStep: () => void;
|
||||
handlePrevStep: () => void;
|
||||
tagsNames: TTags;
|
||||
setTagsNames: Dispatch<SetStateAction<TTags>>;
|
||||
setIdTags: Dispatch<SetStateAction<TTags>>;
|
||||
arrayOfTags: TTags[]
|
||||
};
|
||||
|
||||
export const AmoStep6: FC<Props> = ({
|
||||
export const AmoTags: FC<Props> = ({
|
||||
handleNextStep,
|
||||
handlePrevStep,
|
||||
tagsNames,
|
||||
setTagsNames
|
||||
setIdTags,
|
||||
arrayOfTags,
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
const [isSelection, setIsSelection] = useState<boolean>(false);
|
||||
const [activeItem, setActiveItem] = useState<string | null>(null);
|
||||
const [activeTag, setActiveItem] = useState<string | null>(null);
|
||||
const [selectedValue, setSelectedValue] = useState<string | null>(null);
|
||||
const [tags, setTags] = useState<Tag[]>([]);
|
||||
const [tagsNamesList, setTagsNamesList] = useState<Record<TagKeys, string[]>>({
|
||||
Lead: [],
|
||||
Contact: [],
|
||||
Company: [],
|
||||
Customer: [],
|
||||
});
|
||||
const handleAdd = useCallback(() => {
|
||||
if (!activeItem || !selectedValue) return;
|
||||
if (!activeTag || !selectedValue) return;
|
||||
|
||||
setTagsNames((prevState) => ({
|
||||
setIdTags((prevState) => ({
|
||||
...prevState,
|
||||
[activeItem]: [...prevState[activeItem as TagKeys], Number(selectedValue)],
|
||||
[activeTag]: [...prevState[activeTag as TagKeys], Number(selectedValue)],
|
||||
}));
|
||||
}, [activeItem, setTagsNames, selectedValue]);
|
||||
|
||||
const items = useMemo(
|
||||
() => ["#тег с результатом 1", "#еще один тег с результатом 2", "#тег"],
|
||||
[],
|
||||
);
|
||||
setTagsNamesList((prevState) => ({
|
||||
...prevState,
|
||||
[activeTag]: [...prevState[activeTag as TagKeys], arrayOfTags.find((tag) => tag.AmoID == selectedValue).Name],
|
||||
}));
|
||||
}, [activeTag, setIdTags, selectedValue]);
|
||||
|
||||
return (
|
||||
<Box
|
||||
@ -75,6 +82,7 @@ export const AmoStep6: FC<Props> = ({
|
||||
/>
|
||||
) : (
|
||||
<TagsDetailsView
|
||||
tagsNamesList={tagsNamesList}
|
||||
setIsSelection={setIsSelection}
|
||||
handlePrevStep={handlePrevStep}
|
||||
handleNextStep={handleNextStep}
|
@ -1,8 +1,8 @@
|
||||
import { Box, Typography, useTheme } from "@mui/material";
|
||||
import { StepButtonsBlock } from "../../StepButtonsBlock/StepButtonsBlock";
|
||||
import { FC } from "react";
|
||||
import { TagKeys, TTags } from "../../AmoCRMModal";
|
||||
import { Item } from "../../IntegrationStep7/Item/Item";
|
||||
import { TagKeys, TitleKeys, TTags } from "../../AmoCRMModal";
|
||||
import { Item } from "../../AmoQuestions/Item/Item";
|
||||
|
||||
type TagsDetailsViewProps = {
|
||||
setIsSelection: (value: boolean) => void;
|
||||
@ -10,6 +10,7 @@ type TagsDetailsViewProps = {
|
||||
handleNextStep: () => void;
|
||||
tagsNames: TTags;
|
||||
setActiveItem: (value: string | null) => void;
|
||||
tagsNamesList: Record<TagKeys, string[]>
|
||||
};
|
||||
|
||||
export const TagsDetailsView: FC<TagsDetailsViewProps> = ({
|
||||
@ -18,6 +19,7 @@ export const TagsDetailsView: FC<TagsDetailsViewProps> = ({
|
||||
tagsNames,
|
||||
setActiveItem,
|
||||
setIsSelection,
|
||||
tagsNamesList,
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
|
||||
@ -71,8 +73,9 @@ export const TagsDetailsView: FC<TagsDetailsViewProps> = ({
|
||||
{tagsNames &&
|
||||
Object.keys(tagsNames).map((item) => (
|
||||
<Item
|
||||
tagsNamesList={tagsNamesList}
|
||||
key={item}
|
||||
title={item as TagKeys}
|
||||
title={item as TitleKeys}
|
||||
onAddBtnClick={() => {
|
||||
setIsSelection(true);
|
||||
setActiveItem(item);
|
@ -3,14 +3,14 @@ import { FC } from "react";
|
||||
import { StepButtonsBlock } from "../StepButtonsBlock/StepButtonsBlock";
|
||||
import { CustomSelect } from "../../../../components/CustomSelect/CustomSelect";
|
||||
|
||||
type AmoStep4Props = {
|
||||
type Props = {
|
||||
handlePrevStep: () => void;
|
||||
handleNextStep: () => void;
|
||||
selectedDealPerformer: string | null;
|
||||
setSelectedDealPerformer: (value: string | null) => void;
|
||||
selectedDealPerformer: number | null;
|
||||
setSelectedDealPerformer: (value: number | null) => void;
|
||||
};
|
||||
|
||||
export const AmoStep4: FC<AmoStep4Props> = ({
|
||||
export const DealPerformers: FC<Props> = ({
|
||||
handlePrevStep,
|
||||
handleNextStep,
|
||||
selectedDealPerformer,
|
@ -4,17 +4,17 @@ import { StepButtonsBlock } from "../StepButtonsBlock/StepButtonsBlock";
|
||||
import { CustomSelect } from "../../../../components/CustomSelect/CustomSelect";
|
||||
import { CustomRadioGroup } from "../../../../components/CustomRadioGroup/CustomRadioGroup";
|
||||
|
||||
type AmoStep3Props = {
|
||||
type Props = {
|
||||
handlePrevStep: () => void;
|
||||
handleNextStep: () => void;
|
||||
selectedStepsPerformer: string | null;
|
||||
setSelectedStepsPerformer: (value: string | null) => void;
|
||||
selectedStep: string | null;
|
||||
setSelectedStep: (value: string | null) => void;
|
||||
pipelineId: string | null;
|
||||
selectedStepsPerformer: number | null;
|
||||
setSelectedStepsPerformer: (value: number | null) => void;
|
||||
selectedStep: number | null;
|
||||
setSelectedStep: (value: number | null) => void;
|
||||
pipelineId: number | null;
|
||||
};
|
||||
|
||||
export const AmoStep3: FC<AmoStep3Props> = ({
|
||||
export const PipelineSteps: FC<Props> = ({
|
||||
handlePrevStep,
|
||||
handleNextStep,
|
||||
selectedStepsPerformer,
|
@ -4,17 +4,17 @@ import { StepButtonsBlock } from "../StepButtonsBlock/StepButtonsBlock";
|
||||
import { CustomSelect } from "../../../../components/CustomSelect/CustomSelect";
|
||||
import { CustomRadioGroup } from "../../../../components/CustomRadioGroup/CustomRadioGroup";
|
||||
|
||||
type AmoStep2Props = {
|
||||
type Props = {
|
||||
handlePrevStep: () => void;
|
||||
handleNextStep: () => void;
|
||||
selectedPipelinePerformer: string | null;
|
||||
setSelectedPipelinePerformer: (value: string | null) => void;
|
||||
selectedPipeline: string | null;
|
||||
setSelectedPipeline: (value: string | null) => void;
|
||||
selectedPipelinePerformer: number | null;
|
||||
setSelectedPipelinePerformer: (value: number | null) => void;
|
||||
selectedPipeline: number | null;
|
||||
setSelectedPipeline: (value: number | null) => void;
|
||||
|
||||
};
|
||||
|
||||
export const AmoStep2: FC<AmoStep2Props> = ({
|
||||
export const Pipelines: FC<Props> = ({
|
||||
handlePrevStep,
|
||||
handleNextStep,
|
||||
selectedPipelinePerformer,
|
@ -8,10 +8,8 @@ type AmoSettingsBlockProps = {
|
||||
stepTitles: string[];
|
||||
setStep: (value: number) => void;
|
||||
setIsSettingsBlock: (value: boolean) => void;
|
||||
selectedFunnelPerformer: string | null;
|
||||
selectedFunnel: string | null;
|
||||
selectedStagePerformer: string | null;
|
||||
selectedStage: string | null;
|
||||
selectedFunnel: number | null;
|
||||
selectedStage: number | null;
|
||||
selectedDealPerformer: string | null;
|
||||
questionEntity: TQuestionEntity;
|
||||
tags: TTags;
|
||||
@ -21,9 +19,7 @@ export const AmoSettingsBlock: FC<AmoSettingsBlockProps> = ({
|
||||
stepTitles,
|
||||
setStep,
|
||||
setIsSettingsBlock,
|
||||
selectedFunnelPerformer,
|
||||
selectedFunnel,
|
||||
selectedStagePerformer,
|
||||
selectedDealPerformer,
|
||||
selectedStage,
|
||||
questionEntity,
|
||||
@ -61,10 +57,8 @@ export const AmoSettingsBlock: FC<AmoSettingsBlockProps> = ({
|
||||
title={title}
|
||||
setIsSettingsBlock={setIsSettingsBlock}
|
||||
setStep={setStep}
|
||||
selectedFunnelPerformer={selectedFunnelPerformer}
|
||||
selectedFunnel={selectedFunnel}
|
||||
selectedStagePerformer={selectedStagePerformer}
|
||||
selectedDealPerformer={selectedDealPerformer}
|
||||
selectedFunnel={selectedFunnel}
|
||||
selectedStage={selectedStage}
|
||||
questionEntity={questionEntity}
|
||||
tags={tags}
|
||||
|
@ -35,7 +35,6 @@ export const SettingItem: FC<SettingItemProps> = ({
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down(600));
|
||||
|
||||
if (step === 0) {
|
||||
return;
|
||||
}
|
||||
@ -44,7 +43,7 @@ export const SettingItem: FC<SettingItemProps> = ({
|
||||
if (step === 1) {
|
||||
return (
|
||||
<>
|
||||
<ResponsiblePerson performer={selectedFunnelPerformer} />
|
||||
<ResponsiblePerson performer={selectedDealPerformer} />
|
||||
<SelectedParameter parameter={selectedFunnel} />
|
||||
</>
|
||||
);
|
||||
@ -52,7 +51,7 @@ export const SettingItem: FC<SettingItemProps> = ({
|
||||
if (step === 2) {
|
||||
return (
|
||||
<>
|
||||
<ResponsiblePerson performer={selectedStagePerformer} />
|
||||
<ResponsiblePerson performer={selectedDealPerformer} />
|
||||
<SelectedParameter parameter={selectedStage} />
|
||||
</>
|
||||
);
|
||||
|
@ -72,16 +72,6 @@ export default function AvailablePrivilege() {
|
||||
);
|
||||
|
||||
const currentDate = moment();
|
||||
console.log(quizUnlimDays);
|
||||
console.log(moment());
|
||||
console.log(
|
||||
moment(
|
||||
moment(userPrivileges?.quizUnlimTime?.created_at).add(
|
||||
quizUnlimTime,
|
||||
"days",
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return (
|
||||
<Box
|
||||
|
@ -82,10 +82,6 @@ export const createUntypedQuestion = (
|
||||
},
|
||||
);
|
||||
|
||||
console.log(
|
||||
33,
|
||||
useQuestionsStore.getState().questions.map((q) => q.type),
|
||||
);
|
||||
};
|
||||
|
||||
const removeQuestion = (questionId: string) =>
|
||||
|
@ -110,7 +110,6 @@ export const ExportResults = async (
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(typeof data);
|
||||
|
||||
const blob = new Blob([data as BlobPart], {
|
||||
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8",
|
||||
@ -118,7 +117,6 @@ export const ExportResults = async (
|
||||
|
||||
const link = document.createElement("a");
|
||||
link.href = window.URL.createObjectURL(data as Blob);
|
||||
console.log(link);
|
||||
link.download = `report_${new Date().getTime()}.xlsx`;
|
||||
link.click();
|
||||
};
|
||||
|
@ -28,7 +28,6 @@ export function CheckFastlink() {
|
||||
const [discounts, setDiscounts] = useState<Discount[]>([]);
|
||||
const [askToChange, setAskToChange] = useState(false);
|
||||
const [promocode, setPromocode] = useState("");
|
||||
console.log(user.userAccount, user.customerAccount);
|
||||
useEffect(() => {
|
||||
const get = async () => {
|
||||
if (!user.userId) {
|
||||
|
@ -25,7 +25,7 @@ const translateMessage: Record<string, string> = {
|
||||
|
||||
export const parseAxiosError = (nativeError: unknown): [string, number?] => {
|
||||
const error = nativeError as AxiosError;
|
||||
console.log(error)
|
||||
console.error(error)
|
||||
if (process.env.NODE_ENV !== "production") console.error(error);
|
||||
if (error.message === "Failed to fetch") return ["Ошибка сети"];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user