diff --git a/src/api/integration.ts b/src/api/integration.ts index a23fd89a..09d5b2f5 100644 --- a/src/api/integration.ts +++ b/src/api/integration.ts @@ -1,3 +1,4 @@ +import { QuestionKeys } from "@/pages/IntegrationsPage/IntegrationsModal/types"; import { makeRequest } from "@api/makeRequest"; import { parseAxiosError } from "@utils/parse-error"; @@ -225,29 +226,13 @@ export const getPipelines = async ({ }; //получение настроек интеграции -type QuestionID = Record +export type QuestionID = Record export type IntegrationRules = { PipelineID: number; StepID: number; PerformerID?: number; - FieldsRule: { - Lead: [ - { - QuestionID: QuestionID; - } - ] | null, - Company: [ - { - QuestionID: QuestionID; - } - ] | null, - Customer: [ - { - QuestionID: QuestionID; - } - ] | null, - }; + FieldsRule: FieldsRule; TagsToAdd: { Lead: number[] | null; Contact: number[] | null; @@ -255,6 +240,7 @@ export type IntegrationRules = { Customer: number[] | null; } }; +export type FieldsRule = Record, null | [{QuestionID: QuestionID;}]> export const getIntegrationRules = async ( quizID: string, diff --git a/src/components/CustomRadioGroup/CustomRadioGroup.tsx b/src/components/CustomRadioGroup/CustomRadioGroup.tsx index f7ba0a8c..3de16dd3 100644 --- a/src/components/CustomRadioGroup/CustomRadioGroup.tsx +++ b/src/components/CustomRadioGroup/CustomRadioGroup.tsx @@ -10,18 +10,15 @@ import { RadioGroup, Radio, } from "@mui/material"; +import { MinifiedData, TagKeys } from "@/pages/IntegrationsPage/IntegrationsModal/types"; -type Items = { - id: string; - title: string; - subTitle?: string; -} type CustomRadioGroupProps = { - items: Items[] | []; + items: MinifiedData[] | []; selectedItemId?: string | null; setSelectedItem: (value: string | null) => void; handleScroll: () => void; + activeScope?: TagKeys; }; export const CustomRadioGroup: FC = ({ @@ -29,6 +26,7 @@ export const CustomRadioGroup: FC = ({ selectedItemId = "", setSelectedItem, handleScroll, + activeScope, }) => { const theme = useTheme(); @@ -39,6 +37,14 @@ export const CustomRadioGroup: FC = ({ return null; }, [selectedItemId, items]) + const filteredItems = useMemo(() => { + let newArray = items + if (activeScope !== undefined) newArray =newArray.filter(item => { + return item.entity === activeScope + }) + return newArray + }, items) + const onScroll = React.useCallback((e: React.UIEvent) => { const scrollHeight = e.currentTarget.scrollHeight; const scrollTop = e.currentTarget.scrollTop; @@ -52,9 +58,9 @@ export const CustomRadioGroup: FC = ({ const formControlLabels = useMemo(() => { - if (items.length !== 0) { - return items.map( item => - + = ({ borderRadius: "12px", margin: 0, backgroundColor: - currentItem?.id === item.id + currentItem?.id === item.id ? theme.palette.background.default : theme.palette.common.white, + "&.MuiFormControlLabel-root > .MuiTypography-root": { + width: "200px", + overflow: "hidden", + textOverflow: "ellipsis" + } + }} value={item.id} control={ @@ -100,7 +112,7 @@ export const CustomRadioGroup: FC = ({ Нет элементов ); - }, [items]); + }, [filteredItems, selectedItemId]); return ( = ({ ) => setSelectedItem(target.value)} onScroll={onScroll} > diff --git a/src/components/CustomSelect/CustomSelect.tsx b/src/components/CustomSelect/CustomSelect.tsx index 929ed823..700287c4 100644 --- a/src/components/CustomSelect/CustomSelect.tsx +++ b/src/components/CustomSelect/CustomSelect.tsx @@ -13,22 +13,15 @@ import { } from "@mui/material"; import "./CustomSelect.css"; import arrow_down from "../../assets/icons/arrow_down.svg"; - - -type Items = { - id: string; - title: string; - subTitle: string; -} +import { MinifiedData } from "@/pages/IntegrationsPage/IntegrationsModal/types"; type CustomSelectProps = { - items: Items[] | []; + items: MinifiedData[] | []; selectedItemId: string | null; setSelectedItem: (value: string | null) => void; handleScroll: () => void; }; - export const CustomSelect: FC = ({ items, selectedItemId, @@ -39,7 +32,6 @@ export const CustomSelect: FC = ({ const isMobile = useMediaQuery(theme.breakpoints.down(600)); const ref = useRef(null); - const [opened, setOpened] = useState(false); const toggleOpened = useCallback(() => { @@ -116,7 +108,7 @@ export const CustomSelect: FC = ({ нет данных ); - }, [items]); + }, [items, selectedItemId]); return ( @@ -171,7 +163,7 @@ export const CustomSelect: FC = ({