Added jsdocs and proptypes
This commit is contained in:
1 parent
dd4d5faf33
commit
a49cf7cc6e
2 files changed
+31
-1
No files matched your search
@@ -1,9 +1,25 @@
|
|||||||
|
import PropTypes from "prop-types";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { MenuItem, Select as MuiSelect } from "@mui/material";
|
import { MenuItem, Select as MuiSelect } from "@mui/material";
|
||||||
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
||||||
|
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @component
|
||||||
|
* @param {object} props
|
||||||
|
* @param {string} props.id - The ID attribute for the select element.
|
||||||
|
* @param {string} props.placeholder - The placeholder text when no option is selected.
|
||||||
|
* @param {boolean} props.isHidden - Whether the placeholder should be hidden.
|
||||||
|
* @param {string} props.value - The currently selected value.
|
||||||
|
* @param {object[]} props.items - The array of items to populate in the select dropdown.
|
||||||
|
* @param {string} props.items._id - The unique identifier of each item.
|
||||||
|
* @param {string} props.items.name - The display name of each item.
|
||||||
|
* @param {function} props.onChange - The function to handle onChange event.
|
||||||
|
* @param {object} props.sx - The custom styles object for MUI Select component.
|
||||||
|
* @returns {JSX.Element}
|
||||||
|
*/
|
||||||
|
|
||||||
const Select = ({ id, placeholder, isHidden, value, items, onChange, sx }) => {
|
const Select = ({ id, placeholder, isHidden, value, items, onChange, sx }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const itemStyles = {
|
const itemStyles = {
|
||||||
@@ -62,4 +78,19 @@ const Select = ({ id, placeholder, isHidden, value, items, onChange, sx }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Select.propTypes = {
|
||||||
|
id: PropTypes.string.isRequired,
|
||||||
|
placeholder: PropTypes.string,
|
||||||
|
isHidden: PropTypes.bool,
|
||||||
|
value: PropTypes.string.isRequired,
|
||||||
|
items: PropTypes.arrayOf(
|
||||||
|
PropTypes.shape({
|
||||||
|
_id: PropTypes.string.isRequired,
|
||||||
|
name: PropTypes.string.isRequired,
|
||||||
|
})
|
||||||
|
).isRequired,
|
||||||
|
onChange: PropTypes.func.isRequired,
|
||||||
|
sx: PropTypes.object,
|
||||||
|
};
|
||||||
|
|
||||||
export default Select;
|
export default Select;
|
||||||
@@ -54,7 +54,6 @@ const Incidents = () => {
|
|||||||
fetchIncidents();
|
fetchIncidents();
|
||||||
}, [authState]);
|
}, [authState]);
|
||||||
|
|
||||||
console.log(monitors);
|
|
||||||
const handleSelect = (event) => {
|
const handleSelect = (event) => {
|
||||||
setSelectedMonitor(event.target.value);
|
setSelectedMonitor(event.target.value);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user