From bce928401d22f39f8bf11d8c66d1f8c6945e05ef Mon Sep 17 00:00:00 2001 From: Victor Frunze Date: Fri, 13 Dec 2024 10:01:32 +0200 Subject: [PATCH] MWB-906: add project-switch dots --- .../app/project-switch2/project-switch.js | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/mapping_workbench/frontend/src/layouts/app/project-switch2/project-switch.js b/mapping_workbench/frontend/src/layouts/app/project-switch2/project-switch.js index 38a7aaa5..0a017ae7 100644 --- a/mapping_workbench/frontend/src/layouts/app/project-switch2/project-switch.js +++ b/mapping_workbench/frontend/src/layouts/app/project-switch2/project-switch.js @@ -1,4 +1,3 @@ -import Tooltip from '@mui/material/Tooltip'; import {useContext, useState} from "react"; import AddIcon from '@mui/icons-material/Add'; @@ -7,6 +6,7 @@ import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos'; import Menu from '@mui/material/Menu'; import Stack from '@mui/material/Stack'; +import Tooltip from '@mui/material/Tooltip'; import Divider from '@mui/material/Divider'; import {useTheme} from '@mui/material/styles'; import MenuItem from "@mui/material/MenuItem"; @@ -19,6 +19,17 @@ import {useRouter} from "next/router"; import {Scrollbar} from 'src/components/scrollbar'; import {ProjectsContext} from "src/contexts/projects"; +const colors = ['error', 'info', 'primary', 'secondary', 'success', 'warning']; + +const getColorForId = (id) => { + const hash = Array.from(id).reduce((sum, char) => sum + char.charCodeAt(0), 0); + return colors[hash % colors.length]; +}; + +const Circle = ({color}) => { + return +} + export const ProjectSwitch = ({small}) => { const [anchorEl, setAnchorEl] = useState(null); const projectsStore = useContext(ProjectsContext) @@ -26,6 +37,8 @@ export const ProjectSwitch = ({small}) => { const router = useRouter(); const theme = useTheme() + console.log(theme) + const handleProjectSelect = (value) => { if (value) @@ -42,17 +55,20 @@ export const ProjectSwitch = ({small}) => { setAnchorEl(null); }; - const projectName = projectsStore.items?.find(project => project._id === projectsStore.sessionProject)?.title + const currentProject = projectsStore.items?.find(project => project._id === projectsStore.sessionProject) + + + console.log(currentProject._id) + return ( - - + { p: '9px', cursor: 'pointer' }}> - {!small && projectName} + {!!currentProject && + + {!small && currentProject.title} + } + sx={{fontSize: '18px'}} + /> { sx={{px: '15px', py: '8px'}} onClick={() => handleProjectSelect(project._id)} > + + {project.title}