"use client" import { useMemo, useState } from "react" import { useAccountOrGuest, useCoState } from "@/lib/providers/jazz-provider" import { ContentHeader, SidebarToggleButton } from "@/components/custom/content-header" import { GuideCommunityToggle } from "@/components/custom/GuideCommunityToggle" import { QuestionList } from "@/components/custom/QuestionList" import { QuestionThread } from "@/components/custom/QuestionThread" import { Topic } from "@/lib/schema" import { JAZZ_GLOBAL_GROUP_ID } from "@/lib/constants" interface CommunityTopicRouteProps { topicName: string } interface Question { id: string title: string author: string timestamp: string } export function CommunityTopicRoute({ topicName }: CommunityTopicRouteProps) { const { me } = useAccountOrGuest({ root: { personalLinks: [] } }) const topicID = useMemo(() => me && Topic.findUnique({ topicName }, JAZZ_GLOBAL_GROUP_ID, me), [topicName, me]) const topic = useCoState(Topic, topicID, { latestGlobalGuide: { sections: [] } }) const [selectedQuestion, setSelectedQuestion] = useState(null) if (!topic) { return null } return (

Topic

{topic.prettyName}
setSelectedQuestion(question)} />
{selectedQuestion && (
setSelectedQuestion(null)} />
)}
) }