Edit.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { makeStyles } from '@material-ui/styles';
  2. import FormControl from '@material-ui/core/FormControl'
  3. import InputLabel from '@material-ui/core/InputLabel'
  4. import MenuItem from '@material-ui/core/MenuItem'
  5. import Select from '@material-ui/core/Select'
  6. import React from 'react';
  7. import SelectWindow from '../SelectWindow';
  8. const useStyles = makeStyles({
  9. wrapper: {
  10. display: 'inline-flex',
  11. },
  12. formControl: {
  13. margin: 8,
  14. minWidth: 120,
  15. },
  16. });
  17. function EditControl({
  18. windowOptions, window, setWindow,
  19. aggregationOptions, aggregateBy, setAggregateBy,
  20. accumulateOptions, accumulate, setAccumulate,
  21. currencyOptions, currency, setCurrency,
  22. }) {
  23. const classes = useStyles();
  24. return (
  25. <div className={classes.wrapper}>
  26. <SelectWindow
  27. windowOptions={windowOptions}
  28. window={window}
  29. setWindow={setWindow} />
  30. <FormControl className={classes.formControl}>
  31. <InputLabel id="aggregation-select-label">Breakdown</InputLabel>
  32. <Select
  33. id="aggregation-select"
  34. value={aggregateBy}
  35. onChange={e => {
  36. setAggregateBy(e.target.value)
  37. }}
  38. >
  39. {aggregationOptions.map((opt) => <MenuItem key={opt.value} value={opt.value}>{opt.name}</MenuItem>)}
  40. </Select>
  41. </FormControl>
  42. <FormControl className={classes.formControl}>
  43. <InputLabel id="accumulate-label">Resolution</InputLabel>
  44. <Select
  45. id="accumulate"
  46. value={accumulate}
  47. onChange={e => setAccumulate(e.target.value)}
  48. >
  49. {accumulateOptions.map((opt) => <MenuItem key={opt.value} value={opt.value}>{opt.name}</MenuItem>)}
  50. </Select>
  51. </FormControl>
  52. <FormControl className={classes.formControl}>
  53. <InputLabel id="currency-label">Currency</InputLabel>
  54. <Select
  55. id="currency"
  56. value={currency}
  57. onChange={e => setCurrency(e.target.value)}
  58. >
  59. {currencyOptions?.map((currency) => (
  60. <MenuItem key={currency} value={currency}>
  61. {currency}
  62. </MenuItem>
  63. ))}
  64. </Select>
  65. </FormControl>
  66. </div>
  67. );
  68. }
  69. export default React.memo(EditControl);