diff --git a/apps/expo/package.json b/apps/expo/package.json index 8f3d4a5..31c4ffb 100644 --- a/apps/expo/package.json +++ b/apps/expo/package.json @@ -19,6 +19,8 @@ "@expo-google-fonts/open-sans": "^0.2.3", "@expo/metro-config": "^0.10.7", "@expo/vector-icons": "^13.0.0", + "@hookform/resolvers": "^3.3.2", + "@react-native-community/datetimepicker": "7.2.0", "@tanstack/react-query": "^5.8.7", "@trpc/client": "next", "@trpc/react-query": "next", @@ -39,15 +41,19 @@ "nativewind": "^4.0.13", "react": "18.2.0", "react-dom": "18.2.0", + "react-hook-form": "^7.49.0", "react-native": "0.72.7", + "react-native-date-picker": "^4.3.4", "react-native-gesture-handler": "~2.12.0", + "react-native-modal-datetime-picker": "^17.1.0", "react-native-reanimated": "~3.3.0", "react-native-safe-area-context": "4.6.3", "react-native-screens": "~3.22.1", "react-native-ui-datepicker": "^1.0.10", "superjson": "2.2.0", "tailwind-merge": "^2.1.0", - "ts-pattern": "^5.0.5" + "ts-pattern": "^5.0.5", + "zod": "^3.22.2" }, "devDependencies": { "@babel/core": "^7.23.2", diff --git a/apps/expo/src/app/(auth)/sign-in.tsx b/apps/expo/src/app/(auth)/sign-in.tsx index 3bf4986..bcef383 100644 --- a/apps/expo/src/app/(auth)/sign-in.tsx +++ b/apps/expo/src/app/(auth)/sign-in.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useState } from 'react'; +import React, { useCallback } from 'react'; import { Keyboard, TouchableWithoutFeedback, View } from 'react-native'; import { Link, Redirect } from 'expo-router'; import { Button } from '@/components/atoms/Button'; @@ -7,12 +7,35 @@ import { TextInput } from '@/components/atoms/TextInput'; import { ScreenView } from '@/components/molecules/ScreenView'; import { useAuth } from '@/context/AuthContext'; import { api } from '@/utils/api'; +import { zodResolver } from '@hookform/resolvers/zod'; +import { Controller, useForm } from 'react-hook-form'; +import { z } from 'zod'; import { type PatientBundle } from '@canvas-challenge/canvas'; +const SignInFormSchema = z.object({ + email: z.string().email().min(1), +}); + +type SignInFormType = z.infer; + const SignIn = () => { const { signIn, patientId } = useAuth(); - const [email, setEmail] = useState(''); + + const { + control, + formState: { errors, isValid }, + handleSubmit, + watch, + } = useForm({ + defaultValues: { + email: '', + }, + resolver: zodResolver(SignInFormSchema), + mode: 'onChange', + }); + + const email = watch('email'); const { isLoading: patientSearchLoading, refetch } = api.patient.search.useQuery( { @@ -54,18 +77,31 @@ const SignIn = () => { Log in to start owning your health data - Email + ( + + )} /> -