File
Blob: src/client/components/admin/permanent-inbox-list.tsx
| 1 | import { Loader2, Mail } from "lucide-react"; |
| 2 | import { Link } from "react-router-dom"; |
| 3 | import { Card, PageHeader } from "@/client/components/ui"; |
| 4 | import type { AdminInbox } from "@/client/lib/api"; |
| 5 | |
| 6 | interface PermanentInboxListProps { |
| 7 | inboxes: AdminInbox[]; |
| 8 | loading: boolean; |
| 9 | } |
| 10 | |
| 11 | export function PermanentInboxList({ inboxes, loading }: PermanentInboxListProps) { |
| 12 | return ( |
| 13 | <Card> |
| 14 | <PageHeader |
| 15 | caption="Permanent Inboxes" |
| 16 | captionIcon={<Mail className="h-3.5 w-3.5 text-zinc-500" />} |
| 17 | heading="Available addresses" |
| 18 | /> |
| 19 | |
| 20 | {loading ? ( |
| 21 | <p className="mt-4 flex items-center gap-2 text-sm text-zinc-400"> |
| 22 | <Loader2 className="h-3.5 w-3.5 animate-spin" /> |
| 23 | Loading permanent inboxes... |
| 24 | </p> |
| 25 | ) : null} |
| 26 | {!loading && inboxes.length === 0 ? ( |
| 27 | <p className="mt-4 text-sm text-zinc-400"> |
| 28 | No permanent inboxes yet. They are created automatically when a domain is added. |
| 29 | </p> |
| 30 | ) : null} |
| 31 | |
| 32 | <div className="mt-4 grid gap-3 sm:grid-cols-2"> |
| 33 | {inboxes.map((inbox) => ( |
| 34 | <Link |
| 35 | key={inbox.address} |
| 36 | className="group rounded-lg border border-zinc-800/50 bg-zinc-800/30 p-4 hover:border-zinc-700/60 hover:bg-zinc-800/60 hover:-translate-y-0.5 transition-transform focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-500/50 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas" |
| 37 | to={`/inbox/${encodeURIComponent(inbox.address)}?admin=1`} |
| 38 | > |
| 39 | <span className="flex items-center justify-between"> |
| 40 | <strong className="text-sm font-semibold text-zinc-200 group-hover:text-accent-400"> |
| 41 | {inbox.localPart} |
| 42 | </strong> |
| 43 | <span className="rounded-full bg-zinc-700/60 px-2 py-0.5 text-xs font-medium tabular-nums text-zinc-300"> |
| 44 | {inbox.emailCount} email{inbox.emailCount !== 1 ? "s" : ""} |
| 45 | </span> |
| 46 | </span> |
| 47 | <span className="mt-0.5 block text-xs text-zinc-400">{inbox.domain}</span> |
| 48 | <small className="mt-1 block truncate font-mono text-xs text-zinc-500">{inbox.address}</small> |
| 49 | </Link> |
| 50 | ))} |
| 51 | </div> |
| 52 | </Card> |
| 53 | ); |
| 54 | } |