Untitled
unknown
plain_text
3 years ago
2.4 kB
3
Indexable
import React, { useState } from 'react' import TextField from '@material-ui/core/TextField'; import FormControl from '@material-ui/core/FormControl'; import Autocomplete from '@material-ui/lab/Autocomplete'; import '../../../assets/stylesheets/newdoctorcitation.css' import { Insurances } from '../../../constants/Insurances'; export const PatientPicker = ({ patients, setEmail, setName, setFirstname, setLastname, setPhone, setAddress, setPatient, setUser, setInsurance }) => { const handleNameChange = (event, value) => { //console.log(value) var fieldValue = value; if (!fieldValue) { fieldValue = null; } else { setName(value.lastname + ', ' + value.firstname); setFirstname(value.firstname); setLastname(value.lastname); setEmail(value.email); setPhone(value.phone); setAddress(value.address); setUser(value.user_id); setPatient(value.id); console.log(value.insurance) if (value.insurance > 0 && value.insurance < 9) { setInsurance(Insurances[parseInt(value.insurance) - 1].name); } } } return ( <> <h1 className='subtitle-modal'>Patient</h1> <div className="row"> <div className="col-10"> <FormControl style={{ minWidth: '100%', textAlign: 'left' }}> <Autocomplete noOptionsText={'Need create a new patient? use add patient button'} id="name" name="name" options={patients} onChange={handleNameChange} getOptionLabel={(option) => (option['lastname'] + ', ' + option['firstname'])} inputValue={patients['lastname']} renderInput={(params) => <TextField {...params} />} /> </FormControl> </div> <div className="col-2"> <button type="submit" className="add-patient-button" onClick={() => window.location.href = '/new-patient'} >NEW </button> </div> </div> </> ) }
Editor is loading...