import {Text, TextInput, View} from 'react-native'; import {Section} from '../common/Section'; import {styles, TextTheme} from '../common/styles'; import {useState} from 'react'; interface MedicineForm { name?: string; dosage_form?: string; strength?: string; quantity?: string; refills?: string; directions?: string; } const MEDICINE_KEY = 'MedicationPrescribed'; interface MedicineFormProps { nestedFormCallback: (tag: string, form: Object) => void; initForm: {[key: string]: any}; } export const MedicineForm: React.FC = ({ nestedFormCallback, initForm, }) => { const [form, setForm] = useState(initForm[MEDICINE_KEY] || {}); const handleTextChange = (tag: keyof MedicineForm, text: string) => { let newForm = {...form}; newForm[tag] = text; setForm(newForm); nestedFormCallback(MEDICINE_KEY, newForm); }; return ( Name of Medicine handleTextChange('name', text)} /> Form of Dosage handleTextChange('dosage_form', text)} /> Strength handleTextChange('strength', text)} /> Quantity handleTextChange('quantity', text)} /> Refills handleTextChange('refills', text)} /> Directions handleTextChange('directions', text)} /> ); };