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