31 lines
883 B
TypeScript
31 lines
883 B
TypeScript
import { getQuizData } from "@api/quizRelase";
|
|
import LoadingSkeleton from "@ui_kit/LoadingSkeleton";
|
|
import useSWR from "swr";
|
|
import QuizAnswerer from "../lib/components/QuizAnswerer";
|
|
import { ApologyPage } from "../lib/components/ViewPublicationPage/ApologyPage";
|
|
|
|
|
|
interface Props {
|
|
quizId: string;
|
|
}
|
|
|
|
export default function WidgetApp({ quizId }: Props) {
|
|
const { data, error, isLoading } = useSWR(["quizData", quizId], params => getQuizData(params[1]), {
|
|
revalidateOnFocus: false,
|
|
revalidateOnReconnect: false,
|
|
shouldRetryOnError: false,
|
|
refreshInterval: 0,
|
|
});
|
|
|
|
if (isLoading) return <LoadingSkeleton />;
|
|
if (error) return <ApologyPage error={error} />;
|
|
if (!data) throw new Error("Quiz data is null");
|
|
|
|
return (
|
|
<QuizAnswerer
|
|
quizSettings={data}
|
|
quizId={quizId}
|
|
/>
|
|
);
|
|
}
|