import "./components/ui/tidal.css"; import { useId, useMemo, useState, type MouseEvent } from "react"; import { TidalCustomerPortalTemplate, type TidalCustomerPortalBillingConfig, type TidalCustomerPortalSupportConfig } from "./components/ui/customer-portal-template"; import type { TidalSessionRecord } from "./components/ui/session-manager"; import type { TidalSupportTicket } from "./components/ui/support-inbox"; import "./components/ui/session-manager.css"; import "./components/ui/support-inbox.css"; import "./components/ui/customer-portal-template.css"; import "./components/ui/customer-profile.css"; import "./components/ui/status-badge.css"; import "./components/ui/billing-overview.css"; import "./components/ui/usage-limits.css"; import "./components/ui/meter.css"; function tidalExampleAvatarDataUri(seed: unknown) { const text = String(seed).replace(/[^a-z0-9]/gi, "").slice(-2) || "UI"; const palette = ["#333333", "#555555", "#777777", "#999999", "#bbbbbb"]; const color = palette[Array.from(text).reduce((sum, character) => sum + character.charCodeAt(0), 0) % palette.length]; const svg = ``; return `data:image/svg+xml,${encodeURIComponent(svg)}`; } function tidalExampleImageDataUri(label: string) { const safeLabel = label.replace(/[<>&]/g, "").slice(0, 28) || "Sample image"; const svg = `${safeLabel}`; return `data:image/svg+xml,${encodeURIComponent(svg)}`; } const tidalExampleStyles = ".tidal-scope .tidal-customer-portal-demo,\n.tidal-scope .tidal-customer-portal-demo * {\n box-sizing: border-box;\n}\n\n.tidal-scope .tidal-customer-portal-demo {\n inline-size: 100%;\n min-inline-size: 0;\n display: grid;\n justify-items: center;\n gap: 16px;\n}\n\n.tidal-scope .tidal-customer-portal-demo-action {\n min-block-size: 44px;\n padding: 8px 13px;\n border: 1px solid var(--t-border-strong);\n border-radius: 10px;\n background: var(--t-surface);\n color: var(--t-ink);\n font: inherit;\n font-size: 11px;\n font-weight: 700;\n cursor: pointer;\n}\n\n.tidal-scope .tidal-customer-portal-demo-action:hover {\n background: var(--t-subtle);\n}\n\n.tidal-scope .tidal-customer-portal-demo-note {\n inline-size: min(100%, 1180px);\n min-inline-size: 0;\n padding: 16px;\n border: 1px solid var(--t-border);\n border-radius: var(--t-radius-card);\n background: var(--t-surface);\n scroll-margin-block-start: 16px;\n}\n\n.tidal-scope .tidal-customer-portal-demo-note h2,\n.tidal-scope .tidal-customer-portal-demo-note p {\n margin: 0;\n}\n\n.tidal-scope .tidal-customer-portal-demo-note h2 {\n font-size: 15px;\n}\n\n.tidal-scope .tidal-customer-portal-demo-note p {\n margin-block-start: 6px;\n color: var(--t-muted);\n font-size: 11px;\n line-height: 1.55;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .tidal-scope .tidal-customer-portal-demo-action {\n transition: none;\n }\n}"; const initialSessions: readonly TidalSessionRecord[] = [ { id: "current", device: "MacBook Pro · Safari", detail: "Current browser", location: "Austin, Texas", lastActive: "Active now", current: true, }, { id: "phone", device: "iPhone · Mobile Safari", location: "Austin, Texas", lastActive: "18 minutes ago", dateTime: "2026-10-15T14:42:00-05:00", }, { id: "studio", device: "Studio PC · Chrome", location: "Dallas, Texas", lastActive: "3 days ago", dateTime: "2026-10-12T09:20:00-05:00", }, ]; const initialTickets: readonly TidalSupportTicket[] = [ { id: "exports", customerName: "Ava Morgan", subject: "Export column order", preview: "Can I save a preferred column order?", timestamp: "Today", status: "open", statusLabel: "Open", unreadCount: 1, avatarSrc: tidalExampleAvatarDataUri("04"), messages: [ { id: "exports-1", authorName: "Ava Morgan", body: "Can I save a preferred column order for future exports?", timestamp: "9:24 AM", avatarSrc: tidalExampleAvatarDataUri("04"), side: "customer", }, { id: "exports-2", authorName: "Support sample", body: "Saved export layouts are available from the export menu.", timestamp: "9:31 AM", side: "agent", }, ], }, { id: "members", customerName: "Ava Morgan", subject: "Member access", preview: "A teammate needs access to the reports folder.", timestamp: "Oct 12", status: "closed", statusLabel: "Closed", messages: [ { id: "members-1", authorName: "Ava Morgan", body: "A teammate needs access to the reports folder.", timestamp: "Oct 12", avatarSrc: tidalExampleAvatarDataUri("04"), side: "customer", }, ], }, ]; function isPlainPrimary(event: MouseEvent) { return ( event.button === 0 && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey ); } export function CustomerPortalTemplateDemo({ theme = "light", }: { theme?: "light" | "dark"; }) { const generatedId = useId().replace(/:/g, ""); const helpId = `customer-portal-help-${generatedId}`; const invoiceId = `customer-portal-invoice-${generatedId}`; const [billingPeriod, setBillingPeriod] = useState("current"); const [sessions, setSessions] = useState(initialSessions); const [tickets, setTickets] = useState(initialTickets); const [selectedTicketId, setSelectedTicketId] = useState("exports"); const [search, setSearch] = useState(""); const [statusFilter, setStatusFilter] = useState("all"); const [draft, setDraft] = useState(""); const [showProfileNote, setShowProfileNote] = useState(false); const [showPlanDetails, setShowPlanDetails] = useState(false); const [showUsageDetails, setShowUsageDetails] = useState(false); const [notice, setNotice] = useState("Local sample ready."); const visibleTickets = useMemo(() => { const query = search.trim().toLocaleLowerCase(); return tickets.filter( (ticket) => (statusFilter === "all" || ticket.status === statusFilter) && (!query || ticket.subject.toLocaleLowerCase().includes(query) || ticket.customerName.toLocaleLowerCase().includes(query)), ); }, [search, statusFilter, tickets]); const billing: TidalCustomerPortalBillingConfig = { title: "Billing overview", description: "Current sample plan, allowances, and invoices.", plan: { name: "Studio", accessibleName: "Studio plan", status: "Active", price: billingPeriod === "current" ? "$32" : "$384", priceNote: billingPeriod === "current" ? "per month" : "per year", description: showPlanDetails ? "Workspace controls and reporting for a small team." : undefined, details: showPlanDetails ? [ { id: "seats", label: "Seats", value: "8 included" }, { id: "renewal", label: "Next review", value: "Nov 15, 2026" }, ] : undefined, action: { id: "review-plan", kind: "button", label: showPlanDetails ? "Hide plan details" : "Show plan details", onAction: () => { setShowPlanDetails((visible) => !visible); setNotice( showPlanDetails ? "Plan details hidden." : "Plan details shown locally.", ); }, }, }, allowances: [ { id: "members", label: "Members", valueLabel: "5 of 8 seats", used: 5, limit: 8, description: "Three seats remain in this sample plan.", }, { id: "storage", label: "Storage", valueLabel: "18 GB of 50 GB", used: 18, limit: 50, }, ], invoices: [ { id: "inv-1048", label: "INV-1048", accessibleLabel: "invoice INV-1048", date: "Oct 15, 2026", total: "$32.00", status: "Paid", destination: { href: `#${invoiceId}`, linkProps: { onClick: (event: import("react").MouseEvent) => { if (isPlainPrimary(event)) setNotice("Sample invoice selected."); }, }, }, }, { id: "inv-1037", label: "INV-1037", accessibleLabel: "invoice INV-1037", date: "Sep 15, 2026", total: "$32.00", status: "Paid", destination: { href: `#${invoiceId}` }, }, ], invoiceCaption: "Sample invoices", periodControl: { value: billingPeriod, label: "Billing period", options: [ { value: "current", label: "Monthly" }, { value: "annual", label: "Annual" }, ], onValueChange: setBillingPeriod, }, footer: "No charge or plan change is made in this preview.", }; const support: TidalCustomerPortalSupportConfig = { title: "Support", eyebrow: "", description: "Search the sample record or add a local reply.", tickets: visibleTickets, selectedTicketId, onTicketSelect: (ticket) => { setSelectedTicketId(ticket.id); setNotice(`${ticket.subject} selected.`); }, searchValue: search, onSearchValueChange: setSearch, statusFilterValue: statusFilter, statusOptions: [ { value: "all", label: "All statuses" }, { value: "open", label: "Open" }, { value: "closed", label: "Closed" }, ], onStatusFilterChange: setStatusFilter, draftValue: draft, onDraftValueChange: setDraft, onReplySubmit: (ticket, event) => { event.preventDefault(); const body = draft.trim(); if (!body) return; setTickets((current) => current.map((item) => item.id === ticket.id ? { ...item, preview: body, messages: [ ...item.messages, { id: `${item.id}-local-${item.messages.length + 1}`, authorName: "Ava Morgan", body, timestamp: "Now", avatarSrc: tidalExampleAvatarDataUri("04"), side: "customer" as const, }, ], } : item, ), ); setDraft(""); setNotice("Reply added to the local sample."); }, composerPlaceholder: "Write a sample reply", submitLabel: "Add local reply", }; return ( { setShowProfileNote((visible) => !visible); setNotice( showProfileNote ? "Profile note hidden." : "Profile note shown locally.", ); }, }, ], note: showProfileNote ? "Preferred workspace contact for billing and support." : undefined, activity: [ { id: "profile-update", title: "Profile reviewed", description: "Workspace contact details were checked.", time: "Oct 14", dateTime: "2026-10-14", }, { id: "invoice-paid", title: "Invoice marked paid", description: "Sample invoice INV-1048.", time: "Oct 15", dateTime: "2026-10-15", href: `#${invoiceId}`, linkLabel: "View invoice note", }, ], }} billing={billing} usage={{ title: "Usage", description: showUsageDetails ? "Sample plan allowances for the current period. Values reset on the dates shown." : undefined, metrics: [ { id: "automation-runs", kind: "metered", label: "Automation runs", value: 642, limit: 1000, valueText: "642 runs", limitText: "1,000 runs", description: showUsageDetails ? "358 sample runs remain in this period." : undefined, reset: { label: "Resets Nov 1", dateTime: "2026-11-01" }, }, { id: "reports", kind: "unlimited", label: "Saved reports", valueText: "No set limit", description: showUsageDetails ? "Saved reports do not use a metered allowance in this sample." : undefined, }, ], action: ( { setShowUsageDetails((visible) => !visible); setNotice( showUsageDetails ? "Usage details hidden." : "Usage details shown locally.", ); }} > {showUsageDetails ? "Hide usage details" : "Show usage details"} ), }} sessions={{ title: "Active sessions", description: "Devices in this fictional account sample.", sessions, onRevokeRequest: (session) => { setSessions((current) => current.filter((item) => item.id !== session.id), ); setNotice( `${String(session.device)} removed from the local sample.`, ); }, onRevokeOthersRequest: () => { setSessions((current) => current.filter((session) => session.current), ); setNotice("Other sessions removed from the local sample."); }, }} support={support} footer={ {notice} All records are fictional and stay in this page. } /> Sample details INV-1048 is a fictional paid invoice used for this local preview. Account help in this sample does not contact a support service. ); } export default function AgentExample() { return ( ); }
INV-1048 is a fictional paid invoice used for this local preview.
Account help in this sample does not contact a support service.