import { useEffect, useState } from "react"; import { Anchor, Badge, Button, Card, CopyButton, Group, Image, ScrollArea, SimpleGrid, Stack, Table, Text, Textarea, Title } from "@mantine/core"; import { call } from "../common.jsx"; const when = t => (t ? t.slice(0, 16).replace("T", " ") : ""); const COLORS = { ready: "green", needs_human: "orange", failed: "red", skipped: "gray" }; // The support agent's suggestions (~/aimsight-support), read-only from Supabase Conversations: one per customer message, // newest first; a click shows the draft reply (to copy into the mail in LibreDesk) and its figures (to download and paste) export default function Suggestions() { const [list, setList] = useState([]), [open, setOpen] = useState(null); const read = () => call("/api/suggestions").then(l => l && setList(l)); useEffect(() => { read(); }, []); const s = list.find(r => r.id === open); return (
Suggestions The support agent's draft replies to the customers' questions about their data. Nothing is sent from here: copy the reply and the figures into the mail in LibreDesk, adapt it, send it.
{list.length ? ( Ref.SubjectStatus ReasonUpdated (UTC) {list.map(r => ( setOpen(r.id)} style={{ cursor: "pointer" }} bg={open === r.id ? "var(--mantine-primary-color-light)" : undefined}> {r.reference}{r.subject} {r.status} {r.error || r.triage?.reason || ""}{when(r.updated_at)} ))}
) : No suggestion yet.}
{s && ( #{s.reference} {s.subject} · station {s.triage?.station || "?"} · days {(s.triage?.range || []).join(" → ")} {s.reply ? ( <>