@burdenoff/microfe-healthybowl 2026.1005.2 → 2026.1007.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/healthybowl/components/BedLayoutGrid.js +128 -115
- package/dist/healthybowl/components/BedLayoutGrid.js.map +1 -1
- package/dist/healthybowl/components/CropPicker.js +37 -0
- package/dist/healthybowl/components/CropPicker.js.map +1 -0
- package/dist/healthybowl/components/DataTable.js +125 -108
- package/dist/healthybowl/components/DataTable.js.map +1 -1
- package/dist/healthybowl/components/FilterBar.js +9 -6
- package/dist/healthybowl/components/FilterBar.js.map +1 -1
- package/dist/healthybowl/components/PlantCatalogPicker.js +32 -0
- package/dist/healthybowl/components/PlantCatalogPicker.js.map +1 -0
- package/dist/healthybowl/components/WorkspaceRecordPicker.js +164 -0
- package/dist/healthybowl/components/WorkspaceRecordPicker.js.map +1 -0
- package/dist/healthybowl/components/index.js +3 -1
- package/dist/healthybowl/hooks/useCropPage.js +71 -0
- package/dist/healthybowl/hooks/useCropPage.js.map +1 -0
- package/dist/healthybowl/hooks/usePlantCatalog.js +133 -44
- package/dist/healthybowl/hooks/usePlantCatalog.js.map +1 -1
- package/dist/healthybowl/hooks/usePlantingEstimate.js +6 -6
- package/dist/healthybowl/hooks/usePlantingEstimate.js.map +1 -1
- package/dist/healthybowl/hooks/useWorkspaceRead.js +46 -0
- package/dist/healthybowl/hooks/useWorkspaceRead.js.map +1 -0
- package/dist/healthybowl/pages/HomePage.js +143 -142
- package/dist/healthybowl/pages/HomePage.js.map +1 -1
- package/dist/healthybowl/pages/analytics/ReportsPage.js +8 -8
- package/dist/healthybowl/pages/catalog/PlantCatalogPage.js +266 -192
- package/dist/healthybowl/pages/catalog/PlantCatalogPage.js.map +1 -1
- package/dist/healthybowl/pages/catalog/WorkspaceBrowseFilters.js +58 -0
- package/dist/healthybowl/pages/catalog/WorkspaceBrowseFilters.js.map +1 -0
- package/dist/healthybowl/pages/catalog/browsePagination.js +24 -0
- package/dist/healthybowl/pages/catalog/browsePagination.js.map +1 -0
- package/dist/healthybowl/pages/compliance/ComplianceDocumentsPage.js +6 -6
- package/dist/healthybowl/pages/crops/CropDetailsPage.js +340 -348
- package/dist/healthybowl/pages/crops/CropDetailsPage.js.map +1 -1
- package/dist/healthybowl/pages/crops/CropPlanningPage.js +468 -434
- package/dist/healthybowl/pages/crops/CropPlanningPage.js.map +1 -1
- package/dist/healthybowl/pages/crops/CropsPage.js +633 -542
- package/dist/healthybowl/pages/crops/CropsPage.js.map +1 -1
- package/dist/healthybowl/pages/crops/FieldDetailsPage.js +875 -800
- package/dist/healthybowl/pages/crops/FieldDetailsPage.js.map +1 -1
- package/dist/healthybowl/pages/crops/PlanningDetailsPage.js +459 -448
- package/dist/healthybowl/pages/crops/PlanningDetailsPage.js.map +1 -1
- package/dist/healthybowl/pages/crops/SuccessionCropLabel.js +21 -0
- package/dist/healthybowl/pages/crops/SuccessionCropLabel.js.map +1 -0
- package/dist/healthybowl/pages/crops/planningEdit.js +30 -0
- package/dist/healthybowl/pages/crops/planningEdit.js.map +1 -0
- package/dist/healthybowl/pages/fields/FieldMapPage.js +989 -941
- package/dist/healthybowl/pages/fields/FieldMapPage.js.map +1 -1
- package/dist/healthybowl/pages/financial/GeneralLedgerPage.js +6 -6
- package/dist/healthybowl/pages/financial/InvoiceManagementPage.js +7 -7
- package/dist/healthybowl/pages/financial/InvoiceManagementPage.js.map +1 -1
- package/dist/healthybowl/pages/financial/TransactionsPage.js +541 -541
- package/dist/healthybowl/pages/financial/TransactionsPage.js.map +1 -1
- package/dist/healthybowl/pages/government-schemes/ApplicationTrackingPage.js +10 -10
- package/dist/healthybowl/pages/government-schemes/CommunicationPage.js +207 -207
- package/dist/healthybowl/pages/government-schemes/CommunicationPage.js.map +1 -1
- package/dist/healthybowl/pages/government-schemes/SchemeAdminPage.js +38 -38
- package/dist/healthybowl/pages/government-schemes/SchemeAdminPage.js.map +1 -1
- package/dist/healthybowl/pages/government-schemes/TrainingProgramsPage.js +15 -15
- package/dist/healthybowl/pages/government-schemes/TrainingProgramsPage.js.map +1 -1
- package/dist/healthybowl/pages/livestock/AnimalRegistryPage.js +4 -4
- package/dist/healthybowl/pages/livestock/BreedingManagementPage.js +4 -4
- package/dist/healthybowl/pages/livestock/FeedManagementPage.js +4 -4
- package/dist/healthybowl/pages/livestock/HealthRecordsPage.js +16 -16
- package/dist/healthybowl/pages/livestock/HealthRecordsPage.js.map +1 -1
- package/dist/healthybowl/pages/livestock/ProductionTrackingPage.js +4 -4
- package/dist/healthybowl/pages/livestock/VaccinationSchedulePage.js +4 -4
- package/dist/healthybowl/pages/market/MarketPricesPage.js +305 -305
- package/dist/healthybowl/pages/market/MarketPricesPage.js.map +1 -1
- package/dist/healthybowl/pages/network/CohortsPage.js +107 -107
- package/dist/healthybowl/pages/network/CohortsPage.js.map +1 -1
- package/dist/healthybowl/pages/network/CommunityPage.js +247 -247
- package/dist/healthybowl/pages/network/CommunityPage.js.map +1 -1
- package/dist/healthybowl/pages/network/EventsPage.js +16 -16
- package/dist/healthybowl/pages/network/EventsPage.js.map +1 -1
- package/dist/healthybowl/pages/network/ExpertsPage.js +470 -470
- package/dist/healthybowl/pages/network/ExpertsPage.js.map +1 -1
- package/dist/healthybowl/pages/network/MentorsPage.js +6 -6
- package/dist/healthybowl/pages/pest-management/PestIssuesPage.js +8 -8
- package/dist/healthybowl/pages/pest-management/TreatmentLibraryPage.js +7 -7
- package/dist/healthybowl/pages/pest-management/TreatmentLibraryPage.js.map +1 -1
- package/dist/healthybowl/pages/production/ProductionBatchesPage.js +7 -7
- package/dist/healthybowl/pages/production/RecipeManagementPage.js +5 -5
- package/dist/healthybowl/pages/production/ValueAddedProductsPage.js +7 -7
- package/dist/healthybowl/pages/soil/SoilTestsPage.js +6 -6
- package/dist/healthybowl/pages/soil/SoilTestsPage.js.map +1 -1
- package/dist/healthybowl/pages/suppliers/SuppliersPage.js +10 -10
- package/dist/healthybowl/pages/sustainability/CarbonCreditLedgerPage.js +6 -6
- package/dist/healthybowl/pages/terrace/PlantingFormModal.js +151 -131
- package/dist/healthybowl/pages/terrace/PlantingFormModal.js.map +1 -1
- package/dist/healthybowl/pages/traceability/BatchTrackingPage.js +6 -6
- package/dist/healthybowl/utils/cropComparison.js +1 -1
- package/dist/healthybowl/utils/cropComparison.js.map +1 -1
- package/dist/healthybowl/utils/cropPicker.js +35 -0
- package/dist/healthybowl/utils/cropPicker.js.map +1 -0
- package/dist/healthybowl/utils/plantingCapacity.js +2 -2
- package/dist/healthybowl/utils/plantingCapacity.js.map +1 -1
- package/dist/healthybowl/utils/quotaLabels.js +8 -0
- package/dist/healthybowl/utils/quotaLabels.js.map +1 -0
- package/dist/healthybowl/utils/seedRate.js +1 -8
- package/dist/healthybowl/utils/seedRate.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommunityPage.js","names":[],"sources":["../../../../src/healthybowl/pages/network/CommunityPage.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState, type FC } from 'react';\nimport {\n Heart,\n MessageSquare,\n Tag,\n Plus,\n ArrowUpDown,\n ChevronDown,\n Eye,\n MessageCircle,\n TrendingUp,\n} from 'lucide-react';\nimport {\n PageLayout,\n StatCard,\n FilterBar,\n StatusBadge,\n EmptyState,\n ErrorState,\n PageLoader,\n Modal,\n} from '../../components';\nimport { ToastContainer } from '../../components/Toast';\nimport { Button, Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '@burdenoff/fe-libs/ui';\nimport { useToast } from '../../hooks/useToast';\nimport { useHealthyBowl } from '../../context/HealthyBowlContext';\nimport { cn, formatDate } from '../../utils/helpers';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { ConversationType } from '../../../generated/wspace-types';\nimport {\n useGetHealthyBowlCommunityChannelsQuery,\n useGetHealthyBowlCommunityMessagesQuery,\n useGetHealthyBowlCommunityThreadQuery,\n useCreateHealthyBowlCommunityChannelMutation,\n useSendHealthyBowlCommunityMessageMutation,\n useAddHealthyBowlCommunityReactionMutation,\n} from '../../../generated/wspace-operations';\n\ntype SortOption = 'recent' | 'likes' | 'replies';\n\n// The HB community is ONE workspace-scoped CHANNEL conversation. We identify it\n// by this stable title so the page reuses the same channel across reloads and\n// bootstraps it on first post if absent. (Genuine reuse of wspace-conversations-svc.)\nconst COMMUNITY_CHANNEL_TITLE = 'HealthyBowl Community';\nconst LIKE_EMOJI = '👍';\n\n/** A post = a top-level Message in the community channel, projected for the UI. */\ninterface CommunityPostVM {\n id: string;\n title: string;\n content: string;\n category: string;\n tags: string[];\n author: string;\n authorRole: string;\n likes: number;\n likedByMe: boolean;\n replies: number;\n createdAt: string;\n}\n\n/** The message `content` JSON we author: structured so a post round-trips. */\ninterface PostContent {\n text?: string;\n payload?: { title?: string; category?: string; tags?: string[]; author?: string };\n}\n\n/** The raw message node shape we consume (generated types are `@ts-nocheck`/any). */\ninterface RawMessageNode {\n id: string;\n content: unknown;\n authorId: string;\n authorName?: string | null;\n parentMessageId?: string | null;\n threadRootId?: string | null;\n replyCount: number;\n createdAt: string;\n reactions: Array<{ id: string; emoji: string; userId: string }>;\n}\ninterface RawChannelNode {\n id: string;\n title?: string | null;\n workspaceId: string;\n}\n\nconst toStringSafe = (v: unknown): string => (typeof v === 'string' ? v : '');\n\n/** Project a raw conversation Message into the post view-model. */\nfunction projectPost(msg: RawMessageNode, currentUserId: string, authorFallback: string): CommunityPostVM {\n const content = (msg.content ?? {}) as PostContent;\n const payload = content.payload ?? {};\n const likes = msg.reactions.filter((r) => r.emoji === LIKE_EMOJI);\n return {\n id: msg.id,\n title: toStringSafe(payload.title) || toStringSafe(content.text).slice(0, 60) || 'Untitled',\n content: toStringSafe(content.text),\n category: toStringSafe(payload.category) || 'General',\n tags: Array.isArray(payload.tags) ? payload.tags.filter((t): t is string => typeof t === 'string') : [],\n // BOFF-6117: the server-resolved display name wins; the stored payload\n // snapshot covers pre-fix messages; the last resort is a neutral label —\n // never a truncated UUID.\n author: toStringSafe(msg.authorName) || toStringSafe(payload.author) || authorFallback,\n authorRole: 'Member',\n likes: likes.length,\n likedByMe: currentUserId ? likes.some((r) => r.userId === currentUserId) : false,\n replies: msg.replyCount,\n createdAt: msg.createdAt,\n };\n}\n\nexport const CommunityPage: FC = () => {\n const { t } = useI18n();\n const { workspaceId, currentUser } = useHealthyBowl();\n const currentUserId = currentUser?.id ?? '';\n const authorName = currentUser\n ? [currentUser.firstName, currentUser.lastName].filter(Boolean).join(' ') || currentUser.email\n : '';\n\n // ── Resolve the community channel ──────────────────────────────────────────\n const {\n data: channelsData,\n loading: channelsLoading,\n error: channelsError,\n refetch: refetchChannels,\n } = useGetHealthyBowlCommunityChannelsQuery({ variables: { first: 100 }, fetchPolicy: 'cache-and-network' });\n\n const channelId = useMemo(() => {\n const edges = (channelsData?.conversations.edges ?? []) as Array<{ node: RawChannelNode }>;\n const match = edges.find(\n (e) => (e.node.title ?? '') === COMMUNITY_CHANNEL_TITLE && e.node.workspaceId === workspaceId\n );\n // Fall back to a workspace CHANNEL with the title even if workspaceId isn't echoed identically.\n return (match ?? edges.find((e) => (e.node.title ?? '') === COMMUNITY_CHANNEL_TITLE))?.node.id ?? null;\n }, [channelsData, workspaceId]);\n\n // ── Messages (posts) for the channel ───────────────────────────────────────\n const {\n data: messagesData,\n loading: messagesLoading,\n error: messagesError,\n refetch: refetchMessages,\n } = useGetHealthyBowlCommunityMessagesQuery({\n variables: { conversationId: channelId ?? '', first: 100 },\n skip: !channelId,\n fetchPolicy: 'cache-and-network',\n });\n\n const [createChannel] = useCreateHealthyBowlCommunityChannelMutation();\n const [sendMessage] = useSendHealthyBowlCommunityMessageMutation();\n const [addReaction] = useAddHealthyBowlCommunityReactionMutation();\n\n const refetchAll = useCallback(async () => {\n await refetchChannels();\n if (channelId) await refetchMessages();\n }, [refetchChannels, refetchMessages, channelId]);\n\n // Top-level posts only (parentMessageId == null); thread replies are excluded.\n const allPosts: CommunityPostVM[] = useMemo(() => {\n const edges = (messagesData?.conversation?.messages.edges ?? []) as Array<{ node: RawMessageNode }>;\n return edges\n .map((e) => e.node)\n .filter((m) => !m.parentMessageId)\n .map((m) => projectPost(m, currentUserId, t('healthybowl.network.community.author.unknown', 'Community member')));\n }, [messagesData, currentUserId, t]);\n\n const loading = channelsLoading || (Boolean(channelId) && messagesLoading);\n const error = channelsError ?? messagesError;\n\n // Category values are logic values (compared against post.category). Only labels are translated.\n const categories = ['All', 'Soil Health', 'Pest Management', 'Irrigation', 'Livestock', 'General'];\n const categoryLabels: Record<string, string> = {\n All: t('healthybowl.common.all', 'All'),\n 'Soil Health': t('healthybowl.network.community.categories.soilHealth', 'Soil Health'),\n 'Pest Management': t('healthybowl.network.community.categories.pestManagement', 'Pest Management'),\n Irrigation: t('healthybowl.network.community.categories.irrigation', 'Irrigation'),\n Livestock: t('healthybowl.network.community.categories.livestock', 'Livestock'),\n General: t('healthybowl.network.community.categories.general', 'General'),\n };\n const sortLabels: Record<SortOption, string> = {\n recent: t('healthybowl.network.community.sort.recent', 'Most Recent'),\n likes: t('healthybowl.network.community.sort.likes', 'Most Liked'),\n replies: t('healthybowl.network.community.sort.replies', 'Most Replies'),\n };\n\n const [search, setSearch] = useState('');\n const [activeCategory, setActiveCategory] = useState('All');\n const [sort, setSort] = useState<SortOption>('recent');\n const [showSortDropdown, setShowSortDropdown] = useState(false);\n const [expandedPost, setExpandedPost] = useState<string | null>(null);\n const [viewingPost, setViewingPost] = useState<CommunityPostVM | null>(null);\n const [showNewPostModal, setShowNewPostModal] = useState(false);\n const [newPostTitle, setNewPostTitle] = useState('');\n const [newPostCategory, setNewPostCategory] = useState('General');\n const [newPostContent, setNewPostContent] = useState('');\n const [newPostTags, setNewPostTags] = useState('');\n const [submitting, setSubmitting] = useState(false);\n const [likingId, setLikingId] = useState<string | null>(null);\n const [replyText, setReplyText] = useState('');\n const [replying, setReplying] = useState(false);\n\n const sortRef = useRef<HTMLDivElement>(null);\n const { toasts, toast, dismiss } = useToast();\n\n useEffect(() => {\n const handleClick = (e: MouseEvent) => {\n if (sortRef.current && !sortRef.current.contains(e.target as Node)) setShowSortDropdown(false);\n };\n document.addEventListener('mousedown', handleClick);\n return () => document.removeEventListener('mousedown', handleClick);\n }, []);\n\n const filtered = useMemo(\n () =>\n allPosts\n .filter((p) => {\n const matchSearch =\n p.title.toLowerCase().includes(search.toLowerCase()) ||\n p.author.toLowerCase().includes(search.toLowerCase()) ||\n p.content.toLowerCase().includes(search.toLowerCase()) ||\n p.tags.some((tag) => tag.toLowerCase().includes(search.toLowerCase()));\n const matchCategory = activeCategory === 'All' || p.category === activeCategory;\n return matchSearch && matchCategory;\n })\n .sort((a, b) => {\n switch (sort) {\n case 'recent':\n return new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();\n case 'likes':\n return b.likes - a.likes;\n case 'replies':\n return b.replies - a.replies;\n default:\n return 0;\n }\n }),\n [allPosts, search, activeCategory, sort]\n );\n\n const totalReplies = allPosts.reduce((sum, p) => sum + p.replies, 0);\n const activeDiscussions = allPosts.filter((p) => p.replies > 10).length;\n const totalLikes = allPosts.reduce((sum, p) => sum + p.likes, 0);\n\n // Ensure the channel exists, creating it on demand. Returns the channel id.\n const ensureChannel = useCallback(async (): Promise<string> => {\n if (channelId) return channelId;\n const res = await createChannel({\n variables: {\n input: {\n title: COMMUNITY_CHANNEL_TITLE,\n description: t(\n 'healthybowl.network.community.channelDescription',\n 'Discussions with fellow farmers and experts'\n ),\n type: ConversationType.Channel,\n workspaceId,\n participantIds: currentUserId ? [currentUserId] : [],\n },\n },\n });\n const created = res.data?.createConversation.conversation?.id;\n if (!created) throw new Error('Channel creation returned no conversation');\n await refetchChannels();\n return created;\n }, [channelId, createChannel, refetchChannels, t, workspaceId, currentUserId]);\n\n // Like a post (a 👍 reaction on the post message). Real write, then refetch.\n const handleLike = useCallback(\n async (post: CommunityPostVM) => {\n setLikingId(post.id);\n try {\n await addReaction({ variables: { messageId: post.id, emoji: LIKE_EMOJI } });\n await refetchMessages();\n } catch (err) {\n toast({\n title: t('healthybowl.network.community.toast.likeFailed.title', 'Could not like post'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setLikingId(null);\n }\n },\n [addReaction, refetchMessages, toast, t]\n );\n\n const handleViewDiscussion = (post: CommunityPostVM) => {\n setReplyText('');\n setViewingPost(post);\n };\n\n const handleCreatePost = async () => {\n if (!newPostTitle.trim() || !newPostContent.trim()) {\n toast({\n title: t('healthybowl.network.community.toast.missingFields.title', 'Missing Fields'),\n description: t(\n 'healthybowl.network.community.toast.missingFields.description',\n 'Please fill in title and content'\n ),\n variant: 'warning',\n });\n return;\n }\n setSubmitting(true);\n try {\n const id = await ensureChannel();\n const tags = newPostTags\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean);\n await sendMessage({\n variables: {\n input: {\n conversationId: id,\n content: {\n text: newPostContent.trim(),\n payload: {\n title: newPostTitle.trim(),\n category: newPostCategory,\n tags,\n author: authorName,\n },\n },\n },\n },\n });\n toast({\n title: t('healthybowl.network.community.toast.postCreated.title', 'Post Created!'),\n description: t(\n 'healthybowl.network.community.toast.postCreated.description',\n '\"{{title}}\" has been published',\n {\n title: newPostTitle,\n }\n ),\n variant: 'success',\n });\n setShowNewPostModal(false);\n setNewPostTitle('');\n setNewPostCategory('General');\n setNewPostContent('');\n setNewPostTags('');\n await refetchAll();\n } catch (err) {\n toast({\n title: t('healthybowl.common.error', 'Error'),\n description:\n err instanceof Error\n ? err.message\n : t('healthybowl.network.community.toast.createFailed.description', 'Failed to create post'),\n variant: 'error',\n });\n } finally {\n setSubmitting(false);\n }\n };\n\n // Post a reply (a thread message whose parentMessageId is the post).\n const handleReply = async () => {\n if (!viewingPost || !replyText.trim() || !channelId) return;\n setReplying(true);\n try {\n await sendMessage({\n variables: {\n input: {\n conversationId: channelId,\n parentMessageId: viewingPost.id,\n content: { text: replyText.trim(), payload: { author: authorName } },\n },\n },\n });\n setReplyText('');\n await refetchMessages();\n toast({\n title: t('healthybowl.network.community.toast.replyPosted.title', 'Reply posted'),\n variant: 'success',\n });\n } catch (err) {\n toast({\n title: t('healthybowl.network.community.toast.replyFailed.title', 'Could not post reply'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setReplying(false);\n }\n };\n\n const getTimeAgo = (dateStr: string) => {\n const diff = Math.floor((Date.now() - new Date(dateStr).getTime()) / (1000 * 60 * 60 * 24));\n if (diff === 0) return t('healthybowl.network.community.time.today', 'Today');\n if (diff === 1) return t('healthybowl.network.community.time.yesterday', 'Yesterday');\n if (diff < 7) return t('healthybowl.network.community.time.daysAgo', '{{count}} days ago', { count: diff });\n return formatDate(dateStr);\n };\n\n return (\n <PageLayout\n title={t('healthybowl.network.community.title', 'Community')}\n description={t('healthybowl.network.community.description', 'Join discussions with fellow farmers and experts')}\n purpose=\"Swap ideas, ask questions and share what's working with other farmers and experts. Farming is easier when you're not doing it alone — this is the place to learn from people who've faced the same challenges.\"\n >\n {/* Stats */}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <StatCard\n hero\n label={t('healthybowl.network.community.stats.totalPosts', 'Total Posts')}\n value={allPosts.length}\n icon={<MessageCircle className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.network.community.stats.totalReplies', 'Total Replies')}\n value={totalReplies}\n icon={<MessageSquare className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.network.community.stats.activeDiscussions', 'Active Discussions')}\n value={activeDiscussions}\n icon={<TrendingUp className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.network.community.stats.totalLikes', 'Total Likes')}\n value={totalLikes}\n icon={<Heart className=\"h-4 w-4\" />}\n />\n </div>\n\n {/* Category Tabs */}\n <div className=\"flex flex-wrap items-center gap-1.5 border-b border-border-subtle pb-3\">\n {categories.map((cat) => (\n <button\n key={cat}\n type=\"button\"\n onClick={() => setActiveCategory(cat)}\n className={cn(\n 'rounded-full px-3 py-1.5 text-xs font-medium transition-colors',\n activeCategory === cat\n ? 'bg-action-primary-bg text-action-primary-text'\n : 'bg-bg-sunken text-text-secondary hover:bg-bg-sunken/80 hover:text-text-primary'\n )}\n >\n {categoryLabels[cat] ?? cat}\n </button>\n ))}\n </div>\n\n {/* Filter Bar */}\n <FilterBar\n searchValue={search}\n onSearchChange={setSearch}\n searchPlaceholder={t('healthybowl.network.community.searchPlaceholder', 'Search posts, authors, or tags...')}\n filters={\n <div ref={sortRef} className=\"relative\">\n <Button variant=\"outline\" size=\"sm\" onClick={() => setShowSortDropdown((prev) => !prev)} className=\"w-auto\">\n <ArrowUpDown className=\"h-3.5 w-3.5\" />\n {sortLabels[sort]}\n <ChevronDown className=\"h-3 w-3\" />\n </Button>\n {showSortDropdown && (\n <div className=\"absolute end-0 z-10 mt-1 w-40 rounded-md border border-border-subtle bg-bg-surface py-1 shadow-lg\">\n {(Object.keys(sortLabels) as SortOption[]).map((key) => (\n <Button\n key={key}\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => {\n setSort(key);\n setShowSortDropdown(false);\n }}\n className={cn(\n 'w-full justify-start',\n sort === key ? 'font-semibold text-primary' : 'text-text-primary'\n )}\n >\n {sortLabels[key]}\n </Button>\n ))}\n </div>\n )}\n </div>\n }\n actions={\n <Button size=\"sm\" onClick={() => setShowNewPostModal(true)}>\n <Plus className=\"h-3.5 w-3.5\" /> {t('healthybowl.network.community.actions.newPost', 'New Post')}\n </Button>\n }\n />\n\n {/* Posts List */}\n {filtered.length > 0 ? (\n <div className=\"space-y-4\">\n {filtered.map((post) => {\n const isExpanded = expandedPost === post.id;\n return (\n <div\n key={post.id}\n className=\"rounded-lg border border-border-subtle bg-bg-surface p-5 transition-colors hover:border-primary/20\"\n >\n {/* Post header */}\n <div className=\"flex items-center gap-2\">\n <div className=\"flex h-8 w-8 items-center justify-center rounded-full bg-bg-sunken text-xs font-semibold text-text-primary\">\n {post.author\n .split(' ')\n .map((n) => n[0])\n .join('')}\n </div>\n <div>\n <span className=\"text-sm font-medium text-text-primary\">{post.author}</span>\n <StatusBadge label={post.authorRole} variant=\"muted\" className=\"ms-2\" />\n </div>\n <span className=\"ms-auto text-xs text-text-secondary\">{getTimeAgo(post.createdAt)}</span>\n </div>\n\n {/* Title and content */}\n <h3\n className=\"mt-3 cursor-pointer text-sm font-semibold text-text-primary hover:text-primary\"\n onClick={() => setExpandedPost(isExpanded ? null : post.id)}\n >\n {post.title}\n </h3>\n <p className={cn('mt-1 text-sm text-text-secondary', !isExpanded && 'line-clamp-2')}>{post.content}</p>\n\n {/* Tags and category */}\n <div className=\"mt-3 flex flex-wrap items-center gap-2\">\n <StatusBadge label={post.category} variant=\"default\" />\n {post.tags.map((tag) => (\n <span\n key={tag}\n className=\"flex items-center gap-1 rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-text-secondary\"\n >\n <Tag className=\"h-2.5 w-2.5\" /> {tag}\n </span>\n ))}\n </div>\n\n {/* Actions — real like + real reply count */}\n <div className=\"mt-3 flex items-center gap-4\">\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => void handleLike(post)}\n disabled={likingId === post.id}\n title={t('healthybowl.network.community.post.like', 'Like this post')}\n className={cn('gap-1', post.likedByMe ? 'text-primary' : 'text-text-secondary')}\n >\n <Heart className={cn('h-3.5 w-3.5', post.likedByMe && 'fill-current')} />\n {post.likes}\n </Button>\n <span className=\"flex items-center gap-1 text-xs text-text-secondary\">\n <MessageSquare className=\"h-3.5 w-3.5\" />{' '}\n {t('healthybowl.network.community.post.replies', '{{count}} replies', { count: post.replies })}\n </span>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => handleViewDiscussion(post)}\n className=\"ms-auto gap-1 font-medium text-primary\"\n >\n <Eye className=\"h-3.5 w-3.5\" />{' '}\n {t('healthybowl.network.community.post.viewDiscussion', 'View Discussion')}\n </Button>\n </div>\n </div>\n );\n })}\n </div>\n ) : allPosts.length === 0 ? (\n loading ? (\n <PageLoader />\n ) : error ? (\n <ErrorState onRetry={() => void refetchAll()} />\n ) : (\n <EmptyState\n illustration=\"empty-people\"\n title={t('healthybowl.network.community.emptyState.noPosts.title', 'No community posts yet')}\n description={t(\n 'healthybowl.network.community.emptyState.noPosts.description',\n 'Be the first to start a discussion. Create a post to share a question or experience with the community.'\n )}\n action={\n <Button onClick={() => setShowNewPostModal(true)}>\n <Plus className=\"h-3.5 w-3.5\" /> {t('healthybowl.network.community.actions.newPost', 'New Post')}\n </Button>\n }\n />\n )\n ) : (\n <EmptyState\n illustration=\"empty-search\"\n title={t('healthybowl.network.community.emptyState.noResults.title', 'No posts found')}\n description={t(\n 'healthybowl.network.community.emptyState.noResults.description',\n 'No community posts match your current filters. Try adjusting your search or category.'\n )}\n action={\n <Button\n onClick={() => {\n setSearch('');\n setActiveCategory('All');\n }}\n >\n {t('healthybowl.network.community.actions.clearFilters', 'Clear Filters')}\n </Button>\n }\n />\n )}\n\n {/* New Post Modal */}\n <Modal\n open={showNewPostModal}\n onClose={() => setShowNewPostModal(false)}\n title={t('healthybowl.network.community.newPostModal.title', 'Create New Post')}\n description={t(\n 'healthybowl.network.community.newPostModal.description',\n 'Share your knowledge with the farming community'\n )}\n size=\"lg\"\n footer={\n <>\n <Button variant=\"outline\" onClick={() => setShowNewPostModal(false)}>\n {t('healthybowl.common.cancel', 'Cancel')}\n </Button>\n <Button onClick={handleCreatePost} disabled={submitting}>\n {submitting\n ? t('healthybowl.network.community.newPostModal.publishing', 'Publishing…')\n : t('healthybowl.network.community.newPostModal.publish', 'Publish Post')}\n </Button>\n </>\n }\n >\n <div className=\"space-y-4\">\n <div>\n <label className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('healthybowl.network.community.form.title.label', 'Title')}\n </label>\n <input\n type=\"text\"\n value={newPostTitle}\n onChange={(e) => setNewPostTitle(e.target.value)}\n placeholder={t('healthybowl.network.community.form.title.placeholder', 'Enter a descriptive title...')}\n className=\"h-9 w-full rounded-md border border-border-subtle bg-bg-surface px-3 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n </div>\n <div>\n <label className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('healthybowl.network.community.form.category.label', 'Category')}\n </label>\n <Select value={newPostCategory} onValueChange={setNewPostCategory}>\n <SelectTrigger className=\"h-9 w-full\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {categories\n .filter((c) => c !== 'All')\n .map((cat) => (\n <SelectItem key={cat} value={cat}>\n {categoryLabels[cat] ?? cat}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div>\n <label className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('healthybowl.network.community.form.content.label', 'Content')}\n </label>\n <textarea\n value={newPostContent}\n onChange={(e) => setNewPostContent(e.target.value)}\n placeholder={t(\n 'healthybowl.network.community.form.content.placeholder',\n 'Share your thoughts, questions, or advice...'\n )}\n rows={5}\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n </div>\n <div>\n <label className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('healthybowl.network.community.form.tags.label', 'Tags')}\n </label>\n <input\n type=\"text\"\n value={newPostTags}\n onChange={(e) => setNewPostTags(e.target.value)}\n placeholder={t(\n 'healthybowl.network.community.form.tags.placeholder',\n 'Comma-separated tags (e.g., organic, soil, irrigation)'\n )}\n className=\"h-9 w-full rounded-md border border-border-subtle bg-bg-surface px-3 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t('healthybowl.network.community.form.tags.helper', 'Separate tags with commas')}\n </p>\n </div>\n </div>\n </Modal>\n\n {/* View Discussion Modal — real thread + reply composer */}\n <Modal\n open={viewingPost !== null}\n onClose={() => setViewingPost(null)}\n title={viewingPost?.title ?? t('healthybowl.network.community.viewModal.titleFallback', 'Discussion')}\n description={t('healthybowl.network.community.viewModal.description', 'Posted by {{author}} in {{category}}', {\n author: viewingPost?.author ?? '',\n category: viewingPost?.category ?? '',\n })}\n size=\"lg\"\n footer={\n <Button variant=\"outline\" onClick={() => setViewingPost(null)}>\n {t('healthybowl.common.close', 'Close')}\n </Button>\n }\n >\n {viewingPost && (\n <div className=\"space-y-4\">\n <div className=\"flex items-center gap-2\">\n <div className=\"flex h-8 w-8 items-center justify-center rounded-full bg-bg-sunken text-xs font-semibold text-text-primary\">\n {viewingPost.author\n .split(' ')\n .map((n) => n[0])\n .join('')}\n </div>\n <div>\n <span className=\"text-sm font-medium text-text-primary\">{viewingPost.author}</span>\n <StatusBadge label={viewingPost.authorRole} variant=\"muted\" className=\"ms-2\" />\n </div>\n <span className=\"ms-auto text-xs text-text-secondary\">{formatDate(viewingPost.createdAt)}</span>\n </div>\n <p className=\"text-sm text-text-primary whitespace-pre-wrap\">{viewingPost.content}</p>\n <div className=\"flex flex-wrap items-center gap-2\">\n <StatusBadge label={viewingPost.category} variant=\"default\" />\n {viewingPost.tags.map((tag) => (\n <span\n key={tag}\n className=\"flex items-center gap-1 rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-text-secondary\"\n >\n <Tag className=\"h-2.5 w-2.5\" /> {tag}\n </span>\n ))}\n </div>\n <div className=\"flex items-center gap-4 border-t border-border-subtle pt-3 text-xs text-text-secondary\">\n <span className=\"flex items-center gap-1\">\n <Heart className=\"h-3.5 w-3.5\" />{' '}\n {t('healthybowl.network.community.viewModal.likes', '{{count}} likes', { count: viewingPost.likes })}\n </span>\n <span className=\"flex items-center gap-1\">\n <MessageSquare className=\"h-3.5 w-3.5\" />{' '}\n {t('healthybowl.network.community.viewModal.replies', '{{count}} replies', {\n count: viewingPost.replies,\n })}\n </span>\n </div>\n\n <CommunityThread messageId={viewingPost.id} />\n\n {/* Reply composer */}\n <div className=\"border-t border-border-subtle pt-3\">\n <textarea\n value={replyText}\n onChange={(e) => setReplyText(e.target.value)}\n placeholder={t('healthybowl.network.community.viewModal.replyPlaceholder', 'Write a reply…')}\n rows={2}\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n <div className=\"mt-2 flex justify-end\">\n <Button size=\"sm\" onClick={() => void handleReply()} disabled={replying || !replyText.trim()}>\n {replying\n ? t('healthybowl.network.community.viewModal.replying', 'Posting…')\n : t('healthybowl.network.community.viewModal.reply', 'Reply')}\n </Button>\n </div>\n </div>\n </div>\n )}\n </Modal>\n\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </PageLayout>\n );\n};\n\n/** Real thread replies for a post, loaded from the conversations subgraph. */\nconst CommunityThread: FC<{ messageId: string }> = ({ messageId }) => {\n const { t } = useI18n();\n const { data, loading } = useGetHealthyBowlCommunityThreadQuery({\n variables: { messageId, first: 100 },\n fetchPolicy: 'cache-and-network',\n });\n const replies = useMemo(\n () => ((data?.thread.edges ?? []) as Array<{ node: RawMessageNode }>).map((e) => e.node),\n [data]\n );\n\n if (loading && replies.length === 0) {\n return (\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.network.community.thread.loading', 'Loading replies…')}\n </p>\n );\n }\n if (replies.length === 0) {\n return (\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.network.community.thread.empty', 'No replies yet. Be the first to respond.')}\n </p>\n );\n }\n return (\n <div className=\"space-y-3 border-t border-border-subtle pt-3\">\n {replies.map((r) => {\n const content = (r.content ?? {}) as PostContent;\n // BOFF-6117: server-resolved name → stored snapshot → neutral label.\n const author =\n toStringSafe(r.authorName) ||\n toStringSafe(content.payload?.author) ||\n t('healthybowl.network.community.author.unknown', 'Community member');\n return (\n <div key={r.id} className=\"rounded-md bg-bg-sunken/40 p-3\">\n <div className=\"flex items-center justify-between\">\n <span className=\"text-xs font-medium text-text-primary\">{author}</span>\n <span className=\"text-[11px] text-text-secondary\">{formatDate(r.createdAt)}</span>\n </div>\n <p className=\"mt-1 whitespace-pre-wrap text-sm text-text-primary\">{toStringSafe(content.text)}</p>\n </div>\n );\n })}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2CA,IAAM,IAA0B,yBAC1B,IAAa,MAyCb,KAAgB,MAAwB,OAAO,KAAM,WAAW,IAAI;AAG1E,SAAS,GAAY,GAAqB,GAAuB,GAAyC;CACxG,IAAM,IAAW,EAAI,WAAW,CAAC,GAC3B,IAAU,EAAQ,WAAW,CAAC,GAC9B,IAAQ,EAAI,UAAU,QAAQ,MAAM,EAAE,UAAU,CAAU;CAChE,OAAO;EACL,IAAI,EAAI;EACR,OAAO,EAAa,EAAQ,KAAK,KAAK,EAAa,EAAQ,IAAI,EAAE,MAAM,GAAG,EAAE,KAAK;EACjF,SAAS,EAAa,EAAQ,IAAI;EAClC,UAAU,EAAa,EAAQ,QAAQ,KAAK;EAC5C,MAAM,MAAM,QAAQ,EAAQ,IAAI,IAAI,EAAQ,KAAK,QAAQ,MAAmB,OAAO,KAAM,QAAQ,IAAI,CAAC;EAItG,QAAQ,EAAa,EAAI,UAAU,KAAK,EAAa,EAAQ,MAAM,KAAK;EACxE,YAAY;EACZ,OAAO,EAAM;EACb,WAAW,IAAgB,EAAM,MAAM,MAAM,EAAE,WAAW,CAAa,IAAI;EAC3E,SAAS,EAAI;EACb,WAAW,EAAI;CACjB;AACF;AAEA,IAAa,UAA0B;CACrC,IAAM,EAAE,SAAM,EAAQ,GAChB,EAAE,gBAAa,mBAAgB,EAAe,GAC9C,IAAgB,GAAa,MAAM,IACnC,IAAa,IACf,CAAC,EAAY,WAAW,EAAY,QAAQ,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,KAAK,EAAY,QACvF,IAGE,EACJ,MAAM,GACN,SAAS,IACT,OAAO,IACP,SAAS,MACP,GAAwC;EAAE,WAAW,EAAE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B,kBAAC,KAAD;EAAG,WAAU;YACV,EAAE,gDAAgD,kBAAkB;CACpE,CAAA,IAGH,EAAQ,WAAW,IAEnB,kBAAC,KAAD;EAAG,WAAU;YACV,EAAE,8CAA8C,0CAA0C;CAC1F,CAAA,IAIL,kBAAC,OAAD;EAAK,WAAU;YACZ,EAAQ,KAAK,MAAM;GAClB,IAAM,IAAW,EAAE,WAAW,CAAC;GAM/B,OACE,kBAAC,OAAD;IAAgB,WAAU;cAA1B,CACE,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,QAAD;MAAM,WAAU;gBANpB,EAAa,EAAE,UAAU,KACzB,EAAa,EAAQ,SAAS,MAAM,KACpC,EAAE,gDAAgD,kBAAkB;KAIM,CAAA,GACtE,kBAAC,QAAD;MAAM,WAAU;gBAAmC,EAAW,EAAE,SAAS;KAAQ,CAAA,CAC9E;QACL,kBAAC,KAAD;KAAG,WAAU;eAAsD,EAAa,EAAQ,IAAI;IAAK,CAAA,CAC9F;MANK,EAAE,EAMP;EAET,CAAC;CACE,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"CommunityPage.js","names":[],"sources":["../../../../src/healthybowl/pages/network/CommunityPage.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState, type FC } from 'react';\nimport {\n Heart,\n MessageSquare,\n Tag,\n Plus,\n ArrowUpDown,\n ChevronDown,\n Eye,\n MessageCircle,\n TrendingUp,\n} from 'lucide-react';\nimport {\n PageLayout,\n StatCard,\n FilterBar,\n StatusBadge,\n EmptyState,\n ErrorState,\n PageLoader,\n Modal,\n} from '../../components';\nimport { ToastContainer } from '../../components/Toast';\nimport { Button, Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '@burdenoff/fe-libs/ui';\nimport { useToast } from '../../hooks/useToast';\nimport { useHealthyBowl } from '../../context/HealthyBowlContext';\nimport { cn, formatDate } from '../../utils/helpers';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { ConversationType } from '../../../generated/wspace-types';\nimport {\n useGetHealthyBowlCommunityChannelsQuery,\n useGetHealthyBowlCommunityMessagesQuery,\n useGetHealthyBowlCommunityThreadQuery,\n useCreateHealthyBowlCommunityChannelMutation,\n useSendHealthyBowlCommunityMessageMutation,\n useAddHealthyBowlCommunityReactionMutation,\n} from '../../../generated/wspace-operations';\n\ntype SortOption = 'recent' | 'likes' | 'replies';\n\n// The HB community is ONE workspace-scoped CHANNEL conversation. We identify it\n// by this stable title so the page reuses the same channel across reloads and\n// bootstraps it on first post if absent. (Genuine reuse of wspace-conversations-svc.)\nconst COMMUNITY_CHANNEL_TITLE = 'HealthyBowl Community';\nconst LIKE_EMOJI = '👍';\n\n/** A post = a top-level Message in the community channel, projected for the UI. */\ninterface CommunityPostVM {\n id: string;\n title: string;\n content: string;\n category: string;\n tags: string[];\n author: string;\n authorRole: string;\n likes: number;\n likedByMe: boolean;\n replies: number;\n createdAt: string;\n}\n\n/** The message `content` JSON we author: structured so a post round-trips. */\ninterface PostContent {\n text?: string;\n payload?: { title?: string; category?: string; tags?: string[]; author?: string };\n}\n\n/** The raw message node shape we consume (generated types are `@ts-nocheck`/any). */\ninterface RawMessageNode {\n id: string;\n content: unknown;\n authorId: string;\n authorName?: string | null;\n parentMessageId?: string | null;\n threadRootId?: string | null;\n replyCount: number;\n createdAt: string;\n reactions: Array<{ id: string; emoji: string; userId: string }>;\n}\ninterface RawChannelNode {\n id: string;\n title?: string | null;\n workspaceId: string;\n}\n\nconst toStringSafe = (v: unknown): string => (typeof v === 'string' ? v : '');\n\n/** Project a raw conversation Message into the post view-model. */\nfunction projectPost(msg: RawMessageNode, currentUserId: string, authorFallback: string): CommunityPostVM {\n const content = (msg.content ?? {}) as PostContent;\n const payload = content.payload ?? {};\n const likes = msg.reactions.filter((r) => r.emoji === LIKE_EMOJI);\n return {\n id: msg.id,\n title: toStringSafe(payload.title) || toStringSafe(content.text).slice(0, 60) || 'Untitled',\n content: toStringSafe(content.text),\n category: toStringSafe(payload.category) || 'General',\n tags: Array.isArray(payload.tags) ? payload.tags.filter((t): t is string => typeof t === 'string') : [],\n // BOFF-6117: the server-resolved display name wins; the stored payload\n // snapshot covers pre-fix messages; the last resort is a neutral label —\n // never a truncated UUID.\n author: toStringSafe(msg.authorName) || toStringSafe(payload.author) || authorFallback,\n authorRole: 'Member',\n likes: likes.length,\n likedByMe: currentUserId ? likes.some((r) => r.userId === currentUserId) : false,\n replies: msg.replyCount,\n createdAt: msg.createdAt,\n };\n}\n\nexport const CommunityPage: FC = () => {\n const { t } = useI18n();\n const { workspaceId, currentUser } = useHealthyBowl();\n const currentUserId = currentUser?.id ?? '';\n const authorName = currentUser\n ? [currentUser.firstName, currentUser.lastName].filter(Boolean).join(' ') || currentUser.email\n : '';\n\n // ── Resolve the community channel ──────────────────────────────────────────\n const {\n data: channelsData,\n loading: channelsLoading,\n error: channelsError,\n refetch: refetchChannels,\n } = useGetHealthyBowlCommunityChannelsQuery({ variables: { first: 100 }, fetchPolicy: 'cache-and-network' });\n\n const channelId = useMemo(() => {\n const edges = (channelsData?.conversations.edges ?? []) as Array<{ node: RawChannelNode }>;\n const match = edges.find(\n (e) => (e.node.title ?? '') === COMMUNITY_CHANNEL_TITLE && e.node.workspaceId === workspaceId\n );\n // Fall back to a workspace CHANNEL with the title even if workspaceId isn't echoed identically.\n return (match ?? edges.find((e) => (e.node.title ?? '') === COMMUNITY_CHANNEL_TITLE))?.node.id ?? null;\n }, [channelsData, workspaceId]);\n\n // ── Messages (posts) for the channel ───────────────────────────────────────\n const {\n data: messagesData,\n loading: messagesLoading,\n error: messagesError,\n refetch: refetchMessages,\n } = useGetHealthyBowlCommunityMessagesQuery({\n variables: { conversationId: channelId ?? '', first: 100 },\n skip: !channelId,\n fetchPolicy: 'cache-and-network',\n });\n\n const [createChannel] = useCreateHealthyBowlCommunityChannelMutation();\n const [sendMessage] = useSendHealthyBowlCommunityMessageMutation();\n const [addReaction] = useAddHealthyBowlCommunityReactionMutation();\n\n const refetchAll = useCallback(async () => {\n await refetchChannels();\n if (channelId) await refetchMessages();\n }, [refetchChannels, refetchMessages, channelId]);\n\n // Top-level posts only (parentMessageId == null); thread replies are excluded.\n const allPosts: CommunityPostVM[] = useMemo(() => {\n const edges = (messagesData?.conversation?.messages.edges ?? []) as Array<{ node: RawMessageNode }>;\n return edges\n .map((e) => e.node)\n .filter((m) => !m.parentMessageId)\n .map((m) => projectPost(m, currentUserId, t('healthybowl.network.community.author.unknown', 'Community member')));\n }, [messagesData, currentUserId, t]);\n\n const loading = channelsLoading || (Boolean(channelId) && messagesLoading);\n const error = channelsError ?? messagesError;\n\n // Category values are logic values (compared against post.category). Only labels are translated.\n const categories = ['All', 'Soil Health', 'Pest Management', 'Irrigation', 'Livestock', 'General'];\n const categoryLabels: Record<string, string> = {\n All: t('healthybowl.common.all', 'All'),\n 'Soil Health': t('healthybowl.network.community.categories.soilHealth', 'Soil Health'),\n 'Pest Management': t('healthybowl.network.community.categories.pestManagement', 'Pest Management'),\n Irrigation: t('healthybowl.network.community.categories.irrigation', 'Irrigation'),\n Livestock: t('healthybowl.network.community.categories.livestock', 'Livestock'),\n General: t('healthybowl.network.community.categories.general', 'General'),\n };\n const sortLabels: Record<SortOption, string> = {\n recent: t('healthybowl.network.community.sort.recent', 'Most Recent'),\n likes: t('healthybowl.network.community.sort.likes', 'Most Liked'),\n replies: t('healthybowl.network.community.sort.replies', 'Most Replies'),\n };\n\n const [search, setSearch] = useState('');\n const [activeCategory, setActiveCategory] = useState('All');\n const [sort, setSort] = useState<SortOption>('recent');\n const [showSortDropdown, setShowSortDropdown] = useState(false);\n const [expandedPost, setExpandedPost] = useState<string | null>(null);\n const [viewingPost, setViewingPost] = useState<CommunityPostVM | null>(null);\n const [showNewPostModal, setShowNewPostModal] = useState(false);\n const [newPostTitle, setNewPostTitle] = useState('');\n const [newPostCategory, setNewPostCategory] = useState('General');\n const [newPostContent, setNewPostContent] = useState('');\n const [newPostTags, setNewPostTags] = useState('');\n const [submitting, setSubmitting] = useState(false);\n const [likingId, setLikingId] = useState<string | null>(null);\n const [replyText, setReplyText] = useState('');\n const [replying, setReplying] = useState(false);\n\n const sortRef = useRef<HTMLDivElement>(null);\n const { toasts, toast, dismiss } = useToast();\n\n useEffect(() => {\n const handleClick = (e: MouseEvent) => {\n if (sortRef.current && !sortRef.current.contains(e.target as Node)) setShowSortDropdown(false);\n };\n document.addEventListener('mousedown', handleClick);\n return () => document.removeEventListener('mousedown', handleClick);\n }, []);\n\n const filtered = useMemo(\n () =>\n allPosts\n .filter((p) => {\n const matchSearch =\n p.title.toLowerCase().includes(search.toLowerCase()) ||\n p.author.toLowerCase().includes(search.toLowerCase()) ||\n p.content.toLowerCase().includes(search.toLowerCase()) ||\n p.tags.some((tag) => tag.toLowerCase().includes(search.toLowerCase()));\n const matchCategory = activeCategory === 'All' || p.category === activeCategory;\n return matchSearch && matchCategory;\n })\n .sort((a, b) => {\n switch (sort) {\n case 'recent':\n return new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();\n case 'likes':\n return b.likes - a.likes;\n case 'replies':\n return b.replies - a.replies;\n default:\n return 0;\n }\n }),\n [allPosts, search, activeCategory, sort]\n );\n\n const totalReplies = allPosts.reduce((sum, p) => sum + p.replies, 0);\n const activeDiscussions = allPosts.filter((p) => p.replies > 10).length;\n const totalLikes = allPosts.reduce((sum, p) => sum + p.likes, 0);\n\n // Ensure the channel exists, creating it on demand. Returns the channel id.\n const ensureChannel = useCallback(async (): Promise<string> => {\n if (channelId) return channelId;\n const res = await createChannel({\n variables: {\n input: {\n title: COMMUNITY_CHANNEL_TITLE,\n description: t(\n 'healthybowl.network.community.channelDescription',\n 'Discussions with fellow farmers and experts'\n ),\n type: ConversationType.Channel,\n workspaceId,\n participantIds: currentUserId ? [currentUserId] : [],\n },\n },\n });\n const created = res.data?.createConversation.conversation?.id;\n if (!created) throw new Error('Channel creation returned no conversation');\n await refetchChannels();\n return created;\n }, [channelId, createChannel, refetchChannels, t, workspaceId, currentUserId]);\n\n // Like a post (a 👍 reaction on the post message). Real write, then refetch.\n const handleLike = useCallback(\n async (post: CommunityPostVM) => {\n setLikingId(post.id);\n try {\n await addReaction({ variables: { messageId: post.id, emoji: LIKE_EMOJI } });\n await refetchMessages();\n } catch (err) {\n toast({\n title: t('healthybowl.network.community.toast.likeFailed.title', 'Could not like post'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setLikingId(null);\n }\n },\n [addReaction, refetchMessages, toast, t]\n );\n\n const handleViewDiscussion = (post: CommunityPostVM) => {\n setReplyText('');\n setViewingPost(post);\n };\n\n const handleCreatePost = async () => {\n if (!newPostTitle.trim() || !newPostContent.trim()) {\n toast({\n title: t('healthybowl.network.community.toast.missingFields.title', 'Missing Fields'),\n description: t(\n 'healthybowl.network.community.toast.missingFields.description',\n 'Please fill in title and content'\n ),\n variant: 'warning',\n });\n return;\n }\n setSubmitting(true);\n try {\n const id = await ensureChannel();\n const tags = newPostTags\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean);\n await sendMessage({\n variables: {\n input: {\n conversationId: id,\n content: {\n text: newPostContent.trim(),\n payload: {\n title: newPostTitle.trim(),\n category: newPostCategory,\n tags,\n author: authorName,\n },\n },\n },\n },\n });\n toast({\n title: t('healthybowl.network.community.toast.postCreated.title', 'Post Created!'),\n description: t(\n 'healthybowl.network.community.toast.postCreated.description',\n '\"{{title}}\" has been published',\n {\n title: newPostTitle,\n }\n ),\n variant: 'success',\n });\n setShowNewPostModal(false);\n setNewPostTitle('');\n setNewPostCategory('General');\n setNewPostContent('');\n setNewPostTags('');\n await refetchAll();\n } catch (err) {\n toast({\n title: t('healthybowl.common.error', 'Error'),\n description:\n err instanceof Error\n ? err.message\n : t('healthybowl.network.community.toast.createFailed.description', 'Failed to create post'),\n variant: 'error',\n });\n } finally {\n setSubmitting(false);\n }\n };\n\n // Post a reply (a thread message whose parentMessageId is the post).\n const handleReply = async () => {\n if (!viewingPost || !replyText.trim() || !channelId) return;\n setReplying(true);\n try {\n await sendMessage({\n variables: {\n input: {\n conversationId: channelId,\n parentMessageId: viewingPost.id,\n content: { text: replyText.trim(), payload: { author: authorName } },\n },\n },\n });\n setReplyText('');\n await refetchMessages();\n toast({\n title: t('healthybowl.network.community.toast.replyPosted.title', 'Reply posted'),\n variant: 'success',\n });\n } catch (err) {\n toast({\n title: t('healthybowl.network.community.toast.replyFailed.title', 'Could not post reply'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setReplying(false);\n }\n };\n\n const getTimeAgo = (dateStr: string) => {\n const diff = Math.floor((Date.now() - new Date(dateStr).getTime()) / (1000 * 60 * 60 * 24));\n if (diff === 0) return t('healthybowl.network.community.time.today', 'Today');\n if (diff === 1) return t('healthybowl.network.community.time.yesterday', 'Yesterday');\n if (diff < 7) return t('healthybowl.network.community.time.daysAgo', '{{count}} days ago', { count: diff });\n return formatDate(dateStr);\n };\n\n return (\n <PageLayout\n title={t('healthybowl.network.community.title', 'Community')}\n description={t('healthybowl.network.community.description', 'Join discussions with fellow farmers and experts')}\n purpose=\"Swap ideas, ask questions and share what's working with other farmers and experts. Farming is easier when you're not doing it alone — this is the place to learn from people who've faced the same challenges.\"\n >\n {/* Stats */}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <StatCard\n hero\n label={t('healthybowl.network.community.stats.totalPosts', 'Total Posts')}\n value={allPosts.length}\n icon={<MessageCircle className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.network.community.stats.totalReplies', 'Total Replies')}\n value={totalReplies}\n icon={<MessageSquare className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.network.community.stats.activeDiscussions', 'Active Discussions')}\n value={activeDiscussions}\n icon={<TrendingUp className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.network.community.stats.totalLikes', 'Total Likes')}\n value={totalLikes}\n icon={<Heart className=\"h-4 w-4\" />}\n />\n </div>\n\n {/* Category Tabs */}\n <div className=\"flex flex-wrap items-center gap-1.5 border-b border-border-subtle pb-3\">\n {categories.map((cat) => (\n <button\n key={cat}\n type=\"button\"\n onClick={() => setActiveCategory(cat)}\n className={cn(\n 'rounded-full px-3 py-1.5 text-xs font-medium transition-colors',\n activeCategory === cat\n ? 'bg-action-primary-bg text-action-primary-text'\n : 'bg-bg-sunken text-text-secondary hover:bg-bg-sunken/80 hover:text-text-primary'\n )}\n >\n {categoryLabels[cat] ?? cat}\n </button>\n ))}\n </div>\n\n {/* Filter Bar */}\n <FilterBar\n searchValue={search}\n onSearchChange={setSearch}\n searchPlaceholder={t('healthybowl.network.community.searchPlaceholder', 'Search posts, authors, or tags...')}\n filters={\n <div ref={sortRef} className=\"relative\">\n <Button variant=\"outline\" size=\"sm\" onClick={() => setShowSortDropdown((prev) => !prev)} className=\"w-auto\">\n <ArrowUpDown className=\"h-3.5 w-3.5\" />\n {sortLabels[sort]}\n <ChevronDown className=\"h-3 w-3\" />\n </Button>\n {showSortDropdown && (\n <div className=\"absolute end-0 z-10 mt-1 w-40 rounded-md border border-border-subtle bg-bg-surface py-1 shadow-lg\">\n {(Object.keys(sortLabels) as SortOption[]).map((key) => (\n <Button\n key={key}\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => {\n setSort(key);\n setShowSortDropdown(false);\n }}\n className={cn(\n 'w-full justify-start',\n sort === key ? 'font-semibold text-primary' : 'text-text-primary'\n )}\n >\n {sortLabels[key]}\n </Button>\n ))}\n </div>\n )}\n </div>\n }\n actions={\n <Button size=\"sm\" onClick={() => setShowNewPostModal(true)}>\n <Plus className=\"h-3.5 w-3.5\" /> {t('healthybowl.network.community.actions.newPost', 'New Post')}\n </Button>\n }\n />\n\n {/* Posts List */}\n {filtered.length > 0 ? (\n <div className=\"space-y-4\">\n {filtered.map((post) => {\n const isExpanded = expandedPost === post.id;\n return (\n <div\n key={post.id}\n className=\"rounded-lg border border-border-subtle bg-bg-surface p-5 transition-colors hover:border-primary/20\"\n >\n {/* Post header */}\n <div className=\"flex items-center gap-2\">\n <div className=\"flex h-8 w-8 items-center justify-center rounded-full bg-bg-sunken text-xs font-semibold text-text-primary\">\n {post.author\n .split(' ')\n .map((n) => n[0])\n .join('')}\n </div>\n <div>\n <span className=\"text-sm font-medium text-text-primary\">{post.author}</span>\n <StatusBadge label={post.authorRole} variant=\"muted\" className=\"ms-2\" />\n </div>\n <span className=\"ms-auto text-xs text-text-secondary\">{getTimeAgo(post.createdAt)}</span>\n </div>\n\n {/* Title and content */}\n <h3\n className=\"mt-3 cursor-pointer text-sm font-semibold text-text-primary hover:text-primary\"\n onClick={() => setExpandedPost(isExpanded ? null : post.id)}\n >\n {post.title}\n </h3>\n <p className={cn('mt-1 text-sm text-text-secondary', !isExpanded && 'line-clamp-2')}>{post.content}</p>\n\n {/* Tags and category */}\n <div className=\"mt-3 flex flex-wrap items-center gap-2\">\n <StatusBadge label={post.category} variant=\"default\" />\n {post.tags.map((tag) => (\n <span\n key={tag}\n className=\"flex items-center gap-1 rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-text-secondary\"\n >\n <Tag className=\"h-2.5 w-2.5\" /> {tag}\n </span>\n ))}\n </div>\n\n {/* Actions — real like + real reply count */}\n <div className=\"mt-3 flex items-center gap-4\">\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => void handleLike(post)}\n disabled={likingId === post.id}\n title={t('healthybowl.network.community.post.like', 'Like this post')}\n className={cn('gap-1', post.likedByMe ? 'text-primary' : 'text-text-secondary')}\n >\n <Heart className={cn('h-3.5 w-3.5', post.likedByMe && 'fill-current')} />\n {post.likes}\n </Button>\n <span className=\"flex items-center gap-1 text-xs text-text-secondary\">\n <MessageSquare className=\"h-3.5 w-3.5\" />{' '}\n {t('healthybowl.network.community.post.replies', '{{count}} replies', { count: post.replies })}\n </span>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => handleViewDiscussion(post)}\n className=\"ms-auto gap-1 font-medium text-primary\"\n >\n <Eye className=\"h-3.5 w-3.5\" />{' '}\n {t('healthybowl.network.community.post.viewDiscussion', 'View Discussion')}\n </Button>\n </div>\n </div>\n );\n })}\n </div>\n ) : allPosts.length === 0 ? (\n loading ? (\n <PageLoader />\n ) : error ? (\n <ErrorState onRetry={() => void refetchAll()} />\n ) : (\n <EmptyState\n illustration=\"empty-people\"\n title={t('healthybowl.network.community.emptyState.noPosts.title', 'No community posts yet')}\n description={t(\n 'healthybowl.network.community.emptyState.noPosts.description',\n 'Be the first to start a discussion. Create a post to share a question or experience with the community.'\n )}\n action={\n <Button onClick={() => setShowNewPostModal(true)}>\n <Plus className=\"h-3.5 w-3.5\" /> {t('healthybowl.network.community.actions.newPost', 'New Post')}\n </Button>\n }\n />\n )\n ) : (\n <EmptyState\n illustration=\"empty-search\"\n title={t('healthybowl.network.community.emptyState.noResults.title', 'No posts found')}\n description={t(\n 'healthybowl.network.community.emptyState.noResults.description',\n 'No community posts match your current filters. Try adjusting your search or category.'\n )}\n action={\n <Button\n onClick={() => {\n setSearch('');\n setActiveCategory('All');\n }}\n >\n {t('healthybowl.network.community.actions.clearFilters', 'Clear Filters')}\n </Button>\n }\n />\n )}\n\n {/* New Post Modal */}\n <Modal\n open={showNewPostModal}\n onClose={() => setShowNewPostModal(false)}\n title={t('healthybowl.network.community.newPostModal.title', 'Create New Post')}\n description={t(\n 'healthybowl.network.community.newPostModal.description',\n 'Share your knowledge with the farming community'\n )}\n size=\"lg\"\n footer={\n <>\n <Button variant=\"outline\" onClick={() => setShowNewPostModal(false)}>\n {t('healthybowl.common.cancel', 'Cancel')}\n </Button>\n <Button onClick={handleCreatePost} disabled={submitting}>\n {submitting\n ? t('healthybowl.network.community.newPostModal.publishing', 'Publishing…')\n : t('healthybowl.network.community.newPostModal.publish', 'Publish Post')}\n </Button>\n </>\n }\n >\n <div className=\"space-y-4\">\n <div>\n <label className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('healthybowl.network.community.form.title.label', 'Title')}\n </label>\n <input\n type=\"text\"\n value={newPostTitle}\n onChange={(e) => setNewPostTitle(e.target.value)}\n placeholder={t('healthybowl.network.community.form.title.placeholder', 'Enter a descriptive title...')}\n className=\"h-9 w-full rounded-md border border-border-subtle bg-bg-surface px-3 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n </div>\n <div>\n <label className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('healthybowl.network.community.form.category.label', 'Category')}\n </label>\n <Select value={newPostCategory} onValueChange={setNewPostCategory}>\n <SelectTrigger className=\"h-9 w-full\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {categories\n .filter((c) => c !== 'All')\n .map((cat) => (\n <SelectItem key={cat} value={cat}>\n {categoryLabels[cat] ?? cat}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div>\n <label className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('healthybowl.network.community.form.content.label', 'Content')}\n </label>\n <textarea\n value={newPostContent}\n onChange={(e) => setNewPostContent(e.target.value)}\n placeholder={t(\n 'healthybowl.network.community.form.content.placeholder',\n 'Share your thoughts, questions, or advice...'\n )}\n rows={5}\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n </div>\n <div>\n <label className=\"mb-1 block text-sm font-medium text-text-primary\">\n {t('healthybowl.network.community.form.tags.label', 'Tags')}\n </label>\n <input\n type=\"text\"\n value={newPostTags}\n onChange={(e) => setNewPostTags(e.target.value)}\n placeholder={t(\n 'healthybowl.network.community.form.tags.placeholder',\n 'Comma-separated tags (e.g., organic, soil, irrigation)'\n )}\n className=\"h-9 w-full rounded-md border border-border-subtle bg-bg-surface px-3 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t('healthybowl.network.community.form.tags.helper', 'Separate tags with commas')}\n </p>\n </div>\n </div>\n </Modal>\n\n {/* View Discussion Modal — real thread + reply composer */}\n <Modal\n open={viewingPost !== null}\n onClose={() => setViewingPost(null)}\n title={viewingPost?.title ?? t('healthybowl.network.community.viewModal.titleFallback', 'Discussion')}\n description={t('healthybowl.network.community.viewModal.description', 'Posted by {{author}} in {{category}}', {\n author: viewingPost?.author ?? '',\n category: viewingPost?.category ?? '',\n })}\n size=\"lg\"\n footer={\n <Button variant=\"outline\" onClick={() => setViewingPost(null)}>\n {t('healthybowl.common.close', 'Close')}\n </Button>\n }\n >\n {viewingPost && (\n <div className=\"space-y-4\">\n <div className=\"flex items-center gap-2\">\n <div className=\"flex h-8 w-8 items-center justify-center rounded-full bg-bg-sunken text-xs font-semibold text-text-primary\">\n {viewingPost.author\n .split(' ')\n .map((n) => n[0])\n .join('')}\n </div>\n <div>\n <span className=\"text-sm font-medium text-text-primary\">{viewingPost.author}</span>\n <StatusBadge label={viewingPost.authorRole} variant=\"muted\" className=\"ms-2\" />\n </div>\n <span className=\"ms-auto text-xs text-text-secondary\">{formatDate(viewingPost.createdAt)}</span>\n </div>\n <p className=\"text-sm text-text-primary whitespace-pre-wrap\">{viewingPost.content}</p>\n <div className=\"flex flex-wrap items-center gap-2\">\n <StatusBadge label={viewingPost.category} variant=\"default\" />\n {viewingPost.tags.map((tag) => (\n <span\n key={tag}\n className=\"flex items-center gap-1 rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-text-secondary\"\n >\n <Tag className=\"h-2.5 w-2.5\" /> {tag}\n </span>\n ))}\n </div>\n <div className=\"flex items-center gap-4 border-t border-border-subtle pt-3 text-xs text-text-secondary\">\n <span className=\"flex items-center gap-1\">\n <Heart className=\"h-3.5 w-3.5\" />{' '}\n {t('healthybowl.network.community.viewModal.likes', '{{count}} likes', { count: viewingPost.likes })}\n </span>\n <span className=\"flex items-center gap-1\">\n <MessageSquare className=\"h-3.5 w-3.5\" />{' '}\n {t('healthybowl.network.community.viewModal.replies', '{{count}} replies', {\n count: viewingPost.replies,\n })}\n </span>\n </div>\n\n <CommunityThread messageId={viewingPost.id} />\n\n {/* Reply composer */}\n <div className=\"border-t border-border-subtle pt-3\">\n <textarea\n value={replyText}\n onChange={(e) => setReplyText(e.target.value)}\n placeholder={t('healthybowl.network.community.viewModal.replyPlaceholder', 'Write a reply…')}\n rows={2}\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n <div className=\"mt-2 flex justify-end\">\n <Button size=\"sm\" onClick={() => void handleReply()} disabled={replying || !replyText.trim()}>\n {replying\n ? t('healthybowl.network.community.viewModal.replying', 'Posting…')\n : t('healthybowl.network.community.viewModal.reply', 'Reply')}\n </Button>\n </div>\n </div>\n </div>\n )}\n </Modal>\n\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </PageLayout>\n );\n};\n\n/** Real thread replies for a post, loaded from the conversations subgraph. */\nconst CommunityThread: FC<{ messageId: string }> = ({ messageId }) => {\n const { t } = useI18n();\n const { data, loading } = useGetHealthyBowlCommunityThreadQuery({\n variables: { messageId, first: 100 },\n fetchPolicy: 'cache-and-network',\n });\n const replies = useMemo(\n () => ((data?.thread.edges ?? []) as Array<{ node: RawMessageNode }>).map((e) => e.node),\n [data]\n );\n\n if (loading && replies.length === 0) {\n return (\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.network.community.thread.loading', 'Loading replies…')}\n </p>\n );\n }\n if (replies.length === 0) {\n return (\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.network.community.thread.empty', 'No replies yet. Be the first to respond.')}\n </p>\n );\n }\n return (\n <div className=\"space-y-3 border-t border-border-subtle pt-3\">\n {replies.map((r) => {\n const content = (r.content ?? {}) as PostContent;\n // BOFF-6117: server-resolved name → stored snapshot → neutral label.\n const author =\n toStringSafe(r.authorName) ||\n toStringSafe(content.payload?.author) ||\n t('healthybowl.network.community.author.unknown', 'Community member');\n return (\n <div key={r.id} className=\"rounded-md bg-bg-sunken/40 p-3\">\n <div className=\"flex items-center justify-between\">\n <span className=\"text-xs font-medium text-text-primary\">{author}</span>\n <span className=\"text-[11px] text-text-secondary\">{formatDate(r.createdAt)}</span>\n </div>\n <p className=\"mt-1 whitespace-pre-wrap text-sm text-text-primary\">{toStringSafe(content.text)}</p>\n </div>\n );\n })}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2CA,IAAM,IAA0B,yBAC1B,KAAa,MAyCb,KAAgB,MAAwB,OAAO,KAAM,WAAW,IAAI;AAG1E,SAAS,GAAY,GAAqB,GAAuB,GAAyC;CACxG,IAAM,IAAW,EAAI,WAAW,CAAC,GAC3B,IAAU,EAAQ,WAAW,CAAC,GAC9B,IAAQ,EAAI,UAAU,QAAQ,MAAM,EAAE,UAAU,EAAU;CAChE,OAAO;EACL,IAAI,EAAI;EACR,OAAO,EAAa,EAAQ,KAAK,KAAK,EAAa,EAAQ,IAAI,EAAE,MAAM,GAAG,EAAE,KAAK;EACjF,SAAS,EAAa,EAAQ,IAAI;EAClC,UAAU,EAAa,EAAQ,QAAQ,KAAK;EAC5C,MAAM,MAAM,QAAQ,EAAQ,IAAI,IAAI,EAAQ,KAAK,QAAQ,MAAmB,OAAO,KAAM,QAAQ,IAAI,CAAC;EAItG,QAAQ,EAAa,EAAI,UAAU,KAAK,EAAa,EAAQ,MAAM,KAAK;EACxE,YAAY;EACZ,OAAO,EAAM;EACb,WAAW,IAAgB,EAAM,MAAM,MAAM,EAAE,WAAW,CAAa,IAAI;EAC3E,SAAS,EAAI;EACb,WAAW,EAAI;CACjB;AACF;AAEA,IAAa,UAA0B;CACrC,IAAM,EAAE,SAAM,EAAQ,GAChB,EAAE,gBAAa,mBAAgB,EAAe,GAC9C,IAAgB,GAAa,MAAM,IACnC,IAAa,IACf,CAAC,EAAY,WAAW,EAAY,QAAQ,EAAE,OAAO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U,SACN,GAAM,OAAO,SAAS,CAAC,GAAuC,KAAK,MAAM,EAAE,IAAI,GACvF,CAAC,CAAI,CACP;CAgBA,OAdI,KAAW,EAAQ,WAAW,IAE9B,kBAAC,KAAD;EAAG,WAAU;YACV,EAAE,gDAAgD,kBAAkB;CACpE,CAAA,IAGH,EAAQ,WAAW,IAEnB,kBAAC,KAAD;EAAG,WAAU;YACV,EAAE,8CAA8C,0CAA0C;CAC1F,CAAA,IAIL,kBAAC,OAAD;EAAK,WAAU;YACZ,EAAQ,KAAK,MAAM;GAClB,IAAM,IAAW,EAAE,WAAW,CAAC;GAM/B,OACE,kBAAC,OAAD;IAAgB,WAAU;cAA1B,CACE,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,QAAD;MAAM,WAAU;gBANpB,EAAa,EAAE,UAAU,KACzB,EAAa,EAAQ,SAAS,MAAM,KACpC,EAAE,gDAAgD,kBAAkB;KAIM,CAAA,GACtE,kBAAC,QAAD;MAAM,WAAU;gBAAmC,EAAW,EAAE,SAAS;KAAQ,CAAA,CAC9E;QACL,kBAAC,KAAD;KAAG,WAAU;eAAsD,EAAa,EAAQ,IAAI;IAAK,CAAA,CAC9F;MANK,EAAE,EAMP;EAET,CAAC;CACE,CAAA;AAET"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { cn as e, formatCurrency as t, formatDate as n } from "../../utils/helpers.js";
|
|
2
2
|
import { PageLayout as r } from "../../components/PageLayout.js";
|
|
3
3
|
import { StatCard as i } from "../../components/StatCard.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { FilterBar as a } from "../../components/FilterBar.js";
|
|
5
|
+
import { StatusBadge as o } from "../../components/StatusBadge.js";
|
|
6
|
+
import { EmptyState as s } from "../../components/EmptyState.js";
|
|
7
|
+
import { ErrorState as ee } from "../../components/ErrorState.js";
|
|
8
8
|
import { ToastContainer as te } from "../../components/Toast.js";
|
|
9
9
|
import { useConfirm as ne } from "../../components/ConfirmDialog.js";
|
|
10
10
|
import { PageLoader as re } from "../../components/PageLoader.js";
|
|
@@ -250,7 +250,7 @@ var T = (e) => {
|
|
|
250
250
|
children: t.label
|
|
251
251
|
}, t.value))
|
|
252
252
|
}),
|
|
253
|
-
/* @__PURE__ */ _(
|
|
253
|
+
/* @__PURE__ */ _(a, {
|
|
254
254
|
searchValue: j,
|
|
255
255
|
onSearchChange: M,
|
|
256
256
|
searchPlaceholder: l("healthybowl.network.events.searchPlaceholder", "Search events..."),
|
|
@@ -322,7 +322,7 @@ var T = (e) => {
|
|
|
322
322
|
Q.length > 0 ? z === "list" ? /* @__PURE__ */ _("div", {
|
|
323
323
|
className: "grid gap-4 sm:grid-cols-2",
|
|
324
324
|
children: Q.map((r) => {
|
|
325
|
-
let i = je === r.id,
|
|
325
|
+
let i = je === r.id, a = Ge(r.attendees, r.maxCapacity), s = be(r.mode);
|
|
326
326
|
return /* @__PURE__ */ v("div", {
|
|
327
327
|
className: "rounded-lg border border-border-subtle bg-bg-surface p-5 transition-colors hover:border-primary/20",
|
|
328
328
|
children: [
|
|
@@ -331,7 +331,7 @@ var T = (e) => {
|
|
|
331
331
|
children: [/* @__PURE__ */ _("h3", {
|
|
332
332
|
className: "text-sm font-semibold text-text-primary",
|
|
333
333
|
children: r.title
|
|
334
|
-
}), /* @__PURE__ */ _(
|
|
334
|
+
}), /* @__PURE__ */ _(o, {
|
|
335
335
|
label: (r.type ?? "").replace(/_/g, " "),
|
|
336
336
|
variant: T(r.type)
|
|
337
337
|
})]
|
|
@@ -361,7 +361,7 @@ var T = (e) => {
|
|
|
361
361
|
}),
|
|
362
362
|
/* @__PURE__ */ v("div", {
|
|
363
363
|
className: "flex items-center gap-2",
|
|
364
|
-
children: [/* @__PURE__ */ _(s, { className: "h-3 w-3" }), /* @__PURE__ */ _(
|
|
364
|
+
children: [/* @__PURE__ */ _(s, { className: "h-3 w-3" }), /* @__PURE__ */ _(o, {
|
|
365
365
|
label: r.mode,
|
|
366
366
|
variant: E(r.mode)
|
|
367
367
|
})]
|
|
@@ -383,14 +383,14 @@ var T = (e) => {
|
|
|
383
383
|
})
|
|
384
384
|
]
|
|
385
385
|
}), /* @__PURE__ */ v("span", {
|
|
386
|
-
className: e("font-medium",
|
|
387
|
-
children: [
|
|
386
|
+
className: e("font-medium", a >= 90 ? "text-status-error-text" : a >= 70 ? "text-warning" : "text-text-secondary"),
|
|
387
|
+
children: [a, "%"]
|
|
388
388
|
})]
|
|
389
389
|
}), /* @__PURE__ */ _("div", {
|
|
390
390
|
className: "mt-1 h-1.5 w-full rounded-full bg-bg-sunken",
|
|
391
391
|
children: /* @__PURE__ */ _("div", {
|
|
392
|
-
className: e("h-1.5 rounded-full transition-all",
|
|
393
|
-
style: { width: `${Math.min(
|
|
392
|
+
className: e("h-1.5 rounded-full transition-all", a >= 90 ? "bg-status-error-bg" : a >= 70 ? "bg-warning" : "bg-action-primary-bg"),
|
|
393
|
+
style: { width: `${Math.min(a, 100)}%` }
|
|
394
394
|
})
|
|
395
395
|
})]
|
|
396
396
|
}),
|
|
@@ -533,11 +533,11 @@ var T = (e) => {
|
|
|
533
533
|
/* @__PURE__ */ v("div", {
|
|
534
534
|
className: "mt-1 flex items-center gap-2",
|
|
535
535
|
children: [
|
|
536
|
-
/* @__PURE__ */ _(
|
|
536
|
+
/* @__PURE__ */ _(o, {
|
|
537
537
|
label: (e.type ?? "").replace(/_/g, " "),
|
|
538
538
|
variant: T(e.type)
|
|
539
539
|
}),
|
|
540
|
-
/* @__PURE__ */ _(
|
|
540
|
+
/* @__PURE__ */ _(o, {
|
|
541
541
|
label: e.mode,
|
|
542
542
|
variant: E(e.mode)
|
|
543
543
|
}),
|
|
@@ -579,7 +579,7 @@ var T = (e) => {
|
|
|
579
579
|
]
|
|
580
580
|
}, e.id))
|
|
581
581
|
})]
|
|
582
|
-
}) : O.length === 0 ? Te.network ? /* @__PURE__ */ _(re, {}) : we.network ? /* @__PURE__ */ _(
|
|
582
|
+
}) : O.length === 0 ? Te.network ? /* @__PURE__ */ _(re, {}) : we.network ? /* @__PURE__ */ _(ee, { onRetry: Ee }) : /* @__PURE__ */ _(s, {
|
|
583
583
|
illustration: "empty-notifications",
|
|
584
584
|
title: l("healthybowl.network.events.emptyState.noEvents.title", "No community events yet"),
|
|
585
585
|
description: l("healthybowl.network.events.emptyState.noEvents.description", "There are no agricultural events in your network yet. Add one to share it with the community."),
|
|
@@ -591,7 +591,7 @@ var T = (e) => {
|
|
|
591
591
|
l("healthybowl.network.events.actions.add", "Add Event")
|
|
592
592
|
]
|
|
593
593
|
})
|
|
594
|
-
}) : /* @__PURE__ */ _(
|
|
594
|
+
}) : /* @__PURE__ */ _(s, {
|
|
595
595
|
illustration: "empty-search",
|
|
596
596
|
title: l("healthybowl.network.events.emptyState.noResults.title", "No events found"),
|
|
597
597
|
description: l("healthybowl.network.events.emptyState.noResults.description", "No events match your current filters. Try adjusting your search criteria."),
|