diff --git a/src/pages/Community/Community.tsx b/src/pages/Community/Community.tsx index 702e645..cb9d9a2 100644 --- a/src/pages/Community/Community.tsx +++ b/src/pages/Community/Community.tsx @@ -75,6 +75,17 @@ export default function Community() { fetchQuestions(); }, []); + const getAnswersCount = (q: any) => { + if (Array.isArray(q.answers)) return q.answers.length; + if (typeof q.answers === 'number') return q.answers; + return 0; + }; + + const getVotesCount = (q: any) => { + const votesVal = typeof q.upvotes === 'number' ? q.upvotes : (typeof q.votes === 'number' ? q.votes : 0); + return votesVal; + }; + const filteredQuestions = questions.filter((q) => q.title.toLowerCase().includes(searchQuery.toLowerCase()) || (q.tags && q.tags.some((t: string) => t.toLowerCase().includes(searchQuery.toLowerCase()))) @@ -316,7 +327,7 @@ export default function Community() {