Email for professionals and teams
improve ui
Hieu Nguyen (Jack)d5b8c413bac8
diff --git a/package.json b/package.jsonindex 141de40..7d13670 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "mailflare",- "version": "0.2.0",+ "version": "0.2.1","private": true,"scripts": {"dev": "npm run db:bundle && next dev",diff --git a/src/app/(admin)/admin/page.tsx b/src/app/(admin)/admin/page.tsxindex 8811c8d..434975b 100644--- a/src/app/(admin)/admin/page.tsx+++ b/src/app/(admin)/admin/page.tsx@@ -25,7 +25,7 @@ const sections = [{href: "/licenses",title: "Licenses",- description: "Compare Pro and Team perpetual licenses.",+ description: "Compare Pro and Team one-time licenses.",icon: BadgeDollarSign,},{diff --git a/src/app/(admin)/domains/page.tsx b/src/app/(admin)/domains/page.tsxindex 00d2031..121a5b3 100644--- a/src/app/(admin)/domains/page.tsx+++ b/src/app/(admin)/domains/page.tsx@@ -19,7 +19,7 @@ import { authFetch } from "@/lib/auth/client";import type { DnsStatusSummary, Domain, DomainDnsView, DomainPreflight } from "./types";import DomainItemCard from "./DomainItemCard";import DomainDnsDetails from "./DomainDnsDetails";-import { CardGridSkeleton } from "@/components/page-skeletons";+import { SectionRowSkeleton } from "@/components/page-skeletons";import { checkDomain } from "./utils";export default function DomainsPage() {@@ -238,7 +238,7 @@ export default function DomainsPage() {<span className="text-sm text-neutral-500">{(data?.domains ?? []).length} total</span></div> */}{isLoading && (- <CardGridSkeleton />+ <SectionRowSkeleton />)}{!isLoading && (data?.domains ?? []).length === 0 && (<p className="rounded-2xl bg-white px-5 py-4 text-sm text-neutral-500">diff --git a/src/app/(admin)/layout.tsx b/src/app/(admin)/layout.tsxindex 2d55e2f..dbe70b3 100644--- a/src/app/(admin)/layout.tsx+++ b/src/app/(admin)/layout.tsx@@ -28,7 +28,7 @@ export default function DashboardLayout({<AdminNav /></aside><div className="flex min-h-0 min-w-0 flex-col">- <span className="fixed top-6 right-6 flex items-center gap-2">+ <span className="fixed top-2 right-4 flex items-center gap-4"><LicenseIndicator /><MailboxSelector /></span>diff --git a/src/app/(admin)/licenses/license-activation.tsx b/src/app/(admin)/licenses/license-activation.tsxindex cc9e368..6e2c3b1 100644--- a/src/app/(admin)/licenses/license-activation.tsx+++ b/src/app/(admin)/licenses/license-activation.tsx@@ -7,7 +7,6 @@ import { Button } from "@/components/ui/button";import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";import { Input } from "@/components/ui/input";import { Label } from "@/components/ui/label";-import { Select } from "@/components/ui/select";import { Skeleton } from "@/components/ui/skeleton";import type { LicenseStatus } from "@/lib/licenses/types";import type { ActivatableLicensePlan, LicenseAction } from "./types";@@ -92,17 +91,6 @@ export function LicenseActivation() {return (<Card className="rounded-3xl border-0 bg-white px-6">- <CardHeader>- <div className="flex items-center justify-between gap-4">- <div className="space-y-1.5">- <CardTitle>License activation</CardTitle>- <CardDescription>Activate the key delivered after your Paymug purchase.</CardDescription>- </div>- <Badge variant={license?.active ? "default" : "outline"}>- {formatLicensePlan(license?.plan ?? "community")}- </Badge>- </div>- </CardHeader><CardContent className="space-y-5 pb-6">{hasActivation && license && (<p className="rounded-2xl bg-amber-50 px-4 py-3 text-sm text-amber-800">@@ -110,18 +98,40 @@ export function LicenseActivation() {</p>)}{!hasActivation && (- <div className="space-y-2">- <Label htmlFor="licensePlan">Product</Label>- <Select- id="licensePlan"- value={selectedPlan}- onChange={(event) => setSelectedPlan(event.target.value as ActivatableLicensePlan)}- disabled={action !== null}- className="flex h-10 w-full rounded-md border border-neutral-200 bg-white px-3 py-2 text-sm outline-none focus-visible:ring-2 focus-visible:ring-neutral-400 disabled:cursor-not-allowed disabled:opacity-50"- >- <option value="pro">Pro</option>- <option value="team">Team</option>- </Select>+ <div className="space-y-4 pt-6">+ <Label className="mb-4">Already has a license? Choose your tier</Label>+ <div className="grid grid-cols-1 gap-3 sm:grid-cols-2 mt-2" role="radiogroup" aria-label="Product">+ <button+ type="button"+ role="radio"+ aria-checked={selectedPlan === "pro"}+ onClick={() => setSelectedPlan("pro")}+ disabled={action !== null}+ className={`rounded-2xl border px-4 py-4 text-left transition-colors disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer ${+ selectedPlan === "pro"+ ? "border-blue-600 bg-neutral-50 ring-1 ring-blue-700"+ : "border-neutral-200 bg-white hover:border-neutral-400"+ }`}+ >+ <span className="block text-xl font-semibold">Pro</span>+ <span className="mt-1 block text-xs text-neutral-500">For individual power users</span>+ </button>+ <button+ type="button"+ role="radio"+ aria-checked={selectedPlan === "team"}+ onClick={() => setSelectedPlan("team")}+ disabled={action !== null}+ className={`rounded-2xl border px-4 py-4 text-left transition-colors disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer ${+ selectedPlan === "team"+ ? "border-blue-600 bg-neutral-50 ring-1 ring-blue-700"+ : "border-neutral-200 bg-white hover:border-neutral-400"+ }`}+ >+ <span className="block text-xl font-semibold text-neutral-900">Team</span>+ <span className="mt-1 block text-xs text-neutral-500">For teams and shared inboxes</span>+ </button>+ </div></div>)}<div className="space-y-2">@@ -132,10 +142,9 @@ export function LicenseActivation() {autoComplete="off"value={licenseKey}onChange={(event) => setLicenseKey(event.target.value)}- placeholder="Enter your Paymug license key"+ placeholder="Enter your Mailflare license key"disabled={action !== null}/>- <p className="text-xs text-neutral-500">The key is sent directly to Paymug and is not stored. Mailflare keeps only a one-way hash. Activation binds the key to this installation and URL.</p></div><div className="flex flex-wrap items-center gap-3">{hasActivation ? (@@ -149,7 +158,7 @@ export function LicenseActivation() {</>) : (<Button type="button" onClick={() => void submit("activate")} disabled={action !== null}>- {action === "activate" ? "Activating..." : "Activate license"}+ {action === "activate" ? "Activating..." : "Activate"}</Button>)}{status && <p className="text-sm text-neutral-500">{status}</p>}diff --git a/src/app/(admin)/licenses/page.tsx b/src/app/(admin)/licenses/page.tsxindex 7bb81a1..64409e7 100644--- a/src/app/(admin)/licenses/page.tsx+++ b/src/app/(admin)/licenses/page.tsx@@ -17,11 +17,10 @@ export default function LicensesPage() {<div><h1 className="text-3xl font-medium text-neutral-900">Licenses</h1><p className="mt-2 text-sm text-neutral-500">- Choose a perpetual license. Each purchase includes updates released+ Choose a one-time license. Each purchase includes updates releasedduring the first year.</p></div>- <LicenseActivation /><div className="grid gap-4 md:grid-cols-2">{LICENSE_PLANS.map((plan) => {const Icon = plan.icon;@@ -76,6 +75,7 @@ export default function LicensesPage() {);})}</div>+ <LicenseActivation /></div>);}diff --git a/src/app/(admin)/licenses/utils.ts b/src/app/(admin)/licenses/utils.tsindex 25be017..ce242fb 100644--- a/src/app/(admin)/licenses/utils.ts+++ b/src/app/(admin)/licenses/utils.ts@@ -9,16 +9,16 @@ export const LICENSE_PLANS: LicensePlan[] = [name: "Pro",price: 19,originalPrice: 39,- description: "A perpetual license for one account, including one year of product updates.",- features: ["Custom branding", "All future Pro features", "One year of updates", "Keep the licensed version forever"],+ description: "A one-time license for one account, including one year of product updates.",+ features: ["Custom branding", "All future Pro features", "Keep the licensed version forever"],icon: Sparkles,checkoutUrl: "https://app.paymug.co/buy/mailflare-pro",},{name: "Team",price: 249,- description: "A perpetual multi-account license with every Pro capability and one year of updates.",- features: ["Everything in Pro", "Add and manage other accounts", "Shared mailbox access as available", "One year of updates", "Keep the licensed version forever"],+ description: "A one-time multi-account license with every Pro capability",+ features: ["Everything in Pro", "Add and manage other accounts", "Shared mailbox access as available", "Keep the licensed version forever"],icon: Building2,checkoutUrl: "https://app.paymug.co/buy/mailflare-team",},diff --git a/src/app/(admin)/loading.tsx b/src/app/(admin)/loading.tsxindex 66b402f..3c9ff51 100644--- a/src/app/(admin)/loading.tsx+++ b/src/app/(admin)/loading.tsx@@ -1,13 +1,5 @@-import { TableSkeleton } from "@/components/page-skeletons";+import { RouteLoadingBar } from "@/components/route-loading-bar";export default function AdminLoading() {- return (- <div className="w-full max-w-3xl space-y-8 py-2">- <div className="space-y-3">- <div className="h-8 w-48 animate-pulse rounded bg-neutral-200" />- <div className="h-4 w-80 animate-pulse rounded bg-neutral-100" />- </div>- <TableSkeleton />- </div>- );+ return <RouteLoadingBar />;}diff --git a/src/app/(admin)/mailboxes/page.tsx b/src/app/(admin)/mailboxes/page.tsxindex 6e6b0ce..d962499 100644--- a/src/app/(admin)/mailboxes/page.tsx+++ b/src/app/(admin)/mailboxes/page.tsx@@ -17,7 +17,7 @@ import {import { Input } from "@/components/ui/input";import { Label } from "@/components/ui/label";import { Select } from "@/components/ui/select";-import { CardGridSkeleton } from "@/components/page-skeletons";+import { SectionRowSkeleton } from "@/components/page-skeletons";import { clearMailboxesCache } from "@/components/mailbox-provider-utils";import { authFetch } from "@/lib/auth/client";import type { CurrentAccountResponse, Domain, MailboxOwner, MailboxesResponse } from "./types";@@ -227,14 +227,14 @@ export default function MailboxesPage() {</span></div> */}{mailboxes.isLoading && (- <CardGridSkeleton />+ <SectionRowSkeleton />)}{!mailboxes.isLoading && (mailboxes.data?.mailboxes ?? []).length === 0 && (<p className="rounded-2xl bg-white px-5 py-4 text-sm text-neutral-500">No mailboxes yet</p>)}- <div className="grid gap-3">+ <div className="divide-y divide-neutral-100 overflow-hidden rounded-3xl bg-white">{(mailboxes.data?.mailboxes ?? []).map((mailbox) => {const mailboxWithHostname = {...mailbox,@@ -245,7 +245,7 @@ export default function MailboxesPage() {<Linkkey={mailbox.id}href={`/mailboxes/${mailbox.id}`}- className="group flex items-start gap-4 rounded-3xl bg-white p-5 transition-colors hover:bg-blue-50/10"+ className="group flex items-center gap-4 px-5 py-4 transition-colors hover:bg-blue-50/40"><span className="relative flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-full bg-blue-100 text-sm font-semibold text-blue-700">{getMailboxName(mailboxWithHostname).trim().charAt(0).toUpperCase() || "?"}diff --git a/src/app/(admin)/webhooks/page.tsx b/src/app/(admin)/webhooks/page.tsxindex bd008f4..f459697 100644--- a/src/app/(admin)/webhooks/page.tsx+++ b/src/app/(admin)/webhooks/page.tsx@@ -5,7 +5,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";import { Activity, Plus, RefreshCw, Send, Trash2 } from "lucide-react";import { Badge } from "@/components/ui/badge";import { Button } from "@/components/ui/button";-import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";+import { Card, CardContent } from "@/components/ui/card";import {Dialog,DialogContent,@@ -16,7 +16,7 @@ import {import { Input } from "@/components/ui/input";import { Label } from "@/components/ui/label";import { Switch } from "@/components/ui/switch";-import { CardGridSkeleton } from "@/components/page-skeletons";+import { SectionRowSkeleton } from "@/components/page-skeletons";import type { Webhook, WebhookEvent } from "./types";import {WEBHOOK_EVENTS,@@ -114,7 +114,7 @@ export default function WebhooksPage() {)}{webhooks.isLoading ? (- <CardGridSkeleton />+ <SectionRowSkeleton />) : !webhooks.data?.length ? (<Card><CardContent className="pt-6 text-sm text-neutral-500">@@ -122,68 +122,103 @@ export default function WebhooksPage() {</CardContent></Card>) : (- <div className="space-y-4">+ <section className="divide-y divide-neutral-100 overflow-hidden rounded-3xl bg-white">{webhooks.data.map((hook) => (- <Card key={hook.id}>- <CardHeader className="flex flex-row flex-wrap items-start justify-between gap-3">- <div className="min-w-0">- <CardTitle className="truncate text-base">{hook.url}</CardTitle>+ <div key={hook.id} className="px-5 py-6 sm:px-6">+ <div className="flex flex-wrap items-start justify-between gap-4">+ <div className="min-w-0 flex-1">+ <h2 className="truncate text-base font-semibold text-neutral-900">{hook.url}</h2>{hook.description && (<p className="mt-1 text-sm text-neutral-500">{hook.description}</p>)}- <div className="mt-2 flex flex-wrap gap-1">+ <div className="mt-3 flex flex-wrap gap-1.5">{hook.events.map((event) => (<Badge key={event} variant="secondary">{event}</Badge>))}- {!hook.enabled && <Badge variant="outline">Disabled</Badge>}</div></div>- <div className="flex items-center gap-2">- <Switch checked={hook.enabled} onCheckedChange={() => toggle.mutate(hook)} />- <Button- variant="outline"- size="sm"- onClick={() => runTest.mutate(hook.id)}- disabled={runTest.isPending}- >- <Send className="h-4 w-4" /> Test- </Button>- <Button variant="ghost" size="sm" onClick={() => remove.mutate(hook.id)}>- <Trash2 className="h-4 w-4 text-red-600" />- </Button>+ <div className="flex items-center gap-2 rounded-full">+ <span className="text-xs font-medium text-neutral-600">{hook.enabled ? "Enabled" : "Disabled"}</span>+ <Switch+ checked={hook.enabled}+ onCheckedChange={() => toggle.mutate(hook)}+ aria-label={`${hook.enabled ? "Disable" : "Enable"} ${hook.url}`}+ /></div>- </CardHeader>- <CardContent className="space-y-3">- <div className="flex flex-wrap gap-4 text-sm text-neutral-600">- <span>{hook.stats.total} deliveries</span>- <span className="text-green-600">{hook.stats.delivered} delivered</span>- <span className="text-amber-600">{hook.stats.pending} in flight</span>- <span className="text-red-600">{hook.stats.failing} failed</span>- <span className="text-neutral-400">up to {hook.maxAttempts} attempts</span>+ </div>+ <div className="mt-5 grid grid-cols-2 overflow-hidden rounded-2xl bg-neutral-50 sm:grid-cols-5">+ <div className="px-4 py-3">+ <span className="block text-lg font-semibold text-neutral-900">{hook.stats.total}</span>+ <span className="block text-xs text-neutral-500">Deliveries</span></div>+ <div className="px-4 py-3">+ <span className={`block text-lg font-semibold ${hook.stats.delivered ? "text-green-600" : "text-neutral-400"}`}>+ {hook.stats.delivered}+ </span>+ <span className="block text-xs text-neutral-500">Delivered</span>+ </div>+ <div className="px-4 py-3">+ <span className={`block text-lg font-semibold ${hook.stats.pending ? "text-amber-600" : "text-neutral-400"}`}>+ {hook.stats.pending}+ </span>+ <span className="block text-xs text-neutral-500">In flight</span>+ </div>+ <div className="px-4 py-3">+ <span className={`block text-lg font-semibold ${hook.stats.failing ? "text-red-600" : "text-neutral-400"}`}>+ {hook.stats.failing}+ </span>+ <span className="block text-xs text-neutral-500">Failed</span>+ </div>+ <div className="px-4 py-3">+ <span className="block text-lg font-semibold text-neutral-500">{hook.maxAttempts}</span>+ <span className="block text-xs text-neutral-500">Max attempts</span>+ </div>+ </div>- {testResult[hook.id] && (- <p className="text-sm text-neutral-600">- Test delivery: <span className="font-medium">{testResult[hook.id]}</span>- </p>- )}-+ <div className="mt-4 flex flex-wrap items-center gap-3"><Button- variant="outline"+ variant="ghost"size="sm"onClick={() => setExpanded(expanded === hook.id ? null : hook.id)}><Activity className="h-4 w-4" />- {expanded === hook.id ? "Hide deliveries" : "View deliveries"}+ {expanded === hook.id ? "Hide delivery history" : "Delivery history"}</Button>+ <div className="ml-auto flex flex-wrap items-center gap-2">+ {testResult[hook.id] && (+ <p className="mr-1 text-sm text-neutral-600">+ Test delivery: <span className="font-medium">{testResult[hook.id]}</span>+ </p>+ )}+ <Button+ variant="ghost"+ size="sm"+ onClick={() => runTest.mutate(hook.id)}+ disabled={runTest.isPending}+ >+ <Send className="h-4 w-4" /> Test+ </Button>+ <Button+ variant="ghost"+ size="sm"+ onClick={() => remove.mutate(hook.id)}+ aria-label={`Delete ${hook.url}`}+ >+ <Trash2 className="h-4 w-4" /> Delete+ </Button>+ </div>+ </div>- {expanded === hook.id && <WebhookDeliveries webhookId={hook.id} />}- </CardContent>- </Card>+ {expanded === hook.id && (+ <div className="mt-4">+ <WebhookDeliveries webhookId={hook.id} />+ </div>+ )}+ </div>))}- </div>+ </section>)}<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>diff --git a/src/app/(dashboard)/loading.tsx b/src/app/(dashboard)/loading.tsxindex 3bcf39d..6484c02 100644--- a/src/app/(dashboard)/loading.tsx+++ b/src/app/(dashboard)/loading.tsx@@ -1,3 +1,3 @@-import { ListPageSkeleton } from "@/components/page-skeletons";+import { RouteLoadingBar } from "@/components/route-loading-bar";-export default ListPageSkeleton;+export default RouteLoadingBar;diff --git a/src/app/globals.css b/src/app/globals.cssindex 0e95a64..5eae65a 100644--- a/src/app/globals.css+++ b/src/app/globals.css@@ -83,11 +83,27 @@ pre {animation: dialog-content-hide 130ms ease-in;}+@keyframes route-loading-bar {+ 0% { transform: translateX(-110%) scaleX(0.55); }+ 50% { transform: translateX(110%) scaleX(1); }+ 100% { transform: translateX(280%) scaleX(0.55); }+}++.route-loading-bar {+ transform-origin: left;+ animation: route-loading-bar 1.1s ease-in-out infinite;+}+@media (prefers-reduced-motion: reduce) {.dialog-overlay,.dialog-content {animation-duration: 1ms !important;}++ .route-loading-bar {+ width: 100%;+ animation: none;+ }}/* Rendered email bodies (reader, conversation cards, composer). Tailwind'sdiff --git a/src/components/loading-transition.tsx b/src/components/loading-transition.tsxindex f3899dc..ab014d1 100644--- a/src/components/loading-transition.tsx+++ b/src/components/loading-transition.tsx@@ -4,18 +4,22 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { useIsFetching } from "@tanstack/react-query";import { useBranding } from "@/components/branding-provider";import { PageLoadingContext } from "@/components/page-loading";+import { RouteLoadingBar } from "@/components/route-loading-bar";import type { LoadingTransitionProps } from "./loading-transition-types";const MINIMUM_LOADING_TIME = 600;const COMPLETION_TIME = 220;const MAXIMUM_DATA_WAIT = 10_000;+let hasShownInitialLoadingTransition = false;export function LoadingTransition({ children, ready }: LoadingTransitionProps) {const branding = useBranding();+ const showInitialLoader = useRef(!hasShownInitialLoadingTransition).current;const startedAt = useRef(Date.now());const [progress, setProgress] = useState(8);- const [loaderVisible, setLoaderVisible] = useState(true);- const [contentVisible, setContentVisible] = useState(false);+ const [loaderVisible, setLoaderVisible] = useState(showInitialLoader);+ const [contentVisible, setContentVisible] = useState(!showInitialLoader);+ const [initialLoadComplete, setInitialLoadComplete] = useState(!showInitialLoader);const [iconUrl, setIconUrl] = useState(branding.iconUrl);const [pageMounted, setPageMounted] = useState(false);const [pendingLoads, setPendingLoads] = useState(0);@@ -57,21 +61,30 @@ export function LoadingTransition({ children, ready }: LoadingTransitionProps) {useEffect(() => {if (!canComplete) return;- const remaining = Math.max(0, MINIMUM_LOADING_TIME - (Date.now() - startedAt.current));+ const remaining = showInitialLoader+ ? Math.max(0, MINIMUM_LOADING_TIME - (Date.now() - startedAt.current))+ : 0;const completeTimer = window.setTimeout(() => setProgress(100), remaining);const revealTimer = window.setTimeout(() => {- setLoaderVisible(false);- setContentVisible(true);+ if (showInitialLoader) {+ hasShownInitialLoadingTransition = true;+ setLoaderVisible(false);+ setContentVisible(true);+ }+ setInitialLoadComplete(true);}, remaining + COMPLETION_TIME);return () => {window.clearTimeout(completeTimer);window.clearTimeout(revealTimer);};- }, [canComplete]);+ }, [canComplete, showInitialLoader]);++ const showTopLoadingBar = initialLoadComplete && (!ready || pendingLoads > 0);return (<PageLoadingContext.Provider value={loadingContext}><div className="relative min-h-dvh bg-[#f6f8fc]">+ {showTopLoadingBar && <RouteLoadingBar />}{ready && (<divclassName={`min-h-dvh transition-opacity duration-300 ${contentVisible ? "opacity-100" : "opacity-0"}`}diff --git a/src/components/page-skeletons.tsx b/src/components/page-skeletons.tsxindex ba3a8ba..69e0f41 100644--- a/src/components/page-skeletons.tsx+++ b/src/components/page-skeletons.tsx@@ -1,8 +1,8 @@import { Skeleton, SkeletonRows } from "@/components/ui/skeleton";-import { LoadingTransition } from "@/components/loading-transition";+import { RouteLoadingBar } from "@/components/route-loading-bar";export function PageSkeleton() {- return <LoadingTransition ready />;+ return <RouteLoadingBar />;}export function ListPageSkeleton() {@@ -71,3 +71,15 @@ export function CardGridSkeleton() {</div>);}++export function SectionRowSkeleton() {+ return (+ <div className="flex min-h-20 items-center gap-4 rounded-3xl bg-white px-5 py-4">+ <Skeleton className="h-10 w-10 shrink-0 rounded-full" />+ <div className="min-w-0 flex-1 space-y-2">+ <Skeleton className="h-4 w-2/5 max-w-48" />+ <Skeleton className="h-3.5 w-3/5 max-w-80" />+ </div>+ </div>+ );+}diff --git a/src/components/route-loading-bar.tsx b/src/components/route-loading-bar.tsxnew file mode 100644index 0000000..bb6e3a5--- /dev/null+++ b/src/components/route-loading-bar.tsx@@ -0,0 +1,7 @@+export function RouteLoadingBar() {+ return (+ <div className="fixed inset-x-0 top-0 z-[120] h-1 overflow-hidden bg-blue-100" role="progressbar" aria-label="Loading page">+ <div className="route-loading-bar h-full w-2/5 bg-blue-600" />+ </div>+ );+}