Skip to content

Email for professionals and teams

improve UI

Hieu Nguyen (Jack)4dc4b38fadf6
diff --git a/src/app/(settings)/settings/auto-reply/page.tsx b/src/app/(settings)/settings/auto-reply/page.tsx
index 4694d75..560d646 100644
--- a/src/app/(settings)/settings/auto-reply/page.tsx
+++ b/src/app/(settings)/settings/auto-reply/page.tsx
@@ -1,25 +1,24 @@
import { MailboxAutoReplyForm } from "@/components/settings/mailbox-auto-reply-form";
-import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
export default function SettingsAutoReplyPage() {
return (
<div className="space-y-8 py-4">
- <div>
+ {/* <div>
<h1 className="text-3xl font-medium text-neutral-900">Auto-reply</h1>
<p className="mt-1 text-sm text-neutral-500">
Automatically respond from the selected inbox when you are away or unavailable.
</p>
- </div>
+ </div> */}
- <Card className="rounded-3xl border-0 bg-white px-6">
- <CardHeader>
- <CardTitle>Automatic response</CardTitle>
- <CardDescription>Configure the subject and message for the inbox currently selected above.</CardDescription>
- </CardHeader>
- <CardContent className="pb-6">
+ <section className="space-y-4">
+ <div>
+ <h2 className="text-xl font-semibold text-neutral-900">Automatic response</h2>
+ <p className="mt-1 text-sm text-neutral-500">Configure the subject and message for the inbox currently selected above.</p>
+ </div>
+ <div className="rounded-3xl bg-white p-6">
<MailboxAutoReplyForm />
- </CardContent>
- </Card>
+ </div>
+ </section>
</div>
);
}
diff --git a/src/app/(settings)/settings/export/page.tsx b/src/app/(settings)/settings/export/page.tsx
index 626015b..b9503d2 100644
--- a/src/app/(settings)/settings/export/page.tsx
+++ b/src/app/(settings)/settings/export/page.tsx
@@ -4,7 +4,6 @@ import { useState } from "react";
import { Download } from "lucide-react";
import { useSelectedMailbox } from "@/components/mailbox-provider";
import { Button } from "@/components/ui/button";
-import { Card, CardContent, CardDescription, CardHeader } from "@/components/ui/card";
import type { ExportState } from "./types";
import { exportMailbox } from "./utils";
@@ -26,21 +25,22 @@ export default function SettingsExportPage() {
return (
<div className="space-y-6">
- <div>
+ {/* <div>
<h1 className="text-3xl font-medium text-neutral-900">Export</h1>
<p className="mt-1 text-sm text-neutral-500">
Download mail from the currently selected mailbox.
</p>
- </div>
+ </div> */}
- <Card className="rounded-3xl border-0 bg-white p-6">
- <CardHeader className="py-0">
- <CardDescription>
+ <section className="space-y-4">
+ <div>
+ <h2 className="text-xl font-semibold text-neutral-900">Export mailbox</h2>
+ <p className="mt-1 text-sm text-neutral-500">
Download message headers and bodies from the selected mailbox as an .mbox file.
Attachments are not included in this export.
- </CardDescription>
- </CardHeader>
- <CardContent className="space-y-3 pt-5">
+ </p>
+ </div>
+ <div className="space-y-3 rounded-3xl bg-white p-6">
<Button type="button" variant="outline" disabled={!selectedMailbox || exportState.loading} onClick={onExport}>
{exportState.loading ? "Preparing..." : "Download .mbox"}
</Button>
@@ -49,8 +49,8 @@ export default function SettingsExportPage() {
{exportState.error}
</p>
)}
- </CardContent>
- </Card>
+ </div>
+ </section>
</div>
);
}
diff --git a/src/app/(settings)/settings/import/page.tsx b/src/app/(settings)/settings/import/page.tsx
index 6ad2b8c..34d0d8f 100644
--- a/src/app/(settings)/settings/import/page.tsx
+++ b/src/app/(settings)/settings/import/page.tsx
@@ -96,14 +96,19 @@ export default function SettingsImportPage() {
setFileLoading(true);
setFileError(null);
setFileResult(null);
- setFileProgress({ completed: 0, total: 100, label: "Preparing files" });
+ setFileProgress({ completed: 0, total: 100, label: "Preparing files" });
try {
const destination = await getDestination(fileImportSource);
const result = await importMessageFiles(
selectedMailbox.id,
files,
destination,
- (percentage) => setFileProgress({ completed: percentage, total: 100, label: percentage < 70 ? "Uploading files" : "Importing messages" }),
+ (percentage) =>
+ setFileProgress({
+ completed: percentage,
+ total: 100,
+ label: percentage < 70 ? "Uploading files" : "Importing messages",
+ }),
);
setFileResult(result);
window.dispatchEvent(new Event("mailflare:messages-changed"));
@@ -122,7 +127,11 @@ export default function SettingsImportPage() {
setImapLoading(true);
setImapError(null);
setImapResult(null);
- setImapProgress({ completed: 0, total: 1, label: "Discovering IMAP folders" });
+ setImapProgress({
+ completed: 0,
+ total: 1,
+ label: "Discovering IMAP folders",
+ });
try {
const total: ImportResult = { imported: 0, skipped: 0, errors: [] };
const discoveredFolders = await fetchImapFolders(imapForm);
@@ -140,7 +149,11 @@ export default function SettingsImportPage() {
}
for (const [index, source] of expandedSources.entries()) {
- setImapProgress({ completed: index, total: expandedSources.length, label: `Importing ${source.label}` });
+ setImapProgress({
+ completed: index,
+ total: expandedSources.length,
+ label: `Importing ${source.label}`,
+ });
const destination = await getDestination(source);
const folder = resolveImapSourceFolder(source, discoveredFolders);
const result = await importFromImap(
@@ -151,7 +164,11 @@ export default function SettingsImportPage() {
total.imported = (total.imported ?? 0) + (result.imported ?? 0);
total.skipped = (total.skipped ?? 0) + (result.skipped ?? 0);
total.errors = [...(total.errors ?? []), ...(result.errors ?? [])];
- setImapProgress({ completed: index + 1, total: expandedSources.length, label: `Imported ${source.label}` });
+ setImapProgress({
+ completed: index + 1,
+ total: expandedSources.length,
+ label: `Imported ${source.label}`,
+ });
}
setImapResult(total);
setImapForm((current) => ({ ...current, password: "" }));
@@ -167,256 +184,294 @@ export default function SettingsImportPage() {
return (
<div className="space-y-6">
- <div>
+ {/* <div>
<h1 className="text-3xl font-medium text-neutral-900">Import</h1>
<p className="mt-1 text-sm text-neutral-500">
Move mail from selected source sections into the matching sections of
the current mailbox.
</p>
- </div>
+ </div> */}
- <div className="space-y-6 rounded-3xl bg-white p-6">
- <div className="flex flex-col gap-2">
- <Label htmlFor="import-source">Import source</Label>
- <Select
- id="import-source"
- value={activeTab}
- onChange={(event) => setActiveTab(event.target.value as ImportTab)}
- className="text-sm w-full py-2"
- // className="h-10 w-full rounded-md border border-neutral-200 bg-white px-3 text-sm text-neutral-900 shadow-sm shadow-neutral-200/50 outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-100"
- >
- <option value="file">Backup File</option>
- <option value="imap">IMAP</option>
- </Select>
+ <section className="space-y-4">
+ <div>
+ <h2 className="text-xl font-semibold text-neutral-900">
+ Import mailbox
+ </h2>
+ <p className="mt-1 text-sm text-neutral-500">
+ Choose what to import and how Mailflare should receive it.
+ </p>
</div>
- {/* <Card className="m-2">
- <CardContent className="space-y-2 py-4"> */}
- <div className="space-y-2">
- <Label>Choose import sections</Label>
+ <div className="space-y-1 overflow-hidden rounded-3xl">
+ <CardContent className="space-y-6 rounded-b-lg rounded-t-3xl bg-white p-6">
+ <div className="flex flex-col gap-2">
+ <Label htmlFor="import-source">Import source</Label>
+ <Select
+ id="import-source"
+ value={activeTab}
+ onChange={(event) =>
+ setActiveTab(event.target.value as ImportTab)
+ }
+ className="text-sm w-full py-2"
+ // className="h-10 w-full rounded-md border border-neutral-200 bg-white px-3 text-sm text-neutral-900 shadow-sm shadow-neutral-200/50 outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-100"
+ >
+ <option value="file">Backup File</option>
+ <option value="imap">IMAP</option>
+ </Select>
+ </div>
+ <div className="space-y-2">
+ <Label>Choose import sections</Label>
- <div className="relative">
- <button
- type="button"
- onClick={() => setSourceDropdownOpen((open) => !open)}
- className="flex w-full items-center justify-between rounded-md border border-neutral-200 bg-white px-3 py-2 text-left text-sm shadow-sm shadow-neutral-200/50"
- >
- <label className="flex-1">Selected</label>
- <span className="truncate">{sourceSummary}</span>
- <span className="text-neutral-400 px-2">▾</span>
- </button>
- {sourceDropdownOpen && (
- <div className="absolute z-20 mt-2 w-full rounded-xl border border-neutral-200 bg-white p-2 shadow-lg">
- {importSourceOptions.map((option) => (
- <label
- key={option.value}
- className="flex items-center gap-2 rounded-lg px-3 py-2 text-sm text-neutral-700 hover:bg-neutral-50"
- >
- <Checkbox
- checked={selectedSections.includes(option.value)}
- onChange={(event) =>
- toggleSection(option.value, event.target.checked)
- }
- />
- {option.label}
- </label>
- ))}
+ <div className="relative">
+ <button
+ type="button"
+ onClick={() => setSourceDropdownOpen((open) => !open)}
+ className="flex w-full items-center justify-between rounded-md border border-neutral-200 bg-white px-3 py-2 text-left text-sm shadow-sm shadow-neutral-200/50"
+ >
+ <label className="flex-1">Selected</label>
+ <span className="truncate">{sourceSummary}</span>
+ <span className="text-neutral-400 px-2">▾</span>
+ </button>
+ {sourceDropdownOpen && (
+ <div className="absolute z-20 mt-2 w-full rounded-xl border border-neutral-200 bg-white p-2 shadow-lg">
+ {importSourceOptions.map((option) => (
+ <label
+ key={option.value}
+ className="flex items-center gap-2 rounded-lg px-3 py-2 text-sm text-neutral-700 hover:bg-neutral-50"
+ >
+ <Checkbox
+ checked={selectedSections.includes(option.value)}
+ onChange={(event) =>
+ toggleSection(option.value, event.target.checked)
+ }
+ />
+ {option.label}
+ </label>
+ ))}
+ </div>
+ )}
</div>
- )}
- </div>
- {/* <p className="text-xs leading-5 text-neutral-500">
+ {/* <p className="text-xs leading-5 text-neutral-500">
Select Folders to import every source IMAP folder into matching
Mailflare folders.
</p> */}
- </div>
- {/* </CardContent>
- </Card> */}
+ </div>
- {activeTab === "file" ? (
- <>
- <CardContent>
- <form onSubmit={onFileSubmit} className="space-y-4">
- <div className="space-y-2">
- <Label>Select Backup File</Label>
- <Input
- id="import-files"
- type="file"
- accept=".eml,.mbox,.mbx,message/rfc822,application/mbox"
- multiple
- onChange={(event) =>
- setFiles(Array.from(event.target.files ?? []))
- }
- className="block w-full rounded-md border border-neutral-200 bg-white px-3 py-1 text-sm shadow-sm shadow-neutral-200/50 file:mr-3 file:rounded-md file:border-0 file:bg-neutral-100 file:px-3 file:py-1.5 file:text-sm file:font-medium"
- />
- <p className="text-xs leading-5 text-neutral-500">
- Upload exported .eml or .mbox files. File exports do not
- reliably include source section metadata, so files are
- imported once into {fileImportSource.label}
- </p>
- </div>
- {selectedSections.includes("others") && (
- <p className="rounded-lg border border-amber-100 bg-amber-50 px-4 py-3 text-sm text-amber-700">
- Other folders can be imported automatically from IMAP. File import
- cannot discover which section a message belongs to.
- </p>
- )}
- <Button
- type="submit"
- disabled={
- !selectedMailbox ||
- selectedSources.length === 0 ||
- files.length === 0 ||
- fileLoading
- }
- >
- {fileLoading ? "Importing..." : "Import selected files"}
- </Button>
- {fileProgress && (
- <div className="space-y-1 text-xs text-neutral-500" aria-live="polite">
- <div className="flex justify-between"><span>{fileProgress.label}</span><span>{fileProgress.completed}%</span></div>
- <div className="h-1.5 overflow-hidden rounded-full bg-neutral-100"><div className="h-full bg-blue-600 transition-[width]" style={{ width: `${fileProgress.completed}%` }} /></div>
- </div>
- )}
- {fileResult && (
- <p className="rounded-lg border border-green-100 bg-green-50 px-4 py-3 text-sm text-green-700">
- {formatImportResult(fileResult)}
- </p>
- )}
- {fileError && (
- <p className="rounded-lg border border-red-100 bg-red-50 px-4 py-3 text-sm text-red-700">
- {fileError}
- </p>
- )}
- </form>
- </CardContent>
- </>
- ) : (
- <>
- <CardContent>
- <form onSubmit={onImapSubmit} className="space-y-4">
- <div className="grid gap-3 md:grid-cols-[1fr_110px]">
+ {activeTab === "file" ? (
+ <>
+ <form onSubmit={onFileSubmit} className="space-y-4">
<div className="space-y-2">
- <Label htmlFor="imap-host">Host</Label>
+ <Label>Select Backup File</Label>
<Input
- id="imap-host"
- value={imapForm.host}
+ id="import-files"
+ type="file"
+ accept=".eml,.mbox,.mbx,message/rfc822,application/mbox"
+ multiple
onChange={(event) =>
- setImapForm({ ...imapForm, host: event.target.value })
+ setFiles(Array.from(event.target.files ?? []))
}
- placeholder="imap.gmail.com"
+ className="block w-full rounded-md border border-neutral-200 bg-white px-3 py-1 text-sm shadow-sm shadow-neutral-200/50 file:mr-3 file:rounded-md file:border-0 file:bg-neutral-100 file:px-3 file:py-1.5 file:text-sm file:font-medium"
/>
+ <p className="text-xs leading-5 text-neutral-500">
+ Upload exported .eml or .mbox files. File exports do not
+ reliably include source section metadata, so files are
+ imported once into {fileImportSource.label}
+ </p>
</div>
- <div className="space-y-2">
- <Label htmlFor="imap-port">Port</Label>
- <Input
- id="imap-port"
- type="number"
- value={imapForm.port}
- onChange={(event) =>
- setImapForm({ ...imapForm, port: event.target.value })
- }
- />
- </div>
- </div>
- <div className="grid gap-3 md:grid-cols-2">
- <div className="space-y-2">
- <Label htmlFor="imap-username">Username</Label>
- <Input
- id="imap-username"
- value={imapForm.username}
- onChange={(event) =>
- setImapForm({
- ...imapForm,
- username: event.target.value,
- })
- }
- placeholder="[email protected]"
- />
+ {selectedSections.includes("others") && (
+ <p className="rounded-lg border border-amber-100 bg-amber-50 px-4 py-3 text-sm text-amber-700">
+ Other folders can be imported automatically from IMAP.
+ File import cannot discover which section a message
+ belongs to.
+ </p>
+ )}
+ <Button
+ type="submit"
+ disabled={
+ !selectedMailbox ||
+ selectedSources.length === 0 ||
+ files.length === 0 ||
+ fileLoading
+ }
+ >
+ {fileLoading ? "Importing..." : "Import selected files"}
+ </Button>
+ {fileProgress && (
+ <div
+ className="space-y-1 text-xs text-neutral-500"
+ aria-live="polite"
+ >
+ <div className="flex justify-between">
+ <span>{fileProgress.label}</span>
+ <span>{fileProgress.completed}%</span>
+ </div>
+ <div className="h-1.5 overflow-hidden rounded-full bg-neutral-100">
+ <div
+ className="h-full bg-blue-600 transition-[width]"
+ style={{ width: `${fileProgress.completed}%` }}
+ />
+ </div>
+ </div>
+ )}
+ {fileResult && (
+ <p className="rounded-lg border border-green-100 bg-green-50 px-4 py-3 text-sm text-green-700">
+ {formatImportResult(fileResult)}
+ </p>
+ )}
+ {fileError && (
+ <p className="rounded-lg border border-red-100 bg-red-50 px-4 py-3 text-sm text-red-700">
+ {fileError}
+ </p>
+ )}
+ </form>
+ </>
+ ) : (
+ <>
+ <form onSubmit={onImapSubmit} className="space-y-4">
+ <div className="grid gap-3 md:grid-cols-[1fr_110px]">
+ <div className="space-y-2">
+ <Label htmlFor="imap-host">Host</Label>
+ <Input
+ id="imap-host"
+ value={imapForm.host}
+ onChange={(event) =>
+ setImapForm({ ...imapForm, host: event.target.value })
+ }
+ placeholder="imap.gmail.com"
+ />
+ </div>
+ <div className="space-y-2">
+ <Label htmlFor="imap-port">Port</Label>
+ <Input
+ id="imap-port"
+ type="number"
+ value={imapForm.port}
+ onChange={(event) =>
+ setImapForm({ ...imapForm, port: event.target.value })
+ }
+ />
+ </div>
</div>
- <div className="space-y-2">
- <Label htmlFor="imap-password">
- Password or app password
- </Label>
- <Input
- id="imap-password"
- type="password"
- value={imapForm.password}
- onChange={(event) =>
- setImapForm({
- ...imapForm,
- password: event.target.value,
- })
- }
- autoComplete="off"
- />
+ <div className="grid gap-3 md:grid-cols-2">
+ <div className="space-y-2">
+ <Label htmlFor="imap-username">Username</Label>
+ <Input
+ id="imap-username"
+ value={imapForm.username}
+ onChange={(event) =>
+ setImapForm({
+ ...imapForm,
+ username: event.target.value,
+ })
+ }
+ placeholder="[email protected]"
+ />
+ </div>
+ <div className="space-y-2">
+ <Label htmlFor="imap-password">
+ Password or app password
+ </Label>
+ <Input
+ id="imap-password"
+ type="password"
+ value={imapForm.password}
+ onChange={(event) =>
+ setImapForm({
+ ...imapForm,
+ password: event.target.value,
+ })
+ }
+ autoComplete="off"
+ />
+ </div>
</div>
- </div>
- <div className="grid gap-3 md:grid-cols-2">
- <div className="space-y-2">
- <Label htmlFor="imap-limit">Message limit per source</Label>
- <Input
- id="imap-limit"
- type="number"
- min={1}
- max={100}
- value={imapForm.limit}
- onChange={(event) =>
- setImapForm({ ...imapForm, limit: event.target.value })
- }
- />
+ <div className="grid gap-3 md:grid-cols-2">
+ <div className="space-y-2">
+ <Label htmlFor="imap-limit">
+ Message limit per source
+ </Label>
+ <Input
+ id="imap-limit"
+ type="number"
+ min={1}
+ max={100}
+ value={imapForm.limit}
+ onChange={(event) =>
+ setImapForm({
+ ...imapForm,
+ limit: event.target.value,
+ })
+ }
+ />
+ </div>
+ <label className="flex items-end gap-2 pb-2 text-sm text-neutral-700">
+ <Checkbox
+ checked={imapForm.secure}
+ onChange={(event) =>
+ setImapForm({
+ ...imapForm,
+ secure: event.target.checked,
+ })
+ }
+ />
+ Use TLS
+ </label>
</div>
- <label className="flex items-end gap-2 pb-2 text-sm text-neutral-700">
- <Checkbox
- checked={imapForm.secure}
- onChange={(event) =>
- setImapForm({
- ...imapForm,
- secure: event.target.checked,
- })
- }
- />
- Use TLS
- </label>
- </div>
- <p className="rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3 text-xs leading-5 text-neutral-500">
- IMAP imports selected source sections automatically. Folders
- are discovered from the source account and imported into
- matching new or existing Mailflare folders.
- </p>
- <Button
- type="submit"
- disabled={
- !selectedMailbox ||
- selectedSources.length === 0 ||
- !imapForm.host ||
- !imapForm.username ||
- !imapForm.password ||
- imapLoading
- }
- >
- <Upload className="h-4 w-4" />
- {imapLoading ? "Importing..." : "Import selected sources"}
- </Button>
- {imapProgress && (
- <div className="space-y-1 text-xs text-neutral-500" aria-live="polite">
- <div className="flex justify-between"><span>{imapProgress.label}</span><span>{imapProgress.completed}/{imapProgress.total}</span></div>
- <div className="h-1.5 overflow-hidden rounded-full bg-neutral-100"><div className="h-full bg-blue-600 transition-[width]" style={{ width: `${Math.round((imapProgress.completed / imapProgress.total) * 100)}%` }} /></div>
- </div>
- )}
- {imapResult && (
- <p className="rounded-lg border border-green-100 bg-green-50 px-4 py-3 text-sm text-green-700">
- {formatImportResult(imapResult)}
+ <p className="rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3 text-xs leading-5 text-neutral-500">
+ IMAP imports selected source sections automatically. Folders
+ are discovered from the source account and imported into
+ matching new or existing Mailflare folders.
</p>
- )}
- {imapError && (
- <p className="rounded-lg border border-red-100 bg-red-50 px-4 py-3 text-sm text-red-700">
- {imapError}
- </p>
- )}
- </form>
- </CardContent>
- </>
- )}
- </div>
+ <Button
+ type="submit"
+ disabled={
+ !selectedMailbox ||
+ selectedSources.length === 0 ||
+ !imapForm.host ||
+ !imapForm.username ||
+ !imapForm.password ||
+ imapLoading
+ }
+ >
+ <Upload className="h-4 w-4" />
+ {imapLoading ? "Importing..." : "Import selected sources"}
+ </Button>
+ {imapProgress && (
+ <div
+ className="space-y-1 text-xs text-neutral-500"
+ aria-live="polite"
+ >
+ <div className="flex justify-between">
+ <span>{imapProgress.label}</span>
+ <span>
+ {imapProgress.completed}/{imapProgress.total}
+ </span>
+ </div>
+ <div className="h-1.5 overflow-hidden rounded-full bg-neutral-100">
+ <div
+ className="h-full bg-blue-600 transition-[width]"
+ style={{
+ width: `${Math.round((imapProgress.completed / imapProgress.total) * 100)}%`,
+ }}
+ />
+ </div>
+ </div>
+ )}
+ {imapResult && (
+ <p className="rounded-lg border border-green-100 bg-green-50 px-4 py-3 text-sm text-green-700">
+ {formatImportResult(imapResult)}
+ </p>
+ )}
+ {imapError && (
+ <p className="rounded-lg border border-red-100 bg-red-50 px-4 py-3 text-sm text-red-700">
+ {imapError}
+ </p>
+ )}
+ </form>
+ </>
+ )}
+ </CardContent>
+ </div>
+ </section>
</div>
);
}
diff --git a/src/app/(settings)/settings/rules/page.tsx b/src/app/(settings)/settings/rules/page.tsx
index 01124d6..4cbcee5 100644
--- a/src/app/(settings)/settings/rules/page.tsx
+++ b/src/app/(settings)/settings/rules/page.tsx
@@ -4,23 +4,17 @@ import { DomainRouting } from "@/components/settings/domain-routing/domain-routi
export default function SettingsRulesPage() {
return (
<div className="space-y-8">
- <div>
+ {/* <div>
<h1 className="text-3xl font-medium text-neutral-900">Rules</h1>
<p className="mt-1 text-sm text-neutral-500">
Rules for the selected inbox.
</p>
- </div>
- <div className="rounded-3xl bg-white p-6">
+ </div> */}
+ <div>
<DomainRouting />
</div>
- <div className="rounded-3xl bg-white p-6">
- <h2 className="text-2xl font-semibold text-neutral-900">Mailbox rules</h2>
- <p className="mt-1 text-sm text-neutral-500">
- Applied after delivery.
- </p>
- <div className="mt-6">
- <InboxRules />
- </div>
+ <div className="py-6">
+ <InboxRules />
</div>
</div>
);
diff --git a/src/components/admin-nav.tsx b/src/components/admin-nav.tsx
index 4114267..5943066 100644
--- a/src/components/admin-nav.tsx
+++ b/src/components/admin-nav.tsx
@@ -29,7 +29,6 @@ const sections = [
links: [
{ href: "/mailboxes", label: "Mailboxes", icon: Mail },
{ href: "/domains", label: "Domains", icon: Globe2 },
- { href: "/routing", label: "Routing", icon: Route },
{ href: "/webhooks", label: "Webhooks", icon: Webhook },
],
},
diff --git a/src/components/settings/account-settings.tsx b/src/components/settings/account-settings.tsx
index bc13dd9..79b1e46 100644
--- a/src/components/settings/account-settings.tsx
+++ b/src/components/settings/account-settings.tsx
@@ -1,13 +1,11 @@
"use client";
import { useEffect, useState } from "react";
-import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Skeleton } from "@/components/ui/skeleton";
import { ChangePasswordForm } from "./change-password-form";
import { ForwardingEmailForm } from "./forwarding-email-form";
import { MailboxSignatureForm } from "./mailbox-signature-form";
import { ProfileForm } from "./profile-form";
-import { ProfileAvatarForm } from "./profile-avatar-form";
import type { AccountSettingsResponse } from "./types";
import { loadAccountSettings } from "./utils";
@@ -46,63 +44,56 @@ export function AccountSettings() {
return (
<div className="space-y-8 py-4">
- <div>
+ {/* <div>
<h1 className="text-3xl font-medium text-neutral-900">Account</h1>
<p className="mt-1 text-sm text-neutral-500">Manage your account details and sign-in password.</p>
- </div>
+ </div> */}
- <Card className="rounded-3xl border-0 bg-white px-6">
- <CardHeader>
- <CardTitle>Account details</CardTitle>
- <CardDescription>Your current email is assigned to this account and cannot be changed here.</CardDescription>
- </CardHeader>
- <CardContent className="pb-6">
- <div className="mb-6 flex items-center gap-4 border-b border-neutral-100 pb-6">
- <ProfileAvatarForm name={user.name} />
- <div>
- <p className="text-sm font-medium text-neutral-900">Profile picture</p>
- <p className="mt-1 text-sm text-neutral-500">Choose a picture to show across your account.</p>
- </div>
- </div>
+ <section className="space-y-4">
+ <div>
+ <h2 className="text-xl font-semibold text-neutral-900">Account details</h2>
+ <p className="mt-1 text-sm text-neutral-500">Manage your identity, recovery options, and email preferences.</p>
+ </div>
+ <div className="space-y-1 overflow-hidden rounded-3xl">
<ProfileForm
initialName={user.name}
initialResetEmail={user.resetEmail ?? ""}
email={user.email}
/>
- </CardContent>
- </Card>
- {user.canForwardEmail && (
- <Card className="rounded-3xl border-0 bg-white px-6">
- <CardHeader>
- <CardTitle>Forwarding email</CardTitle>
- <CardDescription>Send a copy of incoming messages to another email address.</CardDescription>
- </CardHeader>
- <CardContent className="pb-6">
+ {user.canForwardEmail && (
+ <div className="space-y-4 rounded-lg bg-white p-6">
+ <div>
+ <h3 className="text-lg font-semibold text-neutral-900">Forwarding email</h3>
+ <p className="mt-1 text-sm text-neutral-500">Send a copy of incoming messages to another email address.</p>
+ </div>
<ForwardingEmailForm initialForwardingEmail={user.forwardingEmail ?? ""} />
- </CardContent>
- </Card>
- )}
+ </div>
+ )}
- <Card className="rounded-3xl border-0 bg-white px-6">
- <CardHeader>
- <CardTitle>Email signature</CardTitle>
- <CardDescription>Configure the signature for the inbox currently selected above.</CardDescription>
- </CardHeader>
- <CardContent className="pb-6">
+ <div className="space-y-4 rounded-b-3xl rounded-t-lg bg-white p-6">
+ <div>
+ <h3 className="text-lg font-semibold text-neutral-900">Email signature</h3>
+ <p className="mt-1 text-sm text-neutral-500">Configure the signature for the inbox currently selected above.</p>
+ </div>
<MailboxSignatureForm />
- </CardContent>
- </Card>
+ </div>
+ </div>
+ </section>
- <Card className="rounded-3xl border-0 bg-white px-6">
- <CardHeader>
- <CardTitle>Change password</CardTitle>
- <CardDescription>Use at least 8 characters for your new password.</CardDescription>
- </CardHeader>
- <CardContent className="pb-6">
+ <section className="space-y-4">
+ <div>
+ <h2 className="text-xl font-semibold text-neutral-900">Security</h2>
+ <p className="mt-1 text-sm text-neutral-500">Manage how you sign in to your account.</p>
+ </div>
+ <div className="space-y-4 rounded-3xl bg-white p-6">
+ <div>
+ <h3 className="text-lg font-semibold text-neutral-900">Change password</h3>
+ <p className="mt-1 text-sm text-neutral-500">Use at least 8 characters for your new password.</p>
+ </div>
<ChangePasswordForm />
- </CardContent>
- </Card>
+ </div>
+ </section>
</div>
);
}
diff --git a/src/components/settings/domain-routing/domain-routing.tsx b/src/components/settings/domain-routing/domain-routing.tsx
index f9e6d0e..eab2564 100644
--- a/src/components/settings/domain-routing/domain-routing.tsx
+++ b/src/components/settings/domain-routing/domain-routing.tsx
@@ -15,7 +15,7 @@ import {
} from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
-import { Select } from "@/components/ui/select";
+import { RoutingRuleSelect } from "./routing-rule-select";
import { Switch } from "@/components/ui/switch";
import { Tooltip } from "@/components/ui/tooltip";
import { CardGridSkeleton } from "@/components/page-skeletons";
@@ -118,11 +118,11 @@ export function DomainRouting() {
</button>
</Tooltip>
</div>
- <p className="mt-1 text-sm text-neutral-500">{hostname || "Select an inbox"}</p>
+ <p className="mt-1 text-sm text-neutral-500">Rules for {hostname || "Select an inbox"}</p>
</div>
<div className="flex items-end gap-2">
<Button onClick={openCreate} disabled={!mailboxId || !canManage}>
- <Plus className="h-4 w-4" /> Add rule
+ <Plus className="h-4 w-4" /> Add route
</Button>
</div>
</div>
@@ -142,8 +142,9 @@ export function DomainRouting() {
</CardContent>
</Card>
) : (
- <div className="space-y-6">
+ <div className="space-y-1 overflow-hidden rounded-3xl">
<RuleSection
+ className="rounded-b-lg rounded-t-3xl"
title="Block rules"
description="Evaluated before delivery. Matching mail is rejected at the edge."
rules={blockRules}
@@ -154,6 +155,7 @@ export function DomainRouting() {
onToggle={(rule) => toggle.mutate(rule)}
/>
<RuleSection
+ className="rounded-b-3xl rounded-t-lg"
title="Catch-all and forwarding"
description="Evaluated only when no mailbox on the domain matched the recipient."
rules={fallbackRules}
@@ -181,8 +183,8 @@ export function DomainRouting() {
save.mutate();
}}
>
- <div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
- <div className="space-y-2">
+ <div className="grid grid-cols-1 items-end gap-4 sm:grid-cols-2">
+ <div className="grid min-w-0 gap-2">
<Label htmlFor="rule-name">Name</Label>
<Input
id="rule-name"
@@ -192,9 +194,9 @@ export function DomainRouting() {
/>
</div>
- <div className="space-y-2">
+ <div className="grid min-w-0 gap-2">
<Label htmlFor="rule-action">Action</Label>
- <Select
+ <RoutingRuleSelect
id="rule-action"
value={form.action}
onChange={(e) =>
@@ -206,14 +208,14 @@ export function DomainRouting() {
{label}
</option>
))}
- </Select>
+ </RoutingRuleSelect>
</div>
</div>
- <div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
- <div className="space-y-2">
+ <div className="grid grid-cols-1 items-end gap-4 sm:grid-cols-2">
+ <div className="grid min-w-0 gap-2">
<Label htmlFor="rule-field">Match on</Label>
- <Select
+ <RoutingRuleSelect
id="rule-field"
value={form.matchField}
onChange={(e) =>
@@ -225,11 +227,11 @@ export function DomainRouting() {
{label}
</option>
))}
- </Select>
+ </RoutingRuleSelect>
</div>
- <div className="space-y-2">
+ <div className="grid min-w-0 gap-2">
<Label htmlFor="rule-operator">Condition</Label>
- <Select
+ <RoutingRuleSelect
id="rule-operator"
value={form.matchOperator}
onChange={(e) =>
@@ -244,33 +246,51 @@ export function DomainRouting() {
{label}
</option>
))}
- </Select>
+ </RoutingRuleSelect>
</div>
</div>
- <div className="space-y-2">
- <div className="flex items-center gap-2">
- <Label htmlFor="rule-value">Match value</Label>
- <Tooltip label="Use * to match every message.">
- <span className="text-neutral-400"><Info className="h-4 w-4" /></span>
- </Tooltip>
+ <div className="grid grid-cols-1 items-end gap-4 sm:grid-cols-2">
+ <div className="grid min-w-0 gap-2">
+ <div className="flex items-center gap-2">
+ <Label htmlFor="rule-value">Match value</Label>
+ <Tooltip label="Use * to match every message.">
+ <span className="text-neutral-400"><Info className="h-4 w-4" /></span>
+ </Tooltip>
+ </div>
+ <Input
+ id="rule-value"
+ required
+ value={form.matchValue}
+ placeholder="* to match everything"
+ onChange={(e) => setForm({ ...form, matchValue: e.target.value })}
+ />
+ </div>
+ <div className="grid min-w-0 gap-2">
+ <div className="flex items-center gap-2">
+ <Label htmlFor="rule-priority">Priority</Label>
+ <Tooltip label="Higher numbers run first.">
+ <span className="text-neutral-400"><Info className="h-4 w-4" /></span>
+ </Tooltip>
+ </div>
+ <Input
+ id="rule-priority"
+ type="number"
+ min={0}
+ max={1000}
+ value={form.priority}
+ onChange={(e) => setForm({ ...form, priority: Number(e.target.value) })}
+ />
</div>
- <Input
- id="rule-value"
- required
- value={form.matchValue}
- placeholder="* to match everything"
- onChange={(e) => setForm({ ...form, matchValue: e.target.value })}
- />
</div>
{form.action !== "reject" && (
- <div className={form.action === "forward" ? "grid grid-cols-1 gap-3 sm:grid-cols-2" : "space-y-2"}>
- <div className="space-y-2">
+ <div className={form.action === "forward" ? "grid grid-cols-1 items-end gap-4 sm:grid-cols-2" : "grid min-w-0 gap-2"}>
+ <div className="grid min-w-0 gap-2">
<Label htmlFor="rule-mailbox">
{form.action === "forward" ? "Mailbox for the kept copy" : "Destination mailbox"}
</Label>
- <Select
+ <RoutingRuleSelect
id="rule-mailbox"
value={form.mailboxId ?? ""}
onChange={(e) => setForm({ ...form, mailboxId: e.target.value || null })}
@@ -282,10 +302,10 @@ export function DomainRouting() {
{mailbox.disabled ? " (disabled)" : ""}
</option>
))}
- </Select>
+ </RoutingRuleSelect>
</div>
{form.action === "forward" && (
- <div className="space-y-2">
+ <div className="grid min-w-0 gap-2">
<Label htmlFor="rule-forward">Forward to</Label>
<Input
id="rule-forward"
@@ -317,7 +337,7 @@ export function DomainRouting() {
)}
{form.action === "reject" && (
- <div className="space-y-2">
+ <div className="grid min-w-0 gap-2">
<Label htmlFor="rule-reason">Rejection reason</Label>
<Input
id="rule-reason"
@@ -328,26 +348,9 @@ export function DomainRouting() {
</div>
)}
- <div className="space-y-2 sm:w-1/2">
- <div className="flex items-center gap-2">
- <Label htmlFor="rule-priority">Priority</Label>
- <Tooltip label="Higher numbers run first.">
- <span className="text-neutral-400"><Info className="h-4 w-4" /></span>
- </Tooltip>
- </div>
- <Input
- id="rule-priority"
- type="number"
- min={0}
- max={1000}
- value={form.priority}
- onChange={(e) => setForm({ ...form, priority: Number(e.target.value) })}
- />
- </div>
-
{error && <p className="text-sm text-red-600">{error}</p>}
- <div className="flex justify-end gap-2">
+ <div className="flex justify-end gap-2 border-t border-neutral-200 pt-4">
<Button type="button" variant="outline" onClick={() => setDialogOpen(false)}>
Cancel
</Button>
@@ -363,6 +366,7 @@ export function DomainRouting() {
}
function RuleSection({
+ className,
title,
description,
rules,
@@ -372,6 +376,7 @@ function RuleSection({
onDelete,
onToggle,
}: {
+ className: string;
title: string;
description: string;
rules: DomainRule[];
@@ -382,16 +387,16 @@ function RuleSection({
onToggle: (rule: DomainRule) => void;
}) {
return (
- <Card>
+ <Card className={`${className} border-0 bg-white px-6`}>
<CardHeader>
<div className="flex items-center gap-2">
- <CardTitle>{title}</CardTitle>
+ <CardTitle className="text-xs uppercase">{title}</CardTitle>
<Tooltip label={description}>
<span className="text-neutral-400"><Info className="h-4 w-4" /></span>
</Tooltip>
</div>
</CardHeader>
- <CardContent className="space-y-2">
+ <CardContent className="space-y-2 pb-5">
{rules.length === 0 ? (
<p className="text-sm text-neutral-500">No rules yet.</p>
) : (
diff --git a/src/components/settings/domain-routing/routing-rule-select.tsx b/src/components/settings/domain-routing/routing-rule-select.tsx
new file mode 100644
index 0000000..9a67419
--- /dev/null
+++ b/src/components/settings/domain-routing/routing-rule-select.tsx
@@ -0,0 +1,21 @@
+import * as React from "react";
+import { ChevronDown } from "lucide-react";
+import type { SelectProps } from "@/components/ui/select-types";
+import { cn } from "@/lib/utils";
+
+export const RoutingRuleSelect = React.forwardRef<HTMLSelectElement, SelectProps>(
+ ({ className, ...props }, ref) => (
+ <span className="relative block min-w-0">
+ <select
+ ref={ref}
+ className={cn(
+ "flex h-10 w-full appearance-none truncate rounded-md border border-neutral-200 bg-transparent py-2 pl-3 pr-9 text-sm shadow-sm shadow-neutral-200/50 focus-visible:border-blue-600 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
+ className,
+ )}
+ {...props}
+ />
+ <ChevronDown aria-hidden="true" className="pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-neutral-500" />
+ </span>
+ ),
+);
+RoutingRuleSelect.displayName = "RoutingRuleSelect";
diff --git a/src/components/settings/inbox-rules.tsx b/src/components/settings/inbox-rules.tsx
index 507b923..ce6a30a 100644
--- a/src/components/settings/inbox-rules.tsx
+++ b/src/components/settings/inbox-rules.tsx
@@ -16,7 +16,7 @@ import {
} from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
-import { Select } from "@/components/ui/select";
+import { RoutingRuleSelect } from "./domain-routing/routing-rule-select";
import type { InboxRule, InboxRuleInput } from "./inbox-rules-types";
import {
createInboxRule,
@@ -129,72 +129,76 @@ export function InboxRules() {
return (
<section className="space-y-4">
- <div className="flex flex-row justify-end">
- <Button
- type="button"
- size="sm"
- onClick={openCreateDialog}
- disabled={!mailboxId}
- >
- <Plus className="h-4 w-4" />
- New rule
- </Button>
- </div>
- {(rules.data?.rules ?? []).length === 0 && (
- <p className="rounded-lg border border-dashed border-neutral-200 px-4 py-5 text-sm text-neutral-500">
- No rules yet
- </p>
- )}
- <div className="divide-y divide-neutral-100">
- {(rules.data?.rules ?? []).map((rule) => (
- <div
- key={rule.id}
- role="button"
- tabIndex={0}
- onClick={() => openEditDialog(rule)}
- onKeyDown={(event) => onRuleKeyDown(event, rule)}
- className="group -mx-3 flex cursor-pointer items-center gap-3 rounded-lg px-3 py-3 outline-none transition-colors hover:bg-neutral-50 focus-visible:bg-neutral-50 focus-visible:ring-2 focus-visible:ring-blue-200"
- >
- <div className="flex h-9 w-9 items-center justify-center rounded-lg bg-blue-50 text-blue-700">
- {rule.action === "spam" ? (
- <ShieldAlert className="h-4 w-4" />
- ) : rule.action === "trash" ? (
+ <div className="flex flex-row items-center">
+ <header className="flex-1">
+ <h2 className="text-2xl font-semibold text-neutral-900">
+ Mailbox rules
+ </h2>
+ <p className="mt-1 text-sm text-neutral-500">
+ Applied after delivery.
+ </p>
+ </header>
+
+ <Button type="button" onClick={openCreateDialog} disabled={!mailboxId}>
+ <Plus className="h-4 w-4" />
+ New rule
+ </Button>
+ </div>
+ <div className="rounded-3xl bg-white p-6">
+ {(rules.data?.rules ?? []).length === 0 && (
+ <p className="text-sm text-neutral-500">No rules yet</p>
+ )}
+ <div className="space-y-1">
+ {(rules.data?.rules ?? []).map((rule) => (
+ <div
+ key={rule.id}
+ role="button"
+ tabIndex={0}
+ onClick={() => openEditDialog(rule)}
+ onKeyDown={(event) => onRuleKeyDown(event, rule)}
+ className="group flex cursor-pointer items-center gap-3 rounded-xl bg-neutral-50 px-3 py-3 outline-none transition-colors hover:bg-neutral-100 focus-visible:ring-2 focus-visible:ring-blue-200"
+ >
+ <div className="flex h-9 w-9 items-center justify-center rounded-lg bg-blue-50 text-blue-700">
+ {rule.action === "spam" ? (
+ <ShieldAlert className="h-4 w-4" />
+ ) : rule.action === "trash" ? (
+ <Trash2 className="h-4 w-4" />
+ ) : (
+ <Folder className="h-4 w-4" />
+ )}
+ </div>
+ <div className="min-w-0 flex-1">
+ <p className="truncate text-sm font-medium text-neutral-900">
+ {getRuleFieldLabel(rule.matchField)}{" "}
+ {getRuleOperatorLabel(rule.matchOperator)}{" "}
+ {rule.matchValue || rule.pattern}
+ </p>
+ <p className="truncate text-xs text-neutral-500">
+ {getRuleDestinationLabel(rule)}
+ </p>
+ </div>
+ <Button
+ type="button"
+ variant="ghost"
+ size="sm"
+ disabled={remove.isPending}
+ onClick={(event) => {
+ event.stopPropagation();
+ remove.mutate(rule.id);
+ }}
+ onKeyDown={(event) => event.stopPropagation()}
+ className="opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100"
+ aria-label="Delete rule"
+ >
<Trash2 className="h-4 w-4" />
- ) : (
- <Folder className="h-4 w-4" />
- )}
- </div>
- <div className="min-w-0 flex-1">
- <p className="truncate text-sm font-medium text-neutral-900">
- {getRuleFieldLabel(rule.matchField)}{" "}
- {getRuleOperatorLabel(rule.matchOperator)}{" "}
- {rule.matchValue || rule.pattern}
- </p>
- <p className="truncate text-xs text-neutral-500">
- {getRuleDestinationLabel(rule)}
- </p>
+ </Button>
</div>
- <Button
- type="button"
- variant="ghost"
- size="sm"
- disabled={remove.isPending}
- onClick={(event) => {
- event.stopPropagation();
- remove.mutate(rule.id);
- }}
- onKeyDown={(event) => event.stopPropagation()}
- className="opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100"
- aria-label="Delete rule"
- >
- <Trash2 className="h-4 w-4" />
- </Button>
- </div>
- ))}
+ ))}
+ </div>
</div>
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
- <DialogContent>
+ <DialogContent className="max-h-[calc(100vh-4rem)] overflow-y-auto sm:max-w-[560px]">
<DialogHeader>
<DialogTitle>
{editingRule ? "Update rule" : "New rule"}
@@ -204,12 +208,11 @@ export function InboxRules() {
</DialogDescription>
</DialogHeader>
<form onSubmit={onSubmit} className="space-y-4">
- <div className="grid gap-3 sm:grid-cols-2">
- <div className="space-2">
+ <div className="grid grid-cols-1 items-end gap-4 sm:grid-cols-2">
+ <div className="grid min-w-0 gap-2">
<Label htmlFor="matchField">Field</Label>
- <Select
+ <RoutingRuleSelect
id="matchField"
- className="h-10 w-full px-3 text-sm"
value={matchField}
onChange={(event) =>
setMatchField(
@@ -220,13 +223,12 @@ export function InboxRules() {
<option value="email">Email address</option>
<option value="content">Content</option>
<option value="title">Title</option>
- </Select>
+ </RoutingRuleSelect>
</div>
- <div className="space-2">
+ <div className="grid min-w-0 gap-2">
<Label htmlFor="matchOperator">Match</Label>
- <Select
+ <RoutingRuleSelect
id="matchOperator"
- className="h-10 w-full px-3 text-sm"
value={matchOperator}
onChange={(event) =>
setMatchOperator(event.target.value as "contains" | "exact")
@@ -234,56 +236,66 @@ export function InboxRules() {
>
<option value="contains">Contains</option>
<option value="exact">Exact match</option>
- </Select>
+ </RoutingRuleSelect>
</div>
</div>
- <div className="space-y-2">
- <Label htmlFor="matchValue">Value</Label>
- <Input
- id="matchValue"
- value={matchValue}
- onChange={(event) => setMatchValue(event.target.value)}
- placeholder={
- matchField === "email" ? "[email protected]" : "Invoice"
- }
- />
- </div>
- <div className="space-y-2">
- <Label htmlFor="destination">Destination</Label>
- <Select
- id="destination"
- className="h-10 w-full px-3 text-sm"
- value={destination}
- onChange={(event) => setDestination(event.target.value)}
- >
- <option value="">Select destination</option>
- <option value="spam">Spam</option>
- <option value="trash">Trash</option>
- {(folders.data?.folders ?? []).map((folder) => (
- <option key={folder.id} value={`folder:${folder.id}`}>
- {folder.name}
- </option>
- ))}
- </Select>
+ <div className="grid grid-cols-1 items-end gap-4 sm:grid-cols-2">
+ <div className="grid min-w-0 gap-2">
+ <Label htmlFor="matchValue">Value</Label>
+ <Input
+ id="matchValue"
+ value={matchValue}
+ onChange={(event) => setMatchValue(event.target.value)}
+ placeholder={
+ matchField === "email" ? "[email protected]" : "Invoice"
+ }
+ />
+ </div>
+ <div className="grid min-w-0 gap-2">
+ <Label htmlFor="destination">Destination</Label>
+ <RoutingRuleSelect
+ id="destination"
+ value={destination}
+ onChange={(event) => setDestination(event.target.value)}
+ >
+ <option value="">Select destination</option>
+ <option value="spam">Spam</option>
+ <option value="trash">Trash</option>
+ {(folders.data?.folders ?? []).map((folder) => (
+ <option key={folder.id} value={`folder:${folder.id}`}>
+ {folder.name}
+ </option>
+ ))}
+ </RoutingRuleSelect>
+ </div>
</div>
{save.isError && (
<p className="text-sm text-red-600">{save.error.message}</p>
)}
- <Button
- type="submit"
- disabled={
- !mailboxId ||
- !destination ||
- !matchValue.trim() ||
- save.isPending
- }
- >
- {save.isPending
- ? "Saving..."
- : editingRule
- ? "Update rule"
- : "Add rule"}
- </Button>
+ <div className="flex justify-end gap-2 border-t border-neutral-200 pt-4">
+ <Button
+ type="button"
+ variant="outline"
+ onClick={() => setDialogOpen(false)}
+ >
+ Cancel
+ </Button>
+ <Button
+ type="submit"
+ disabled={
+ !mailboxId ||
+ !destination ||
+ !matchValue.trim() ||
+ save.isPending
+ }
+ >
+ {save.isPending
+ ? "Saving..."
+ : editingRule
+ ? "Save changes"
+ : "Create rule"}
+ </Button>
+ </div>
</form>
</DialogContent>
</Dialog>
diff --git a/src/components/settings/mailbox-auto-reply-form.tsx b/src/components/settings/mailbox-auto-reply-form.tsx
index f5856ed..951a251 100644
--- a/src/components/settings/mailbox-auto-reply-form.tsx
+++ b/src/components/settings/mailbox-auto-reply-form.tsx
@@ -9,113 +9,138 @@ import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
import type { MailboxAutoReplySettings } from "./types";
import { updateMailboxAutoReply } from "./utils";
+import { Switch } from "../ui/switch";
const defaultSettings: MailboxAutoReplySettings = {
- enabled: false,
- subject: "Out of office",
- body: "",
+ enabled: false,
+ subject: "Out of office",
+ body: "",
};
export function MailboxAutoReplyForm() {
- const { selectedMailbox, setSelectedMailbox, isLoading } = useSelectedMailbox();
- const [settings, setSettings] = useState(defaultSettings);
- const [savedSettings, setSavedSettings] = useState(defaultSettings);
- const [status, setStatus] = useState<string | null>(null);
- const [saving, setSaving] = useState(false);
+ const { selectedMailbox, setSelectedMailbox, isLoading } =
+ useSelectedMailbox();
+ const [settings, setSettings] = useState(defaultSettings);
+ const [savedSettings, setSavedSettings] = useState(defaultSettings);
+ const [status, setStatus] = useState<string | null>(null);
+ const [saving, setSaving] = useState(false);
- useEffect(() => {
- const nextSettings = {
- enabled: selectedMailbox?.autoReplyEnabled ?? false,
- subject: selectedMailbox?.autoReplySubject ?? "Out of office",
- body: selectedMailbox?.autoReplyBody ?? "",
- };
- setSettings(nextSettings);
- setSavedSettings(nextSettings);
- setStatus(null);
- }, [
- selectedMailbox?.id,
- selectedMailbox?.autoReplyEnabled,
- selectedMailbox?.autoReplySubject,
- selectedMailbox?.autoReplyBody,
- ]);
+ useEffect(() => {
+ const nextSettings = {
+ enabled: selectedMailbox?.autoReplyEnabled ?? false,
+ subject: selectedMailbox?.autoReplySubject ?? "Out of office",
+ body: selectedMailbox?.autoReplyBody ?? "",
+ };
+ setSettings(nextSettings);
+ setSavedSettings(nextSettings);
+ setStatus(null);
+ }, [
+ selectedMailbox?.id,
+ selectedMailbox?.autoReplyEnabled,
+ selectedMailbox?.autoReplySubject,
+ selectedMailbox?.autoReplyBody,
+ ]);
- async function onSubmit(event: React.FormEvent<HTMLFormElement>) {
- event.preventDefault();
- if (!selectedMailbox) return;
- if (settings.enabled && !settings.body.trim()) {
- setStatus("Enter an auto-reply message before enabling it.");
- return;
- }
- setSaving(true);
- setStatus(null);
- try {
- const saved = await updateMailboxAutoReply(selectedMailbox.id, settings);
- setSettings(saved);
- setSavedSettings(saved);
- setSelectedMailbox({
- ...selectedMailbox,
- autoReplyEnabled: saved.enabled,
- autoReplySubject: saved.subject,
- autoReplyBody: saved.body,
- });
- setStatus("Saved");
- } catch (error) {
- setStatus(error instanceof Error ? error.message : "Failed to update auto-reply");
- } finally {
- setSaving(false);
- }
- }
+ async function onSubmit(event: React.FormEvent<HTMLFormElement>) {
+ event.preventDefault();
+ if (!selectedMailbox) return;
+ if (settings.enabled && !settings.body.trim()) {
+ setStatus("Enter an auto-reply message before enabling it.");
+ return;
+ }
+ setSaving(true);
+ setStatus(null);
+ try {
+ const saved = await updateMailboxAutoReply(selectedMailbox.id, settings);
+ setSettings(saved);
+ setSavedSettings(saved);
+ setSelectedMailbox({
+ ...selectedMailbox,
+ autoReplyEnabled: saved.enabled,
+ autoReplySubject: saved.subject,
+ autoReplyBody: saved.body,
+ });
+ setStatus("Saved");
+ } catch (error) {
+ setStatus(
+ error instanceof Error ? error.message : "Failed to update auto-reply",
+ );
+ } finally {
+ setSaving(false);
+ }
+ }
- if (isLoading) return <p className="text-sm text-neutral-500">Loading inbox…</p>;
- if (!selectedMailbox) return <p className="text-sm text-neutral-500">Select an inbox to configure auto-reply.</p>;
+ if (isLoading)
+ return <p className="text-sm text-neutral-500">Loading inbox…</p>;
+ if (!selectedMailbox)
+ return (
+ <p className="text-sm text-neutral-500">
+ Select an inbox to configure auto-reply.
+ </p>
+ );
- const address = `${selectedMailbox.localPart}@${selectedMailbox.hostname}`;
- const canManage = selectedMailbox.permission === "full_access";
- const changed = JSON.stringify(settings) !== JSON.stringify(savedSettings);
+ const address = `${selectedMailbox.localPart}@${selectedMailbox.hostname}`;
+ const canManage = selectedMailbox.permission === "full_access";
+ const changed = JSON.stringify(settings) !== JSON.stringify(savedSettings);
- return (
- <form onSubmit={onSubmit} className="space-y-4">
- <label className="flex items-start gap-3 rounded-xl bg-neutral-50 p-4">
- <Checkbox
- checked={settings.enabled}
- onChange={(event) => setSettings({ ...settings, enabled: event.target.checked })}
- disabled={!canManage || saving}
- />
- <span>
- <span className="block text-sm font-medium text-neutral-900">Enable auto-reply for {address}</span>
- <span className="mt-1 block text-sm text-neutral-500">
- Each sender receives at most one automatic response every 24 hours.
- </span>
- </span>
- </label>
- <div className="space-y-2">
- <Label htmlFor="autoReplySubject">Subject</Label>
- <Input
- id="autoReplySubject"
- value={settings.subject}
- onChange={(event) => setSettings({ ...settings, subject: event.target.value })}
- placeholder="Out of office"
- disabled={!canManage || saving}
- />
- </div>
- <div className="space-y-2">
- <Label htmlFor="autoReplyBody">Message</Label>
- <Textarea
- id="autoReplyBody"
- value={settings.body}
- onChange={(event) => setSettings({ ...settings, body: event.target.value })}
- placeholder="Thanks for your message. I am currently away and will reply when I return."
- rows={7}
- disabled={!canManage || saving}
- />
- </div>
- <div className="flex items-center gap-3">
- <Button type="submit" disabled={!canManage || saving || !changed}>
- {saving ? "Saving..." : "Save auto-reply"}
- </Button>
- {!canManage && <p className="text-sm text-neutral-500">Full access is required to edit auto-reply.</p>}
- {status && <p className="text-sm text-neutral-500">{status}</p>}
- </div>
- </form>
- );
+ return (
+ <form onSubmit={onSubmit} className="space-y-4">
+ <label className="flex items-start gap-3 rounded-xl bg-neutral-50 p-4">
+ <span className="flex-1">
+ <span className="block text-sm font-medium text-neutral-900">
+ Enable auto-reply for {address}
+ </span>
+ <span className="mt-1 block text-sm text-neutral-500">
+ Each sender receives at most one automatic response every 24 hours.
+ </span>
+ </span>
+
+ <Switch
+ checked={settings.enabled}
+ onCheckedChange={(enabled) => setSettings({ ...settings, enabled })}
+ disabled={!canManage || saving}
+ />
+ </label>
+ {settings.enabled && (
+ <>
+ <div className="space-y-2">
+ <Label htmlFor="autoReplySubject">Subject</Label>
+ <Input
+ id="autoReplySubject"
+ value={settings.subject}
+ onChange={(event) =>
+ setSettings({ ...settings, subject: event.target.value })
+ }
+ placeholder="Out of office"
+ disabled={!canManage || saving}
+ />
+ </div>
+ <div className="space-y-2">
+ <Label htmlFor="autoReplyBody">Message</Label>
+ <Textarea
+ id="autoReplyBody"
+ value={settings.body}
+ onChange={(event) =>
+ setSettings({ ...settings, body: event.target.value })
+ }
+ placeholder="Thanks for your message. I am currently away and will reply when I return."
+ rows={7}
+ disabled={!canManage || saving}
+ />
+ </div>
+ <div className="flex items-center gap-3">
+ <Button type="submit" disabled={!canManage || saving || !changed}>
+ {saving ? "Saving..." : "Save"}
+ </Button>
+ {!canManage && (
+ <p className="text-sm text-neutral-500">
+ Full access is required to edit auto-reply.
+ </p>
+ )}
+ {status && <p className="text-sm text-neutral-500">{status}</p>}
+ </div>
+ </>
+ )}
+ </form>
+ );
}
diff --git a/src/components/settings/profile-form.tsx b/src/components/settings/profile-form.tsx
index d598c6f..1adaead 100644
--- a/src/components/settings/profile-form.tsx
+++ b/src/components/settings/profile-form.tsx
@@ -5,77 +5,173 @@ import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { authFetch } from "@/lib/auth/client";
+import { ProfileAvatarForm } from "./profile-avatar-form";
import type { ProfileFormProps, ProfileFormResponse } from "./types";
-export function ProfileForm({ initialName, initialResetEmail, email }: ProfileFormProps) {
- const [name, setName] = useState(initialName);
- const [resetEmail, setResetEmail] = useState(initialResetEmail);
- const [savedName, setSavedName] = useState(initialName);
- const [savedResetEmail, setSavedResetEmail] = useState(initialResetEmail);
- const [status, setStatus] = useState<string | null>(null);
- const [loading, setLoading] = useState(false);
- const hasChanges =
- name.trim() !== savedName ||
- resetEmail.trim() !== savedResetEmail;
+export function ProfileForm({
+ initialName,
+ initialResetEmail,
+ email,
+}: ProfileFormProps) {
+ const [name, setName] = useState(initialName);
+ const [resetEmail, setResetEmail] = useState(initialResetEmail);
+ const [savedName, setSavedName] = useState(initialName);
+ const [savedResetEmail, setSavedResetEmail] = useState(initialResetEmail);
+ const [profileStatus, setProfileStatus] = useState<string | null>(null);
+ const [recoveryStatus, setRecoveryStatus] = useState<string | null>(null);
+ const [savingProfile, setSavingProfile] = useState(false);
+ const [savingRecovery, setSavingRecovery] = useState(false);
- async function onSubmit(event: React.FormEvent<HTMLFormElement>) {
- event.preventDefault();
- setLoading(true);
- setStatus(null);
+ async function saveProfile(nextName: string, nextResetEmail: string) {
+ try {
+ const res = await authFetch("/api/settings/profile", {
+ method: "PATCH",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ name: nextName, resetEmail: nextResetEmail }),
+ });
+ const data = (await res.json()) as ProfileFormResponse;
- try {
- const res = await authFetch("/api/settings/profile", {
- method: "PATCH",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ name, resetEmail }),
- });
- const data = (await res.json()) as ProfileFormResponse;
+ if (!res.ok) {
+ throw new Error(
+ typeof data.error === "string"
+ ? data.error
+ : "Failed to update account",
+ );
+ }
- if (!res.ok) {
- setStatus(typeof data.error === "string" ? data.error : "Failed to update account");
- return;
- }
+ const savedName = data.user?.name ?? nextName.trim();
+ const savedResetEmail = data.user?.resetEmail ?? "";
+ setName(savedName);
+ setResetEmail(savedResetEmail);
+ setSavedName(savedName);
+ setSavedResetEmail(savedResetEmail);
+ } catch (error) {
+ throw error instanceof Error
+ ? error
+ : new Error("Failed to update account");
+ }
+ }
- const nextName = data.user?.name ?? name.trim();
- const nextResetEmail = data.user?.resetEmail ?? "";
- setName(nextName);
- setResetEmail(nextResetEmail);
- setSavedName(nextName);
- setSavedResetEmail(nextResetEmail);
- setStatus("Saved");
- } catch (err) {
- setStatus(err instanceof Error ? err.message : "Failed to update account");
- } finally {
- setLoading(false);
- }
- }
+ async function onProfileSubmit(event: React.FormEvent<HTMLFormElement>) {
+ event.preventDefault();
+ setSavingProfile(true);
+ setProfileStatus(null);
+ try {
+ await saveProfile(name, savedResetEmail);
+ setProfileStatus("Saved");
+ } catch (error) {
+ setProfileStatus(
+ error instanceof Error ? error.message : "Failed to update account",
+ );
+ } finally {
+ setSavingProfile(false);
+ }
+ }
- return (
- <form onSubmit={onSubmit} className="space-y-4">
- <div className="space-y-2">
- <Label htmlFor="accountEmail">Current email</Label>
- <Input id="accountEmail" value={email} type="email" readOnly aria-readonly="true" className="bg-neutral-50" />
- </div>
- <div className="space-y-2">
- <Label htmlFor="name">Name</Label>
- <Input id="name" value={name} onChange={(event) => setName(event.target.value)} required />
- </div>
- <div className="space-y-2">
- <Label htmlFor="resetEmail">Recovery email</Label>
- <Input
- id="resetEmail"
- value={resetEmail}
- onChange={(event) => setResetEmail(event.target.value)}
- type="email"
- placeholder="[email protected]"
- />
- </div>
- <div className="flex items-center gap-3">
- <Button type="submit" disabled={loading || !hasChanges}>
- {loading ? "Saving..." : "Save"}
- </Button>
- {status && <p className="text-sm text-neutral-500">{status}</p>}
- </div>
- </form>
- );
+ async function onRecoverySubmit(event: React.FormEvent<HTMLFormElement>) {
+ event.preventDefault();
+ setSavingRecovery(true);
+ setRecoveryStatus(null);
+ try {
+ await saveProfile(savedName, resetEmail);
+ setRecoveryStatus("Saved");
+ } catch (error) {
+ setRecoveryStatus(
+ error instanceof Error
+ ? error.message
+ : "Failed to update recovery email",
+ );
+ } finally {
+ setSavingRecovery(false);
+ }
+ }
+
+ return (
+ <>
+ <form
+ onSubmit={onProfileSubmit}
+ className="space-y-6 rounded-b-lg rounded-t-3xl bg-white p-6"
+ >
+ <div className="flex items-center gap-4">
+ <ProfileAvatarForm name={name} />
+ <div>
+ <p className="text-sm font-medium text-neutral-900">
+ Profile picture
+ </p>
+ <p className="mt-1 text-sm text-neutral-500">
+ Choose a picture to show across your account.
+ </p>
+ </div>
+ </div>
+
+ <div className="space-y-2">
+ <Label htmlFor="name">Name</Label>
+ <Input
+ id="name"
+ value={name}
+ onChange={(event) => setName(event.target.value)}
+ required
+ />
+ </div>
+ <div className="space-y-2">
+ <Label htmlFor="accountEmail">Current email</Label>
+ <Input
+ id="accountEmail"
+ value={email}
+ type="email"
+ readOnly
+ aria-readonly="true"
+ className="bg-neutral-50"
+ />
+ </div>
+
+ <div className="flex items-center gap-3">
+ <Button
+ type="submit"
+ disabled={savingProfile || name.trim() === savedName}
+ >
+ {savingProfile ? "Saving..." : "Save profile"}
+ </Button>
+ {profileStatus && (
+ <p className="text-sm text-neutral-500">{profileStatus}</p>
+ )}
+ </div>
+ </form>
+
+ <form
+ onSubmit={onRecoverySubmit}
+ className="space-y-4 rounded-lg bg-white p-6"
+ >
+ <div>
+ <h3 className="text-lg font-semibold text-neutral-900">
+ Recovery email
+ </h3>
+ <p className="mt-1 text-sm text-neutral-500">
+ Used to recover access if you cannot sign in.
+ </p>
+ </div>
+ <div className="space-y-2">
+ <Label htmlFor="resetEmail">Email address</Label>
+ <Input
+ id="resetEmail"
+ value={resetEmail}
+ onChange={(event) => setResetEmail(event.target.value)}
+ type="email"
+ placeholder="[email protected]"
+ />
+ </div>
+ <div className="flex items-center gap-3">
+ <Button
+ type="submit"
+ disabled={savingRecovery || resetEmail.trim() === savedResetEmail}
+ >
+ {savingRecovery ? "Saving..." : "Save recovery email"}
+ </Button>
+ {recoveryStatus && (
+ <p className="text-sm text-neutral-500">{recoveryStatus}</p>
+ )}
+ </div>
+ </form>
+ </>
+ );
}
diff --git a/src/components/settings/settings-nav-utils.ts b/src/components/settings/settings-nav-utils.ts
index bda0d57..686930f 100644
--- a/src/components/settings/settings-nav-utils.ts
+++ b/src/components/settings/settings-nav-utils.ts
@@ -8,19 +8,19 @@ export const settingsNavSections: SettingsNavSection[] = [
href: "/settings/account",
label: "Account",
},
+ {
+ href: "/settings/auto-reply",
+ label: "Auto Reply",
+ },
{
href: "/settings/rules",
- label: "Rules",
+ label: "Rules & Routing",
},
],
},
{
label: "Mailbox",
items: [
- {
- href: "/settings/auto-reply",
- label: "Auto-Reply",
- },
{
href: "/settings/import",
label: "Import",
diff --git a/src/components/ui/tooltip-types.d.ts b/src/components/ui/tooltip-types.d.ts
index 9c01666..9b9689b 100644
--- a/src/components/ui/tooltip-types.d.ts
+++ b/src/components/ui/tooltip-types.d.ts
@@ -5,3 +5,8 @@ export type TooltipProps = {
children: ReactNode;
className?: string;
};
+
+export type TooltipPosition = {
+ left: number;
+ top: number;
+};
diff --git a/src/components/ui/tooltip-utils.ts b/src/components/ui/tooltip-utils.ts
new file mode 100644
index 0000000..7ab0fb0
--- /dev/null
+++ b/src/components/ui/tooltip-utils.ts
@@ -0,0 +1,27 @@
+import type { TooltipPosition } from "./tooltip-types";
+
+const TOOLTIP_GAP = 8;
+const VIEWPORT_PADDING = 8;
+
+export function getTooltipPosition(
+ trigger: HTMLElement,
+ tooltip: HTMLElement,
+): TooltipPosition {
+ const triggerRect = trigger.getBoundingClientRect();
+ const tooltipRect = tooltip.getBoundingClientRect();
+ const centeredLeft = triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2;
+ const left = Math.min(
+ Math.max(centeredLeft, VIEWPORT_PADDING),
+ window.innerWidth - tooltipRect.width - VIEWPORT_PADDING,
+ );
+ const fitsBelow =
+ window.innerHeight - triggerRect.bottom >= tooltipRect.height + TOOLTIP_GAP;
+ const top = fitsBelow
+ ? triggerRect.bottom + TOOLTIP_GAP
+ : triggerRect.top - tooltipRect.height - TOOLTIP_GAP;
+
+ return {
+ left,
+ top: Math.max(VIEWPORT_PADDING, top),
+ };
+}
diff --git a/src/components/ui/tooltip.tsx b/src/components/ui/tooltip.tsx
index 945eeaf..a8010f8 100644
--- a/src/components/ui/tooltip.tsx
+++ b/src/components/ui/tooltip.tsx
@@ -1,32 +1,65 @@
"use client";
import { cn } from "@/lib/utils";
-import { useState } from "react";
-import type { TooltipProps } from "./tooltip-types";
+import { useLayoutEffect, useRef, useState } from "react";
+import { createPortal } from "react-dom";
+import type { TooltipPosition, TooltipProps } from "./tooltip-types";
+import { getTooltipPosition } from "./tooltip-utils";
export function Tooltip({ label, children, className }: TooltipProps) {
- const [dismissed, setDismissed] = useState(false);
+ const [open, setOpen] = useState(false);
+ const [position, setPosition] = useState<TooltipPosition | null>(null);
+ const triggerRef = useRef<HTMLSpanElement>(null);
+ const tooltipRef = useRef<HTMLSpanElement>(null);
+
+ useLayoutEffect(() => {
+ if (!open) return;
+
+ function updatePosition() {
+ if (!triggerRef.current || !tooltipRef.current) return;
+ setPosition(getTooltipPosition(triggerRef.current, tooltipRef.current));
+ }
+
+ updatePosition();
+ window.addEventListener("resize", updatePosition);
+ window.addEventListener("scroll", updatePosition, true);
+
+ return () => {
+ window.removeEventListener("resize", updatePosition);
+ window.removeEventListener("scroll", updatePosition, true);
+ };
+ }, [label, open]);
return (
<span
- className={cn("group/tooltip relative inline-flex", className)}
- onFocusCapture={() => setDismissed(false)}
- onMouseLeave={() => setDismissed(false)}
+ ref={triggerRef}
+ className={cn("inline-flex", className)}
+ onFocusCapture={() => setOpen(true)}
+ onBlurCapture={() => setOpen(false)}
+ onMouseEnter={() => setOpen(true)}
+ onMouseLeave={() => setOpen(false)}
onClickCapture={() => {
- setDismissed(true);
+ setOpen(false);
if (document.activeElement instanceof HTMLElement) document.activeElement.blur();
}}
>
{children}
- <span
- role="tooltip"
- className={cn(
- "pointer-events-none absolute left-1/2 top-full z-50 mt-2 -translate-x-1/2 whitespace-nowrap rounded-md bg-neutral-900 px-2 py-1 text-xs font-medium text-white opacity-0 shadow-lg transition-opacity delay-150",
- !dismissed && "group-hover/tooltip:opacity-100 group-focus-within/tooltip:opacity-100",
+ {open && typeof document !== "undefined" &&
+ createPortal(
+ <span
+ ref={tooltipRef}
+ role="tooltip"
+ className="pointer-events-none fixed z-[100] max-w-[min(20rem,calc(100vw-1rem))] rounded-md bg-neutral-900 px-2 py-1 text-center text-xs font-medium text-white shadow-lg"
+ style={{
+ left: position?.left ?? 0,
+ top: position?.top ?? 0,
+ visibility: position ? "visible" : "hidden",
+ }}
+ >
+ {label}
+ </span>,
+ document.body,
)}
- >
- {label}
- </span>
</span>
);
}