@@ -2,28 +2,23 @@ import { Box } from '@mui/system';
22import { MaterialPreview , Project } from 'shared' ;
33import { NERButton } from '../../../components/NERButton' ;
44import WarningIcon from '@mui/icons-material/Warning' ;
5- import { MenuItem , Select , SelectChangeEvent , Tooltip , useTheme } from '@mui/material' ;
5+ import { Tooltip , useTheme } from '@mui/material' ;
66import { useState } from 'react' ;
77import BOMTableWrapper from './BOM/BOMTableWrapper' ;
88import CreateMaterialModal from './BOM/MaterialForm/CreateMaterialModal' ;
99import CreateAssemblyModal from './BOM/AssemblyForm/CreateAssemblyModal' ;
1010import NERSuccessButton from '../../../components/NERSuccessButton' ;
11+ import { centsToDollar } from '../../../utils/pipes' ;
1112
1213export const addMaterialCosts = ( accumulator : number , currentMaterial : MaterialPreview ) =>
1314 currentMaterial . subtotal + accumulator ;
1415
1516const BOMTab = ( { project } : { project : Project } ) => {
1617 const [ showAddMaterial , setShowAddMaterial ] = useState ( false ) ;
1718 const [ showAddAssembly , setShowAddAssembly ] = useState ( false ) ;
18- const [ assembly , setAssembly ] = useState ( 'Total' ) ;
1919 const theme = useTheme ( ) ;
2020
21- const costOptions = project . assemblies . map ( ( assembly ) => assembly . name ) ;
22- costOptions . push ( 'Total' ) ;
23-
2421 const totalCost = project . materials . reduce ( addMaterialCosts , 0 ) ;
25- const selectedAssemblyMaterials = project . assemblies . find ( ( a ) => a . name === assembly ) ?. materials ;
26- const displayedCost = selectedAssemblyMaterials ? selectedAssemblyMaterials . reduce ( addMaterialCosts , 0 ) : totalCost ;
2722
2823 return (
2924 < Box >
@@ -44,33 +39,9 @@ const BOMTab = ({ project }: { project: Project }) => {
4439 < Box sx = { { backgroundColor : theme . palette . background . paper , padding : '8px 14px 8px 14px' , borderRadius : '6px' } } >
4540 Budget: ${ project . budget }
4641 </ Box >
47- < Select
48- id = "cr-autocomplete"
49- value = { assembly }
50- onChange = { ( event : SelectChangeEvent < string > ) => setAssembly ( event . target . value ) }
51- size = { 'small' }
52- placeholder = { 'Change Request Id' }
53- sx = { { width : 200 , textAlign : 'left' } }
54- MenuProps = { {
55- anchorOrigin : {
56- vertical : 'top' ,
57- horizontal : 'left'
58- } ,
59- transformOrigin : {
60- vertical : 'bottom' ,
61- horizontal : 'left'
62- }
63- } }
64- >
65- { costOptions . map ( ( option ) => (
66- < MenuItem key = { option } value = { option } >
67- { option === 'Total' ? option : `Assembly: ${ option } ` }
68- </ MenuItem >
69- ) ) }
70- </ Select >
7142
7243 < Box sx = { { backgroundColor : theme . palette . background . paper , padding : '8px 14px 8px 14px' , borderRadius : '6px' } } >
73- $ { displayedCost }
44+ Total Cost: $ { centsToDollar ( totalCost ) }
7445 </ Box >
7546 { totalCost > project . budget && (
7647 < Tooltip title = "Current Total Cost Exceeds Budget!" placement = "top" arrow >
0 commit comments