({fClose, fOnSubmit}: IProps)
| 13 | } |
| 14 | |
| 15 | const AddClientDialog = ({fClose, fOnSubmit}: IProps) => { |
| 16 | const [name, setName] = useState(''); |
| 17 | |
| 18 | const submitEnabled = name.length !== 0; |
| 19 | const submitAndClose = async () => { |
| 20 | await fOnSubmit(name); |
| 21 | fClose(); |
| 22 | }; |
| 23 | |
| 24 | return ( |
| 25 | <Dialog open={true} onClose={fClose} aria-labelledby="form-dialog-title" id="client-dialog"> |
| 26 | <DialogTitle id="form-dialog-title">Create a client</DialogTitle> |
| 27 | <DialogContent> |
| 28 | <TextField |
| 29 | autoFocus |
| 30 | margin="dense" |
| 31 | className="name" |
| 32 | label="Name *" |
| 33 | type="email" |
| 34 | value={name} |
| 35 | onChange={(e) => setName(e.target.value)} |
| 36 | fullWidth |
| 37 | /> |
| 38 | </DialogContent> |
| 39 | <DialogActions> |
| 40 | <Button onClick={fClose}>Cancel</Button> |
| 41 | <Tooltip placement={'bottom-start'} title={submitEnabled ? '' : 'name is required'}> |
| 42 | <div> |
| 43 | <Button |
| 44 | className="create" |
| 45 | disabled={!submitEnabled} |
| 46 | onClick={submitAndClose} |
| 47 | color="primary" |
| 48 | variant="contained"> |
| 49 | Create |
| 50 | </Button> |
| 51 | </div> |
| 52 | </Tooltip> |
| 53 | </DialogActions> |
| 54 | </Dialog> |
| 55 | ); |
| 56 | }; |
| 57 | |
| 58 | export default AddClientDialog; |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…