diff --git a/src/pages/PersonalizationAI/AuditoryLink.tsx b/src/pages/PersonalizationAI/AuditoryLink.tsx
index e0cbe976..9264d420 100644
--- a/src/pages/PersonalizationAI/AuditoryLink.tsx
+++ b/src/pages/PersonalizationAI/AuditoryLink.tsx
@@ -2,6 +2,7 @@ import { AuditoryItem } from "@/api/auditory";
import CopyIcon from "@/assets/icons/CopyIcon";
import Trash from "@/assets/icons/trash";
import { InfoPopover } from "@/ui_kit/InfoPopover";
+import TooltipClickInfo from "@/ui_kit/Toolbars/TooltipClickInfo";
import { useDomainDefine } from "@/utils/hooks/useDomainDefine";
import { IconButton, ListItem, Typography, useTheme } from "@mui/material";
@@ -42,7 +43,7 @@ export const AuditoryLink = ({ item, index, onDelete }: AuditoryLinkProps) => {
display: 'flex',
alignItems: 'center',
gap: '12px',
- width: "60px",
+ width: "70px",
justifyContent: "space-between",
},
}}
@@ -61,7 +62,7 @@ export const AuditoryLink = ({ item, index, onDelete }: AuditoryLinkProps) => {
}} />
-
+
void;
+ handleAdd: (item: any) => void;
}
-
-export default function GenderAndAgeSelector({ gender, setGender }: GenderAndAgeSelectorProps) {
+export default function GenderAndAgeSelector({ handleAdd }: GenderAndAgeSelectorProps) {
const theme = useTheme();
+ const [age, setAge] = useState('');
+ const [gender, setGender] = useState('');
+ const quiz = useCurrentQuiz();
+ const { enqueueSnackbar } = useSnackbar();
+
+ const isFormValid = gender && age;
+
+ const addItem = async () => {
+ if (!quiz?.backendId) {
+ enqueueSnackbar('Ошибка: не выбран квиз', { variant: 'error' });
+ return;
+ }
+
+ try {
+ const [result, error] = await auditoryAdd({
+ quizId: quiz.backendId,
+ body: {
+ sex: gender === "male",
+ age
+ }
+ });
+
+ if (error) {
+ enqueueSnackbar('Не удалось добавить ссылку', { variant: 'error' });
+ return;
+ }
+
+ if (result) {
+ handleAdd({
+ id: result.ID,
+ quiz_id: quiz.backendId,
+ sex: gender === "male",
+ age,
+ deleted: false,
+ });
+ enqueueSnackbar('Ссылка успешно добавлена', { variant: 'success' });
+ // Очищаем форму
+ setGender('');
+ setAge('');
+ }
+ } catch (error) {
+ enqueueSnackbar('Произошла ошибка при добавлении', { variant: 'error' });
+ }
+ };
+
return (
-
+
+
-
-
-
-
-
+
+ Пол
+
+
+ setGender(e.target.value)}
+ >
+ } checkedIcon={} />}
+ label="М"
+ />
+ } checkedIcon={} />}
+ label="Ж"
+ />
+
+
+
+
+
+ Пол
-
-
- setGender(e.target.value)}>
-
- Возраст
+
+
+
+
+
- value="male" control={} checkedIcon={} />} label="М" />
- } checkedIcon={} />} label="Ж" />
-
-
-
-
-
-
-
- Возраст
-
-
-
-
-
+
);
}
\ No newline at end of file
diff --git a/src/pages/PersonalizationAI/PersonalizationAI.tsx b/src/pages/PersonalizationAI/PersonalizationAI.tsx
index 9330b162..b2686e52 100644
--- a/src/pages/PersonalizationAI/PersonalizationAI.tsx
+++ b/src/pages/PersonalizationAI/PersonalizationAI.tsx
@@ -1,11 +1,8 @@
import { Box, Container, Typography, TextField, Button, List, ListItem, IconButton, Modal } from "@mui/material";
import { InfoPopover } from '@ui_kit/InfoPopover';
-import CopyIcon from "@/assets/icons/CopyIcon";
import GenderAndAgeSelector from "./GenderAndAgeSelector";
import { useEffect, useState } from "react";
import CustomTextField from "@ui_kit/CustomTextField";
-import Collapse from '@mui/material/Collapse';
-import { ArrowDownIcon } from "../../assets/icons/questionsPage/ArrowDownIcon";
import { useTheme } from "@mui/material";
import { AuditoryItem, auditoryAdd, auditoryDelete, auditoryGet } from "@/api/auditory";
import { useCurrentQuiz } from "@/stores/quizes/hooks";
@@ -15,7 +12,6 @@ import { useSnackbar } from "notistack";
export default function PersonalizationAI() {
const theme = useTheme();
- const [gender, setGender] = useState('');
const [auditory, setAuditory] = useState([]);
const [deleteModal, setDeleteModal] = useState(0);
const quiz = useCurrentQuiz();
@@ -75,9 +71,13 @@ export default function PersonalizationAI() {
}
}
+ const handleAdd = (item:AuditoryItem) => {
+ setAuditory(old => ([...old, item]))
+ }
+
return (
<>
-
+
Персонализация вопросов с помощью AI
@@ -100,7 +100,7 @@ export default function PersonalizationAI() {
boxShadow: "none",
maxWidth: "796px"
}}>
-
+
{/* Ссылка */}