From 7536c244d5c337db3765f125e91cae01f14a6b9a Mon Sep 17 00:00:00 2001 From: Devesh S Date: Wed, 22 Jul 2026 14:30:52 +0530 Subject: [PATCH] feat: show 5 recent questions by default with Load More / Show Less pagination --- src/pages/Community/Community.tsx | 117 ++++++++++++++++++++---------- telegram-bot/config.json | 2 +- 2 files changed, 79 insertions(+), 40 deletions(-) diff --git a/src/pages/Community/Community.tsx b/src/pages/Community/Community.tsx index 9101410..9b63b83 100644 --- a/src/pages/Community/Community.tsx +++ b/src/pages/Community/Community.tsx @@ -73,6 +73,7 @@ export default function Community() { const [likedIds, setLikedIds] = useState>(new Set()); const [expandedQuestionIds, setExpandedQuestionIds] = useState>(new Set()); const [questions, setQuestions] = useState(QUESTIONS_DATA); + const [visibleCount, setVisibleCount] = useState(5); const toggleAnswers = (id: string) => { setExpandedQuestionIds((prev) => { @@ -130,6 +131,9 @@ export default function Community() { tagsVal.some((t: string) => t.toLowerCase().includes(searchQuery.toLowerCase())); }); + const visibleQuestions = filteredQuestions.slice(0, visibleCount); + const hasMore = visibleCount < filteredQuestions.length; + const handleConfess = () => { if (!confessionText.trim()) return; setConfessionPosted(true); @@ -302,24 +306,24 @@ export default function Community() { type="text" placeholder="Search questions..." value={searchQuery} - onChange={(e) => setSearchQuery(e.target.value)} + onChange={(e) => { setSearchQuery(e.target.value); setVisibleCount(5); }} className="w-full pl-10 pr-4 py-2.5 rounded-xl border border-slate-200 bg-white text-[13px] text-slate-800 placeholder-slate-400 focus:outline-none focus:border-slate-400 transition-colors" style={{ fontFamily: 'Inter, sans-serif' }} /> {/* Questions */} - - {filteredQuestions.map((q, idx) => { + + {visibleQuestions.map((q, idx) => { const isFeatured = idx === 0 && searchQuery === ''; return (
@@ -327,36 +331,36 @@ export default function Community() { {q.author}
{/* Header / Meta */}
- {q.author} + {q.author} - {getRelativeTime(q.createdAt)} + {getRelativeTime(q.createdAt)} {isFeatured && ( - ★ Popular + ★ Popular )}
-

{q.title}

-

+

{q.body}

-
+
{(q.tags || []).map((tag) => ( #{tag} @@ -364,29 +368,29 @@ export default function Community() { ))}
-
+
{q.isAnswered && ( - ✓ Answered + ✓ Answered )} {/* Like/Vote Button inside bottom bar */}
diff --git a/telegram-bot/config.json b/telegram-bot/config.json index 9f2183a..3ea7da8 100644 --- a/telegram-bot/config.json +++ b/telegram-bot/config.json @@ -1,5 +1,5 @@ { "telegram_bot_token": "8859374355:AAH0dhwstkTBhRerRTjzmb2RG2fjPbigzvo", - "helper_chat_ids": [971749136], + "helper_chat_ids": [971749136,5567776672], "spring_backend_url": "http://localhost:8080" }