2024-04-15 16:30:40 +00:00
|
|
|
import { Box, Typography, useTheme } from "@mui/material";
|
2024-04-12 15:07:37 +00:00
|
|
|
import { FC } from "react";
|
2024-04-15 16:30:40 +00:00
|
|
|
import { IconBtnAdd } from "./IconBtnAdd/IconBtnAdd";
|
|
|
|
import { AnswerItem } from "./AnswerItem/AnswerItem";
|
2024-05-17 12:04:59 +00:00
|
|
|
import { TagKeys, TitleKeys, TQuestionEntity, TTags } from "../../AmoCRMModal";
|
2024-04-12 15:07:37 +00:00
|
|
|
|
|
|
|
type ItemProps = {
|
2024-04-16 10:57:38 +00:00
|
|
|
title: TitleKeys | TagKeys;
|
2024-04-12 15:07:37 +00:00
|
|
|
onAddBtnClick: () => void;
|
2024-04-16 10:57:38 +00:00
|
|
|
data: TQuestionEntity | TTags;
|
2024-04-12 15:07:37 +00:00
|
|
|
};
|
2024-06-14 02:30:30 +00:00
|
|
|
export const Item: FC<ItemProps> = ({ title, onAddBtnClick, data, tagsNamesList }) => {
|
2024-04-12 15:07:37 +00:00
|
|
|
const theme = useTheme();
|
2024-04-16 10:57:38 +00:00
|
|
|
|
|
|
|
const titleDictionary = {
|
2024-06-10 20:26:07 +00:00
|
|
|
Company: "Компания",
|
|
|
|
Lead: "Сделка",
|
|
|
|
Contact: "Контакты",
|
|
|
|
Customer: "Покупатели",
|
2024-04-16 10:57:38 +00:00
|
|
|
};
|
|
|
|
|
2024-04-15 16:30:40 +00:00
|
|
|
const translatedTitle = titleDictionary[title];
|
2024-04-16 10:57:38 +00:00
|
|
|
const selectedOptions = data[title];
|
2024-04-12 15:07:37 +00:00
|
|
|
return (
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
width: "172px",
|
|
|
|
display: "flex",
|
|
|
|
flexDirection: "column",
|
2024-04-15 16:30:40 +00:00
|
|
|
borderRight: `1px solid ${theme.palette.background.default}`,
|
2024-04-12 15:07:37 +00:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
alignSelf: "center",
|
|
|
|
display: "flex",
|
|
|
|
alignItems: "center",
|
|
|
|
justifyContent: "center",
|
|
|
|
borderRadius: "12px",
|
|
|
|
backgroundColor: theme.palette.background.default,
|
|
|
|
width: "156px",
|
|
|
|
height: "40px",
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Typography sx={{ fontSize: "16px", fontWeight: 500 }}>
|
2024-04-15 16:30:40 +00:00
|
|
|
{translatedTitle}
|
2024-04-12 15:07:37 +00:00
|
|
|
</Typography>
|
|
|
|
</Box>
|
2024-04-16 10:57:38 +00:00
|
|
|
{selectedOptions &&
|
|
|
|
selectedOptions.map((text, index) => (
|
|
|
|
<AnswerItem
|
|
|
|
key={text + index}
|
|
|
|
fieldValue={"Значение поля"}
|
2024-06-14 02:30:30 +00:00
|
|
|
fieldName={tagsNamesList?.[title][index] || text}
|
2024-04-16 10:57:38 +00:00
|
|
|
/>
|
|
|
|
))}
|
2024-04-15 16:30:40 +00:00
|
|
|
|
|
|
|
<IconBtnAdd onAddBtnClick={onAddBtnClick} />
|
2024-04-12 15:07:37 +00:00
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
};
|