From d68285fa3d1c36c8ec987458df4c0cea9bedb98d Mon Sep 17 00:00:00 2001 From: Nastya Date: Sat, 30 Dec 2023 04:04:33 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BA=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82?= =?UTF-8?q?=D0=BD=D0=BE=D0=B5=20=D1=83=D0=B1=D0=B8=D1=80=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D1=81=D1=82=D1=80=D0=BE=D0=BA=20=D1=81=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B1=D0=B5=D0=BB=D0=B0=D0=BC=D0=B8,=20=D0=BA=D0=BE?= =?UTF-8?q?=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D0=B0=D1=8F=20=D0=BE=D1=82?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D1=84=D0=B0=D0=B9=D0=BB?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/quizRelase.ts | 4 ++-- src/pages/ViewPublicationPage/index.tsx | 15 ++++++++++++++- .../tools/replaceSpacesToEmptyLines.ts | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/api/quizRelase.ts b/src/api/quizRelase.ts index 735f6a6..9f92d07 100644 --- a/src/api/quizRelase.ts +++ b/src/api/quizRelase.ts @@ -16,7 +16,7 @@ export function getData(quizId: string) { export function sendAnswer({ questionId, body, qid }: any) { const formData = new FormData(); - +console.log(qid) const answers = [{ question_id: questionId, content: body, //тут массив с ответом @@ -40,7 +40,7 @@ export function sendFile({ questionId, body, qid }: any) { content: body.name, } - fd[body.name] = body.filen //target.files[0] + fd[body.name] = body.file //target.files[0] const answers = [fd] formData.append("answers", JSON.stringify(answers)); diff --git a/src/pages/ViewPublicationPage/index.tsx b/src/pages/ViewPublicationPage/index.tsx index db072d1..37260fd 100644 --- a/src/pages/ViewPublicationPage/index.tsx +++ b/src/pages/ViewPublicationPage/index.tsx @@ -18,7 +18,7 @@ const QID = process.env.NODE_ENV === "production" ? window.location.pathname.replace(/\//g, '') : - "6e96e958-d30e-49f6-aa85-32aaef975733" + "2363ad2c-0c19-4f51-80c0-ed2242daa0c4" export const ViewPage = () => { @@ -67,6 +67,19 @@ export const ViewPage = () => { //@ts-ignore cnt: data.cnt } + + + parseData.items = parseData.items.map((question:any) => { + let data = question + for (let key in question) { + if (question[key] === " ") data[key] = "" + } + return data + }) + + + + useQuestionsStore.setState(parseData) } catch (e) { diff --git a/src/pages/ViewPublicationPage/tools/replaceSpacesToEmptyLines.ts b/src/pages/ViewPublicationPage/tools/replaceSpacesToEmptyLines.ts index 3f94da6..f48a27e 100644 --- a/src/pages/ViewPublicationPage/tools/replaceSpacesToEmptyLines.ts +++ b/src/pages/ViewPublicationPage/tools/replaceSpacesToEmptyLines.ts @@ -11,7 +11,7 @@ export const replaceSpacesToEmptyLines = (object: T): T => { for (const [key, value] of Object.entries(object)) { if (typeof value === "string") { - result[key] = value.replace(/ /g, ""); + result[key] = value.replace(/\" \"/g, '""'); continue; }