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-02 14:35:02 +00:00
|
|
|
import QuizAnswerer from "./QuizAnswerer";
|
|
|
|
import { QuizIdContext } from "./contexts/QuizIdContext";
|
2024-02-05 10:10:02 +00:00
|
|
|
import { RootContainerWidthContext } from "./contexts/RootContainerWidthContext";
|
2023-12-16 14:55:56 +00:00
|
|
|
|
|
|
|
|
2024-02-08 13:42:31 +00:00
|
|
|
const defaultQuizId = "45ef7f9c-784d-4e58-badb-f6b337f08ba0";
|
2024-01-31 14:39:50 +00:00
|
|
|
|
2024-02-01 13:18:16 +00:00
|
|
|
export default function App() {
|
|
|
|
const quizId = useParams().quizId ?? defaultQuizId;
|
2024-02-08 13:42:31 +00:00
|
|
|
const [rootContainerSize, setRootContainerSize] = useState<number>(() => window.innerWidth);
|
2024-02-05 10:10:02 +00:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const handleWindowResize = () => {
|
2024-02-08 13:42:31 +00:00
|
|
|
startTransition(() => {
|
|
|
|
setRootContainerSize(window.innerWidth);
|
|
|
|
});
|
2024-02-05 10:10:02 +00:00
|
|
|
};
|
|
|
|
window.addEventListener("resize", handleWindowResize);
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
window.removeEventListener("resize", handleWindowResize);
|
|
|
|
};
|
|
|
|
}, []);
|
2023-12-16 14:55:56 +00:00
|
|
|
|
2024-01-20 12:25:08 +00:00
|
|
|
return (
|
2024-02-05 10:10:02 +00:00
|
|
|
<RootContainerWidthContext.Provider value={rootContainerSize}>
|
|
|
|
<QuizIdContext.Provider value={quizId}>
|
|
|
|
<Box sx={{
|
|
|
|
height: "100dvh",
|
|
|
|
}}>
|
|
|
|
<QuizAnswerer />
|
|
|
|
</Box>
|
|
|
|
</QuizIdContext.Provider>
|
|
|
|
</RootContainerWidthContext.Provider>
|
2024-01-20 12:25:08 +00:00
|
|
|
);
|
2023-12-16 14:55:56 +00:00
|
|
|
}
|