diff --git a/apps/expo/src/app/(app)/home/index.tsx b/apps/expo/src/app/(app)/home/index.tsx index 67ae043..2baf161 100644 --- a/apps/expo/src/app/(app)/home/index.tsx +++ b/apps/expo/src/app/(app)/home/index.tsx @@ -47,10 +47,6 @@ const Home = () => { }, ); - console.log({ - medicationStatementBundle, - }); - if (isLoading) { return ( diff --git a/apps/expo/src/components/atoms/RadioButton.tsx b/apps/expo/src/components/atoms/RadioButton.tsx new file mode 100644 index 0000000..6bfbaf8 --- /dev/null +++ b/apps/expo/src/components/atoms/RadioButton.tsx @@ -0,0 +1,26 @@ +import { TouchableWithoutFeedback, View } from 'react-native'; +import { cn } from '@/utils/cn'; + +import { Text } from './Text'; + +export interface RadioButtonProps { + selected?: boolean; + label?: string; + onPress?: () => void; +} + +export const RadioButton = ({ label, selected, onPress }: RadioButtonProps) => { + return ( + + + + {label} + + + ); +}; diff --git a/apps/expo/src/components/molecules/ScheduleAppointmentModal.tsx b/apps/expo/src/components/molecules/ScheduleAppointmentModal.tsx index 3f1280a..35568c2 100644 --- a/apps/expo/src/components/molecules/ScheduleAppointmentModal.tsx +++ b/apps/expo/src/components/molecules/ScheduleAppointmentModal.tsx @@ -1,22 +1,72 @@ -import { Modal, View } from 'react-native'; +import { useCallback } from 'react'; +import { ActivityIndicator, Modal, View } from 'react-native'; +import { getLocationAddress } from '@/fhirpath/location'; +import { getPractitionerName } from '@/fhirpath/practitioner'; +import { usePractitioner } from '@/hooks/usePractitioner'; +import { api } from '@/utils/api'; +import { HARDCODED_OFFICE_LOCATION_ID } from '@/utils/constants'; +import dayjs from 'dayjs'; +import { Controller, useForm } from 'react-hook-form'; +import { z } from 'zod'; import { type Slot } from '@canvas-challenge/canvas'; import { Button } from '../atoms/Button'; +import { RadioButton } from '../atoms/RadioButton'; import { Text } from '../atoms/Text'; +import { TextInput } from '../atoms/TextInput'; import { ScreenView } from './ScreenView'; +const ConfirmAppointmentFormSchema = z.object({ + reasonText: z.string().optional(), + appointmentType: z.enum(['office', 'telehealth']), +}); + +type ConfirmAppointmentForm = z.infer; + export const ScheduleAppointmentModal = ({ slot, isOpen, onClose, onConfirm, + practitionerId, + isConfirming, }: { + isConfirming?: boolean; + practitionerId: string; slot: Slot; isOpen: boolean; onClose: () => void; - onConfirm: () => void; + onConfirm: (appointmentType: 'office' | 'telehealth', reasonText?: string) => void; }) => { + const { practitioner, isLoading } = usePractitioner(practitionerId); + + const { data: location } = api.location.get.useQuery({ + // TODO: remove this when Canvas fixes bug with location IDs + id: HARDCODED_OFFICE_LOCATION_ID, + }); + + const onSubmit = useCallback( + (form: ConfirmAppointmentForm) => { + onConfirm(form.appointmentType, form.reasonText === '' ? undefined : form.reasonText); + }, + [onConfirm], + ); + + const { + formState: { isValid }, + control, + handleSubmit, + watch, + } = useForm({ + defaultValues: { + appointmentType: 'office', + reasonText: '', + }, + }); + + const appointmentType = watch('appointmentType'); + return ( - - TODO: schedule appt - - {slot.start} - {slot.end} - -