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 (
{item.title}
-{item.description}
-- Created At {new Date(item.createdAt).toLocaleString()} -
-{item.title}
+{item.description}
+Created At {new Date(item.createdAt).toLocaleString()}
+