fix: request
This commit is contained in:
parent
c3d39cde78
commit
bd3564dd0c
@ -166,15 +166,19 @@ export const addQuizImages = async (
|
|||||||
|
|
||||||
export const copyQuizTemplate = async (
|
export const copyQuizTemplate = async (
|
||||||
qid: string,
|
qid: string,
|
||||||
): Promise<[string | null, string?]> => {
|
): Promise<[number | null, string?]> => {
|
||||||
try {
|
try {
|
||||||
const copyQuizTemplateResult = await makeRequest<{ Qid: string }, string>({
|
const { id } = await makeRequest<{ Qid: string }, { id: number }>({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: `${API_URL}/quiz/template`,
|
url: `${API_URL}/quiz/template`,
|
||||||
body: { Qid: qid },
|
body: { Qid: qid },
|
||||||
});
|
});
|
||||||
|
|
||||||
return [copyQuizTemplateResult];
|
if (!id) {
|
||||||
|
return [null, `Не удалось скопировать шаблон квиза.`];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [id];
|
||||||
} catch (nativeError) {
|
} catch (nativeError) {
|
||||||
const [error] = parseAxiosError(nativeError);
|
const [error] = parseAxiosError(nativeError);
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ export const QuizTemplateCard = ({
|
|||||||
return enqueueSnackbar(copyError);
|
return enqueueSnackbar(copyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
setEditQuizId(0);
|
setEditQuizId(copiedQuizId);
|
||||||
navigate("/edit");
|
navigate("/edit");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user