Skip to content

Commit 91c0aa6

Browse files
authored
Merge pull request #2014 from Northeastern-Electric-Racing/#1928-fix-color-BOM
#1928 fix color bom
2 parents 7310216 + aca4563 commit 91c0aa6

3 files changed

Lines changed: 55 additions & 16 deletions

File tree

src/frontend/src/pages/ProjectDetailPage/ProjectViewContainer/BOM/BOMTable.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Assembly, Material } from 'shared';
44
import { BomRow, bomTableStyles, materialToRow, BomStyledDataGrid } from '../../../../utils/bom.utils';
55
import { addMaterialCosts } from '../BOMTab';
66
import { centsToDollar } from '../../../../utils/pipes';
7+
import { useTheme } from '@mui/material';
78
import { useState } from 'react';
89

910
interface BOMTableProps {
@@ -20,6 +21,7 @@ const BOMTable: React.FC<BOMTableProps> = ({ columns, materials, assemblies }) =
2021
};
2122

2223
const noAssemblyMaterials = materials.filter((material) => !material.assembly);
24+
const theme = useTheme();
2325
const miscAssembly: BomRow = {
2426
id: `assembly-misc`,
2527
materialId: '',
@@ -82,7 +84,20 @@ const BOMTable: React.FC<BOMTableProps> = ({ columns, materials, assemblies }) =
8284
return (
8385
<Box
8486
sx={{
85-
height: 'calc(100vh - 180px)'
87+
height: 'calc(100vh - 180px)',
88+
width: '100%',
89+
'& .super-app-theme--header': {
90+
backgroundColor: '#ef4345'
91+
},
92+
'& .super-app-theme--assembly': {
93+
backgroundColor: theme.palette.grey[600],
94+
'&:hover': {
95+
backgroundColor: theme.palette.grey[700]
96+
},
97+
'&:focus': {
98+
backgroundColor: '#997570'
99+
}
100+
}
86101
}}
87102
>
88103
<BomStyledDataGrid

src/frontend/src/pages/ProjectDetailPage/ProjectViewContainer/BOM/BOMTableCustomCells.tsx

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,46 @@ export const renderLinkBOM = (params: GridRenderCellParams) =>
1111
</Link>
1212
);
1313

14+
const getStatusColor = (status: MaterialStatus) => {
15+
switch (status) {
16+
case MaterialStatus.Ordered:
17+
return '#dba63e';
18+
case MaterialStatus.Unordered:
19+
return '#a63737';
20+
case MaterialStatus.Received:
21+
return '#2a712a';
22+
case MaterialStatus.Shipped:
23+
return '#1b537a';
24+
default:
25+
return 'grey';
26+
}
27+
};
28+
29+
const bomStatusChipStyle = (status: MaterialStatus) => ({
30+
backgroundColor: getStatusColor(status),
31+
display: 'flex',
32+
justifyContent: 'center',
33+
alignItems: 'center',
34+
padding: '4px',
35+
borderRadius: '6px',
36+
minWidth: '85px',
37+
height: '36px',
38+
textAlign: 'center'
39+
});
40+
1441
export const renderStatusBOM = (params: GridRenderCellParams) => {
1542
if (!params.value) return;
16-
const status = params.value;
17-
const color =
18-
status === MaterialStatus.Ordered
19-
? 'orange'
20-
: status === MaterialStatus.Unordered
21-
? 'red'
22-
: status === MaterialStatus.Received
23-
? 'green'
24-
: status === MaterialStatus.Shipped
25-
? 'yellow'
26-
: 'grey';
43+
const status = params.value as MaterialStatus;
44+
2745
return (
28-
<Box sx={{ backgroundColor: color, padding: '6px 10px 6px 10px', borderRadius: '6px' }}>
29-
<Typography fontSize="14px" color="black">
46+
<Box sx={bomStatusChipStyle(status)}>
47+
<Typography
48+
fontSize={{
49+
xs: '11px',
50+
sm: '14px'
51+
}}
52+
color="black"
53+
>
3054
{displayEnum(status)}
3155
</Typography>
3256
</Box>

src/frontend/src/utils/bom.utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ export const BomStyledDataGrid = styled(DataGrid)(({ theme }) => ({
7171
backgroundColor: '#ef4345'
7272
},
7373
'& .super-app-theme--assembly': {
74-
backgroundColor: '#997570',
74+
backgroundColor: theme.palette.grey[600],
7575
'&:hover': {
76-
backgroundColor: '#997570'
76+
backgroundColor: theme.palette.grey[700]
7777
},
7878
'&.Mui-selected': {
7979
backgroundColor: '#997570',

0 commit comments

Comments
 (0)