import { useCallback, useEffect, useMemo, useState } from "react"; import { EyeOff, Eye, MessageCircle, RefreshCw, Send } from "lucide-react"; import { api } from "../api.js"; import { Badge, Button, cx, Empty, ErrorNote, Panel, Spinner, timeAgo } from "../ui.jsx"; export default function Inbox() { const [clients, setClients] = useState([]); const [client, setClient] = useState(""); const [days, setDays] = useState(14); const [items, setItems] = useState(null); const [view, setView] = useState("unreplied"); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); useEffect(() => { api("/api/overview").then((r) => { const l = r.clients.filter((c) => c.linked); setClients(l); setClient((c) => c || l[0]?.slug || ""); }).catch(setError); }, []); const load = useCallback(() => { if (!client) return; setLoading(true); setError(null); api(`/api/inbox?client=${client}&days=${days}`).then((r) => setItems(r.comments)).catch((e) => { setError(e); setItems([]); }).finally(() => setLoading(false)); }, [client, days]); useEffect(() => { setItems(null); load(); }, [load]); const shown = useMemo(() => (items || []).filter((c) => view === "all" || (view === "unreplied" ? !c.replied && !c.hidden : c.hidden)), [items, view]); const open = (items || []).filter((c) => !c.replied && !c.hidden).length; const patch = (id, p) => setItems((xs) => xs.map((x) => (x.id === id ? { ...x, ...p } : x))); return (
Comments on Instagram and Facebook posts. Reply within a few hours; it helps reach.
{c.text}
{c.myReply &&You: {c.myReply}
} {!c.replied && !c.hidden && (