Обработка ошибки, когда вопросы для аудитории ещё не созданы
Some checks failed
Deploy / CreateImage (push) Failing after 3h13m52s
Deploy / DeployService (push) Has been cancelled

This commit is contained in:
Nastya 2025-06-12 15:35:31 +03:00
parent c186a04fa5
commit 770966ab4f
4 changed files with 62 additions and 50 deletions

@ -93,18 +93,21 @@ export async function getData({ quizId }: { quizId: string }): Promise<{
if (paudParam) body.auditory = Number(paudParam); if (paudParam) body.auditory = Number(paudParam);
try { try {
const { data, headers } = await axios<GetQuizDataResponse>(domain + `/answer/v1.0.0/settings`, { const { data, headers } = await axios<GetQuizDataResponse>(
method: "POST", domain + `/answer/v1.0.0/settings${window.location.search}`,
headers: { {
"X-Sessionkey": SESSIONS, method: "POST",
"Content-Type": "application/json", headers: {
DeviceType: DeviceType, "X-Sessionkey": SESSIONS,
Device: Device, "Content-Type": "application/json",
OS: OSDevice, DeviceType: DeviceType,
Browser: userAgent, Device: Device,
}, OS: OSDevice,
data: body, Browser: userAgent,
}); },
data: body,
}
);
const sessions = JSON.parse(localStorage.getItem("sessions") || "{}"); const sessions = JSON.parse(localStorage.getItem("sessions") || "{}");
//Тут ещё проверка на антифрод без парса конфига. Нам не интересно время если не нужно запрещать проходить чаще чем в сутки //Тут ещё проверка на антифрод без парса конфига. Нам не интересно время если не нужно запрещать проходить чаще чем в сутки
@ -133,23 +136,26 @@ export async function getDataSingle({ quizId, page }: { quizId: string; page?: n
try { try {
// Первый запрос: 1 вопрос + конфиг // Первый запрос: 1 вопрос + конфиг
if (isFirstRequest) { if (isFirstRequest) {
const { data, headers } = await axios<GetQuizDataResponse>(domain + `/answer/v1.0.0/settings`, { const { data, headers } = await axios<GetQuizDataResponse>(
method: "POST", domain + `/answer/v1.0.0/settings${window.location.search}`,
headers: { {
"X-Sessionkey": SESSIONS, method: "POST",
"Content-Type": "application/json", headers: {
DeviceType: DeviceType, "X-Sessionkey": SESSIONS,
Device: Device, "Content-Type": "application/json",
OS: OSDevice, DeviceType: DeviceType,
Browser: userAgent, Device: Device,
}, OS: OSDevice,
data: { Browser: userAgent,
quiz_id: quizId, },
limit: 1, data: {
page: 0, quiz_id: quizId,
need_config: true, limit: 1,
}, page: 0,
}); need_config: true,
},
}
);
globalStatus = data.settings.status; globalStatus = data.settings.status;
isFirstRequest = false; isFirstRequest = false;
@ -165,23 +171,26 @@ export async function getDataSingle({ quizId, page }: { quizId: string; page?: n
// Если статус не AI - сразу делаем запрос за всеми вопросами // Если статус не AI - сразу делаем запрос за всеми вопросами
if (globalStatus !== "ai") { if (globalStatus !== "ai") {
const secondResponse = await axios<GetQuizDataResponse>(domain + `/answer/v1.0.0/settings`, { const secondResponse = await axios<GetQuizDataResponse>(
method: "POST", domain + `/answer/v1.0.0/settings${window.location.search}`,
headers: { {
"X-Sessionkey": SESSIONS, method: "POST",
"Content-Type": "application/json", headers: {
DeviceType: DeviceType, "X-Sessionkey": SESSIONS,
Device: Device, "Content-Type": "application/json",
OS: OSDevice, DeviceType: DeviceType,
Browser: userAgent, Device: Device,
}, OS: OSDevice,
data: { Browser: userAgent,
quiz_id: quizId, },
limit: 100, data: {
page: 0, quiz_id: quizId,
need_config: false, limit: 100,
}, page: 0,
}); need_config: false,
},
}
);
return { return {
data: { ...data, items: secondResponse.data.items }, data: { ...data, items: secondResponse.data.items },
isRecentlyCompleted: false, isRecentlyCompleted: false,
@ -192,7 +201,7 @@ export async function getDataSingle({ quizId, page }: { quizId: string; page?: n
} }
// Последующие запросы // Последующие запросы
const response = await axios<GetQuizDataResponse>(domain + `/answer/v1.0.0/settings`, { const response = await axios<GetQuizDataResponse>(domain + `/answer/v1.0.0/settings${window.location.search}`, {
method: "POST", method: "POST",
headers: { headers: {
"X-Sessionkey": SESSIONS, "X-Sessionkey": SESSIONS,

@ -53,5 +53,6 @@
"and": "and", "and": "and",
"Get results": "Get results", "Get results": "Get results",
"Data sent successfully": "Data sent successfully", "Data sent successfully": "Data sent successfully",
"Step": "Step" "Step": "Step",
"questions are not ready yet": "There are no questions for the audience yet. Please wait"
} }

@ -53,5 +53,6 @@
"and": "и", "and": "и",
"Get results": "Получить результаты", "Get results": "Получить результаты",
"Data sent successfully": "Данные успешно отправлены", "Data sent successfully": "Данные успешно отправлены",
"Step": "Шаг" "Step": "Шаг",
"questions are not ready yet": "Вопросы для аудитории ещё не созданы. Пожалуйста, подождите"
} }

@ -53,5 +53,6 @@
"and": "va", "and": "va",
"Get results": "Natijalarni olish", "Get results": "Natijalarni olish",
"Data sent successfully": "Ma'lumotlar muvaffaqiyatli yuborildi", "Data sent successfully": "Ma'lumotlar muvaffaqiyatli yuborildi",
"Step": "Qadam" "Step": "Qadam",
"questions are not ready yet": "Tomoshabinlar uchun hozircha savollar yo'q. Iltimos kuting"
} }