diff --git a/src/widgets/button/OpenQuizButton.tsx b/src/widgets/button/OpenQuizButton.tsx index 72cc093..aac0186 100644 --- a/src/widgets/button/OpenQuizButton.tsx +++ b/src/widgets/button/OpenQuizButton.tsx @@ -14,9 +14,9 @@ interface Props { fixedSide?: "left" | "right"; dimensions?: { width: string; height: string; }; /** - * Открыть квиз через X секунд + * Открыть квиз через X секунд, 0 - сразу */ - autoShowQuizTime?: number; + autoShowQuizTime?: number | null; hideOnMobile?: boolean; openOnLeaveAttempt?: boolean; buttonFlash?: boolean; @@ -30,7 +30,7 @@ interface Props { export default function OpenQuizButton({ quizId, fixedSide, - autoShowQuizTime = 0, + autoShowQuizTime = null, dimensions, hideOnMobile, openOnLeaveAttempt, @@ -49,7 +49,7 @@ export default function OpenQuizButton({ const preventOpenOnLeaveAttemptRef = useRef(false); useEffect(function setAutoShowQuizTimer() { - if (!autoShowQuizTime || openOnLeaveAttempt) return; + if (autoShowQuizTime === null || openOnLeaveAttempt) return; const timeout = setTimeout(() => { setIsQuizShown(true); diff --git a/src/widgets/popup/QuizPopup.tsx b/src/widgets/popup/QuizPopup.tsx index f824328..068068e 100644 --- a/src/widgets/popup/QuizPopup.tsx +++ b/src/widgets/popup/QuizPopup.tsx @@ -11,9 +11,9 @@ interface Props { quizId: string; dimensions?: { width: string; height: string; }; /** - * Открыть квиз через X секунд + * Открыть квиз через X секунд, 0 - сразу */ - autoShowQuizTime?: number; + autoShowQuizTime?: number | null; hideOnMobile?: boolean; openOnLeaveAttempt?: boolean; } @@ -21,11 +21,11 @@ interface Props { export default function QuizPopup({ quizId, dimensions, - autoShowQuizTime = 0, + autoShowQuizTime = null, hideOnMobile = false, openOnLeaveAttempt = false, }: Props) { - const initialIsQuizShown = (autoShowQuizTime || openOnLeaveAttempt) ? false : true; + const initialIsQuizShown = (autoShowQuizTime !== null || openOnLeaveAttempt) ? false : true; const [isQuizShown, setIsQuizShown] = useState(initialIsQuizShown); const isQuizCompleted = useQuizCompletionStatus(quizId); @@ -33,7 +33,7 @@ export default function QuizPopup({ const preventOpenOnLeaveAttemptRef = useRef(false); useEffect(function setAutoShowQuizTimer() { - if (!autoShowQuizTime || openOnLeaveAttempt) return; + if (autoShowQuizTime === null || openOnLeaveAttempt) return; const timeout = setTimeout(() => { setIsQuizShown(true); diff --git a/src/widgets/side/QuizSideButton.tsx b/src/widgets/side/QuizSideButton.tsx index 3e14cee..6ad6fe2 100644 --- a/src/widgets/side/QuizSideButton.tsx +++ b/src/widgets/side/QuizSideButton.tsx @@ -25,9 +25,9 @@ interface Props { */ autoOpenTime?: number; /** - * Открыть квиз через X секунд + * Открыть квиз через X секунд, 0 - сразу */ - autoShowQuizTime?: number; + autoShowQuizTime?: number | null; hideOnMobile?: boolean; } @@ -40,7 +40,7 @@ export default function QuizSideButton({ fullScreen = false, buttonFlash = false, autoOpenTime = 0, - autoShowQuizTime = 0, + autoShowQuizTime = null, hideOnMobile = false, }: Props) { const [isQuizShown, setIsQuizShown] = useState(false); @@ -51,7 +51,7 @@ export default function QuizSideButton({ const preventQuizAutoShowRef = useRef(false); useEffect(function setAutoShowQuizTimer() { - if (!autoShowQuizTime) return; + if (autoShowQuizTime === null) return; const timeout = setTimeout(() => { if (!preventQuizAutoShowRef.current) setIsQuizShown(true);