Finish Method
This commit is contained in:
1 parent
c70141b26a
commit
ff6f3e6f4f
3 files changed
+31
-2
No files matched your search
@@ -2,7 +2,7 @@ import { useLocalStorage } from "@/hooks/useLocalStorage"
|
||||
import { PREF } from "@/utils/const"
|
||||
import ChargedButton from "../ChargedButton";
|
||||
import styles from "@/css/Outro.module.css";
|
||||
import { ChangeEvent, InputEvent, MouseEvent, MouseEventHandler, PointerEvent, useMemo, useRef, useState } from "react";
|
||||
import { ChangeEvent, InputEvent, MouseEvent, MouseEventHandler, PointerEvent, useEffect, useMemo, useRef, useState } from "react";
|
||||
import Image from "next/image";
|
||||
import StyledContainer from "../StyledContainer";
|
||||
import OldButton from "../OldButton";
|
||||
@@ -12,8 +12,10 @@ import { getPoints } from "@/utils/points";
|
||||
import VoiceOver from "../VoiceOver";
|
||||
import { VoiceOverMode } from "@/types/voiceOverMode";
|
||||
import { isDemoMode } from "@/utils/demoMode";
|
||||
import { finishSession } from "@/utils/sessionHandler";
|
||||
|
||||
export default function Outro() {
|
||||
const [ tourCode, setTourCode ] = useLocalStorage(PREF.code, "");
|
||||
const [ resultPage, setResultPage ] = useState(0);
|
||||
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
||||
const [ pointsStr, setPoints ] = useLocalStorage(PREF.points, "0");
|
||||
@@ -37,6 +39,24 @@ export default function Outro() {
|
||||
return true;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!tourCode || tourCode.length === 0 || demoMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
finishSession(tourCode).then((res) => {
|
||||
if (!res.ok) {
|
||||
finishSession(tourCode).finally(() => {
|
||||
setTourCode("");
|
||||
});
|
||||
} else {
|
||||
setTourCode("");
|
||||
}
|
||||
}).catch(() => {
|
||||
setTourCode("");
|
||||
});
|
||||
}, [tourCode]);
|
||||
|
||||
const pages = [
|
||||
(
|
||||
<div className={styles["outro-video-container"]} key={0}>
|
||||
|
||||
Reference in new issue
Block a user