2024-02-01 13:18:16 +00:00
|
|
|
import { Box } from "@mui/material";
|
2024-02-08 13:42:31 +00:00
|
|
|
import { startTransition, useEffect, useState } from "react";
|
2024-02-01 13:18:16 +00:00
|
|
|
import { useParams } from "react-router-dom";
|
2024-02-12 10:58:51 +00:00
|
|
|
import { QuizIdContext } from "@contexts/QuizIdContext";
|
|
|
|
import { RootContainerWidthContext } from "@contexts/RootContainerWidthContext";
|
|
|
|
import QuizAnswerer from "../lib/components/QuizAnswerer";
|
2023-12-16 14:55:56 +00:00
|
|
|
|
2024-02-13 20:12:51 +00:00
|
|
|
const defaultQuizId = "0c568ac9-d176-491b-b6cd-5afd31254951"; // branching
|
2024-02-13 15:57:42 +00:00
|
|
|
//const defaultQuizId = "9ed8d0e9-d355-4fc1-8b89-4f962e3efc52"; //looooong header
|
|
|
|
// const defaultQuizId = "ad7f5a87-b833-4f5b-854e-453706ed655c"; // linear
|
2024-01-31 14:39:50 +00:00
|
|
|
|
2024-02-01 13:18:16 +00:00
|
|
|
export default function App() {
|
2024-02-13 15:57:42 +00:00
|
|
|
const quizId = useParams().quizId ?? defaultQuizId;
|
|
|
|
const [rootContainerSize, setRootContainerSize] = useState<number>(
|
|
|
|
() => window.innerWidth
|
|
|
|
);
|
2024-02-05 10:10:02 +00:00
|
|
|
|
2024-02-12 14:34:29 +00:00
|
|
|
useEffect(() => {
|
|
|
|
const handleWindowResize = () => {
|
|
|
|
startTransition(() => {
|
|
|
|
setRootContainerSize(window.innerWidth);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
window.addEventListener("resize", handleWindowResize);
|
2024-02-05 10:10:02 +00:00
|
|
|
|
2024-02-12 14:34:29 +00:00
|
|
|
return () => {
|
|
|
|
window.removeEventListener("resize", handleWindowResize);
|
|
|
|
};
|
|
|
|
}, []);
|
2023-12-16 14:55:56 +00:00
|
|
|
|
2024-02-12 14:34:29 +00:00
|
|
|
return (
|
|
|
|
<RootContainerWidthContext.Provider value={rootContainerSize}>
|
|
|
|
<QuizIdContext.Provider value={quizId}>
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
height: "100dvh",
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<QuizAnswerer />
|
|
|
|
</Box>
|
|
|
|
</QuizIdContext.Provider>
|
|
|
|
</RootContainerWidthContext.Provider>
|
|
|
|
);
|
2023-12-16 14:55:56 +00:00
|
|
|
}
|