hide ai
This commit is contained in:
parent
4190ae767e
commit
58a8fdb25e
@ -1,8 +1,8 @@
|
|||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
import { getQuizData } from "./quizRelase";
|
import { getQuizData } from "./quizRelase";
|
||||||
|
|
||||||
export function useQuizData(quizId: string, preview: boolean = false) {
|
export function useQuizData(quizId: string, preview: boolean = false, isAi: boolean = false) {
|
||||||
return useSWR(preview ? null : ["quizData", quizId], (params) => getQuizData(params[1]), {
|
return useSWR(preview ? null : ["quizData", quizId], (params) => getQuizData(params[1], isAi), {
|
||||||
revalidateOnFocus: false,
|
revalidateOnFocus: false,
|
||||||
revalidateOnReconnect: false,
|
revalidateOnReconnect: false,
|
||||||
shouldRetryOnError: false,
|
shouldRetryOnError: false,
|
||||||
|
@ -72,7 +72,10 @@ export const publicationMakeRequest = ({ url, body }: PublicationMakeRequestPara
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function getData(quizId: string): Promise<{
|
export async function getData(
|
||||||
|
quizId: string,
|
||||||
|
isAi: boolean
|
||||||
|
): Promise<{
|
||||||
data: GetQuizDataResponse | null;
|
data: GetQuizDataResponse | null;
|
||||||
isRecentlyCompleted: boolean;
|
isRecentlyCompleted: boolean;
|
||||||
error?: AxiosError;
|
error?: AxiosError;
|
||||||
@ -92,7 +95,7 @@ export async function getData(quizId: string): Promise<{
|
|||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
quiz_id: quizId,
|
quiz_id: quizId,
|
||||||
limit: 100,
|
limit: isAi ? 1 : 100,
|
||||||
page: 0,
|
page: 0,
|
||||||
need_config: true,
|
need_config: true,
|
||||||
},
|
},
|
||||||
@ -118,10 +121,10 @@ export async function getData(quizId: string): Promise<{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getQuizData(quizId: string) {
|
export async function getQuizData(quizId: string, isAi: boolean) {
|
||||||
if (!quizId) throw new Error("No quiz id");
|
if (!quizId) throw new Error("No quiz id");
|
||||||
|
|
||||||
const response = await getData(quizId);
|
const response = await getData(quizId, isAi);
|
||||||
const quizDataResponse = response.data;
|
const quizDataResponse = response.data;
|
||||||
|
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
|
@ -38,7 +38,7 @@ export const Footer = ({ stepNumber, nextButton, prevButton }: FooterProps) => {
|
|||||||
gap: "10px",
|
gap: "10px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{stepNumber !== null && (
|
{stepNumber !== null && settings.status !== "ai" && (
|
||||||
<Box sx={{ flexGrow: 1 }}>
|
<Box sx={{ flexGrow: 1 }}>
|
||||||
<Typography sx={{ color: theme.palette.text.primary }}>
|
<Typography sx={{ color: theme.palette.text.primary }}>
|
||||||
Вопрос {stepNumber} из {questionsAmount}
|
Вопрос {stepNumber} из {questionsAmount}
|
||||||
|
@ -12,6 +12,7 @@ export interface GetQuizDataResponse {
|
|||||||
due: number;
|
due: number;
|
||||||
delay: number;
|
delay: number;
|
||||||
pausable: boolean;
|
pausable: boolean;
|
||||||
|
status: "start" | "stop" | "ai";
|
||||||
};
|
};
|
||||||
items: {
|
items: {
|
||||||
id: number;
|
id: number;
|
||||||
@ -49,6 +50,7 @@ export function parseQuizData(quizDataResponse: GetQuizDataResponse): Omit<QuizS
|
|||||||
due: quizDataResponse.settings.due,
|
due: quizDataResponse.settings.due,
|
||||||
delay: quizDataResponse.settings.delay,
|
delay: quizDataResponse.settings.delay,
|
||||||
pausable: quizDataResponse.settings.pausable,
|
pausable: quizDataResponse.settings.pausable,
|
||||||
|
status: quizDataResponse.settings.status,
|
||||||
};
|
};
|
||||||
|
|
||||||
return { cnt: quizDataResponse.cnt, settings, questions: items, show_badge: quizDataResponse.show_badge };
|
return { cnt: quizDataResponse.cnt, settings, questions: items, show_badge: quizDataResponse.show_badge };
|
||||||
|
@ -51,6 +51,7 @@ export type QuizSettingsConfig = {
|
|||||||
delay: number;
|
delay: number;
|
||||||
pausable: boolean;
|
pausable: boolean;
|
||||||
cfg: QuizConfig;
|
cfg: QuizConfig;
|
||||||
|
status: "start" | "stop" | "ai";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type QuizSettings = {
|
export type QuizSettings = {
|
||||||
|
@ -246,7 +246,8 @@ export function useQuestionFlowControl() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
currentQuestion,
|
currentQuestion,
|
||||||
currentQuestionStepNumber: linearQuestionIndex === null ? null : linearQuestionIndex + 1,
|
currentQuestionStepNumber:
|
||||||
|
settings.status === "ai" ? null : linearQuestionIndex === null ? null : linearQuestionIndex + 1,
|
||||||
nextQuestion,
|
nextQuestion,
|
||||||
isNextButtonEnabled,
|
isNextButtonEnabled,
|
||||||
isPreviousButtonEnabled,
|
isPreviousButtonEnabled,
|
||||||
|
Loading…
Reference in New Issue
Block a user