Connect, collaborate, and grow with a community of TypeScript developers
feat: settings page enhancements mock (#595)
Soodit Kumar3003e89767ba
diff --git a/apps/web/src/app/[locale]/settings/_components/appearance.tsx b/apps/web/src/app/[locale]/settings/_components/appearance.tsxnew file mode 100644index 00000000..e83df436--- /dev/null+++ b/apps/web/src/app/[locale]/settings/_components/appearance.tsx@@ -0,0 +1,187 @@+'use client';++import { zodResolver } from '@hookform/resolvers/zod';+import type { User } from '@repo/db/types';+import { Button } from '@repo/ui/components/button';+import {+ Form,+ FormControl,+ FormDescription,+ FormField,+ FormItem,+ FormLabel,+ FormMessage,+} from '@repo/ui/components/form';+import { RadioGroup, RadioGroupItem } from '@repo/ui/components/radio-group';+import {+ Select,+ SelectContent,+ SelectGroup,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from '@repo/ui/components/select';+import { Separator } from '@repo/ui/components/separator';+import { useToast } from '@repo/ui/components/use-toast';+import { ChevronDown } from '@repo/ui/icons';+import { useForm } from 'react-hook-form';+import { z } from 'zod';++interface Props {+ user: User & { userLinks: { id: string | null; url: string }[] };+}++export function Appearances({ user }: Props) {+ return (+ <div className="max-w-lg space-y-6 p-8">+ <div className="mb-4">+ <h3 className="text-lg font-medium">Notifications</h3>+ <p className="text-muted-foreground mb-4 text-sm">+ Configure how you receive notifications.+ </p>+ <Separator />+ </div>+ <AppearanceForm />+ </div>+ );+}++const appearanceFormSchema = z.object({+ theme: z.enum(['light', 'dark'], {+ required_error: 'Please select a theme.',+ }),+ font: z.enum(['inter', 'manrope', 'system'], {+ invalid_type_error: 'Select a font',+ required_error: 'Please select a font.',+ }),+});++type AppearanceFormValues = z.infer<typeof appearanceFormSchema>;++// This can come from your database or API.+const defaultValues: Partial<AppearanceFormValues> = {+ theme: 'light',+};++export function AppearanceForm() {+ const { toast } = useToast();+ const form = useForm<AppearanceFormValues>({+ resolver: zodResolver(appearanceFormSchema),+ defaultValues,+ });++ function onSubmit(data: AppearanceFormValues) {+ toast({+ title: 'You submitted the following values:',+ description: (+ <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">+ <code className="text-white">{JSON.stringify(data, null, 2)}</code>+ </pre>+ ),+ });+ }++ return (+ <Form {...form}>+ <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">+ <FormField+ control={form.control}+ name="font"+ render={({ field }) => (+ <FormItem>+ <div className="relative w-max">+ <FormControl>+ <Select+ defaultValue={field.value}+ onValueChange={field.onChange as (event: string) => void}+ >+ <SelectTrigger className="w-[180px]">+ <SelectValue placeholder="Select a font" />+ </SelectTrigger>+ <SelectContent>+ <SelectGroup>+ <SelectItem value="inter">Inter</SelectItem>+ <SelectItem value="manrope">Manrope</SelectItem>+ <SelectItem value="system">System</SelectItem>+ </SelectGroup>+ </SelectContent>+ </Select>+ </FormControl>+ <ChevronDown className="absolute right-3 top-2.5 h-4 w-4 opacity-50" />+ </div>+ <FormDescription>Set the font you want to use in the dashboard.</FormDescription>+ <FormMessage />+ </FormItem>+ )}+ />+ <FormField+ control={form.control}+ name="theme"+ render={({ field }) => (+ <FormItem className="space-y-1">+ <FormLabel>Theme</FormLabel>+ <FormDescription>Select the theme for the dashboard.</FormDescription>+ <FormMessage />+ <RadioGroup+ onValueChange={(e: 'dark' | 'light') => field.onChange(e)}+ defaultValue={field.value}+ className="grid max-w-md grid-cols-2 gap-8 pt-2"+ >+ <FormItem>+ <FormLabel className="[&:has([data-state=checked])>div]:border-primary">+ <FormControl>+ <RadioGroupItem value="light" className="sr-only" />+ </FormControl>+ <div className="border-muted hover:border-accent items-center rounded-md border-2 p-1">+ <div className="space-y-2 rounded-sm bg-[#ecedef] p-2">+ <div className="space-y-2 rounded-md bg-white p-2 shadow-sm">+ <div className="h-2 w-[80px] rounded-lg bg-[#ecedef]" />+ <div className="h-2 w-[100px] rounded-lg bg-[#ecedef]" />+ </div>+ <div className="flex items-center space-x-2 rounded-md bg-white p-2 shadow-sm">+ <div className="h-4 w-4 rounded-full bg-[#ecedef]" />+ <div className="h-2 w-[100px] rounded-lg bg-[#ecedef]" />+ </div>+ <div className="flex items-center space-x-2 rounded-md bg-white p-2 shadow-sm">+ <div className="h-4 w-4 rounded-full bg-[#ecedef]" />+ <div className="h-2 w-[100px] rounded-lg bg-[#ecedef]" />+ </div>+ </div>+ </div>+ <span className="block w-full p-2 text-center font-normal">Light</span>+ </FormLabel>+ </FormItem>+ <FormItem>+ <FormLabel className="[&:has([data-state=checked])>div]:border-primary">+ <FormControl>+ <RadioGroupItem value="dark" className="sr-only" />+ </FormControl>+ <div className="border-muted bg-popover hover:bg-accent hover:text-accent-foreground items-center rounded-md border-2 p-1">+ <div className="space-y-2 rounded-sm bg-slate-950 p-2">+ <div className="space-y-2 rounded-md bg-slate-800 p-2 shadow-sm">+ <div className="h-2 w-[80px] rounded-lg bg-slate-400" />+ <div className="h-2 w-[100px] rounded-lg bg-slate-400" />+ </div>+ <div className="flex items-center space-x-2 rounded-md bg-slate-800 p-2 shadow-sm">+ <div className="h-4 w-4 rounded-full bg-slate-400" />+ <div className="h-2 w-[100px] rounded-lg bg-slate-400" />+ </div>+ <div className="flex items-center space-x-2 rounded-md bg-slate-800 p-2 shadow-sm">+ <div className="h-4 w-4 rounded-full bg-slate-400" />+ <div className="h-2 w-[100px] rounded-lg bg-slate-400" />+ </div>+ </div>+ </div>+ <span className="block w-full p-2 text-center font-normal">Dark</span>+ </FormLabel>+ </FormItem>+ </RadioGroup>+ </FormItem>+ )}+ />++ <Button type="submit">Update preferences</Button>+ </form>+ </Form>+ );+}diff --git a/apps/web/src/app/[locale]/settings/_components/new-settings.tsx b/apps/web/src/app/[locale]/settings/_components/new-settings.tsxnew file mode 100644index 00000000..28a1bf6a--- /dev/null+++ b/apps/web/src/app/[locale]/settings/_components/new-settings.tsx@@ -0,0 +1,113 @@+'use client';++import type { User } from '@repo/db/types';+import {+ Tabs,+ VerticalTabsContent,+ VerticalTabsList,+ VerticalTabsTrigger,+} from '@repo/ui/components/tabs';+import { Card } from '@repo/ui/components/card';+import { BellRing, Brush, Settings2, Shapes } from '@repo/ui/icons';+import Link from 'next/link';+import { getRelativeTime } from '~/utils/relativeTime';+import { ProfileSettings } from './profile';+import { Notifications } from './notifications';+import { Appearances } from './appearance';+import { usePathname } from 'next/navigation';+import UserHeader from '../../[username]/_components/dashboard/user-header';++interface Props {+ user: User & { userLinks: { id: string | null; url: string }[] };+}++export const links = [+ {+ icon: Settings2,+ name: 'Profile',+ link: '/settings',+ disabled: false,+ },+ {+ icon: Shapes,+ name: 'Connections',+ link: '/settings/connections',+ disabled: true,+ },+ {+ icon: BellRing,+ name: 'Notifications',+ link: '/settings/notifications',+ disabled: false,+ },+ {+ icon: Brush,+ name: 'Appearance',+ link: '/settings/appearance',+ disabled: false,+ },+];++export const NewSettings = ({ user }: Props) => {+ const path = usePathname();+ let selectedTabValue: string;+ if (path === '/settings') {+ selectedTabValue = 'profile';+ } else if (path === '/settings/connections') {+ selectedTabValue = 'connections';+ } else if (path === '/settings/notifications') {+ selectedTabValue = 'notifications';+ } else if (path === '/settings/appearance') {+ selectedTabValue = 'appearance';+ } else {+ // TODO: 404+ selectedTabValue = 'profile';+ }+ return (+ <div className="container">+ <Tabs className="flex flex-col gap-8 py-8 md:flex-row" defaultValue={selectedTabValue}>+ <VerticalTabsList>+ <div className="mb-2 flex flex-col items-center md:items-start">+ <div+ className="mb-10 h-32 w-32 rounded-3xl bg-cover bg-center bg-no-repeat md:h-64 md:w-64"+ style={{ backgroundImage: `url(${user.image ?? '/avatar.jpeg'})` }}+ />+ <UserHeader user={user} isOwnProfile />+ <p+ className="text-sm italic tracking-tight text-neutral-500"+ title={`Joined ${user.createdAt.toString()}`}+ >+ Joined {getRelativeTime(user.createdAt)}+ </p>+ <div className="mb-4 mt-2 w-full text-center text-sm md:w-64 md:text-start">+ {user.bio}+ </div>+ </div>+ <div className="flex gap-4 pr-6 md:flex-col">+ {links.map(({ icon: Icon, name, link, disabled }) => (+ <Link href={link} key={name} className="w-full">+ <VerticalTabsTrigger+ className="flex w-full items-center justify-center gap-3 px-2 md:justify-normal md:px-3"+ value={name.toLowerCase()}+ key={name}+ disabled={disabled}+ >+ <Icon className="h-4 w-4" />+ <span className="hidden md:block">{name}</span>+ </VerticalTabsTrigger>+ </Link>+ ))}+ </div>+ </VerticalTabsList>+ <VerticalTabsContent className="shrink grow space-y-4" value={selectedTabValue}>+ <Card className="col-span-4 min-h-[calc(100vh_-_56px_-_6rem)]">+ {selectedTabValue === 'profile' && <ProfileSettings user={user} />}+ {selectedTabValue === 'connections' && <div>Connections</div>}+ {selectedTabValue === 'notifications' && <Notifications user={user} />}+ {selectedTabValue === 'appearance' && <Appearances user={user} />}+ </Card>+ </VerticalTabsContent>+ </Tabs>+ </div>+ );+};diff --git a/apps/web/src/app/[locale]/settings/_components/notifications.tsx b/apps/web/src/app/[locale]/settings/_components/notifications.tsxnew file mode 100644index 00000000..c5cc39ab--- /dev/null+++ b/apps/web/src/app/[locale]/settings/_components/notifications.tsx@@ -0,0 +1,222 @@+'use client';++import { zodResolver } from '@hookform/resolvers/zod';+import type { User } from '@repo/db/types';+import { Separator } from '@repo/ui/components/separator';+import { Checkbox } from '@repo/ui/components/checkbox';+import { Switch } from '@repo/ui/components/switch';+import {+ Form,+ FormControl,+ FormDescription,+ FormField,+ FormItem,+ FormLabel,+ FormMessage,+} from '@repo/ui/components/form';+import { RadioGroup, RadioGroupItem } from '@repo/ui/components/radio-group';+import { Button } from '@repo/ui/components/button';+import { useToast } from '@repo/ui/components/use-toast';+import Link from 'next/link';+import { useForm } from 'react-hook-form';+import { z } from 'zod';++interface Props {+ user: User & { userLinks: { id: string | null; url: string }[] };+}++export function Notifications({ user }: Props) {+ return (+ <div className="max-w-lg space-y-6 p-8">+ <div className="mb-4">+ <h3 className="text-lg font-medium">Notifications</h3>+ <p className="text-muted-foreground mb-4 text-sm">+ Configure how you receive notifications.+ </p>+ <Separator />+ </div>+ <NotificationsForm />+ </div>+ );+}++const notificationsFormSchema = z.object({+ type: z.enum(['all', 'mentions', 'none'], {+ required_error: 'You need to select a notification type.',+ }),+ mobile: z.boolean().default(false).optional(),+ communication_emails: z.boolean().default(false).optional(),+ social_emails: z.boolean().default(false).optional(),+ marketing_emails: z.boolean().default(false).optional(),+ security_emails: z.boolean(),+});++type NotificationsFormValues = z.infer<typeof notificationsFormSchema>;++// This can come from your database or API.+const defaultValues: Partial<NotificationsFormValues> = {+ communication_emails: false,+ marketing_emails: false,+ social_emails: true,+ security_emails: true,+};++export function NotificationsForm() {+ const { toast } = useToast();+ const form = useForm<NotificationsFormValues>({+ resolver: zodResolver(notificationsFormSchema),+ defaultValues,+ });++ async function onSubmit(data: NotificationsFormValues) {+ toast({+ title: 'You submitted the following values:',+ description: (+ <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">+ <code className="text-white">{JSON.stringify(data, null, 2)}</code>+ </pre>+ ),+ });+ }++ return (+ <Form {...form}>+ <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">+ <FormField+ control={form.control}+ name="type"+ render={({ field }) => (+ <FormItem className="space-y-3">+ <FormLabel>Notify me about...</FormLabel>+ <FormControl>+ <RadioGroup+ onValueChange={(e: 'all' | 'mentions' | 'none') => field.onChange(e)}+ defaultValue={field.value}+ className="flex flex-col space-y-1"+ >+ <FormItem className="flex items-center space-x-3 space-y-0">+ <FormControl>+ <RadioGroupItem value="all" />+ </FormControl>+ <FormLabel className="font-normal">All new messages</FormLabel>+ </FormItem>+ <FormItem className="flex items-center space-x-3 space-y-0">+ <FormControl>+ <RadioGroupItem value="mentions" />+ </FormControl>+ <FormLabel className="font-normal">Direct messages and mentions</FormLabel>+ </FormItem>+ <FormItem className="flex items-center space-x-3 space-y-0">+ <FormControl>+ <RadioGroupItem value="none" />+ </FormControl>+ <FormLabel className="font-normal">Nothing</FormLabel>+ </FormItem>+ </RadioGroup>+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />+ <div>+ <h3 className="mb-4 text-lg font-medium">Email Notifications</h3>+ <div className="space-y-4">+ <FormField+ control={form.control}+ name="communication_emails"+ render={({ field }) => (+ <FormItem className="flex flex-row items-center justify-between rounded-lg border p-4">+ <div className="space-y-0.5">+ <FormLabel className="text-base">Communication emails</FormLabel>+ <FormDescription>Receive emails about your account activity.</FormDescription>+ </div>+ <FormControl>+ <Switch checked={field.value} onCheckedChange={field.onChange} />+ </FormControl>+ </FormItem>+ )}+ />+ <FormField+ control={form.control}+ name="marketing_emails"+ render={({ field }) => (+ <FormItem className="flex flex-row items-center justify-between rounded-lg border p-4">+ <div className="space-y-0.5">+ <FormLabel className="text-base">Marketing emails</FormLabel>+ <FormDescription>+ Receive emails about new products, features, and more.+ </FormDescription>+ </div>+ <FormControl>+ <Switch checked={field.value} onCheckedChange={field.onChange} />+ </FormControl>+ </FormItem>+ )}+ />+ <FormField+ control={form.control}+ name="social_emails"+ render={({ field }) => (+ <FormItem className="flex flex-row items-center justify-between rounded-lg border p-4">+ <div className="space-y-0.5">+ <FormLabel className="text-base">Social emails</FormLabel>+ <FormDescription>+ Receive emails for friend requests, follows, and more.+ </FormDescription>+ </div>+ <FormControl>+ <Switch checked={field.value} onCheckedChange={field.onChange} />+ </FormControl>+ </FormItem>+ )}+ />+ <FormField+ control={form.control}+ name="security_emails"+ render={({ field }) => (+ <FormItem className="flex flex-row items-center justify-between rounded-lg border p-4">+ <div className="space-y-0.5">+ <FormLabel className="text-base">Security emails</FormLabel>+ <FormDescription>+ Receive emails about your account activity and security.+ </FormDescription>+ </div>+ <FormControl>+ <Switch+ checked={field.value}+ onCheckedChange={field.onChange}+ disabled+ aria-readonly+ />+ </FormControl>+ </FormItem>+ )}+ />+ </div>+ </div>+ <FormField+ control={form.control}+ name="mobile"+ render={({ field }) => (+ <FormItem className="flex flex-row items-start space-x-3 space-y-0">+ <FormControl>+ <Checkbox+ checked={field.value}+ onCheckedChange={(e: boolean) => field.onChange(e)}+ />+ </FormControl>+ <div className="space-y-1 leading-none">+ <FormLabel>Use different settings for my mobile devices</FormLabel>+ <FormDescription>+ You can manage your mobile notifications in the{' '}+ <Link href="/examples/forms">mobile settings</Link> page.+ </FormDescription>+ </div>+ </FormItem>+ )}+ />+ <Button type="submit">Update notifications</Button>+ </form>+ </Form>+ );+}diff --git a/apps/web/src/app/[locale]/settings/_components/profile.tsx b/apps/web/src/app/[locale]/settings/_components/profile.tsxnew file mode 100644index 00000000..0a3258fe--- /dev/null+++ b/apps/web/src/app/[locale]/settings/_components/profile.tsx@@ -0,0 +1,198 @@+'use client';++import { zodResolver } from '@hookform/resolvers/zod';+import type { User } from '@repo/db/types';+import { Button } from '@repo/ui/components/button';+import {+ Form,+ FormControl,+ FormDescription,+ FormField,+ FormItem,+ FormLabel,+ FormMessage,+} from '@repo/ui/components/form';+import { Input } from '@repo/ui/components/input';+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from '@repo/ui/components/select';+import { Separator } from '@repo/ui/components/separator';+import { Textarea } from '@repo/ui/components/textarea';+import { useToast } from '@repo/ui/components/use-toast';+import clsx from 'clsx';+import Link from 'next/link';+import { useFieldArray, useForm } from 'react-hook-form';+import { z } from 'zod';++const profileFormSchema = z.object({+ username: z+ .string()+ .min(2, {+ message: 'Username must be at least 2 characters.',+ })+ .max(30, {+ message: 'Username must not be longer than 30 characters.',+ }),+ email: z+ .string({+ required_error: 'Please select an email to display.',+ })+ .email(),+ bio: z.string().max(160).min(4),+ urls: z+ .array(+ z.object({+ value: z.string().url({ message: 'Please enter a valid URL.' }),+ }),+ )+ .optional(),+});++type ProfileFormValues = z.infer<typeof profileFormSchema>;+interface Props {+ user: User & { userLinks: { id: string | null; url: string }[] };+}++export function ProfileSettings({ user }: Props) {+ return (+ <div className="space-y-8 p-8">+ <div className="mb-4">+ <h3 className="text-lg font-medium">Profile</h3>+ <p className="text-muted-foreground mb-4 text-sm">+ This is how others will see you on the site.+ </p>+ <Separator />+ </div>+ <ProfileForm />+ </div>+ );+}++function ProfileForm() {+ const { toast } = useToast();+ const form = useForm<ProfileFormValues>({+ resolver: zodResolver(profileFormSchema),+ mode: 'onChange',+ });++ const { fields, append } = useFieldArray({+ name: 'urls',+ control: form.control,+ });++ async function onSubmit(data: ProfileFormValues) {+ toast({+ title: 'You submitted the following values:',+ description: (+ <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">+ <code className="text-white">{JSON.stringify(data, null, 2)}</code>+ </pre>+ ),+ });+ }++ return (+ <Form {...form}>+ <form onSubmit={(e) => form.handleSubmit(onSubmit)(e)} className="space-y-8">+ <FormField+ control={form.control}+ name="username"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Username</FormLabel>+ <FormControl>+ <Input placeholder="shadcn" {...field} />+ </FormControl>+ <FormDescription>+ This is your public display name. It can be your real name or a pseudonym. You can+ only change this once every 30 days.+ </FormDescription>+ <FormMessage />+ </FormItem>+ )}+ />+ <FormField+ control={form.control}+ name="email"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Email</FormLabel>+ <Select onValueChange={field.onChange} defaultValue={field.value}>+ <FormControl>+ <SelectTrigger>+ <SelectValue placeholder="Select a verified email to display" />+ </SelectTrigger>+ </FormControl>+ <SelectContent>+ <SelectItem value="[email protected]">[email protected]</SelectItem>+ <SelectItem value="[email protected]">[email protected]</SelectItem>+ <SelectItem value="[email protected]">[email protected]</SelectItem>+ </SelectContent>+ </Select>+ <FormDescription>+ You can manage verified email addresses in your{' '}+ <Link href="/examples/forms">email settings</Link>.+ </FormDescription>+ <FormMessage />+ </FormItem>+ )}+ />+ <FormField+ control={form.control}+ name="bio"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Bio</FormLabel>+ <FormControl>+ <Textarea+ placeholder="Tell us a little bit about yourself"+ className="resize-none"+ {...field}+ />+ </FormControl>+ <FormDescription>+ You can <span>@mention</span> other users and organizations to link to them.+ </FormDescription>+ <FormMessage />+ </FormItem>+ )}+ />+ <div>+ {fields.map((field, index) => (+ <FormField+ control={form.control}+ key={field.id}+ name={`urls.${index}.value`}+ render={({ field }) => (+ <FormItem>+ <FormLabel className={clsx(index !== 0 && 'sr-only')}>URLs</FormLabel>+ <FormDescription className={clsx(index !== 0 && 'sr-only')}>+ Add links to your website, blog, or social media profiles.+ </FormDescription>+ <FormControl>+ <Input {...field} />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />+ ))}+ <Button+ type="button"+ variant="outline"+ size="sm"+ className="mt-2"+ onClick={() => append({ value: '' })}+ >+ Add URL+ </Button>+ </div>+ <Button type="submit">Update profile</Button>+ </form>+ </Form>+ );+}diff --git a/apps/web/src/app/[locale]/settings/appearance/error.tsx b/apps/web/src/app/[locale]/settings/appearance/error.tsxnew file mode 100644index 00000000..d42f3afb--- /dev/null+++ b/apps/web/src/app/[locale]/settings/appearance/error.tsx@@ -0,0 +1,11 @@+'use client';+function ErrorBounds() {+ return (+ <div>+ <h1>404</h1>+ <p>Page not found</p>+ </div>+ );+}++export default ErrorBounds;diff --git a/apps/web/src/app/[locale]/settings/appearance/page.tsx b/apps/web/src/app/[locale]/settings/appearance/page.tsxnew file mode 100644index 00000000..ef4c5701--- /dev/null+++ b/apps/web/src/app/[locale]/settings/appearance/page.tsx@@ -0,0 +1,40 @@+import { getServerAuthSession } from '@repo/auth/server';+import { prisma } from '@repo/db';+import { NewSettings } from '../_components/new-settings';++export default async function SettingsPage() {+ const session = await getServerAuthSession();++ if (!session?.user || !session.user.name) {+ return null;+ }++ const profileData = await prisma.user.findFirstOrThrow({+ where: {+ id: session.user.id,+ },+ include: {+ userLinks: true,+ },+ orderBy: {+ updatedAt: 'asc',+ },+ });++ // NOTE: make the user links have 4 at all times+ const userLinks = (profileData.userLinks = [+ ...profileData.userLinks,+ ...Array(4 - profileData.userLinks.length).fill({+ id: null,+ url: '',+ }),+ ])+ // NOTE: sort the user links so empty strings are at the bottom+ .sort((a, b) => b.url.localeCompare(a.url));++ return (+ <>+ <NewSettings user={profileData} />+ </>+ );+}diff --git a/apps/web/src/app/[locale]/settings/notifications/error.tsx b/apps/web/src/app/[locale]/settings/notifications/error.tsxnew file mode 100644index 00000000..d42f3afb--- /dev/null+++ b/apps/web/src/app/[locale]/settings/notifications/error.tsx@@ -0,0 +1,11 @@+'use client';+function ErrorBounds() {+ return (+ <div>+ <h1>404</h1>+ <p>Page not found</p>+ </div>+ );+}++export default ErrorBounds;diff --git a/apps/web/src/app/[locale]/settings/notifications/page.tsx b/apps/web/src/app/[locale]/settings/notifications/page.tsxnew file mode 100644index 00000000..ef4c5701--- /dev/null+++ b/apps/web/src/app/[locale]/settings/notifications/page.tsx@@ -0,0 +1,40 @@+import { getServerAuthSession } from '@repo/auth/server';+import { prisma } from '@repo/db';+import { NewSettings } from '../_components/new-settings';++export default async function SettingsPage() {+ const session = await getServerAuthSession();++ if (!session?.user || !session.user.name) {+ return null;+ }++ const profileData = await prisma.user.findFirstOrThrow({+ where: {+ id: session.user.id,+ },+ include: {+ userLinks: true,+ },+ orderBy: {+ updatedAt: 'asc',+ },+ });++ // NOTE: make the user links have 4 at all times+ const userLinks = (profileData.userLinks = [+ ...profileData.userLinks,+ ...Array(4 - profileData.userLinks.length).fill({+ id: null,+ url: '',+ }),+ ])+ // NOTE: sort the user links so empty strings are at the bottom+ .sort((a, b) => b.url.localeCompare(a.url));++ return (+ <>+ <NewSettings user={profileData} />+ </>+ );+}diff --git a/apps/web/src/app/[locale]/settings/page.tsx b/apps/web/src/app/[locale]/settings/page.tsxindex e6d01ffc..ca9c9540 100644--- a/apps/web/src/app/[locale]/settings/page.tsx+++ b/apps/web/src/app/[locale]/settings/page.tsx@@ -1,11 +1,14 @@import { getServerAuthSession } from '@repo/auth/server';import { prisma } from '@repo/db';import type { Metadata } from 'next';-import { Settings } from '~/app/[locale]/settings/_components';+import { NewSettings } from './_components/new-settings';++export const metadata: Metadata = {+ title: 'Settings | TypeHero',+ description: 'Change your settings on TypeHero.',+};export default async function SettingsPage() {- // NOTE: what's weird about this API is that it should have the- // param to be required but it's not for some reasonconst session = await getServerAuthSession();if (!session?.user || !session.user.name) {@@ -36,17 +39,8 @@ export default async function SettingsPage() {.sort((a, b) => b.url.localeCompare(a.url));return (- <Settings- profileData={{- bio: profileData.bio,- userLinks,- }}- username={profileData.name}- />+ <>+ <NewSettings user={profileData} />+ </>);}--export const metadata: Metadata = {- title: 'Settings | TypeHero',- description: 'Change your settings on TypeHero.',-};diff --git a/packages/ui/package.json b/packages/ui/package.jsonindex 7d9e32c9..65ea0d9d 100644--- a/packages/ui/package.json+++ b/packages/ui/package.json@@ -3,16 +3,12 @@"version": "0.1.1","private": true,"exports": {- ".": "./src/index.ts","./types": "./src/types.ts","./icons": "./src/icons.ts","./components/*": "./src/components/*"},"typesVersions": {"*": {- "*": [- "./src/index.ts"- ],"types": ["./src/types.ts"],@@ -41,10 +37,12 @@"@radix-ui/react-navigation-menu": "^1.1.3","@radix-ui/react-popover": "^1.0.6","@radix-ui/react-progress": "^1.0.3",+ "@radix-ui/react-radio-group": "1.1.3","@radix-ui/react-scroll-area": "^1.0.4","@radix-ui/react-select": "^1.2.2","@radix-ui/react-separator": "^1.0.3","@radix-ui/react-slot": "^1.0.2",+ "@radix-ui/react-switch": "^1.0.3","@radix-ui/react-tabs": "^1.0.4","@radix-ui/react-toast": "^1.1.4","@radix-ui/react-toggle": "^1.0.3",diff --git a/packages/ui/src/components/radio-group.tsx b/packages/ui/src/components/radio-group.tsxnew file mode 100644index 00000000..0b908c47--- /dev/null+++ b/packages/ui/src/components/radio-group.tsx@@ -0,0 +1,38 @@+'use client';++import * as React from 'react';+import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';+import { Circle } from 'lucide-react';++import { cn } from '../cn';++const RadioGroup = React.forwardRef<+ React.ElementRef<typeof RadioGroupPrimitive.Root>,+ React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>+>(({ className, ...props }, ref) => {+ return <RadioGroupPrimitive.Root className={cn('grid gap-2', className)} {...props} ref={ref} />;+});+RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;++const RadioGroupItem = React.forwardRef<+ React.ElementRef<typeof RadioGroupPrimitive.Item>,+ React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>+>(({ className, children, ...props }, ref) => {+ return (+ <RadioGroupPrimitive.Item+ ref={ref}+ className={cn(+ 'border-primary text-primary ring-offset-background focus-visible:ring-ring aspect-square h-4 w-4 rounded-full border focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',+ className,+ )}+ {...props}+ >+ <RadioGroupPrimitive.Indicator className="flex items-center justify-center">+ <Circle className="h-2.5 w-2.5 fill-current text-current" />+ </RadioGroupPrimitive.Indicator>+ </RadioGroupPrimitive.Item>+ );+});+RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;++export { RadioGroup, RadioGroupItem };diff --git a/packages/ui/src/components/switch.tsx b/packages/ui/src/components/switch.tsxnew file mode 100644index 00000000..0c933a2e--- /dev/null+++ b/packages/ui/src/components/switch.tsx@@ -0,0 +1,29 @@+'use client';++import * as React from 'react';+import * as SwitchPrimitives from '@radix-ui/react-switch';++import { cn } from '../cn';++const Switch = React.forwardRef<+ React.ElementRef<typeof SwitchPrimitives.Root>,+ React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>+>(({ className, ...props }, ref) => (+ <SwitchPrimitives.Root+ className={cn(+ 'focus-visible:ring-ring focus-visible:ring-offset-background data-[state=checked]:bg-primary data-[state=unchecked]:bg-input peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',+ className,+ )}+ {...props}+ ref={ref}+ >+ <SwitchPrimitives.Thumb+ className={cn(+ 'bg-background pointer-events-none block h-5 w-5 rounded-full shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0',+ )}+ />+ </SwitchPrimitives.Root>+));+Switch.displayName = SwitchPrimitives.Root.displayName;++export { Switch };diff --git a/packages/ui/src/icons.ts b/packages/ui/src/icons.tsindex b284e1f5..753880fc 100644--- a/packages/ui/src/icons.ts+++ b/packages/ui/src/icons.ts@@ -1,18 +1,23 @@export {AlertCircle,+ ArrowDownNarrowWide,ArrowUp,+ ArrowUpNarrowWide,+ BellRing,Binary,Bookmark,+ Brush,Calendar,Check,CheckCircle2,ChevronDown,ChevronLeft,ChevronRight,+ ChevronRightSquare,ChevronUp,- Command,Circle,Clipboard,+ Command,Copy,Diamond,ExternalLink,@@ -27,35 +32,32 @@ export {MailCheck,Maximize2,MessageCircle,- Minus,+ MessagesSquare,+ Minimize2,Moon,+ MoreHorizontal,Pencil,PieChart,Play,Plus,Reply,+ RotateCcw,Settings,Settings2,+ Shapes,Share,+ Sparkle,SquareSlash,Sun,+ Sword,+ Swords,ThumbsUp,Trash2,- Triangle,- Sparkle,TrendingUpIcon,+ Triangle,+ Twitter,Unlock,User,X,XCircle,- RotateCcw,- Twitter,- Minimize2,- ArrowDownNarrowWide,- ArrowUpNarrowWide,- ChevronRightSquare,- MessagesSquare,- Swords,- Sword,- MoreHorizontal,} from 'lucide-react';diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 965e2e0c..1a1ee4ce 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -595,6 +595,9 @@ importers:'@radix-ui/react-progress':specifier: ^1.0.3+ '@radix-ui/react-radio-group':+ specifier: 1.1.3'@radix-ui/react-scroll-area':specifier: ^1.0.4@@ -607,6 +610,9 @@ importers:'@radix-ui/react-slot':specifier: ^1.0.2version: 1.0.2(@types/[email protected])([email protected])+ '@radix-ui/react-switch':+ specifier: ^1.0.3'@radix-ui/react-tabs':specifier: ^1.0.4@@ -2978,6 +2984,35 @@ packages:react-dom: 18.2.0([email protected])dev: false+ resolution: {integrity: sha512-x+yELayyefNeKeTx4fjK6j99Fs6c4qKm3aY38G3swQVTN6xMpsrbigC0uHs2L//g8q4qR7qOcww8430jJmi2ag==}+ peerDependencies:+ '@types/react': '*'+ '@types/react-dom': '*'+ react: ^16.8 || ^17.0 || ^18.0+ react-dom: ^16.8 || ^17.0 || ^18.0+ peerDependenciesMeta:+ '@types/react':+ optional: true+ '@types/react-dom':+ optional: true+ dependencies:+ '@babel/runtime': 7.22.6+ '@radix-ui/primitive': 1.0.1+ '@radix-ui/react-compose-refs': 1.0.1(@types/[email protected])([email protected])+ '@radix-ui/react-context': 1.0.1(@types/[email protected])([email protected])+ '@radix-ui/react-direction': 1.0.1(@types/[email protected])([email protected])+ '@radix-ui/react-presence': 1.0.1(@types/[email protected])(@types/[email protected])([email protected])([email protected])+ '@radix-ui/react-primitive': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])+ '@radix-ui/react-roving-focus': 1.0.4(@types/[email protected])([email protected])([email protected])+ '@radix-ui/react-use-controllable-state': 1.0.1(@types/[email protected])([email protected])+ '@radix-ui/react-use-previous': 1.0.1(@types/[email protected])([email protected])+ '@radix-ui/react-use-size': 1.0.1(@types/[email protected])([email protected])+ '@types/react': 18.2.20+ react: 18.2.0+ react-dom: 18.2.0([email protected])+ dev: false+resolution: {integrity: sha512-2mUg5Mgcu001VkGy+FfzZyzbmuUWzgWkj3rvv4yu+mLw03+mTzbxZHvfcGyFp2b8EkQeMkpRQ5FiA2Vr2O6TeQ==}peerDependencies:@@ -3119,6 +3154,32 @@ packages:react: 18.2.0dev: false+ resolution: {integrity: sha512-mxm87F88HyHztsI7N+ZUmEoARGkC22YVW5CaC+Byc+HRpuvCrOBPTAnXgf+tZ/7i0Sg/eOePGdMhUKhPaQEqow==}+ peerDependencies:+ '@types/react': '*'+ '@types/react-dom': '*'+ react: ^16.8 || ^17.0 || ^18.0+ react-dom: ^16.8 || ^17.0 || ^18.0+ peerDependenciesMeta:+ '@types/react':+ optional: true+ '@types/react-dom':+ optional: true+ dependencies:+ '@babel/runtime': 7.22.6+ '@radix-ui/primitive': 1.0.1+ '@radix-ui/react-compose-refs': 1.0.1(@types/[email protected])([email protected])+ '@radix-ui/react-context': 1.0.1(@types/[email protected])([email protected])+ '@radix-ui/react-primitive': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])+ '@radix-ui/react-use-controllable-state': 1.0.1(@types/[email protected])([email protected])+ '@radix-ui/react-use-previous': 1.0.1(@types/[email protected])([email protected])+ '@radix-ui/react-use-size': 1.0.1(@types/[email protected])([email protected])+ '@types/react': 18.2.20+ react: 18.2.0+ react-dom: 18.2.0([email protected])+ dev: false+resolution: {integrity: sha512-egZfYY/+wRNCflXNHx+dePvnz9FbmssDTJBtgRfDY7e8SE5oIo3Py2eCB1ckAbh1Q7cQ/6yJZThJ++sgbxibog==}peerDependencies: