@@ -126,10 +152,21 @@ const ListeningGeneration = () => {
{part: part2, setPart: setPart2},
{part: part3, setPart: setPart3},
].map(({part, setPart}, index) => (
-
+
))}
+
>
);
};
diff --git a/src/pages/(generation)/ReadingGeneration.tsx b/src/pages/(generation)/ReadingGeneration.tsx
index b95253d8..4796636a 100644
--- a/src/pages/(generation)/ReadingGeneration.tsx
+++ b/src/pages/(generation)/ReadingGeneration.tsx
@@ -8,14 +8,19 @@ import {useState} from "react";
import {BsArrowRepeat} from "react-icons/bs";
import {toast} from "react-toastify";
-const PartTab = ({part, types, index, setPart}: {part?: ReadingPart; types: string[]; index: number; setPart: (part: ReadingPart) => void}) => {
+const PartTab = ({part, types, index, setPart}: {part?: ReadingPart; types: string[]; index: number; setPart: (part?: ReadingPart) => void}) => {
const [topic, setTopic] = useState("");
const [isLoading, setIsLoading] = useState(false);
const generate = () => {
+ const url = new URLSearchParams();
+ if (topic) url.append("topic", topic);
+ if (types) types.forEach((t) => url.append("exercises", t));
+
+ setPart(undefined);
setIsLoading(true);
axios
- .get(`/api/exam/reading/generate/reading_passage_${index}?topic=${topic}&exercises=${types.join("&exercises=")}`)
+ .get(`/api/exam/reading/generate/reading_passage_${index}${topic || types ? `?${url.toString()}` : ""}`)
.then((result) => setPart(result.data))
.catch((error) => {
console.log(error);
@@ -30,17 +35,13 @@ const PartTab = ({part, types, index, setPart}: {part?: ReadingPart; types: stri