diff --git a/frontend/src/pages/Q&A/Q&A.jsx b/frontend/src/pages/Q&A/Q&A.jsx index 90ef356f..f3d92d0b 100644 --- a/frontend/src/pages/Q&A/Q&A.jsx +++ b/frontend/src/pages/Q&A/Q&A.jsx @@ -59,8 +59,17 @@ function Ques(props) { ); setCheckedState(updatedCheckedState); - formdata.tags.length = 0; - formdata.tags.push(checkedState); + + const selectedTags = updatedCheckedState + .map((currentState, index) => { + if (currentState === true) { + return Tags[index].value; + } + return null; + }) + .filter((item) => item !== null); + + setFormData({ ...formdata, tags: selectedTags }); }; const schema = { @@ -130,9 +139,6 @@ function Ques(props) { const fetchQuestions = () => { getAllQuestion(setToast).then((data) => { setLoading(true); - data = data.map((item) => { - return { ...item, tags: item.tags[0] }; - }); setQuestions(filterApprovedQuestions(data)); }); }; @@ -154,61 +160,53 @@ function Ques(props) { return (
- { - !loading ? - : - getQuestions.length == 0 ? -
-

No Questions Found !

-
- : -
- {getQuestions?.map((item, key) => { - let tags = [...Object.values(item.tags)]; - return ( -
-
-

{item.title}

-

{item.description}

-
- {tags.map((i, index) => { - if (i == true) - return ( - - {i === true ? `#${Tags[index].value}` : ""} - - ); - })} -
-
-
-
-

- Created At {new Date(item.createdAt).toLocaleString()} -

-
-
- - -
-
+ className="popup-creator" + style={{ background: dark ? "#171717" : "white" }} + > + { + !loading ? + : + getQuestions.length == 0 ? +
+

No Questions Found !

+
+ : +
+ {getQuestions?.map((item, key) => ( +
+
+

{item.title}

+

{item.description}

+
+ {item.tags.map((tag, index) => ( + + #{tag} + + ))}
- ); - })} -
+
+
+
+

Created At {new Date(item.createdAt).toLocaleString()}

+
+
+ + +
+
+
+ ))} +
} {toast.toastStatus && (