"use client"; import React from 'react'; import { useForm, Controller } from 'react-hook-form'; import { z } from 'zod'; import { zodResolver } from '@hookform/resolvers/zod'; 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; const defaultValues: Partial = { communication_emails: false, marketing_emails: false, social_emails: true, security_emails: true, }; export function NotificationsForm() { const { control, handleSubmit } = useForm({ resolver: zodResolver(notificationsFormSchema), defaultValues, }); const onSubmit = (data: NotificationsFormValues) => { console.log(JSON.stringify(data, null, 2)); }; return (
(
onChange('all')} className="h-4 w-4 border-gray-300 text-blue-600 focus:ring-blue-500" />
onChange('mentions')} className="h-4 w-4 border-gray-300 text-blue-600 focus:ring-blue-500" />
onChange('none')} className="h-4 w-4 border-gray-300 text-blue-600 focus:ring-blue-500" />
)} />

Email Notifications

(

Receive emails about your account activity.

onChange(e.target.checked)} className="h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" />
)} /> (

Receive emails about new products, features, and more.

onChange(e.target.checked)} className="h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" />
)} /> (

Receive emails for friend requests, follows, and more.

onChange(e.target.checked)} className="h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" />
)} /> (

Receive emails about your account activity and security.

)} />
); }