2024-06-28 19:34:13 +00:00
|
|
|
|
import { Box, Button } from "@mui/material"
|
|
|
|
|
|
import { StepButtonsBlock } from "../StepButtonsBlock/StepButtonsBlock"
|
|
|
|
|
|
import { FC, useState } from "react";
|
2024-06-30 15:32:16 +00:00
|
|
|
|
import { MinifiedData, TagKeys } from "../types";
|
2024-06-28 19:34:13 +00:00
|
|
|
|
import { CurrentFields } from "./CurrentFields";
|
|
|
|
|
|
import { NewFields } from "./NewFields";
|
2024-06-30 15:32:16 +00:00
|
|
|
|
import { QuestionPair } from "./AmoQuestions";
|
2024-06-28 19:34:13 +00:00
|
|
|
|
|
|
|
|
|
|
type ItemsSelectionViewProps = {
|
|
|
|
|
|
items: MinifiedData[] | [];
|
2024-06-30 15:32:16 +00:00
|
|
|
|
fieldsItems: MinifiedData[] | [];
|
2024-06-28 19:34:13 +00:00
|
|
|
|
selectedItemId?: string | null;
|
2024-06-30 15:32:16 +00:00
|
|
|
|
setSelectedQuestion: (value: string | null) => void;
|
|
|
|
|
|
selectedField?: string | null;
|
|
|
|
|
|
setSelectedField: (value: string | null) => void;
|
2024-06-28 19:34:13 +00:00
|
|
|
|
handleScroll?: () => void;
|
|
|
|
|
|
onLargeBtnClick: () => void;
|
|
|
|
|
|
onSmallBtnClick: () => void;
|
|
|
|
|
|
activeScope: TagKeys;
|
2024-06-30 15:32:16 +00:00
|
|
|
|
FieldsAllowedFC: MinifiedData[];
|
|
|
|
|
|
setIsCurrentFields: (a:boolean) => void;
|
|
|
|
|
|
isCurrentFields: boolean
|
|
|
|
|
|
}
|
2024-06-28 19:34:13 +00:00
|
|
|
|
export const EntitiesQuestions: FC<ItemsSelectionViewProps> = ({
|
|
|
|
|
|
items,
|
2024-06-30 15:32:16 +00:00
|
|
|
|
fieldsItems,
|
2024-06-28 19:34:13 +00:00
|
|
|
|
selectedItemId,
|
2024-06-30 15:32:16 +00:00
|
|
|
|
setSelectedQuestion,
|
|
|
|
|
|
selectedField,
|
|
|
|
|
|
setSelectedField,
|
2024-06-28 19:34:13 +00:00
|
|
|
|
handleScroll,
|
|
|
|
|
|
onLargeBtnClick,
|
|
|
|
|
|
onSmallBtnClick,
|
|
|
|
|
|
activeScope,
|
2024-06-30 15:32:16 +00:00
|
|
|
|
FieldsAllowedFC,
|
|
|
|
|
|
setIsCurrentFields,
|
|
|
|
|
|
isCurrentFields,
|
2024-06-28 19:34:13 +00:00
|
|
|
|
}) => {
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Box
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
display: "flex",
|
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
|
height: "100%",
|
|
|
|
|
|
flexGrow: 1,
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Box
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
marginTop: "20px",
|
|
|
|
|
|
flexGrow: 1,
|
|
|
|
|
|
width: "100%",
|
|
|
|
|
|
height: "346px",
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Box>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
onClick={() => setIsCurrentFields(old => !old)}
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
borderRadius: "50px",
|
|
|
|
|
|
p: "10px 30px",
|
|
|
|
|
|
mr: "10px",
|
|
|
|
|
|
|
|
|
|
|
|
border: isCurrentFields ? "1px solid #7E2AEA" : "",
|
|
|
|
|
|
bgcolor: isCurrentFields ? "#7E2AEA1A" : "#F2F3F7",
|
|
|
|
|
|
color: isCurrentFields ? "#7E2AEA" : "",
|
|
|
|
|
|
}}
|
|
|
|
|
|
>Ваши готовые поля</Button>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
onClick={() => setIsCurrentFields(old => !old)}
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
borderRadius: "50px",
|
|
|
|
|
|
p: "10px 30px",
|
|
|
|
|
|
|
|
|
|
|
|
border: !isCurrentFields ? "1px solid #7E2AEA" : "",
|
|
|
|
|
|
bgcolor: !isCurrentFields ? "#7E2AEA1A" : "#F2F3F7",
|
|
|
|
|
|
color: !isCurrentFields ? "#7E2AEA" : "",
|
|
|
|
|
|
}}
|
|
|
|
|
|
>Новые поля</Button>
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
{
|
|
|
|
|
|
isCurrentFields ?
|
2024-06-30 15:32:16 +00:00
|
|
|
|
<CurrentFields
|
|
|
|
|
|
items={items}
|
|
|
|
|
|
fieldsItems={[...FieldsAllowedFC, ...fieldsItems].filter(e => e.entity === activeScope)}
|
|
|
|
|
|
currentField={selectedField}
|
|
|
|
|
|
currentQuestion={selectedItemId}
|
|
|
|
|
|
setCurrentField={setSelectedField}
|
|
|
|
|
|
setCurrentQuestion={setSelectedQuestion}
|
|
|
|
|
|
/>
|
2024-06-28 19:34:13 +00:00
|
|
|
|
:
|
2024-06-30 15:32:16 +00:00
|
|
|
|
<NewFields
|
|
|
|
|
|
items={items}
|
|
|
|
|
|
currentQuestion={selectedItemId}
|
|
|
|
|
|
setCurrentQuestion={setSelectedQuestion}
|
|
|
|
|
|
/>
|
2024-06-28 19:34:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
<Box
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
marginTop: "20px",
|
|
|
|
|
|
alignSelf: "end",
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<StepButtonsBlock
|
2024-06-30 15:32:16 +00:00
|
|
|
|
onLargeBtnClick={() => {
|
|
|
|
|
|
onLargeBtnClick()
|
|
|
|
|
|
}}
|
2024-06-28 19:34:13 +00:00
|
|
|
|
largeBtnText={"Добавить"}
|
|
|
|
|
|
onSmallBtnClick={onSmallBtnClick}
|
|
|
|
|
|
smallBtnText={"Отменить"}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|