diff --git a/Client/src/Components/Inputs/Select/index.css b/Client/src/Components/Inputs/Select/index.css index 0777b29e2..1e8e4e354 100644 --- a/Client/src/Components/Inputs/Select/index.css +++ b/Client/src/Components/Inputs/Select/index.css @@ -1,13 +1,17 @@ -.select-component > .MuiSelect-select { +.select-wrapper .select-component > .MuiSelect-select { + padding: 0 10px; height: 34px !important; display: flex !important; align-items: center; + text-transform: capitalize; + line-height: 1; } -.MuiInputBase-root:has(> .MuiSelect-select) { +.select-wrapper .MuiInputBase-root:has(> .MuiSelect-select) { min-width: 150px; } -.MuiInputBase-root:has(> .MuiSelect-select), -.MuiMenu-List .MuiMenuItem-root { +.select-wrapper .MuiInputBase-root:has(> .MuiSelect-select), +.MuiMenu-List .MuiMenuItem-root, +.select-wrapper h3.MuiTypography-root { font-size: var(--env-var-font-size-medium); color: var(--env-var-color-5); } diff --git a/Client/src/Components/Inputs/Select/index.jsx b/Client/src/Components/Inputs/Select/index.jsx index 76feb6daa..9e637f8d1 100644 --- a/Client/src/Components/Inputs/Select/index.jsx +++ b/Client/src/Components/Inputs/Select/index.jsx @@ -1,6 +1,11 @@ import PropTypes from "prop-types"; import { useTheme } from "@emotion/react"; -import { MenuItem, Select as MuiSelect } from "@mui/material"; +import { + MenuItem, + Select as MuiSelect, + Stack, + Typography, +} from "@mui/material"; import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown"; import "./index.css"; @@ -9,6 +14,7 @@ import "./index.css"; * @component * @param {object} props * @param {string} props.id - The ID attribute for the select element. + * @param {string} props.placeholder - The label of 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. @@ -20,7 +26,16 @@ import "./index.css"; * @returns {JSX.Element} */ -const Select = ({ id, placeholder, isHidden, value, items, onChange, sx }) => { +const Select = ({ + id, + label, + placeholder, + isHidden, + value, + items, + onChange, + sx, +}) => { const theme = useTheme(); const itemStyles = { fontSize: "var(--env-var-font-size-medium)", @@ -31,61 +46,66 @@ const Select = ({ id, placeholder, isHidden, value, items, onChange, sx }) => { }; return ( - + {label && {label}} + - {placeholder && ( - - {placeholder} - - )} - {items.map((item) => ( - - {item.name} - - ))} - + MenuListProps: { + style: { padding: 0 }, + }, + }} + IconComponent={KeyboardArrowDownIcon} + sx={{ ...sx }} + > + {placeholder && ( + + {placeholder} + + )} + {items.map((item) => ( + + {item.name} + + ))} + + ); }; Select.propTypes = { id: PropTypes.string.isRequired, + label: PropTypes.string, placeholder: PropTypes.string, isHidden: PropTypes.bool, - value: PropTypes.string.isRequired, + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, items: PropTypes.arrayOf( PropTypes.shape({ - _id: PropTypes.string.isRequired, + _id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, name: PropTypes.string.isRequired, }) ).isRequired, diff --git a/Client/src/Components/TabPanels/Account/TeamPanel.jsx b/Client/src/Components/TabPanels/Account/TeamPanel.jsx index a2ebebd97..699624528 100644 --- a/Client/src/Components/TabPanels/Account/TeamPanel.jsx +++ b/Client/src/Components/TabPanels/Account/TeamPanel.jsx @@ -5,9 +5,7 @@ import { ButtonGroup, Divider, IconButton, - MenuItem, Modal, - Select, Stack, TextField, Typography, @@ -18,12 +16,12 @@ import { useEffect, useState } from "react"; import EditSvg from "../../../assets/icons/edit.svg?react"; import Field from "../../Inputs/Field"; import { credentials } from "../../../Validation/validation"; -import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown"; import axiosInstance from "../../../Utils/axiosConfig"; import { createToast } from "../../../Utils/toastUtils"; import { useSelector } from "react-redux"; import BasicTable from "../../BasicTable"; import Remove from "../../../assets/icons/trash-bin.svg?react"; +import Select from "../../Inputs/Select"; /** * TeamPanel component manages the organization and team members, @@ -44,7 +42,7 @@ const TeamPanel = () => { }); const [toInvite, setToInvite] = useState({ email: "", - role: [""], + role: ["0"], }); const [tableData, setTableData] = useState({}); const [members, setMembers] = useState([]); @@ -202,7 +200,7 @@ const TeamPanel = () => { }; const closeInviteModal = () => { setIsOpen(false); - setToInvite({ email: "", role: [""] }); + setToInvite({ email: "", role: ["0"] }); setErrors({}); }; @@ -377,6 +375,8 @@ const TeamPanel = () => { /> + items={[ + { _id: "admin", name: "admin" }, + { _id: "user", name: "user" }, + ]} + /> { value={selectedMonitor} onChange={handleSelect} items={Object.values(monitors)} - field="name" />