Merge branch 'copy-quiz' into 'dev'
Copy quiz See merge request frontend/squiz!304
This commit is contained in:
commit
f7b295551f
@ -114,13 +114,13 @@ export interface QuizConfig {
|
|||||||
law?: string;
|
law?: string;
|
||||||
};
|
};
|
||||||
meta: string;
|
meta: string;
|
||||||
yandexMetricNumber: number | undefined;
|
yandexMetricsNumber: number | undefined;
|
||||||
vkMetricNumber: number | undefined;
|
vkMetricsNumber: number | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum QuizMetricType {
|
export enum QuizMetricType {
|
||||||
yandex = "yandexMetricNumber",
|
yandex = "yandexMetricsNumber",
|
||||||
vk = "vkMetricNumber",
|
vk = "vkMetricsNumber",
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FormContactFieldName =
|
export type FormContactFieldName =
|
||||||
@ -228,6 +228,6 @@ export const defaultQuizConfig: QuizConfig = {
|
|||||||
button: "",
|
button: "",
|
||||||
},
|
},
|
||||||
meta: "",
|
meta: "",
|
||||||
yandexMetricNumber: undefined,
|
yandexMetricsNumber: undefined,
|
||||||
vkMetricNumber: undefined,
|
vkMetricsNumber: undefined,
|
||||||
};
|
};
|
||||||
|
@ -142,7 +142,7 @@ export default function QuizInstallationCard() {
|
|||||||
id="outlined-multiline-static"
|
id="outlined-multiline-static"
|
||||||
multiline
|
multiline
|
||||||
rows={9}
|
rows={9}
|
||||||
value={`<div id="idpena"></div> <script type="module"> import widget from "https://${isTestServer ? "s." : ""}hbpn.link/export/pub.js"; widget.create({ selector: "idpena", quizId: ${quiz.qid} }) </script>`}
|
value={`<div id="idpena"></div> <script type="module"> import widget from "https://${isTestServer ? "s." : ""}hbpn.link/export/pub.js"; widget.create({ selector: "idpena", quizId: "${quiz.qid}" }) </script>`}
|
||||||
sx={{
|
sx={{
|
||||||
"& .MuiInputBase-root": {
|
"& .MuiInputBase-root": {
|
||||||
maxWidth: "520px",
|
maxWidth: "520px",
|
||||||
@ -158,11 +158,11 @@ export default function QuizInstallationCard() {
|
|||||||
<IconButton
|
<IconButton
|
||||||
edge="end"
|
edge="end"
|
||||||
sx={{ marginTop: "22px" }}
|
sx={{ marginTop: "22px" }}
|
||||||
// onClick={() => navigator.clipboard.writeText( // TODO
|
onClick={() => navigator.clipboard.writeText( // TODO
|
||||||
// document.getElementById(
|
document.getElementById(
|
||||||
// "outlined-multiline-static"
|
"outlined-multiline-static"
|
||||||
// ).value
|
).value
|
||||||
// )}
|
)}
|
||||||
>
|
>
|
||||||
<CopyIcon
|
<CopyIcon
|
||||||
color={"#ffffff"}
|
color={"#ffffff"}
|
||||||
|
@ -21,9 +21,9 @@ export default function ViewPublicationPage() {
|
|||||||
if (!quizId) return null;
|
if (!quizId) return null;
|
||||||
|
|
||||||
const quiz = quizes?.find((quiz) => quiz.qid === quizId);
|
const quiz = quizes?.find((quiz) => quiz.qid === quizId);
|
||||||
const yandexMetricNumber = quiz?.config.yandexMetricNumber;
|
const yandexMetricsNumber = quiz?.config.yandexMetricsNumber;
|
||||||
|
|
||||||
useYandexMetrics(yandexMetricNumber);
|
useYandexMetrics(yandexMetricsNumber);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: rawQuestions,
|
data: rawQuestions,
|
||||||
|
@ -13,6 +13,7 @@ import {
|
|||||||
resetEditConfig,
|
resetEditConfig,
|
||||||
updateQuiz,
|
updateQuiz,
|
||||||
} from "@root/quizes/actions";
|
} from "@root/quizes/actions";
|
||||||
|
import { mutate } from "swr";
|
||||||
import { useQuizes } from "@root/quizes/hooks";
|
import { useQuizes } from "@root/quizes/hooks";
|
||||||
import SectionWrapper from "@ui_kit/SectionWrapper";
|
import SectionWrapper from "@ui_kit/SectionWrapper";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
@ -32,19 +33,16 @@ export default function MyQuizzesFull({
|
|||||||
outerContainerSx: sx,
|
outerContainerSx: sx,
|
||||||
children,
|
children,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const { quizes, isValidating } = useQuizes();
|
const { quizes } = useQuizes();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isMobile = useMediaQuery(theme.breakpoints.down(500));
|
const isMobile = useMediaQuery(theme.breakpoints.down(500));
|
||||||
|
|
||||||
const onClickCopy = (value: string) => {
|
const onClickCopy = (value: string) => {
|
||||||
copyQuiz(value);
|
copyQuiz(value);
|
||||||
|
mutate("quizes");
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isValidating) {
|
|
||||||
return <HeaderFull isRequest={false} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<HeaderFull isRequest={false} />
|
<HeaderFull isRequest={false} />
|
||||||
|
@ -250,11 +250,16 @@ export const copyQuiz = async (quizId: string) =>
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const { updated } = await quizApi.copy(quiz.backendId);
|
const { updated } = await quizApi.copy(quiz.backendId);
|
||||||
let newQuiz = { ...quiz, id: updated };
|
let newQuiz: Quiz = {
|
||||||
|
...quiz,
|
||||||
|
id: String(updated),
|
||||||
|
session_count: 0,
|
||||||
|
passed_count: 0,
|
||||||
|
};
|
||||||
|
|
||||||
setProducedState(
|
setProducedState(
|
||||||
(state) => {
|
(state) => {
|
||||||
state.quizes.unshift(quiz);
|
state.quizes.unshift(newQuiz);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "addQuiz",
|
type: "addQuiz",
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
|
|
||||||
export const useYandexMetrics = (yandexMetricNumber: number | undefined) => {
|
export const useYandexMetrics = (yandexMetricsNumber: number | undefined) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
yandexMetricNumber &&
|
yandexMetricsNumber &&
|
||||||
typeof yandexMetricNumber === "number" &&
|
typeof yandexMetricsNumber === "number" &&
|
||||||
!Number.isNaN(yandexMetricNumber)
|
!Number.isNaN(yandexMetricsNumber)
|
||||||
) {
|
) {
|
||||||
const script = document.createElement("script");
|
const script = document.createElement("script");
|
||||||
script.type = "text/javascript";
|
script.type = "text/javascript";
|
||||||
@ -16,7 +16,7 @@ export const useYandexMetrics = (yandexMetricNumber: number | undefined) => {
|
|||||||
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
|
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
|
||||||
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
|
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
|
||||||
|
|
||||||
ym(${yandexMetricNumber}, "init", {
|
ym(${yandexMetricsNumber}, "init", {
|
||||||
clickmap:true,
|
clickmap:true,
|
||||||
trackLinks:true,
|
trackLinks:true,
|
||||||
accurateTrackBounce:true,
|
accurateTrackBounce:true,
|
||||||
@ -26,8 +26,8 @@ export const useYandexMetrics = (yandexMetricNumber: number | undefined) => {
|
|||||||
document.body.appendChild(script);
|
document.body.appendChild(script);
|
||||||
|
|
||||||
const noscript = document.createElement("noscript");
|
const noscript = document.createElement("noscript");
|
||||||
noscript.innerHTML = `<div><img src="https://mc.yandex.ru/watch/${yandexMetricNumber}" style="position:absolute; left:-9999px;" alt="" /></div>`;
|
noscript.innerHTML = `<div><img src="https://mc.yandex.ru/watch/${yandexMetricsNumber}" style="position:absolute; left:-9999px;" alt="" /></div>`;
|
||||||
document.body.appendChild(noscript);
|
document.body.appendChild(noscript);
|
||||||
}
|
}
|
||||||
}, [yandexMetricNumber]);
|
}, [yandexMetricsNumber]);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user