"use client"; import { useState, useEffect, useRef } from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Badge } from "@/components/ui/badge"; import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs"; import { Send, Image as ImageIcon, Users, Lock, Zap, ChevronDown, ChevronUp } from "lucide-react"; import { timeAgo } from "@/lib/utils"; import { CannedMessagesPanel } from "@/components/CannedMessagesPanel"; import { PinkPulsePartner } from "@/components/PinkPulsePartner"; interface Message { id: string; sender: string; content: string; image_url?: string; created_at: string; isMe?: boolean; } const CITY = process.env.NEXT_PUBLIC_DEFAULT_CITY || "Fort Lauderdale"; const MOCK_CITY_MESSAGES: Message[] = [ { id: "1", sender: "Mike_Top", content: "Anyone at the beach right now?", created_at: new Date(Date.now() - 300000).toISOString(), }, { id: "2", sender: "Anonymous", content: "Yeah, south end. Busy tonight.", created_at: new Date(Date.now() - 240000).toISOString(), }, { id: "3", sender: "VersBear", content: "Hosting near Wilton. Door code 1234. Clean only.", created_at: new Date(Date.now() - 120000).toISOString(), }, { id: "4", sender: "PupRex", content: "Woof! At Ramrod later if anyone wants to meet up", created_at: new Date(Date.now() - 60000).toISOString(), }, ]; const MOCK_DM_MESSAGES: Message[] = [ { id: "dm1", sender: "You", content: "Hey, saw you on the map. What's up?", created_at: new Date(Date.now() - 600000).toISOString(), isMe: true, }, { id: "dm2", sender: "Mike_Top", content: "Not much, hosting. You?", created_at: new Date(Date.now() - 540000).toISOString(), }, ]; interface ChatPanelProps { dmUserId?: string | null; } export function ChatPanel({ dmUserId }: ChatPanelProps) { const [cityMessages, setCityMessages] = useState(MOCK_CITY_MESSAGES); const [dmMessages, setDmMessages] = useState(MOCK_DM_MESSAGES); const [input, setInput] = useState(""); const [activeTab, setActiveTab] = useState(dmUserId ? "dm" : "city"); const [showQuickReplies, setShowQuickReplies] = useState(false); const bottomRef = useRef(null); useEffect(() => { bottomRef.current?.scrollIntoView({ behavior: "smooth" }); }, [cityMessages, dmMessages, activeTab]); const sendMessage = (text?: string) => { const content = (text ?? input).trim(); if (!content) return; const msg: Message = { id: Date.now().toString(), sender: "You", content, created_at: new Date().toISOString(), isMe: true, }; if (activeTab === "city") { setCityMessages((prev) => [...prev, msg]); } else { setDmMessages((prev) => [...prev, msg]); } setInput(""); setShowQuickReplies(false); }; const messages = activeTab === "city" ? cityMessages : dmMessages; const showComposer = activeTab === "city" || activeTab === "dm"; return (
{CITY} DMs Groups
{cityMessages.length + 12} in room

Auto-joined based on your location. Public city chat.

{dmUserId ? `Chat with User #${dmUserId}` : "Private Messages"}

Use quick replies for address, directions & hosting notes

Create a group room — free, no limits.

{showComposer && (
{activeTab === "dm" && (
{showQuickReplies && (
sendMessage(c)} />
)}
)}
setInput(e.target.value)} onKeyDown={(e) => e.key === "Enter" && sendMessage()} className="flex-1 h-11 text-base" />
)}
); } function MessageList({ messages }: { messages: Message[] }) { return (
{messages.map((msg) => (
{msg.sender} {timeAgo(msg.created_at)}
{msg.content}
))}
); } function GroupRoom({ name, members }: { name: string; members: number }) { return (

{name}

{members} members

Live
); }