Simplify theme and fix Redux state bugs

## Changes

- Remove unused semantic color groups (successSecondary, map, chatbot)
- Remove unused properties from primary and tertiary groups
- Inline accent.darker usage in globalTheme.js
- Fix greeting component crash with persisted Redux state
- Fix MonitorGrid key prop warning

## Details

Theme simplification:
- Reduced constants.js from 355 to 291 lines
- Removed 3 unused semantic color groups
- Removed 6 unused properties (contrastBorder, contrastBorderDisabled, etc.)
- Inlined darken() call for accent hover states

Bug fixes:
- Added null-safe selectors in greeting.jsx for state.ui.greeting
- Added initialization check in setGreeting reducer for older persisted state
- Fixed key prop in MonitorGrid to handle both _id and id
- Removed unused console.log and Grid2 import
This commit is contained in:
gorkem-bwl committed 2026-01-15 18:06:40 -05:00
1 parent 206dcae196
commit 8b2ee8d937
9 files changed
+17 -77

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@ const langMap = {
const LanguageSelector = () => { const LanguageSelector = () => {
const { i18n } = useTranslation(); const { i18n } = useTranslation();
const theme = useTheme(); const theme = useTheme();
const { language } = useSelector((state) => state.ui); const { language = "en" } = useSelector((state) => state.ui);
const dispatch = useDispatch(); const dispatch = useDispatch();
const handleChange = (event) => { const handleChange = (event) => {
const newLang = event.target.value; const newLang = event.target.value;
@@ -2,7 +2,7 @@ import i18n from "../../../Utils/i18n.js";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { useEffect } from "react"; import { useEffect } from "react";
const I18nLoader = () => { const I18nLoader = () => {
const language = useSelector((state) => state.ui.language); const language = useSelector((state) => state.ui.language ?? "en");
useEffect(() => { useEffect(() => {
if (language && i18n.language !== language) { if (language && i18n.language !== language) {
+1 -1
View File
@@ -84,7 +84,7 @@ const Sidebar = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const navigate = useNavigate(); const navigate = useNavigate();
// Redux state // Redux state
const collapsed = useSelector((state) => state.ui.sidebar.collapsed); const collapsed = useSelector((state) => state.ui.sidebar?.collapsed ?? false);
const menu = getMenu(t); const menu = getMenu(t);
const otherMenuItems = getOtherMenuItems(t); const otherMenuItems = getOtherMenuItems(t);
+3
View File
@@ -58,6 +58,9 @@ const uiSlice = createSlice({
state.showURL = action.payload; state.showURL = action.payload;
}, },
setGreeting(state, action) { setGreeting(state, action) {
if (!state.greeting) {
state.greeting = { index: 0, lastUpdate: null };
}
state.greeting.index = action.payload.index; state.greeting.index = action.payload.index;
state.greeting.lastUpdate = action.payload.lastUpdate; state.greeting.lastUpdate = action.payload.lastUpdate;
}, },
@@ -1,8 +1,9 @@
import { Grid, Grid2 } from "@mui/material"; import { Grid } from "@mui/material";
import Card from "../Card/index.jsx"; import Card from "../Card/index.jsx";
const MonitorGrid = ({ shouldRender, monitors }) => { const MonitorGrid = ({ monitors, shouldRender = true }) => {
console.log(monitors); if (!shouldRender) return null;
return ( return (
<Grid <Grid
container container
@@ -11,7 +12,7 @@ const MonitorGrid = ({ shouldRender, monitors }) => {
{monitors?.map((monitor) => ( {monitors?.map((monitor) => (
<Card <Card
monitor={monitor} monitor={monitor}
key={monitor._id} key={monitor._id || monitor.id}
/> />
))} ))}
</Grid> </Grid>
+1 -1
View File
@@ -33,7 +33,7 @@ const BREADCRUMBS = [{ name: `Settings`, path: "/settings" }];
const Settings = () => { const Settings = () => {
// Redux state // Redux state
const { mode, language, timezone, showURL } = useSelector((state) => state.ui); const { mode, language = "en", timezone, showURL } = useSelector((state) => state.ui);
// Local state // Local state
const [settingsData, setSettingsData] = useState({}); const [settingsData, setSettingsData] = useState({});
+1 -65
View File
@@ -1,4 +1,4 @@
import { lighten, darken } from "@mui/material/styles"; // CAIO_REVIEW import { lighten } from "@mui/material/styles"; // CAIO_REVIEW
const typographyBase = 13; const typographyBase = 13;
@@ -133,12 +133,6 @@ const newSemanticColors = {
light: lighten(newColors.blueBlueWave, 0.2), //CAIO_REVIEW light: lighten(newColors.blueBlueWave, 0.2), //CAIO_REVIEW
dark: lighten(newColors.blueBlueWave, 0.2), //CAIO_REVIEW dark: lighten(newColors.blueBlueWave, 0.2), //CAIO_REVIEW
}, },
darker: {
// CAIO_REVIEW
light: darken(newColors.blueBlueWave, 0.2), // CAIO_REVIEW
dark: darken(newColors.blueBlueWave, 0.2), // CAIO_REVIEW
},
contrastText: { contrastText: {
light: newColors.offWhite, light: newColors.offWhite,
dark: newColors.offWhite, dark: newColors.offWhite,
@@ -165,14 +159,6 @@ const newSemanticColors = {
light: newColors.blueGray500, light: newColors.blueGray500,
dark: newColors.gray500, dark: newColors.gray500,
}, },
contrastBorder: {
light: newColors.gray500,
dark: newColors.blueGray600,
},
contrastBorderDisabled: {
light: newColors.gray100,
dark: newColors.blueGray800,
},
lowContrast: { lowContrast: {
light: newColors.gray250, light: newColors.gray250,
dark: newColors.blueGray600, dark: newColors.blueGray600,
@@ -207,18 +193,6 @@ const newSemanticColors = {
light: newColors.blueGray800, light: newColors.blueGray800,
dark: newColors.gray100, dark: newColors.gray100,
}, },
background: {
light: newColors.gray50,
dark: newColors.offBlack,
},
border: {
light: newColors.gray500,
dark: newColors.blueGray600,
},
cardShadow: {
light: "0 0 0 1px rgba(0, 0, 0, 0.04), 0 12px 24px rgba(0, 0, 0, 0.08)",
dark: "0 2px 10px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.04)",
},
}, },
success: { success: {
main: { main: {
@@ -234,20 +208,6 @@ const newSemanticColors = {
dark: newColors.green200, dark: newColors.green200,
}, },
}, },
successSecondary: {
main: {
light: undefined,
dark: "#073C2D",
},
contrastText: {
light: undefined,
dark: "#34D399",
},
lowContrast: {
light: undefined,
dark: "#094434",
},
},
warning: { warning: {
main: { main: {
light: newColors.orange700, light: newColors.orange700,
@@ -316,30 +276,6 @@ const newSemanticColors = {
}, },
}, },
map: {
main: {
light: newColors.offWhite,
dark: undefined,
},
lowContrast: {
light: newColors.gray200,
dark: undefined,
},
highContrast: {
light: newColors.gray500,
dark: undefined,
},
},
chatbot: {
background: {
light: newColors.gray200,
dark: "#112B2B",
},
textAccent: {
light: "#C084FC",
dark: "#C084FC",
},
},
alert: { alert: {
main: { main: {
light: newColors.gray200, light: newColors.gray200,
+2 -2
View File
@@ -64,7 +64,7 @@ const baseTheme = (palette) => ({
letterSpacing: "0.5px", letterSpacing: "0.5px",
textShadow: "0 0 1px rgba(0, 0, 0, 0.15)", textShadow: "0 0 1px rgba(0, 0, 0, 0.15)",
"&:hover": { "&:hover": {
backgroundColor: darken(theme.palette.accent.darker, 0.05), backgroundColor: darken(theme.palette.accent.main, 0.25),
boxShadow: `0 2px 6px rgba(0, 0, 0, 0.1)`, boxShadow: `0 2px 6px rgba(0, 0, 0, 0.1)`,
transition: "all 0.2s ease-in-out", transition: "all 0.2s ease-in-out",
}, },
@@ -74,7 +74,7 @@ const baseTheme = (palette) => ({
props: (props) => props.color === "accent", props: (props) => props.color === "accent",
style: { style: {
"&:hover": { "&:hover": {
backgroundColor: theme.palette.accent.darker, backgroundColor: darken(theme.palette.accent.main, 0.2),
}, },
}, },
}, },
+2 -2
View File
@@ -136,8 +136,8 @@ const Greeting = ({ type = "" }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const { t } = useTranslation(); const { t } = useTranslation();
const { firstName } = useSelector((state) => state.auth.user); const { firstName } = useSelector((state) => state.auth.user);
const index = useSelector((state) => state.ui.greeting.index); const index = useSelector((state) => state.ui.greeting?.index ?? 0);
const lastUpdate = useSelector((state) => state.ui.greeting.lastUpdate); const lastUpdate = useSelector((state) => state.ui.greeting?.lastUpdate ?? null);
const now = new Date(); const now = new Date();
const hour = now.getHours(); const hour = now.getHours();