Files
superbrain/web/app/unsubscribe/client.tsx
T
Andrew S Erwin e8f04a4082
release gate / check (push) Canceled after 2m9s
Brand icon: replace the LinkOS-era placeholders with the real Superbrain mark
The favicon was a purple block placeholder and og-image.png still said
"LinkOS — Connect Everything"; every brand surface (sidebar, login,
signup, forgot/reset password, unsubscribe) drew a generic Link2 glyph in
a primary-colored square instead of the logo.

Assets (from the operator's superbrain-icon.svg/png):
- public/favicon.svg: the real mark, with the multi-KB C2PA provenance
  manifest stripped (graphics, gradients and filters verified intact via
  rsvg-convert at tab size).
- public/superbrain-icon.png: the 1024px RGBA asset; also wired as the
  apple-touch icon in the root metadata.
- public/og-image.png: recomposed 1200x630 banner — mark + Superbrain
  wordmark + tagline on the brand's deep-blue gradient.

Surfaces: new components/brand-icon.tsx is the single source for the mark
(one img, transparent rounded corners); sidebar brand, all auth pages,
all three unsubscribe states and the help header now use it. State icons
(Check/BellOff) and unused Link2 imports removed where the mark replaced
them; Link2 stays where it is a nav glyph (All Bookmarks).

Verified: web lint/SSR-lint/build 0 errors; full browser regressions pass
(login, mobile shell overflow checks and sign-out flows included).
2026-11-21 23:52:28 -06:00

122 lines
4.9 KiB
TypeScript

'use client'
import { useState } from 'react'
import { useSearchParams } from 'next/navigation'
import { Button } from '@/components/ui/button'
import { BrandIcon } from '@/components/brand-icon'
import Link from 'next/link'
import { toast } from 'sonner'
// The token in the link IS the credential (HMAC-signed user id, issued only
// in mail to the owner's own address). The page never needs a session; the
// Go endpoint validates the token and disables email notification channels
// plus self-addressed agent email tasks. Transactional mail (password
// resets) keeps flowing — the copy must say so.
export function UnsubscribeClient() {
const params = useSearchParams()
const token = params.get('token') ?? ''
const [loading, setLoading] = useState(false)
const [done, setDone] = useState(false)
const [invalid, setInvalid] = useState(false)
const handleUnsubscribe = async () => {
setLoading(true)
try {
const res = await fetch('/api/notifications/unsubscribe', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ token }),
})
const data = await res.json().catch(() => null)
if (res.ok && data?.ok) {
setDone(true)
} else if (res.status === 400) {
setInvalid(true)
} else {
toast.error(data?.error ?? 'Could not unsubscribe right now')
}
} catch {
toast.error('Could not unsubscribe right now')
}
setLoading(false)
}
if (!token || invalid) {
return (
<div className="min-h-screen flex items-center justify-center bg-background p-4">
<div className="w-full max-w-sm space-y-8 text-center">
<div className="flex justify-center mb-4">
<BrandIcon className="h-14 w-14" />
</div>
<h1 className="font-display text-3xl font-bold tracking-tight">Invalid Link</h1>
<p className="text-sm text-muted-foreground mt-2">
This unsubscribe link is invalid or has expired. Open Settings → Notifications
in the app to manage your email preferences directly.
</p>
<p className="text-center text-xs text-muted-foreground">
<Link href="/settings?tab=notifications" className="text-primary hover:underline">Email preferences</Link>
{' · '}
<Link href="/help" className="text-primary hover:underline">Help center</Link>
{' · '}
<Link href="/login" className="text-primary hover:underline">Back to sign in</Link>
</p>
</div>
</div>
)
}
if (done) {
return (
<div className="min-h-screen flex items-center justify-center bg-background p-4">
<div className="w-full max-w-sm space-y-8 text-center">
<div className="flex justify-center mb-4">
<BrandIcon className="h-14 w-14" />
</div>
<h1 className="font-display text-3xl font-bold tracking-tight">You&apos;re Unsubscribed</h1>
<p className="text-sm text-muted-foreground mt-2">
Notification emails and automations that email you have been turned off.
You can re-enable them anytime in Settings → Notifications. Account emails
such as password resets are not affected.
</p>
<p className="text-center text-xs text-muted-foreground">
<Link href="/settings?tab=notifications" className="text-primary hover:underline">Email preferences</Link>
{' · '}
<Link href="/help" className="text-primary hover:underline">Help center</Link>
{' · '}
<Link href="/login" className="text-primary hover:underline">Back to sign in</Link>
</p>
</div>
</div>
)
}
return (
<div className="min-h-screen flex items-center justify-center bg-background p-4">
<div className="w-full max-w-sm space-y-8">
<div className="text-center">
<div className="flex justify-center mb-4">
<BrandIcon className="h-14 w-14" />
</div>
<h1 className="font-display text-3xl font-bold tracking-tight">Unsubscribe</h1>
<p className="text-sm text-muted-foreground mt-2">
Stop notification emails and automations that email you. Password resets and
other account emails keep working, and you can re-enable notifications anytime
in Settings.
</p>
</div>
<div className="space-y-3">
<Button className="w-full" onClick={handleUnsubscribe} loading={loading}>
Unsubscribe from notification emails
</Button>
<Button variant="outline" className="w-full" asChild>
<Link href="/settings?tab=notifications">Keep my current preferences</Link>
</Button>
</div>
<p className="text-center text-xs text-muted-foreground">
<Link href="/help" className="text-primary hover:underline">Help center</Link>
</p>
</div>
</div>
)
}