cloudCostEditControls.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 * as React from "react";
  7. import SelectWindow from "../../components/SelectWindow";
  8. const useStyles = makeStyles({
  9. wrapper: {
  10. display: "inline-flex",
  11. },
  12. formControl: {
  13. margin: 8,
  14. minWidth: 120,
  15. },
  16. });
  17. function EditCloudCostControls({
  18. windowOptions,
  19. window,
  20. setWindow,
  21. aggregationOptions,
  22. aggregateBy,
  23. setAggregateBy,
  24. costMetricOptions,
  25. costMetric,
  26. setCostMetric,
  27. currencyOptions,
  28. currency,
  29. setCurrency,
  30. }) {
  31. const classes = useStyles();
  32. return (
  33. <div className={classes.wrapper}>
  34. <SelectWindow
  35. windowOptions={windowOptions}
  36. window={window}
  37. setWindow={setWindow}
  38. />
  39. <FormControl className={classes.formControl}>
  40. <InputLabel id="aggregation-select-label">Breakdown</InputLabel>
  41. <Select
  42. id="aggregation-select"
  43. value={aggregateBy}
  44. onChange={(e) => {
  45. setAggregateBy(e.target.value);
  46. }}
  47. >
  48. {aggregationOptions.map((opt) => (
  49. <MenuItem key={opt.value} value={opt.value}>
  50. {opt.name}
  51. </MenuItem>
  52. ))}
  53. </Select>
  54. </FormControl>
  55. <FormControl className={classes.formControl}>
  56. <InputLabel id="costMetric-label">Cost Metric</InputLabel>
  57. <Select
  58. id="costMetric"
  59. value={costMetric}
  60. onChange={(e) => setCostMetric(e.target.value)}
  61. >
  62. {costMetricOptions.map((opt) => (
  63. <MenuItem key={opt.value} value={opt.value}>
  64. {opt.name}
  65. </MenuItem>
  66. ))}
  67. </Select>
  68. </FormControl>
  69. <FormControl className={classes.formControl}>
  70. <InputLabel id="currency-label">Currency</InputLabel>
  71. <Select
  72. id="currency"
  73. value={currency}
  74. onChange={(e) => setCurrency(e.target.value)}
  75. >
  76. {currencyOptions?.map((currency) => (
  77. <MenuItem key={currency} value={currency}>
  78. {currency}
  79. </MenuItem>
  80. ))}
  81. </Select>
  82. </FormControl>
  83. </div>
  84. );
  85. }
  86. export default React.memo(EditCloudCostControls);