({fClose, fOnSubmit}: IProps)
| 15 | } |
| 16 | |
| 17 | export const AddApplicationDialog = ({fClose, fOnSubmit}: IProps) => { |
| 18 | const [name, setName] = useState(''); |
| 19 | const [description, setDescription] = useState(''); |
| 20 | const [defaultPriority, setDefaultPriority] = useState(0); |
| 21 | |
| 22 | const submitEnabled = name.length !== 0; |
| 23 | const submitAndClose = async () => { |
| 24 | await fOnSubmit(name, description, defaultPriority); |
| 25 | fClose(); |
| 26 | }; |
| 27 | |
| 28 | return ( |
| 29 | <Dialog open={true} onClose={fClose} aria-labelledby="form-dialog-title" id="app-dialog"> |
| 30 | <DialogTitle id="form-dialog-title">Create an application</DialogTitle> |
| 31 | <DialogContent> |
| 32 | <DialogContentText>An application is allowed to send messages.</DialogContentText> |
| 33 | <TextField |
| 34 | autoFocus |
| 35 | margin="dense" |
| 36 | className="name" |
| 37 | label="Name *" |
| 38 | type="text" |
| 39 | value={name} |
| 40 | onChange={(e) => setName(e.target.value)} |
| 41 | fullWidth |
| 42 | /> |
| 43 | <TextField |
| 44 | margin="dense" |
| 45 | className="description" |
| 46 | label="Short Description" |
| 47 | value={description} |
| 48 | onChange={(e) => setDescription(e.target.value)} |
| 49 | fullWidth |
| 50 | multiline |
| 51 | /> |
| 52 | <NumberField |
| 53 | margin="dense" |
| 54 | className="priority" |
| 55 | label="Default Priority" |
| 56 | value={defaultPriority} |
| 57 | onChange={(value) => setDefaultPriority(value)} |
| 58 | fullWidth |
| 59 | /> |
| 60 | </DialogContent> |
| 61 | <DialogActions> |
| 62 | <Button onClick={fClose}>Cancel</Button> |
| 63 | <Tooltip title={submitEnabled ? '' : 'name is required'}> |
| 64 | <div> |
| 65 | <Button |
| 66 | className="create" |
| 67 | disabled={!submitEnabled} |
| 68 | onClick={submitAndClose} |
| 69 | color="primary" |
| 70 | variant="contained"> |
| 71 | Create |
| 72 | </Button> |
| 73 | </div> |
| 74 | </Tooltip> |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…