· 4 years ago · Jul 27, 2021, 07:02 AM
1import React from 'react';
2import {TextField} from '@material-ui/core';
3import {Autocomplete} from '@material-ui/lab';
4import _ from 'lodash';
5
6type Props = {
7 requestType: string;
8 onChange: (requestType: string) => void;
9 disabled: boolean;
10};
11
12const RequestTypeSelector = ({requestType, onChange, disabled}: Props): JSX.Element => {
13 const options: {[key: string]: string} = {
14 api: 'Agent through the API',
15 'tservice-agent': 'Agent service directly via TService',
16 tservice: 'Internal service via TService',
17 };
18 return (
19 <Autocomplete
20 disabled={disabled}
21 disableClearable={true}
22 size="small"
23 options={_.keys(options)}
24 getOptionLabel={(option) => options[option]}
25 value={requestType}
26 renderInput={(params) => <TextField {...params} label="Request type" />}
27 onChange={(e, newValue) => onChange(newValue as string)}
28 />
29 );
30};
31
32export default RequestTypeSelector;
33