Merge branch 'dev' into 'staging'
Dev See merge request frontend/squzanswerer!158
This commit is contained in:
commit
cecfa8bbdd
@ -78,7 +78,7 @@ export async function getData(quizId: string): Promise<{
|
||||
error?: AxiosError;
|
||||
}> {
|
||||
try {
|
||||
const { data, headers } = await axios<GetQuizDataResponse>(domain + `/answer/settings`, {
|
||||
const { data, headers } = await axios<GetQuizDataResponse>(domain + `/answer/settings${window.location.search}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"X-Sessionkey": SESSIONS,
|
||||
@ -160,7 +160,7 @@ export function sendAnswer({ questionId, body, qid, preview }: SendAnswerProps)
|
||||
formData.append("qid", qid);
|
||||
|
||||
return publicationMakeRequest({
|
||||
url: domain + `/answer/answer`,
|
||||
url: domain + `/answer/v1.0.0/answer`,
|
||||
body: formData,
|
||||
method: "POST",
|
||||
});
|
||||
@ -199,7 +199,7 @@ export function sendFile({ questionId, body, qid }: SendFileParams) {
|
||||
formData.append("qid", qid);
|
||||
|
||||
return publicationMakeRequest({
|
||||
url: domain + `/answer/answer`,
|
||||
url: domain + `/answer/v1.0.0/answer`,
|
||||
body: formData,
|
||||
method: "POST",
|
||||
});
|
||||
@ -242,7 +242,7 @@ export function sendFC({ questionId, body, qid, preview }: SendFCParams) {
|
||||
formData.append("qid", qid);
|
||||
|
||||
return publicationMakeRequest({
|
||||
url: domain + `/answer/answer`,
|
||||
url: domain + `/answer/v1.0.0/answer`,
|
||||
body: formData,
|
||||
method: "POST",
|
||||
});
|
||||
|
@ -310,7 +310,7 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => {
|
||||
target={"_blank"}
|
||||
href={`https://${
|
||||
window.location.hostname.includes("s") ? "s" : ""
|
||||
}quiz.pena.digital/squiz/quiz/logo?q=${quizId}`}
|
||||
}quiz.pena.digital/answer/v1.0.0/logo?q=${quizId}`}
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
|
@ -40,7 +40,7 @@ export const Question = ({
|
||||
questionSelect,
|
||||
}: Props) => {
|
||||
const theme = useTheme();
|
||||
const { settings, show_badge } = useQuizSettings();
|
||||
const { settings, show_badge, quizId } = useQuizSettings();
|
||||
|
||||
return (
|
||||
<Box
|
||||
@ -95,7 +95,7 @@ export const Question = ({
|
||||
{show_badge && (
|
||||
<Link
|
||||
target="_blank"
|
||||
href="https://quiz.pena.digital"
|
||||
href={`https://${window.location.hostname.includes("s") ? "s" : ""}quiz.pena.digital/answer/v1.0.0/logo?q=${quizId}`}
|
||||
sx={{
|
||||
mt: "20px",
|
||||
alignSelf: "end",
|
||||
|
@ -34,7 +34,7 @@ export const ResultForm = ({ resultQuestion }: ResultFormProps) => {
|
||||
useEffect(() => {
|
||||
vkMetrics.resultIdShown(resultQuestion.id);
|
||||
yandexMetrics.resultIdShown(resultQuestion.id);
|
||||
}, []);
|
||||
}, [resultQuestion.id, vkMetrics, yandexMetrics]);
|
||||
|
||||
return (
|
||||
<Box
|
||||
@ -195,7 +195,7 @@ export const ResultForm = ({ resultQuestion }: ResultFormProps) => {
|
||||
target={"_blank"}
|
||||
href={`https://${
|
||||
window.location.hostname.includes("s") ? "s" : ""
|
||||
}quiz.pena.digital/squiz/quiz/logo?q=${quizId}`}
|
||||
}quiz.pena.digital/answer/v1.0.0/logo?q=${quizId}`}
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
@ -229,7 +229,9 @@ export const ResultForm = ({ resultQuestion }: ResultFormProps) => {
|
||||
bottom: 0,
|
||||
}}
|
||||
>
|
||||
{settings.cfg.resultInfo.showResultForm === "before" && !settings.cfg.score && (
|
||||
{settings.cfg.resultInfo.showResultForm === "before" &&
|
||||
settings.cfg.showfc !== false &&
|
||||
!settings.cfg.score && (
|
||||
<Button
|
||||
onClick={() => setCurrentQuizStep("contactform")}
|
||||
variant="contained"
|
||||
|
@ -136,7 +136,7 @@ export const StartPageViewPublication = () => {
|
||||
<Box
|
||||
component={Link}
|
||||
target={"_blank"}
|
||||
href={`https://${window.location.hostname.includes("s") ? "s" : ""}quiz.pena.digital/squiz/quiz/logo?q=${quizId}`}
|
||||
href={`https://${window.location.hostname.includes("s") ? "s" : ""}quiz.pena.digital/answer/v1.0.0/logo?q=${quizId}`}
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
|
@ -110,10 +110,10 @@ export interface QuizConfig {
|
||||
law?: string;
|
||||
};
|
||||
meta: string;
|
||||
antifraud: boolean;
|
||||
showfc: boolean;
|
||||
yandexMetricsNumber: number | undefined;
|
||||
vkMetricsNumber: number | undefined;
|
||||
antifraud?: boolean;
|
||||
showfc?: boolean;
|
||||
yandexMetricsNumber?: number;
|
||||
vkMetricsNumber?: number;
|
||||
}
|
||||
|
||||
export type FormContactFieldName = "name" | "email" | "phone" | "text" | "address";
|
||||
|
@ -1,4 +1,5 @@
|
||||
import type { MetricsMessengers } from "@model/metrics";
|
||||
import { useMemo } from "react";
|
||||
|
||||
type MetricsGoal = {
|
||||
type: "reachGoal";
|
||||
@ -19,7 +20,8 @@ const sendMetrics = (vkPixelId: number | undefined, goal: string) => {
|
||||
};
|
||||
|
||||
export const useVkMetricsGoals = (vkId: number | undefined) => {
|
||||
return {
|
||||
return useMemo(
|
||||
() => ({
|
||||
// Посетитель открыл квиз
|
||||
quizOpened: () => sendMetrics(vkId, "penaquiz-start"),
|
||||
// Посетитель нажал на кнопку стартовой страницы
|
||||
@ -42,5 +44,7 @@ export const useVkMetricsGoals = (vkId: number | undefined) => {
|
||||
messengerRequestSended: (messenger: MetricsMessengers) => sendMetrics(vkId, `penaquiz-messengers-${messenger}`),
|
||||
// Посетитель прошёл вопрос
|
||||
questionPassed: (questionId: string) => sendMetrics(vkId, `penaquiz-step${questionId}`),
|
||||
};
|
||||
}),
|
||||
[vkId]
|
||||
);
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
import type { MetricsMessengers } from "@model/metrics";
|
||||
import { useMemo } from "react";
|
||||
|
||||
type ExtendedWindow = Window & {
|
||||
ym?: (id: number, type: string, goal: string) => void;
|
||||
@ -11,7 +12,8 @@ const sendMetrics = (yandexMetricsId: number | undefined, goal: string) => {
|
||||
};
|
||||
|
||||
export const useYandexMetricsGoals = (id: number | undefined) => {
|
||||
return {
|
||||
return useMemo(
|
||||
() => ({
|
||||
// Посетитель открыл квиз
|
||||
quizOpened: () => sendMetrics(id, "penaquiz-start"),
|
||||
// Посетитель нажал на кнопку стартовой страницы
|
||||
@ -34,5 +36,7 @@ export const useYandexMetricsGoals = (id: number | undefined) => {
|
||||
messengerRequestSended: (messenger: MetricsMessengers) => sendMetrics(id, `penaquiz-messengers-${messenger}`),
|
||||
// Посетитель прошёл вопрос
|
||||
questionPassed: (questionId: string) => sendMetrics(id, `penaquiz-step${questionId}`),
|
||||
};
|
||||
}),
|
||||
[id]
|
||||
);
|
||||
};
|
||||
|
@ -23,7 +23,6 @@ export function useQuestionFlowControl() {
|
||||
const yandexMetrics = useYandexMetricsGoals(settings.cfg.yandexMetricsNumber);
|
||||
|
||||
const currentQuestion = sortedQuestions.find((question) => question.id === currentQuestionId) ?? sortedQuestions[0];
|
||||
console.log("currentQuestion", currentQuestion);
|
||||
|
||||
const linearQuestionIndex =
|
||||
currentQuestion && sortedQuestions.every(({ content }) => content.rule.parentId !== "root") // null when branching enabled
|
||||
@ -131,9 +130,12 @@ export function useQuestionFlowControl() {
|
||||
if (nextQuestion?.type !== "result") throw new Error("Current question is not result");
|
||||
|
||||
setCurrentQuestionId(nextQuestion.id);
|
||||
if (settings.cfg.resultInfo.showResultForm === "after" || isResultQuestionEmpty(nextQuestion))
|
||||
if (
|
||||
settings.cfg.showfc !== false &&
|
||||
(settings.cfg.resultInfo.showResultForm === "after" || isResultQuestionEmpty(nextQuestion))
|
||||
)
|
||||
setCurrentQuizStep("contactform");
|
||||
}, [nextQuestion, setCurrentQuizStep, settings.cfg.resultInfo.showResultForm]);
|
||||
}, [nextQuestion, setCurrentQuizStep, settings.cfg.resultInfo.showResultForm, settings.cfg.showfc]);
|
||||
|
||||
const showResultAfterContactForm = useCallback(() => {
|
||||
if (currentQuestion?.type !== "result") throw new Error("Current question is not result");
|
||||
@ -161,7 +163,7 @@ export function useQuestionFlowControl() {
|
||||
if (nextQuestion.type === "result") return showResult();
|
||||
|
||||
setCurrentQuestionId(nextQuestion.id);
|
||||
}, [currentQuestion, nextQuestion, showResult]);
|
||||
}, [currentQuestion.id, nextQuestion, showResult, vkMetrics, yandexMetrics]);
|
||||
|
||||
const setQuestion = useCallback(
|
||||
(questionId: string) => {
|
||||
|
Loading…
Reference in New Issue
Block a user