add ai
All checks were successful
Deploy / CreateImage (push) Successful in 3m29s
Deploy / DeployService (push) Successful in 21s

This commit is contained in:
Nastya 2025-04-15 23:16:01 +03:00
parent 9336508260
commit 62762c955c
5 changed files with 106 additions and 9 deletions

@ -199,7 +199,7 @@ export default function Main({ sidebar, header, footer, Page }: Props) {
))}
<ButtonTestPublication />
<ButtonRecallQuiz />
{quiz?.status === "start" &&
{(quiz?.status === "start" || quiz?.status === "ai") &&
(!isLinkButton ? (
<Box
data-cy="link-test"
@ -249,7 +249,7 @@ export default function Main({ sidebar, header, footer, Page }: Props) {
<LinkSimple />
</Box>
))}
{isMobile && quiz?.status === "start" && (
{isMobile && (quiz?.status === "start" || quiz?.status === "ai") && (
<Box
data-cy="link-test"
component={Link}

@ -44,6 +44,7 @@ import Extra from "./extra";
import TooltipClickInfo from "@ui_kit/Toolbars/TooltipClickInfo";
import { VideoElement } from "./VideoElement";
import UploadVideoModal from "../Questions/UploadVideoModal";
import { SwitchAI } from "@/ui_kit/crutchFunctionAI";
const designTypes = [
["standard", (color: string) => <LayoutStandartIcon color={color} />, "Standard"],
@ -89,9 +90,9 @@ export default function StartPageSettings() {
let cropAspectRatio:
| undefined
| {
width: number;
height: number;
};
width: number;
height: number;
};
switch (designType) {
case "standard":
cropAspectRatio = { width: 1680.8, height: 960.5 };
@ -595,6 +596,7 @@ export default function StartPageSettings() {
Favicon
</Typography>
{favIconDropZoneElement}
{isSmallMonitor && <SwitchAI />}
</>
)}
</Box>
@ -674,6 +676,7 @@ export default function StartPageSettings() {
Favicon
</Typography>
{favIconDropZoneElement}
<SwitchAI />
</>
)}
{(!isSmallMonitor || (isSmallMonitor && formState === "content")) && (
@ -872,6 +875,7 @@ export default function StartPageSettings() {
Включить защиту от копирования
</Typography>
</Box>
{!isSmallMonitor &&<SwitchAI />}
</>
)}
</Box>

@ -18,13 +18,13 @@ export const selectSendingMethod = async ({messageField, isSnackbar = true, syst
console.log("click 2")
let successful = false;
if (!(window.location.hostname == 'localhost' && systemError)) { //предупреждать о системных ошибках вне локалхост
if (!(window.location.hostname == 'localhost' && systemError )) { //предупреждать о системных ошибках вне локалхост
if (!ticket.sessionData?.ticketId) {
console.log("autorisated 2")
const [data, createError] = await createTicket(
messageField,
Boolean(user),
systemError,
false,
);
if (createError || !data) {
@ -41,7 +41,7 @@ export const selectSendingMethod = async ({messageField, isSnackbar = true, syst
const [_, sendTicketMessageError] = await sendTicketMessage(
ticket.sessionData?.ticketId,
messageField,
systemError,
false,
);
successful = true;

@ -17,6 +17,7 @@ export const ButtonRecallQuiz = () => {
useEffect(() => {
if (quiz && buttonText === "обработка...")
setButtonText(quiz?.status === "stop" ? "Опубликовать" : "Отозвать");
if (quiz?.status === "ai") setButtonText("Отозвать");
}, [quiz]);
const handleClickStatusQuiz = () => {
@ -31,7 +32,7 @@ export const ButtonRecallQuiz = () => {
}
updateQuiz(quiz?.id, (state) => {
state.status = quiz?.status === "start" ? "stop" : "start";
state.status = (quiz?.status === "start" || quiz?.status === "ai") ? "stop" : "start";
});
} else {
updateModalInfoWhyCantCreate(true);

@ -0,0 +1,92 @@
import { updateQuiz } from "@/stores/quizes/actions";
import { useCurrentQuiz } from "@/stores/quizes/hooks";
import { Switch, Button, Modal, Typography, useTheme, Box } from "@mui/material"
import { useState } from "react";
import CustomizedSwitch from "@ui_kit/CustomSwitch";
import { useUserStore } from "@/stores/user";
export const SwitchAI = () => {
const theme = useTheme();
const [open, setOpen] = useState(false);
const quiz = useCurrentQuiz();
const account = useUserStore()
console.log(account.userId)
if (account.userId === "6755b1ddd5802e9f13663f56") {
return (
<>
<Box sx={{ display: "flex", gap: "20px", alignItems: "center", mt: "20px" }}>
<CustomizedSwitch
checked={quiz?.status === "ai"}
onChange={(e) => {
if (e.target.checked) {
setOpen(true);
} else {
updateQuiz(quiz?.id, (quiz) => {
quiz.status = "start"
});
}
}}
/>
<Typography
sx={{
fontWeight: 500,
color: theme.palette.grey3.main,
}}
>
ИИ опрос
</Typography>
</Box>
<Modal
open={open}
onClose={() => setOpen(false)}
aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description"
>
<Box
sx={{
position: "absolute" as "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
maxWidth: "620px",
width: "100%",
bgcolor: "background.paper",
borderRadius: "12px",
boxShadow: 24,
p: 0,
}}
>
<Box
sx={{
display: "flex",
flexDirection: "column",
padding: "20px",
borderRadius: "12px 12px 0 0",
background: theme.palette.background.default,
}}
>
<Typography sx={{ p: "20px" }}>
Учтите, что в случае ИИ-опроса сперва будут заданы все созданные вопросы, и только потом вопросы, сгенерированные ИИ.
</Typography>
<Button
variant="contained"
onClick={() => {
updateQuiz(quiz?.id, (state) => {
state.status = "ai";
});
setOpen(false);
}}
>Согласиться</Button>
</Box>
</Box>
</Modal>
</>
)
} else return <></>
}