Create ProjectBox component

This commit is contained in:
Mathias Wagner
2024-07-20 13:10:00 +02:00
parent af30d1bc28
commit d7f09d70ae
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,32 @@
import {Avatar, Box, Divider, Typography} from "@mui/material";
import {ProjectContext} from "@/states/Dashboard/contexts/Project";
import {useContext} from "react";
import {useNavigate} from "react-router-dom";
export const ProjectBox = ({project}) => {
const boxStyle = {cursor: "pointer", "&:hover": {backgroundColor: "#eee"},
"&:active": {backgroundColor: "#ddd", scale: "0.95"}, "&:focus": {outline: "none"},
transition: "all 0.1s ease-in-out", userSelect: "none"}
const {setCurrentProject} = useContext(ProjectContext);
const navigate = useNavigate();
const switchProject = () => {
setCurrentProject(project);
navigate("/projects/" + project.id + "/stats");
}
return (
<Box justifyContent="center" alignItems="center" display="flex" borderRadius="10px"
border="1px solid #ccc" p={2.5} sx={boxStyle} onClick={switchProject}>
<Avatar sx={{width: "50px", height: "50px", marginRight: "10px"}} variant="rounded">
{project.name.charAt(0).toUpperCase()}
</Avatar>
<Divider orientation="vertical" sx={{marginRight: "10px", height: "35px"}} />
<Typography variant="h5">{project.name}</Typography>
</Box>
);
}

View File

@ -0,0 +1 @@
export {ProjectBox as default} from "./ProjectBox.jsx";