import React from 'react'; import { View, Text, Switch, TouchableOpacity } from 'react-native'; 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 ( Notify me about... ( onChange('all')} > All new messages onChange('mentions')} > Direct messages and mentions onChange('none')} > Nothing )} /> Email Notifications ( Communication emails Receive emails about your account activity. )} /> ( Marketing emails Receive emails about new products, features, and more. )} /> ( Social emails Receive emails for friend requests, follows, and more. )} /> ( Security emails Receive emails about your account activity and security. )} /> Update notifications ); }