setHost(userData)}
name="host"
size="small"
fullWidth
variant="outlined"
- value={values.host}
- onChange={handleChange}
+ value={host}
+ debounced
+ filterOptions={(options) => options}
+ renderOption={(option) => (option.newUser
+ ? option.newUser
+ : `${option.first_name} ${option.last_name}, (${option.email})`)}
+ getOptionLabel={(option) => option.first_name}
+ asyncSearch={(searchTerm) => bc.auth().getAllUsers({ like: searchTerm || '' })}
+ getOptions={(options, params) => {
+ const filtered = filter(options, params);
+ if (params.inputValue !== '') {
+ filtered.push({
+ newUser: (
+ {
+ e.stopPropagation();
+ setShowForm(true);
+ values.showForm = true;
+ if (params.inputValue.includes('@')) setFieldValue('email', params.inputValue);
+ else setFieldValue('first_name', params.inputValue);
+ }}
+ >
+ {`Invite ${params.inputValue} to 4Geeks.`}
+
+ ),
+ });
+ }
+ return filtered;
+ }}
/>