'use client';
import {
LaptopIcon,
MonitorIcon,
SmartphoneIcon,
TriangleAlertIcon,
} from 'lucide-react';
import { useState } from 'react';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from '@/components/ui/card';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
import { Separator } from '@/components/ui/separator';
import { Switch } from '@/components/ui/switch';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { Textarea } from '@/components/ui/textarea';
const sessions = [
{
device: 'MacBook Pro 14” · Safari',
location: 'Stockholm, Sweden',
lastActive: 'Active now',
current: true,
icon: LaptopIcon,
},
{
device: 'iPhone 15 · Beacon for iOS',
location: 'Stockholm, Sweden',
lastActive: '2 hours ago',
current: false,
icon: SmartphoneIcon,
},
{
device: 'Windows 11 · Edge',
location: 'Gothenburg, Sweden',
lastActive: 'Oct 21, 2026',
current: false,
icon: MonitorIcon,
},
];
const notificationGroups = [
{
id: 'mentions',
title: 'Mentions',
description: 'Someone @mentions you in an issue or comment.',
email: true,
push: true,
},
{
id: 'assignments',
title: 'Assignments',
description: 'An issue is assigned to you or re-assigned away from you.',
email: true,
push: true,
},
{
id: 'comments',
title: 'Comments',
description: 'New comments on issues you created or are subscribed to.',
email: false,
push: true,
},
{
id: 'digest',
title: 'Weekly digest',
description: 'A Monday summary of what moved across your projects.',
email: true,
push: false,
},
];
const members = [
{ name: 'Daniel Achterberg', role: 'Admin', slug: 'daniel-achterberg' },
{ name: 'Maja Lindgren', role: 'Member', slug: 'maja-lindgren' },
{ name: 'Priya Raman', role: 'Member', slug: 'priya-raman' },
{ name: 'Oskar Berg', role: 'Member', slug: 'oskar-berg' },
];
const timezones = [
{ label: '(GMT+01:00) Stockholm', value: 'stockholm' },
{ label: '(GMT+00:00) London', value: 'london' },
{ label: '(GMT+01:00) Berlin', value: 'berlin' },
{ label: '(GMT−05:00) New York', value: 'newyork' },
{ label: '(GMT+09:00) Tokyo', value: 'tokyo' },
];
const projects = [
{ label: 'Orbit Mobile Relaunch', value: 'orbit' },
{ label: 'Billing v2', value: 'billing' },
{ label: 'Design System', value: 'design' },
];
const initials = (name: string) =>
name
.split(' ')
.map((part) => part[0])
.join('');
/**
* Settings page with horizontal Tabs (Profile / Security / Notifications / Workspace) under a page header; each panel is a stack of Cards whose footers hold the Save/Cancel actions.
*/
export default function Settings01() {
const [twoFactor, setTwoFactor] = useState(true);
return (
<div className="w-full max-w-4xl px-4 py-8 sm:py-12">
<div className="space-y-1.5">
<h1 className="font-semibold text-2xl text-foreground tracking-tight">
Settings
</h1>
<p className="text-muted-foreground text-sm text-pretty">
Manage your Beacon profile, security preferences and how Aurora Labs
keeps you in the loop.
</p>
</div>
<Tabs className="mt-8 gap-6" defaultValue="profile">
<TabsList>
<TabsTrigger value="profile">Profile</TabsTrigger>
<TabsTrigger value="security">Security</TabsTrigger>
<TabsTrigger value="notifications">Notifications</TabsTrigger>
<TabsTrigger value="workspace">Workspace</TabsTrigger>
</TabsList>
{/* Profile */}
<TabsContent className="space-y-6" value="profile">
<form onSubmit={(e) => e.preventDefault()}>
<Card>
<CardHeader>
<CardTitle>Profile</CardTitle>
<CardDescription>
This is how teammates see you in issues, comments and mentions.
</CardDescription>
</CardHeader>
<CardContent className="space-y-6">
<div className="flex items-center gap-4">
<Avatar className="size-16">
<AvatarImage
alt="Maja Lindgren"
src="https://avatar.vercel.sh/maja-lindgren"
/>
<AvatarFallback>ML</AvatarFallback>
</Avatar>
<div className="space-y-2">
<div className="flex gap-2">
<Button size="sm" type="button" variant="outline">
Change photo
</Button>
<Button
className="text-muted-foreground"
size="sm"
type="button"
variant="ghost"
>
Remove
</Button>
</div>
<p className="text-muted-foreground text-xs">
JPG, PNG or GIF · max. 2 MB
</p>
</div>
</div>
<div className="grid gap-4 sm:grid-cols-2">
<div className="space-y-1.5">
<Label htmlFor="settings01-name">Full name</Label>
<Input
autoComplete="name"
defaultValue="Maja Lindgren"
id="settings01-name"
name="name"
/>
</div>
<div className="space-y-1.5">
<Label htmlFor="settings01-email">Email</Label>
<Input
autoComplete="email"
defaultValue="maja@auroralabs.io"
id="settings01-email"
name="email"
type="email"
/>
</div>
<div className="space-y-1.5">
<Label htmlFor="settings01-username">Username</Label>
<Input
autoComplete="username"
defaultValue="maja"
id="settings01-username"
name="username"
/>
<p className="text-muted-foreground text-xs">
People can mention you with @maja.
</p>
</div>
<div className="space-y-1.5">
<Label htmlFor="settings01-timezone">Timezone</Label>
<Select
defaultValue="stockholm"
items={timezones}
name="timezone"
>
<SelectTrigger className="w-full" id="settings01-timezone">
<SelectValue />
</SelectTrigger>
<SelectContent alignItemWithTrigger={false}>
{timezones.map((timezone) => (
<SelectItem key={timezone.value} value={timezone.value}>
{timezone.label}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
<div className="space-y-1.5 sm:col-span-2">
<Label htmlFor="settings01-bio">Bio</Label>
<Textarea
className="min-h-24 resize-none"
defaultValue="Product Manager for Orbit Mobile at Aurora Labs. I care about release notes people actually read."
id="settings01-bio"
name="bio"
/>
<p className="text-muted-foreground text-xs">
Shown on your profile card. 160 characters max.
</p>
</div>
</div>
</CardContent>
<CardFooter className="justify-end gap-2 border-t">
<Button type="button" variant="ghost">
Cancel
</Button>
<Button type="submit">Save changes</Button>
</CardFooter>
</Card>
</form>
</TabsContent>
{/* Security */}
<TabsContent className="space-y-6" value="security">
<form onSubmit={(e) => e.preventDefault()}>
<Card>
<CardHeader>
<CardTitle>Change password</CardTitle>
<CardDescription>
Use at least 12 characters. You will stay signed in on this
device.
</CardDescription>
</CardHeader>
<CardContent className="grid gap-4 sm:grid-cols-2">
<div className="space-y-1.5 sm:col-span-2">
<Label htmlFor="settings01-current">Current password</Label>
<Input
autoComplete="current-password"
id="settings01-current"
name="currentPassword"
type="password"
/>
</div>
<div className="space-y-1.5">
<Label htmlFor="settings01-new">New password</Label>
<Input
autoComplete="new-password"
id="settings01-new"
name="newPassword"
type="password"
/>
</div>
<div className="space-y-1.5">
<Label htmlFor="settings01-confirm">Confirm new password</Label>
<Input
autoComplete="new-password"
id="settings01-confirm"
name="confirmPassword"
type="password"
/>
</div>
</CardContent>
<CardFooter className="justify-end gap-2 border-t">
<Button type="button" variant="ghost">
Cancel
</Button>
<Button type="submit">Update password</Button>
</CardFooter>
</Card>
</form>
<Card>
<CardHeader>
<CardTitle>Two-factor authentication</CardTitle>
<CardDescription>
Add a second step when signing in from a new device.
</CardDescription>
</CardHeader>
<CardContent>
<div className="flex items-center justify-between gap-4 rounded-lg border p-4">
<div className="space-y-1">
<div className="flex items-center gap-2">
<Label htmlFor="settings01-2fa">Authenticator app</Label>
<Badge
className={
twoFactor
? 'border-transparent bg-chart-2/15 text-chart-2'
: undefined
}
variant={twoFactor ? 'outline' : 'secondary'}
>
{twoFactor ? 'Enabled' : 'Off'}
</Badge>
</div>
<p className="text-muted-foreground text-sm">
{twoFactor
? 'Codes from your authenticator app are required on new devices.'
: 'Turn on to require a 6-digit code at sign-in.'}
</p>
</div>
<Switch
aria-label="Toggle two-factor authentication"
checked={twoFactor}
id="settings01-2fa"
onCheckedChange={setTwoFactor}
/>
</div>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle>Active sessions</CardTitle>
<CardDescription>
Devices currently signed in to your account.
</CardDescription>
</CardHeader>
<CardContent>
<ul className="divide-y rounded-lg border">
{sessions.map((session) => (
<li
className="flex items-center gap-4 p-4"
key={session.device}
>
<span className="flex size-9 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground">
<session.icon aria-hidden="true" className="size-4" />
</span>
<div className="min-w-0 flex-1">
<div className="flex items-center gap-2">
<p className="truncate font-medium text-foreground text-sm">
{session.device}
</p>
{session.current ? (
<Badge variant="secondary">This device</Badge>
) : null}
</div>
<p className="text-muted-foreground text-xs tabular-nums">
{session.location} · {session.lastActive}
</p>
</div>
<Button
disabled={session.current}
size="sm"
type="button"
variant="outline"
>
Revoke
</Button>
</li>
))}
</ul>
</CardContent>
<CardFooter className="justify-end border-t">
<Button type="button" variant="ghost">
Sign out of all other sessions
</Button>
</CardFooter>
</Card>
<Card className="border-destructive/40">
<CardHeader>
<CardTitle className="flex items-center gap-2 text-destructive">
<TriangleAlertIcon aria-hidden="true" className="size-4" />
Danger zone
</CardTitle>
<CardDescription>
Deleting your account removes you from Aurora Labs and
unassigns your 23 open issues. This cannot be undone.
</CardDescription>
</CardHeader>
<CardFooter className="justify-between gap-4 border-t">
<p className="text-muted-foreground text-sm">
Member since Mar 3, 2024
</p>
<Button type="button" variant="destructive">
Delete account
</Button>
</CardFooter>
</Card>
</TabsContent>
{/* Notifications */}
<TabsContent value="notifications">
<form onSubmit={(e) => e.preventDefault()}>
<Card>
<CardHeader>
<CardTitle>Notifications</CardTitle>
<CardDescription>
Choose which events reach you by email and push. In-app
notifications are always on.
</CardDescription>
</CardHeader>
<CardContent>
<div className="hidden grid-cols-[1fr_5rem_5rem] px-4 pb-2 text-muted-foreground text-xs sm:grid">
<span>Event</span>
<span className="text-center">Email</span>
<span className="text-center">Push</span>
</div>
<ul className="divide-y rounded-lg border">
{notificationGroups.map((group) => (
<li
className="grid gap-3 p-4 sm:grid-cols-[1fr_5rem_5rem] sm:items-center"
key={group.id}
>
<div className="space-y-0.5">
<p className="font-medium text-foreground text-sm">
{group.title}
</p>
<p className="text-muted-foreground text-sm text-pretty">
{group.description}
</p>
</div>
<div className="flex items-center gap-2 sm:justify-center">
<Switch
aria-label={`${group.title} by email`}
defaultChecked={group.email}
id={`settings01-${group.id}-email`}
name={`${group.id}Email`}
/>
<Label
className="font-normal text-muted-foreground sm:sr-only"
htmlFor={`settings01-${group.id}-email`}
>
Email
</Label>
</div>
<div className="flex items-center gap-2 sm:justify-center">
<Switch
aria-label={`${group.title} by push`}
defaultChecked={group.push}
id={`settings01-${group.id}-push`}
name={`${group.id}Push`}
/>
<Label
className="font-normal text-muted-foreground sm:sr-only"
htmlFor={`settings01-${group.id}-push`}
>
Push
</Label>
</div>
</li>
))}
</ul>
<Separator className="my-6" />
<div className="flex items-center justify-between gap-4">
<div className="space-y-0.5">
<Label htmlFor="settings01-quiet">Quiet hours</Label>
<p className="text-muted-foreground text-sm">
Pause push notifications from 19:00 to 08:00 on weekdays.
</p>
</div>
<Switch defaultChecked id="settings01-quiet" name="quietHours" />
</div>
</CardContent>
<CardFooter className="justify-end gap-2 border-t">
<Button type="button" variant="ghost">
Cancel
</Button>
<Button type="submit">Save preferences</Button>
</CardFooter>
</Card>
</form>
</TabsContent>
{/* Workspace */}
<TabsContent className="space-y-6" value="workspace">
<form onSubmit={(e) => e.preventDefault()}>
<Card>
<CardHeader>
<CardTitle>Workspace</CardTitle>
<CardDescription>
Settings that apply to everyone in Aurora Labs.
</CardDescription>
</CardHeader>
<CardContent className="grid gap-4 sm:grid-cols-2">
<div className="space-y-1.5">
<Label htmlFor="settings01-ws-name">Workspace name</Label>
<Input
autoComplete="organization"
defaultValue="Aurora Labs"
id="settings01-ws-name"
name="workspaceName"
/>
</div>
<div className="space-y-1.5">
<Label htmlFor="settings01-ws-slug">Workspace URL</Label>
<div className="flex items-center">
<span className="flex h-9 items-center rounded-l-md border border-r-0 bg-muted px-3 text-muted-foreground text-sm">
beacon.app/
</span>
<Input
autoComplete="off"
className="rounded-l-none"
defaultValue="aurora-labs"
id="settings01-ws-slug"
name="workspaceSlug"
/>
</div>
</div>
<div className="space-y-1.5">
<Label htmlFor="settings01-ws-key">Issue key prefix</Label>
<Input
autoComplete="off"
className="uppercase tabular-nums"
defaultValue="AUR"
id="settings01-ws-key"
maxLength={4}
name="issuePrefix"
/>
<p className="text-muted-foreground text-xs">
Next issue will be AUR-163.
</p>
</div>
<div className="space-y-1.5">
<Label htmlFor="settings01-ws-project">Default project</Label>
<Select
defaultValue="orbit"
items={projects}
name="defaultProject"
>
<SelectTrigger className="w-full" id="settings01-ws-project">
<SelectValue />
</SelectTrigger>
<SelectContent alignItemWithTrigger={false}>
{projects.map((project) => (
<SelectItem key={project.value} value={project.value}>
{project.label}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
</CardContent>
<CardFooter className="justify-end gap-2 border-t">
<Button type="button" variant="ghost">
Cancel
</Button>
<Button type="submit">Save changes</Button>
</CardFooter>
</Card>
</form>
<Card>
<CardHeader>
<CardTitle>Members</CardTitle>
<CardDescription>
6 of 10 seats used on the Team plan.
</CardDescription>
</CardHeader>
<CardContent>
<ul className="divide-y rounded-lg border">
{members.map((member) => (
<li
className="flex items-center gap-3 p-3"
key={member.slug}
>
<Avatar className="size-8">
<AvatarImage
alt={member.name}
src={`https://avatar.vercel.sh/${member.slug}`}
/>
<AvatarFallback className="text-xs">
{initials(member.name)}
</AvatarFallback>
</Avatar>
<p className="min-w-0 flex-1 truncate font-medium text-foreground text-sm">
{member.name}
{member.slug === 'maja-lindgren' ? (
<span className="font-normal text-muted-foreground">
{' '}
(you)
</span>
) : null}
</p>
<Badge
variant={member.role === 'Admin' ? 'default' : 'outline'}
>
{member.role}
</Badge>
</li>
))}
</ul>
</CardContent>
<CardFooter className="justify-between gap-4 border-t">
<a
className="text-muted-foreground text-sm underline-offset-4 hover:underline"
href="#"
>
View all 6 members
</a>
<Button type="button" variant="outline">
Invite member
</Button>
</CardFooter>
</Card>
</TabsContent>
</Tabs>
</div>
);
}