crutch neftyanka
All checks were successful
Deploy / CreateImage (push) Successful in 9m55s
Deploy / DeployService (push) Successful in 22s

This commit is contained in:
Nastya 2025-05-21 08:48:32 +03:00
parent fba39bec1d
commit e54475bfe9
10 changed files with 168 additions and 8 deletions

@ -26,6 +26,7 @@ import type { AnyTypedQuizQuestion } from "@model/questionTypes/shared";
import { isProduction } from "@/utils/defineDomain";
import { useQuizStore } from "@/stores/useQuizStore";
import { useTranslation } from "react-i18next";
import { isNeftyanka } from "@/ui_kit/neftyankacrutch";
type Props = {
currentQuestion: AnyTypedQuizQuestion;
@ -317,7 +318,7 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => {
},
}}
>
{settings.cfg.formContact?.button || t("Get results")}
{isNeftyanka ? t("neftyanka button") : settings.cfg.formContact?.button || t("Get results")}
</Button>
</Box>
{show_badge && (

@ -3,6 +3,7 @@ import { useRootContainerSize } from "@contexts/RootContainerWidthContext.ts";
import { QuizSettingsConfig } from "@model/settingsData.ts";
import { FC } from "react";
import { useTranslation } from "react-i18next";
import { isNeftyanka } from "@/ui_kit/neftyankacrutch";
type ContactTextBlockProps = {
settings: QuizSettingsConfig;
@ -47,7 +48,9 @@ export const ContactTextBlock: FC<ContactTextBlockProps> = ({ settings }) => {
wordBreak: "break-word",
}}
>
{settings.cfg.formContact.title || t("Fill out the form to receive your test results")}
{isNeftyanka
? t("neftyanka FK")
: settings.cfg.formContact.title || t("Fill out the form to receive your test results")}
</Typography>
{settings.cfg.formContact.desc && (
<Typography

@ -0,0 +1,120 @@
import { Box, TextField as MuiTextField, TextFieldProps, Typography, useTheme } from "@mui/material";
import { Answer, useQuizViewStore } from "@stores/quizView";
import { useRootContainerSize } from "@contexts/RootContainerWidthContext";
import { quizThemes } from "@utils/themes/Publication/themePublication";
import type { ChangeEvent, FC } from "react";
import type { QuizQuestionText } from "@model/questionTypes/text";
import { useQuizStore } from "@/stores/useQuizStore";
const TextField = MuiTextField as unknown as FC<TextFieldProps>; // temporary fix ts(2590)
interface TextSpecialProps {
currentQuestion: QuizQuestionText;
answer?: Answer;
stepNumber?: number | null;
}
function highlightQuestions(text: string) {
// Регулярка с учётом возможной точки в конце
const regex = /(вопрос\s\d+[a-zA-Zа-яА-Я]\.?)/g;
// Замена на <span> с жирным текстом
return text.replace(regex, '<span style="font-weight: bold">$1</span>');
}
export const TextNeftyanka = ({ currentQuestion, answer, stepNumber }: TextSpecialProps) => {
const { settings } = useQuizStore();
const { updateAnswer } = useQuizViewStore((state) => state);
const isHorizontal = true;
const theme = useTheme();
const isMobile = useRootContainerSize() < 650;
const onInputChange = async ({ target }: ChangeEvent<HTMLInputElement>) => {
updateAnswer(currentQuestion.id, target.value, 0);
};
return (
<Box
sx={{
display: "flex",
flexDirection: isMobile ? "column" : undefined,
alignItems: isMobile ? "center" : undefined,
}}
>
<Box
sx={{
display: "flex",
width: "100%",
marginTop: "20px",
flexDirection: "column",
alignItems: "center",
gap: "20px",
}}
>
{isHorizontal && currentQuestion.content.back && currentQuestion.content.back !== " " && (
<Box
sx={{ margin: "30px", width: "50vw", maxHeight: "550px" }}
onClick={(event) => event.preventDefault()}
>
<img
key={currentQuestion.id}
src={currentQuestion.content.back}
style={{ width: "100%", height: "100%", objectFit: "contain" }}
alt=""
/>
</Box>
)}
<Typography
variant="h5"
color={theme.palette.text.primary}
sx={{ wordBreak: "break-word" }}
>
{highlightQuestions(currentQuestion.title)}
</Typography>
{
<TextField
autoFocus={true}
multiline
maxRows={4}
placeholder={currentQuestion.content.placeholder}
value={answer || ""}
onChange={onInputChange}
inputProps={{
maxLength: 400,
background: settings.cfg.design
? quizThemes[settings.cfg.theme].isLight
? "#F2F3F7"
: "rgba(154,154,175, 0.2)"
: "transparent",
}}
sx={{
width: "100%",
"& .MuiOutlinedInput-root": {
backgroundColor: settings.cfg.design ? "rgba(154,154,175, 0.2)" : "#FFFFFF",
},
"&:focus-visible": {
borderColor: theme.palette.primary.main,
},
}}
/>
}
</Box>
{!isHorizontal && currentQuestion.content.back && currentQuestion.content.back !== " " && (
<Box
sx={{ margin: "15px", width: "40vw" }}
onClick={(event) => event.preventDefault()}
>
<img
key={currentQuestion.id}
src={currentQuestion.content.back}
style={{ width: "100%", height: "100%", objectFit: "contain" }}
alt=""
/>
</Box>
)}
</Box>
);
};

@ -60,6 +60,7 @@ export const TextNormal = ({ currentQuestion, answer }: TextNormalProps) => {
placeholder={currentQuestion.content.placeholder}
value={answer || ""}
onChange={onInputChange}
multiline={Boolean(currentQuestion.content?.multi)}
sx={{
"& .MuiOutlinedInput-root": {
background: settings.cfg.design

@ -5,6 +5,8 @@ import { TextSpecialHorisontal } from "./TextSpecialHorisontal";
import type { QuizQuestionText } from "@model/questionTypes/text";
import { useQuizStore } from "@/stores/useQuizStore";
import { isNeftyanka } from "@/ui_kit/neftyankacrutch";
import { TextNeftyanka } from "./TextNeftyanka";
type TextProps = {
currentQuestion: QuizQuestionText;
@ -18,7 +20,16 @@ export const Text = ({ currentQuestion, stepNumber }: TextProps) => {
const answers = useQuizViewStore((state) => state.answers);
const { answer } = answers.find(({ questionId }) => questionId === currentQuestion.id) ?? {};
if (pathOnly === "/92ed5e3e-8e6a-491e-87d0-d3197682d0e3" || pathOnly === "/cc006b40-ccbd-4600-a1d3-f902f85aa0a0")
if (isNeftyanka)
return (
<TextNeftyanka
currentQuestion={currentQuestion}
answer={answer}
stepNumber={stepNumber}
/>
);
if (pathOnly === "/92ed5e3e-8e6a-491e-87d0-d3197682d0e3")
return (
<TextSpecialHorisontal
currentQuestion={currentQuestion}

@ -20,5 +20,7 @@ export interface QuizQuestionText extends QuizQuestionBase {
back: string | null;
originalBack: string | null;
onlyNumbers: boolean;
multi?: boolean;
detailedAnswer?: boolean;
};
}

@ -16,6 +16,7 @@ interface CustomTextFieldProps {
text?: string;
sx?: SxProps<Theme>;
InputProps?: Partial<InputProps>;
multiline?: boolean;
}
export default function CustomTextField({
@ -28,11 +29,16 @@ export default function CustomTextField({
onKeyDown,
onBlur,
InputProps,
multiline = false,
}: CustomTextFieldProps) {
const theme = useTheme();
return (
<FormControl fullWidth variant="standard" sx={{ p: 0 }}>
<FormControl
fullWidth
variant="standard"
sx={{ p: 0 }}
>
<TextField
defaultValue={text}
fullWidth
@ -43,10 +49,11 @@ export default function CustomTextField({
onChange={onChange}
onKeyDown={onKeyDown}
onBlur={onBlur}
multiline={multiline}
sx={{
"& .MuiInputBase-root": {
backgroundColor: theme.palette.background.default,
height: "48px",
minHeight: "48px",
borderRadius: "10px",
},
"& .MuiInputLabel-root": {

@ -0,0 +1 @@
export const isNeftyanka = window.location.pathname === "/cc006b40-ccbd-4600-a1d3-f902f85aa0a0";

@ -52,7 +52,8 @@
"familiarized": "ознакомлен",
"and": "и",
"Get results": "Получить результаты",
"Data sent successfully": "Данные успешно отправлены",
"Step": "Шаг",
"D": "-_-",
"d": "-_-"
"neftyanka FK": "Заполните форму, чтобы отправить ваши ответы на викторину",
"neftyanka button": "Отправить"
}

@ -3,23 +3,36 @@ import { createRoot } from "react-dom/client";
// eslint-disable-next-line react-refresh/only-export-components
export * from "./widgets";
/*
Две точки использования:
Или из конструктора квизов на сайте
Или запрос вместе с уже записанными в файлик данными
*/
// old widget
const widget = {
create({
selector,
quizId,
changeFaviconAndTitle = true,
preview = false, //Слать ли ответы на сервер
}: {
selector: string;
quizId: string;
changeFaviconAndTitle: boolean;
preview: boolean;
}) {
const element = document.getElementById(selector);
if (!element) throw new Error("Element for widget doesn't exist");
const root = createRoot(element);
root.render(<QuizAnswerer quizId={quizId} changeFaviconAndTitle={changeFaviconAndTitle} disableGlobalCss />);
root.render(
<QuizAnswerer
quizId={quizId}
changeFaviconAndTitle={changeFaviconAndTitle}
disableGlobalCss
/>
);
},
};