MDropdown.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import {
  4. Box,
  5. Button
  6. } from '@material-ui/core';
  7. import { makeStyles } from '@material-ui/core/styles';
  8. const useStyles = makeStyles((theme) => ({
  9. root: {
  10. width: '100%',
  11. },
  12. }));
  13. function MDropdown(props) {
  14. const classes = useStyles();
  15. const { field } = props;
  16. return (
  17. <div className={classes.root}>
  18. <Grid key={field.fieldName} container style={{ display: 'flex', alignItems: 'center', marginBottom: '10px' }}>
  19. <Grid item xs={12} sm={5}>
  20. <Box style={{ width: '150px' }}>
  21. <Typography style={{ paddingRight: '30px', color: 'grey' }}>{field.label}</Typography>
  22. </Box>
  23. </Grid>
  24. <Grid item xs={12} sm={7}>
  25. <NativeSelect
  26. id="demo-customized-select-native"
  27. value={data != undefined ? data[fieldId] : ''}
  28. // onChange={(e) => handleDropDownChange(e, field.fieldName)}
  29. id={field.fieldName}
  30. input={<BootstrapInput />}
  31. style={{ width: '100%' }}
  32. >
  33. <option aria-label="None" value="" >Select</option>
  34. {field.options.map((d, i) => {
  35. var name = d[field.fieldName] != undefined ? d[field.fieldName] : d.name;
  36. return <option name={name} value={d.id}>{name}</option>;
  37. })}
  38. </NativeSelect>
  39. </Grid>
  40. </Grid>
  41. </div>
  42. );
  43. }
  44. MDropdown.propTypes = {
  45. history: PropTypes.object,
  46. field: PropTypes.any,
  47. };
  48. export default (MDropdown);