diff --git a/lib/api/quizRelase.ts b/lib/api/quizRelase.ts index e653904..9f58778 100644 --- a/lib/api/quizRelase.ts +++ b/lib/api/quizRelase.ts @@ -55,7 +55,7 @@ export const publicationMakeRequest = ({ url, body }: any) => { export async function getData(quizId: string): Promise<{ data: GetQuizDataResponse | null; isRecentlyCompleted: boolean; - error?: string; + error?: any; }> { try { const { data, headers } = await axios( @@ -93,7 +93,7 @@ export async function getData(quizId: string): Promise<{ } catch (nativeError) { const error = nativeError as AxiosError; - return { data: null, isRecentlyCompleted: false, error: error.message }; + return { data: null, isRecentlyCompleted: false, error: error }; } } @@ -102,7 +102,7 @@ export async function getQuizData(quizId: string) { const quizDataResponse = response.data; if (response.error) { - throw new Error(response.error); + throw response.error; } if (!quizDataResponse) { throw new Error("Quiz not found"); diff --git a/lib/components/QuizAnswerer.tsx b/lib/components/QuizAnswerer.tsx index 4a365af..bbcd50e 100644 --- a/lib/components/QuizAnswerer.tsx +++ b/lib/components/QuizAnswerer.tsx @@ -57,8 +57,16 @@ export default function QuizAnswerer({ quizSettings, quizId, preview = false, ch }; }, []); - if (isLoading) return ; - if (error) return ; + if (isLoading) return ( + + + + ); + if (error) return ( + + + + ); quizSettings ??= data; if (!quizSettings) throw new Error("Quiz data is null"); diff --git a/lib/components/ViewPublicationPage/ApologyPage.tsx b/lib/components/ViewPublicationPage/ApologyPage.tsx index e8c2823..5795a1d 100644 --- a/lib/components/ViewPublicationPage/ApologyPage.tsx +++ b/lib/components/ViewPublicationPage/ApologyPage.tsx @@ -5,7 +5,8 @@ type Props = Partial; export const ApologyPage = ({ error }: Props) => { let message = "Что-то пошло не так"; - + + if (error.response.data === "quiz is inactive") message = "Квиз не активирован"; if (error.message === "No questions found") message = "Нет созданных вопросов"; if (error.message === "Quiz already completed") message = "Вы уже прошли этот опрос"; diff --git a/package.json b/package.json index baa1cef..aa052ff 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@frontend/squzanswerer", - "version": "1.0.19", + "version": "1.0.20", "type": "module", "main": "./dist-package/index.js", "module": "./dist-package/index.js",