MDropdown.js 1.8 KB

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