diff --git a/lib/api/quizRelase.ts b/lib/api/quizRelase.ts index ae4025e..18846e9 100644 --- a/lib/api/quizRelase.ts +++ b/lib/api/quizRelase.ts @@ -1,5 +1,7 @@ import { GetQuizDataResponse, parseQuizData } from "@model/api/getQuizData"; import axios from "axios"; +import MobileDetect from 'mobile-detect'; +import device from "current-device"; import type { AxiosError } from "axios"; import { replaceSpacesToEmptyLines } from "../components/ViewPublicationPage/tools/replaceSpacesToEmptyLines"; @@ -9,12 +11,26 @@ let SESSIONS = ""; const domain = location.hostname === "hbpn.link" ? "" : "https://s.hbpn.link"; +const md = new MobileDetect(window.navigator.userAgent); + +const userAgent = navigator.userAgent +let OSDevice = md.os() +if (OSDevice === null) {OSDevice = userAgent} + +const DeviceType = device.type +let Device = md.mobile() +if (Device === null) {Device = userAgent} + export const publicationMakeRequest = ({ url, body }: any) => { return axios(url, { data: body, headers: { "X-Sessionkey": SESSIONS, "Content-Type": "multipart/form-data", + "DeviceType" : DeviceType, + "Device" : Device, + "OS": OSDevice, + "Browser" : userAgent }, method: "POST", }); @@ -33,6 +49,10 @@ export async function getData(quizId: string): Promise<{ headers: { "X-Sessionkey": SESSIONS, "Content-Type": "application/json", + "DeviceType" : DeviceType, + "Device" : Device, + "OS": OSDevice, + "Browser" : userAgent }, data: { quiz_id: quizId, diff --git a/lib/assets/icons/ArrowDownIcon.tsx b/lib/assets/icons/ArrowDownIcon.tsx index 5939247..c62184b 100644 --- a/lib/assets/icons/ArrowDownIcon.tsx +++ b/lib/assets/icons/ArrowDownIcon.tsx @@ -22,7 +22,7 @@ export default function ArrowDownIcon( }} > - + ); diff --git a/lib/assets/icons/ContactFormIcon/AddressIcon.tsx b/lib/assets/icons/ContactFormIcon/AddressIcon.tsx index 9918ee4..66ba584 100644 --- a/lib/assets/icons/ContactFormIcon/AddressIcon.tsx +++ b/lib/assets/icons/ContactFormIcon/AddressIcon.tsx @@ -2,17 +2,23 @@ import { Box } from "@mui/material"; interface Props { color: string; + backgroundColor: string } -export default function AddressIcon({ color }: Props) { +export default function AddressIcon({ color, backgroundColor }: Props) { return ( diff --git a/lib/assets/icons/ContactFormIcon/TextIcon.tsx b/lib/assets/icons/ContactFormIcon/TextIcon.tsx index b272b37..e4b1ce4 100644 --- a/lib/assets/icons/ContactFormIcon/TextIcon.tsx +++ b/lib/assets/icons/ContactFormIcon/TextIcon.tsx @@ -2,9 +2,10 @@ import { Box } from "@mui/material"; interface Props { color: string; + backgroundColor: string } -export default function TextIcon({ color }: Props) { +export default function TextIcon({ color, backgroundColor }: Props) { return ( ; // temporary fix ts(2590) @@ -27,9 +36,9 @@ type Props = { onShowResult: () => void; }; -export const ContactForm = ({ currentQuestion, onShowResult }: Props) => { +export const ContactForm = ({currentQuestion, onShowResult}: Props) => { const theme = useTheme(); - const { settings, questions, quizId, show_badge } = useQuizData(); + const {settings, questions, quizId, show_badge} = useQuizData(); const [ready, setReady] = useState(false); const [name, setName] = useState(""); @@ -66,7 +75,7 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => { if (email.length > 0) body.email = email; if (phone.length > 0) body.phone = phone; if (adress.length > 0) body.address = adress; - if (text.length > 0) body.customs = { [FC.text.text || "Фамилия"]: text }; + if (text.length > 0) body.customs = {[FC.text.text || "Фамилия"]: text}; if (Object.keys(body).length > 0) { try { @@ -79,7 +88,7 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => { const sessions = JSON.parse(localStorage.getItem("sessions") || "{}"); localStorage.setItem( "sessions", - JSON.stringify({ ...sessions, [quizId]: new Date().getTime() }) + JSON.stringify({...sessions, [quizId]: new Date().getTime()}) ); } catch (e) { enqueueSnackbar("ответ не был засчитан"); @@ -99,7 +108,7 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => { const isWide = Object.keys(filteredFC).length > 2; async function handleShowResultsClick() { - const FC: any = settings.cfg.formContact.fields + const FC: any = settings.cfg.formContact.fields if (FC["email"].used !== EMAIL_REGEXP.test(email)) { return enqueueSnackbar("введена некорректная почта"); } @@ -156,7 +165,7 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => { msOverflowStyle: "none", backgroundPosition: "center", backgroundSize: "cover", - backgroundImage: settings.cfg.design + backgroundImage: settings.cfg.design && !isMobile ? `url(${DESIGN_LIST[settings.cfg.theme]})` : null, }} @@ -168,6 +177,11 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => { height: "100%", minHeight: "100vh", display: isWide && !isMobile ? "flex" : undefined, + background: settings.cfg.design && !isMobile + ? quizThemes[settings.cfg.theme].isLight + ? "transparent" + : "linear-gradient(90deg,#272626, transparent)" + : theme.palette.background.default, }} > { borderRight: isWide && !isMobile ? "1px solid gray" : undefined, }} > - - {settings.cfg.formContact.title || - "Заполните форму, чтобы получить результаты теста"} - - {settings.cfg.formContact.desc && ( - {settings.cfg.formContact.desc} + {settings.cfg.formContact.title || + "Заполните форму, чтобы получить результаты теста"} - )} + {settings.cfg.formContact.desc && ( + + {settings.cfg.formContact.desc} + + )} + + { justifyContent: "center", flexDirection: "column", backgroundColor: theme.palette.background.default, - p: "30px", + p: "0px 20px 30px 20px", }} > { > { + handleChange={({target}) => { setReady(target.checked); }} checked={ready} colorIcon={theme.palette.primary.main} /> - + С  Положением об обработке персональных данных{" "} @@ -326,18 +352,18 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => { }; const Inputs = ({ - name, - setName, - email, - setEmail, - phone, - setPhone, - text, - setText, - adress, - setAdress, -}: any) => { - const { settings } = useQuizData(); + name, + setName, + email, + setEmail, + phone, + setPhone, + text, + setText, + adress, + setAdress, + }: any) => { + const {settings} = useQuizData(); const FC = settings.cfg.formContact.fields; @@ -345,16 +371,16 @@ const Inputs = ({ const Name = ( setName(target.value)} + onChange={({target}) => setName(target.value)} id={name} title={FC["name"].innerText || "Введите имя"} - desc={FC["name"].text || "имя"} + desc={FC["name"].text || "Имя"} Icon={NameIcon} /> ); const Email = ( setEmail(target.value)} + onChange={({target}) => setEmail(target.value)} id={email} title={FC["email"].innerText || "Введите Email"} desc={FC["email"].text || "Email"} @@ -363,28 +389,28 @@ const Inputs = ({ ); const Phone = ( setPhone(target.value)} + onChange={({target}) => setPhone(target.value)} id={phone} title={FC["phone"].innerText || "Введите номер телефона"} - desc={FC["phone"].text || "номер телефона"} + desc={FC["phone"].text || "Номер телефона"} Icon={PhoneIcon} /> ); const Text = ( setText(target.value)} + onChange={({target}) => setText(target.value)} id={text} title={FC["text"].text || "Введите фамилию"} - desc={FC["text"].innerText || "фамилию"} + desc={FC["text"].innerText || "Фамилия"} Icon={TextIcon} /> ); const Adress = ( setAdress(target.value)} + onChange={({target}) => setAdress(target.value)} id={adress} title={FC["address"].innerText || "Введите адрес"} - desc={FC["address"].text || "адрес"} + desc={FC["address"].text || "Адрес"} Icon={AddressIcon} /> ); @@ -410,16 +436,16 @@ const Inputs = ({ } }; -const CustomInput = ({ title, desc, Icon, onChange, id }: { +const CustomInput = ({title, desc, Icon, onChange, id}: { id: string; title: string; desc: string; - Icon: FC<{ color: string; }>; + Icon: FC<{ color: string; backgroundColor: string }>; onChange: TextFieldProps["onChange"]; }) => { const theme = useTheme(); const isMobile = useRootContainerSize() < 600; - + const {settings} = useQuizData(); return ( @@ -430,15 +456,22 @@ const CustomInput = ({ title, desc, Icon, onChange, id }: { onChange={onChange} sx={{ width: isMobile ? "300px" : "350px", + backgroundColor: theme.palette.background.default, "& .MuiOutlinedInput-notchedOutline": { - borderColor: "#9A9AAF" + borderColor: "#9A9AAF80", + borderRadius: "12px" + }, + "& .MuiInputBase-root": { + paddingLeft: 0 } + }} placeholder={desc} InputProps={{ startAdornment: ( - + ), }} diff --git a/lib/components/ViewPublicationPage/ResultForm.tsx b/lib/components/ViewPublicationPage/ResultForm.tsx index d28cf83..edfdf2b 100644 --- a/lib/components/ViewPublicationPage/ResultForm.tsx +++ b/lib/components/ViewPublicationPage/ResultForm.tsx @@ -5,25 +5,25 @@ import { useTheme } from "@mui/material"; -import { NameplateLogo } from "@icons/NameplateLogo"; +import {NameplateLogo} from "@icons/NameplateLogo"; import YoutubeEmbedIframe from "./tools/YoutubeEmbedIframe"; -import { useQuizData } from "@contexts/QuizDataContext"; -import { quizThemes } from "@utils/themes/Publication/themePublication"; -import { useRootContainerSize } from "../../contexts/RootContainerWidthContext"; -import type { QuizQuestionResult } from "../../model/questionTypes/result"; -import { setCurrentQuizStep } from "@stores/quizView"; -import { DESIGN_LIST } from "@/components/ViewPublicationPage/Question"; +import {useQuizData} from "@contexts/QuizDataContext"; +import {quizThemes} from "@utils/themes/Publication/themePublication"; +import {useRootContainerSize} from "../../contexts/RootContainerWidthContext"; +import type {QuizQuestionResult} from "../../model/questionTypes/result"; +import {setCurrentQuizStep} from "@stores/quizView"; +import {DESIGN_LIST} from "@/components/ViewPublicationPage/Question"; type ResultFormProps = { resultQuestion: QuizQuestionResult; }; -export const ResultForm = ({ resultQuestion }: ResultFormProps) => { +export const ResultForm = ({resultQuestion}: ResultFormProps) => { const theme = useTheme(); const isMobile = useRootContainerSize() < 650; const isTablet = useRootContainerSize() < 1000; - const { settings, show_badge } = useQuizData(); + const {settings, show_badge} = useQuizData(); const spec = settings.cfg.spec return ( @@ -36,52 +36,67 @@ export const ResultForm = ({ resultQuestion }: ResultFormProps) => { height: "100%", minHeight: "100vh", width: "100%", - pt: "28px", overflow: "auto", backgroundColor: theme.palette.background.default, backgroundPosition: "center", backgroundSize: "cover", - backgroundImage: settings.cfg.design + backgroundImage: settings.cfg.design && !isMobile ? `url(${DESIGN_LIST[settings.cfg.theme]})` : null, - }} + + }} > - { - !resultQuestion?.content.useImage && resultQuestion.content.video && ( - - ) - } - { - resultQuestion?.content.useImage && resultQuestion.content.back && ( - - ) - } - {resultQuestion.description !== "" && + + { + !resultQuestion?.content.useImage && resultQuestion.content.video && ( + + ) + } + { + resultQuestion?.content.useImage && resultQuestion.content.back && ( + + ) + } + {resultQuestion.description !== "" && resultQuestion.description !== " " && ( { )} - - {resultQuestion.title} - - - { - resultQuestion.content.text !== "" && - resultQuestion.content.text !== " " && ( - - { - resultQuestion.content.text - } - - ) - } - - - - - {show_badge && - - - + + { + resultQuestion.content.text !== "" && + resultQuestion.content.text !== " " && ( + + { + resultQuestion.content.text + } + + ) + } + + + + + + {show_badge && + - Сделано на PenaQuiz - - - } + + + Сделано на PenaQuiz + + + } - + {settings.cfg.resultInfo.showResultForm === "before" && !Boolean(settings.cfg.score) && ( @@ -202,16 +219,17 @@ export const ResultForm = ({ resultQuestion }: ResultFormProps) => { )} {settings.cfg.resultInfo.showResultForm === "after" && - resultQuestion.content.redirect && ( - - )} + resultQuestion.content.redirect && ( + + )} + ); diff --git a/lib/components/ViewPublicationPage/ViewPublicationPage.tsx b/lib/components/ViewPublicationPage/ViewPublicationPage.tsx index 7ec4b68..867a411 100644 --- a/lib/components/ViewPublicationPage/ViewPublicationPage.tsx +++ b/lib/components/ViewPublicationPage/ViewPublicationPage.tsx @@ -64,7 +64,7 @@ export default function ViewPublicationPage() { sx={{ fontSize: "16px", padding: "10px 15px", - color: "#FFFFFF", + color: "#9A9AAF", border: "1px solid #9A9AAF", background: "rgba(154,154,175, 0.2)", "&:disabled": { diff --git a/lib/components/ViewPublicationPage/tools/Select.tsx b/lib/components/ViewPublicationPage/tools/Select.tsx index 3795f24..db04121 100644 --- a/lib/components/ViewPublicationPage/tools/Select.tsx +++ b/lib/components/ViewPublicationPage/tools/Select.tsx @@ -88,6 +88,9 @@ export const Select = ({ height: "48px", borderRadius: "10px", }, + "& .MuiSelect-icon": { + color: theme.palette.primary.main + } }} MenuProps={{ PaperProps: { @@ -106,7 +109,7 @@ export const Select = ({ flexDirection: "column", gap: "8px", "& .Mui-selected": { - backgroundColor: theme.palette.background.default, + backgroundColor: "#F2F3F7", color: colorMain, }, }, @@ -114,7 +117,7 @@ export const Select = ({ }} inputProps={{ sx: { - color: colorMain, + color: theme.palette.text.primary, display: "block", px: "9px", gap: "20px", diff --git a/package.json b/package.json index 52ac4d6..79560eb 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@frontend/squzanswerer", - "version": "1.0.5", + "version": "1.0.6", "type": "module", "main": "./dist-package/index.js", "module": "./dist-package/index.js", @@ -86,6 +86,8 @@ }, "dependencies": { "country-flag-emoji-polyfill": "^0.1.8", - "hex-rgb": "^5.0.0" + "current-device": "^0.10.2", + "hex-rgb": "^5.0.0", + "mobile-detect": "^1.4.5" } } diff --git a/yarn.lock b/yarn.lock index 4d84606..44316e8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1593,6 +1593,11 @@ csstype@^3.0.2, csstype@^3.1.2: resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.3.tgz#d80ff294d114fb0e6ac500fbf85b60137d7eff81" integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw== +current-device@^0.10.2: + version "0.10.2" + resolved "https://registry.yarnpkg.com/current-device/-/current-device-0.10.2.tgz#1e40176bee7da655383ab7245b853fae7d2dfc8e" + integrity sha512-FN223n2Cp1fRI/gyjJEAdagHhJ/2Z2STz3tUg1t4F259BhmVRCChkmxcgFtjYJsWuIacQEs7bqJpnAczIXIkWw== + cypress@^13.6.1: version "13.6.3" resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.6.3.tgz#54f03ca07ee56b2bc18211e7bd32abd2533982ba" @@ -2687,6 +2692,11 @@ minimist@^1.2.8: resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== +mobile-detect@^1.4.5: + version "1.4.5" + resolved "https://registry.yarnpkg.com/mobile-detect/-/mobile-detect-1.4.5.tgz#da393c3c413ca1a9bcdd9ced653c38281c0fb6ad" + integrity sha512-yc0LhH6tItlvfLBugVUEtgawwFU2sIe+cSdmRJJCTMZ5GEJyLxNyC/NIOAOGk67Fa8GNpOttO3Xz/1bHpXFD/g== + moment@^2.30.1: version "2.30.1" resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae"