Refactored old select components
This commit is contained in:
1 parent
a49cf7cc6e
commit
6f668942d6
10 files changed
+142
-237
No files matched your search
@@ -1,13 +1,17 @@
|
|||||||
.select-component > .MuiSelect-select {
|
.select-wrapper .select-component > .MuiSelect-select {
|
||||||
|
padding: 0 10px;
|
||||||
height: 34px !important;
|
height: 34px !important;
|
||||||
display: flex !important;
|
display: flex !important;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
text-transform: capitalize;
|
||||||
|
line-height: 1;
|
||||||
}
|
}
|
||||||
.MuiInputBase-root:has(> .MuiSelect-select) {
|
.select-wrapper .MuiInputBase-root:has(> .MuiSelect-select) {
|
||||||
min-width: 150px;
|
min-width: 150px;
|
||||||
}
|
}
|
||||||
.MuiInputBase-root:has(> .MuiSelect-select),
|
.select-wrapper .MuiInputBase-root:has(> .MuiSelect-select),
|
||||||
.MuiMenu-List .MuiMenuItem-root {
|
.MuiMenu-List .MuiMenuItem-root,
|
||||||
|
.select-wrapper h3.MuiTypography-root {
|
||||||
font-size: var(--env-var-font-size-medium);
|
font-size: var(--env-var-font-size-medium);
|
||||||
color: var(--env-var-color-5);
|
color: var(--env-var-color-5);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
import PropTypes from "prop-types";
|
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,
|
||||||
|
Stack,
|
||||||
|
Typography,
|
||||||
|
} from "@mui/material";
|
||||||
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
||||||
|
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
@@ -9,6 +14,7 @@ import "./index.css";
|
|||||||
* @component
|
* @component
|
||||||
* @param {object} props
|
* @param {object} props
|
||||||
* @param {string} props.id - The ID attribute for the select element.
|
* @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 {string} props.placeholder - The placeholder text when no option is selected.
|
||||||
* @param {boolean} props.isHidden - Whether the placeholder should be hidden.
|
* @param {boolean} props.isHidden - Whether the placeholder should be hidden.
|
||||||
* @param {string} props.value - The currently selected value.
|
* @param {string} props.value - The currently selected value.
|
||||||
@@ -20,7 +26,16 @@ import "./index.css";
|
|||||||
* @returns {JSX.Element}
|
* @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 theme = useTheme();
|
||||||
const itemStyles = {
|
const itemStyles = {
|
||||||
fontSize: "var(--env-var-font-size-medium)",
|
fontSize: "var(--env-var-font-size-medium)",
|
||||||
@@ -31,61 +46,66 @@ const Select = ({ id, placeholder, isHidden, value, items, onChange, sx }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MuiSelect
|
<Stack gap={theme.gap.xs} className="select-wrapper">
|
||||||
id={id}
|
{label && <Typography component="h3">{label}</Typography>}
|
||||||
className="select-component"
|
<MuiSelect
|
||||||
value={value}
|
className="select-component"
|
||||||
onChange={onChange}
|
value={value}
|
||||||
displayEmpty
|
onChange={onChange}
|
||||||
MenuProps={{
|
displayEmpty
|
||||||
PaperProps: {
|
inputProps={{ id: id }}
|
||||||
style: {
|
MenuProps={{
|
||||||
marginTop: theme.gap.xs,
|
PaperProps: {
|
||||||
|
className: "select-dropdown",
|
||||||
|
style: {
|
||||||
|
marginTop: theme.gap.xs,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
MenuListProps: {
|
||||||
MenuListProps: {
|
style: { padding: 0 },
|
||||||
style: { padding: 0 },
|
},
|
||||||
},
|
}}
|
||||||
}}
|
IconComponent={KeyboardArrowDownIcon}
|
||||||
IconComponent={KeyboardArrowDownIcon}
|
sx={{ ...sx }}
|
||||||
sx={{ ...sx }}
|
>
|
||||||
>
|
{placeholder && (
|
||||||
{placeholder && (
|
<MenuItem
|
||||||
<MenuItem
|
className="select-placeholder"
|
||||||
className="select-placeholder"
|
value="0"
|
||||||
value="0"
|
sx={{
|
||||||
sx={{
|
display: isHidden ? "none" : "flex",
|
||||||
display: isHidden ? "none" : "flex",
|
visibility: isHidden ? "none" : "visible",
|
||||||
visibility: isHidden ? "none" : "visible",
|
...itemStyles,
|
||||||
...itemStyles,
|
}}
|
||||||
}}
|
>
|
||||||
>
|
{placeholder}
|
||||||
{placeholder}
|
</MenuItem>
|
||||||
</MenuItem>
|
)}
|
||||||
)}
|
{items.map((item) => (
|
||||||
{items.map((item) => (
|
<MenuItem
|
||||||
<MenuItem
|
value={item._id}
|
||||||
value={item._id}
|
key={`${id}-${item._id}`}
|
||||||
key={`${id}-${item._id}`}
|
sx={{
|
||||||
sx={{
|
...itemStyles,
|
||||||
...itemStyles,
|
}}
|
||||||
}}
|
>
|
||||||
>
|
{item.name}
|
||||||
{item.name}
|
</MenuItem>
|
||||||
</MenuItem>
|
))}
|
||||||
))}
|
</MuiSelect>
|
||||||
</MuiSelect>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Select.propTypes = {
|
Select.propTypes = {
|
||||||
id: PropTypes.string.isRequired,
|
id: PropTypes.string.isRequired,
|
||||||
|
label: PropTypes.string,
|
||||||
placeholder: PropTypes.string,
|
placeholder: PropTypes.string,
|
||||||
isHidden: PropTypes.bool,
|
isHidden: PropTypes.bool,
|
||||||
value: PropTypes.string.isRequired,
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
||||||
items: PropTypes.arrayOf(
|
items: PropTypes.arrayOf(
|
||||||
PropTypes.shape({
|
PropTypes.shape({
|
||||||
_id: PropTypes.string.isRequired,
|
_id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
||||||
name: PropTypes.string.isRequired,
|
name: PropTypes.string.isRequired,
|
||||||
})
|
})
|
||||||
).isRequired,
|
).isRequired,
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import {
|
|||||||
ButtonGroup,
|
ButtonGroup,
|
||||||
Divider,
|
Divider,
|
||||||
IconButton,
|
IconButton,
|
||||||
MenuItem,
|
|
||||||
Modal,
|
Modal,
|
||||||
Select,
|
|
||||||
Stack,
|
Stack,
|
||||||
TextField,
|
TextField,
|
||||||
Typography,
|
Typography,
|
||||||
@@ -18,12 +16,12 @@ import { useEffect, useState } from "react";
|
|||||||
import EditSvg from "../../../assets/icons/edit.svg?react";
|
import EditSvg from "../../../assets/icons/edit.svg?react";
|
||||||
import Field from "../../Inputs/Field";
|
import Field from "../../Inputs/Field";
|
||||||
import { credentials } from "../../../Validation/validation";
|
import { credentials } from "../../../Validation/validation";
|
||||||
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
|
||||||
import axiosInstance from "../../../Utils/axiosConfig";
|
import axiosInstance from "../../../Utils/axiosConfig";
|
||||||
import { createToast } from "../../../Utils/toastUtils";
|
import { createToast } from "../../../Utils/toastUtils";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import BasicTable from "../../BasicTable";
|
import BasicTable from "../../BasicTable";
|
||||||
import Remove from "../../../assets/icons/trash-bin.svg?react";
|
import Remove from "../../../assets/icons/trash-bin.svg?react";
|
||||||
|
import Select from "../../Inputs/Select";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TeamPanel component manages the organization and team members,
|
* TeamPanel component manages the organization and team members,
|
||||||
@@ -44,7 +42,7 @@ const TeamPanel = () => {
|
|||||||
});
|
});
|
||||||
const [toInvite, setToInvite] = useState({
|
const [toInvite, setToInvite] = useState({
|
||||||
email: "",
|
email: "",
|
||||||
role: [""],
|
role: ["0"],
|
||||||
});
|
});
|
||||||
const [tableData, setTableData] = useState({});
|
const [tableData, setTableData] = useState({});
|
||||||
const [members, setMembers] = useState([]);
|
const [members, setMembers] = useState([]);
|
||||||
@@ -202,7 +200,7 @@ const TeamPanel = () => {
|
|||||||
};
|
};
|
||||||
const closeInviteModal = () => {
|
const closeInviteModal = () => {
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
setToInvite({ email: "", role: [""] });
|
setToInvite({ email: "", role: ["0"] });
|
||||||
setErrors({});
|
setErrors({});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -377,6 +375,8 @@ const TeamPanel = () => {
|
|||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
id="team-member-role"
|
id="team-member-role"
|
||||||
|
placeholder="Select role"
|
||||||
|
isHidden={true}
|
||||||
value={toInvite.role[0]}
|
value={toInvite.role[0]}
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
setToInvite((prev) => ({
|
setToInvite((prev) => ({
|
||||||
@@ -384,46 +384,11 @@ const TeamPanel = () => {
|
|||||||
role: [event.target.value],
|
role: [event.target.value],
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
displayEmpty
|
items={[
|
||||||
MenuProps={{
|
{ _id: "admin", name: "admin" },
|
||||||
PaperProps: {
|
{ _id: "user", name: "user" },
|
||||||
style: {
|
]}
|
||||||
marginTop: theme.gap.xs,
|
/>
|
||||||
},
|
|
||||||
},
|
|
||||||
MenuListProps: {
|
|
||||||
style: { padding: 0 },
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
IconComponent={KeyboardArrowDownIcon}
|
|
||||||
sx={{ mt: theme.gap.xs }}
|
|
||||||
>
|
|
||||||
<MenuItem disableRipple id="role-default" value="">
|
|
||||||
Select role
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem
|
|
||||||
disableRipple
|
|
||||||
value="admin"
|
|
||||||
sx={{
|
|
||||||
fontSize: "13px",
|
|
||||||
borderRadius: `${theme.shape.borderRadius}px`,
|
|
||||||
margin: theme.gap.xs,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Admin
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem
|
|
||||||
disableRipple
|
|
||||||
value="user"
|
|
||||||
sx={{
|
|
||||||
fontSize: "13px",
|
|
||||||
borderRadius: `${theme.shape.borderRadius}px`,
|
|
||||||
margin: theme.gap.xs,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
User
|
|
||||||
</MenuItem>
|
|
||||||
</Select>
|
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
gap={theme.gap.small}
|
gap={theme.gap.small}
|
||||||
|
|||||||
@@ -67,23 +67,6 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
#select-actions,
|
|
||||||
#select-role {
|
|
||||||
padding: 5px 0;
|
|
||||||
padding-left: 15px;
|
|
||||||
padding-right: 50px;
|
|
||||||
line-height: 1.75;
|
|
||||||
}
|
|
||||||
.MuiInputBase-root:has(#select-actions) fieldset,
|
|
||||||
.MuiInputBase-root:has(#select-role) fieldset {
|
|
||||||
border-color: #a1a7b1;
|
|
||||||
margin: -1px;
|
|
||||||
border-width: 1px;
|
|
||||||
}
|
|
||||||
.MuiInputBase-root:has(#select-actions):hover fieldset,
|
|
||||||
.MuiInputBase-root:has(#select-role):hover fieldset {
|
|
||||||
border-color: var(--env-var-color-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* for testing, will remove later */
|
/* for testing, will remove later */
|
||||||
@media only screen and (max-width: 1600px) {
|
@media only screen and (max-width: 1600px) {
|
||||||
@@ -111,23 +94,6 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#role-default {
|
|
||||||
display: none;
|
|
||||||
visibility: none;
|
|
||||||
}
|
|
||||||
.MuiInputBase-root:has(#team-member-role) {
|
|
||||||
height: 34px;
|
|
||||||
}
|
|
||||||
#team-member-role {
|
|
||||||
padding: 0 10px;
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
.MuiInputBase-root:not(.Mui-focused):has(#team-member-role):hover fieldset {
|
|
||||||
border-color: var(--env-var-color-29);
|
|
||||||
}
|
|
||||||
|
|
||||||
.edit-organization-form {
|
.edit-organization-form {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -119,7 +119,6 @@ const Incidents = () => {
|
|||||||
value={selectedMonitor}
|
value={selectedMonitor}
|
||||||
onChange={handleSelect}
|
onChange={handleSelect}
|
||||||
items={Object.values(monitors)}
|
items={Object.values(monitors)}
|
||||||
field="name"
|
|
||||||
/>
|
/>
|
||||||
<ButtonGroup sx={{ ml: "auto" }}>
|
<ButtonGroup sx={{ ml: "auto" }}>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -70,3 +70,8 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: var(--env-var-spacing-4);
|
gap: var(--env-var-spacing-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body:has(.configure-monitor) .select-dropdown .MuiMenuItem-root,
|
||||||
|
.configure-monitor .select-wrapper .select-component > .MuiSelect-select {
|
||||||
|
text-transform: lowercase;
|
||||||
|
}
|
||||||
@@ -5,15 +5,15 @@ import { useEffect, useState } from "react";
|
|||||||
import Button from "../../../Components/Button";
|
import Button from "../../../Components/Button";
|
||||||
import Field from "../../../Components/Inputs/Field";
|
import Field from "../../../Components/Inputs/Field";
|
||||||
import RadioButton from "../../../Components/RadioButton";
|
import RadioButton from "../../../Components/RadioButton";
|
||||||
import { Box, MenuItem, Select, Stack, Typography } from "@mui/material";
|
import { Box, MenuItem, Stack, Typography } from "@mui/material";
|
||||||
import WestRoundedIcon from "@mui/icons-material/WestRounded";
|
import WestRoundedIcon from "@mui/icons-material/WestRounded";
|
||||||
import GreenCheck from "../../../assets/icons/checkbox-green.svg?react";
|
import GreenCheck from "../../../assets/icons/checkbox-green.svg?react";
|
||||||
import RedCheck from "../../../assets/icons/checkbox-red.svg?react";
|
import RedCheck from "../../../assets/icons/checkbox-red.svg?react";
|
||||||
import PauseCircleOutlineIcon from "@mui/icons-material/PauseCircleOutline";
|
import PauseCircleOutlineIcon from "@mui/icons-material/PauseCircleOutline";
|
||||||
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
|
||||||
|
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import { monitorValidation } from "../../../Validation/validation";
|
import { monitorValidation } from "../../../Validation/validation";
|
||||||
|
import Select from "../../../Components/Inputs/Select";
|
||||||
|
|
||||||
const formatDurationRounded = (ms) => {
|
const formatDurationRounded = (ms) => {
|
||||||
const seconds = Math.floor(ms / 1000);
|
const seconds = Math.floor(ms / 1000);
|
||||||
@@ -119,7 +119,13 @@ const Configure = () => {
|
|||||||
// TODO
|
// TODO
|
||||||
};
|
};
|
||||||
|
|
||||||
const frequencies = [1, 2, 3, 4, 5];
|
const frequencies = [
|
||||||
|
{ _id: 1, name: "1 minute" },
|
||||||
|
{ _id: 2, name: "2 minutes" },
|
||||||
|
{ _id: 3, name: "3 minutes" },
|
||||||
|
{ _id: 4, name: "4 minutes" },
|
||||||
|
{ _id: 5, name: "5 minutes" },
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -284,40 +290,13 @@ const Configure = () => {
|
|||||||
<Typography component="h2">Advanced settings</Typography>
|
<Typography component="h2">Advanced settings</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack gap={theme.gap.xl}>
|
<Stack gap={theme.gap.xl}>
|
||||||
<Box>
|
<Select
|
||||||
<Typography component="p" mb={theme.gap.small}>
|
id="monitor-interval-configure"
|
||||||
Check frequency
|
label="Check frequency"
|
||||||
</Typography>
|
value={monitor?.interval || 1}
|
||||||
<Select
|
onChange={(event) => handleChange(event, "interval")}
|
||||||
id="monitor-interval"
|
items={frequencies}
|
||||||
value={monitor?.interval || 1}
|
/>
|
||||||
inputProps={{ id: "monitor-interval-select" }}
|
|
||||||
MenuProps={{
|
|
||||||
PaperProps: {
|
|
||||||
style: {
|
|
||||||
marginTop: "10px",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
IconComponent={KeyboardArrowDownIcon}
|
|
||||||
onChange={(event) => handleChange(event, "interval")}
|
|
||||||
>
|
|
||||||
{frequencies.map((freq) => (
|
|
||||||
<MenuItem
|
|
||||||
key={`port-${freq}`}
|
|
||||||
value={freq}
|
|
||||||
disableRipple
|
|
||||||
sx={{
|
|
||||||
fontSize: "13px",
|
|
||||||
borderRadius: `${theme.shape.borderRadius}px`,
|
|
||||||
margin: theme.gap.xs,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{freq} {freq === 1 ? "minute" : "minutes"}
|
|
||||||
</MenuItem>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</Box>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack direction="row" justifyContent="flex-end">
|
<Stack direction="row" justifyContent="flex-end">
|
||||||
|
|||||||
@@ -10,14 +10,12 @@
|
|||||||
font-size: var(--env-var-font-size-large);
|
font-size: var(--env-var-font-size-large);
|
||||||
}
|
}
|
||||||
.create-monitor p.MuiTypography-root,
|
.create-monitor p.MuiTypography-root,
|
||||||
.create-monitor button.MuiButtonBase-root,
|
.create-monitor button.MuiButtonBase-root {
|
||||||
#monitor-frequencies {
|
|
||||||
font-size: var(--env-var-font-size-medium);
|
font-size: var(--env-var-font-size-medium);
|
||||||
}
|
}
|
||||||
.create-monitor h2.MuiTypography-root,
|
.create-monitor h2.MuiTypography-root,
|
||||||
.create-monitor h6.MuiTypography-root,
|
.create-monitor h6.MuiTypography-root,
|
||||||
.create-monitor p.MuiTypography-root,
|
.create-monitor p.MuiTypography-root {
|
||||||
#monitor-frequencies {
|
|
||||||
color: var(--env-var-color-2);
|
color: var(--env-var-color-2);
|
||||||
}
|
}
|
||||||
.create-monitor h6.MuiTypography-root {
|
.create-monitor h6.MuiTypography-root {
|
||||||
@@ -36,21 +34,6 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
}
|
}
|
||||||
.create-monitor .MuiSelect-select.MuiSelect-outlined.MuiInputBase-input {
|
|
||||||
padding: var(--env-var-spacing-1);
|
|
||||||
}
|
|
||||||
.create-monitor .MuiInputBase-root:has(#monitor-frequencies) {
|
|
||||||
min-width: 300px;
|
|
||||||
width: 100%;
|
|
||||||
height: 34px;
|
|
||||||
border: 1px solid var(--env-var-color-4);
|
|
||||||
border-radius: var(--env-var-radius-1);
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.create-monitor .MuiInputBase-root:has(#monitor-frequencies) fieldset {
|
|
||||||
outline: none;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
.create-monitor .MuiStack-root:has(span.MuiTypography-root.input-error) {
|
.create-monitor .MuiStack-root:has(span.MuiTypography-root.input-error) {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
@@ -76,3 +59,8 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: var(--env-var-spacing-4);
|
gap: var(--env-var-spacing-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body:has(.create-monitor) .select-dropdown .MuiMenuItem-root,
|
||||||
|
.create-monitor .select-wrapper .select-component > .MuiSelect-select {
|
||||||
|
text-transform: lowercase;
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ import "./index.css";
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import RadioButton from "../../../Components/RadioButton";
|
import RadioButton from "../../../Components/RadioButton";
|
||||||
import Button from "../../../Components/Button";
|
import Button from "../../../Components/Button";
|
||||||
import { Box, MenuItem, Select, Stack, Typography } from "@mui/material";
|
import { Box, MenuItem, Stack, Typography } from "@mui/material";
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import { monitorValidation } from "../../../Validation/validation";
|
import { monitorValidation } from "../../../Validation/validation";
|
||||||
import { createMonitor } from "../../../Features/Monitors/monitorsSlice";
|
import { createMonitor } from "../../../Features/Monitors/monitorsSlice";
|
||||||
@@ -10,6 +10,7 @@ import { useNavigate } from "react-router-dom";
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import WestRoundedIcon from "@mui/icons-material/WestRounded";
|
import WestRoundedIcon from "@mui/icons-material/WestRounded";
|
||||||
import Field from "../../../Components/Inputs/Field";
|
import Field from "../../../Components/Inputs/Field";
|
||||||
|
import Select from "../../../Components/Inputs/Select";
|
||||||
|
|
||||||
const CreateMonitor = () => {
|
const CreateMonitor = () => {
|
||||||
const MS_PER_MINUTE = 60000;
|
const MS_PER_MINUTE = 60000;
|
||||||
@@ -125,7 +126,13 @@ const CreateMonitor = () => {
|
|||||||
|
|
||||||
//select values
|
//select values
|
||||||
// const ports = ["Port 1", "Port 2", "Port 3"];
|
// const ports = ["Port 1", "Port 2", "Port 3"];
|
||||||
const frequencies = [1, 2, 3, 4, 5];
|
const frequencies = [
|
||||||
|
{ _id: 1, name: "1 minute" },
|
||||||
|
{ _id: 2, name: "2 minutes" },
|
||||||
|
{ _id: 3, name: "3 minutes" },
|
||||||
|
{ _id: 4, name: "4 minutes" },
|
||||||
|
{ _id: 5, name: "5 minutes" },
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -308,41 +315,15 @@ const CreateMonitor = () => {
|
|||||||
<Typography component="h2">Advanced settings</Typography>
|
<Typography component="h2">Advanced settings</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack gap={theme.gap.large}>
|
<Stack gap={theme.gap.large}>
|
||||||
{/* TODO - refactor select component */}
|
<Select
|
||||||
<Box>
|
id="monitor-interval"
|
||||||
<Typography component="p" mb={theme.gap.small}>
|
label="Check frequency"
|
||||||
Check frequency
|
value={advancedSettings.interval || 1}
|
||||||
</Typography>
|
onChange={(event) =>
|
||||||
<Select
|
handleChange(event, "interval", setAdvancedSettings)
|
||||||
id="monitor-frequencies"
|
}
|
||||||
value={advancedSettings.interval || 1}
|
items={frequencies}
|
||||||
inputProps={{ id: "monitor-frequencies-select" }}
|
/>
|
||||||
onChange={(event) =>
|
|
||||||
handleChange(event, "interval", setAdvancedSettings)
|
|
||||||
}
|
|
||||||
MenuProps={{
|
|
||||||
PaperProps: {
|
|
||||||
style: {
|
|
||||||
marginTop: "10px",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{frequencies.map((freq) => (
|
|
||||||
<MenuItem
|
|
||||||
key={`port-${freq}`}
|
|
||||||
value={freq}
|
|
||||||
sx={{
|
|
||||||
fontSize: "13px",
|
|
||||||
borderRadius: `${theme.shape.borderRadius}px`,
|
|
||||||
margin: "5px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{freq} {freq === 1 ? "minute" : "minutes"}
|
|
||||||
</MenuItem>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</Box>
|
|
||||||
{/* TODO */}
|
{/* TODO */}
|
||||||
{/* <FlexibileTextField
|
{/* <FlexibileTextField
|
||||||
id="monitor-settings-retries"
|
id="monitor-settings-retries"
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { Box, Stack, Typography } from "@mui/material";
|
import { Box, Stack, Typography } from "@mui/material";
|
||||||
import Button from "../../Components/Button";
|
import Button from "../../Components/Button";
|
||||||
|
|
||||||
import "./index.css";
|
|
||||||
import Field from "../../Components/Inputs/Field";
|
import Field from "../../Components/Inputs/Field";
|
||||||
import Link from "../../Components/Link";
|
import Link from "../../Components/Link";
|
||||||
|
import Select from "../../Components/Inputs/Select";
|
||||||
|
|
||||||
|
import "./index.css";
|
||||||
|
|
||||||
const Settings = () => {
|
const Settings = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -37,22 +38,19 @@ const Settings = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack gap={theme.gap.xl}>
|
<Stack gap={theme.gap.xl}>
|
||||||
{/* TODO - build select component */}
|
<Select
|
||||||
<Field
|
|
||||||
type="text"
|
|
||||||
id="display-timezone"
|
id="display-timezone"
|
||||||
label="Display timezone"
|
label="Display timezone"
|
||||||
placeholder="America / Toronto"
|
value="est"
|
||||||
value=""
|
onChange={() => console.log("disabled")}
|
||||||
onChange={() => console.log("Disabled")}
|
items={[{ _id: "est", name: "America / Toronto" }]}
|
||||||
/>
|
/>
|
||||||
<Field
|
<Select
|
||||||
type="text"
|
|
||||||
id="server-timezone"
|
id="server-timezone"
|
||||||
label="Server timezone"
|
label="Server timezone"
|
||||||
placeholder="America / Toronto"
|
value="est"
|
||||||
value=""
|
onChange={() => console.log("disabled")}
|
||||||
onChange={() => console.log("Disabled")}
|
items={[{ _id: "est", name: "America / Toronto" }]}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
Reference in new issue
Block a user