@@ -27,6 +27,7 @@ const BOMTable: React.FC<BOMTableProps> = ({ setHideColumn, assignMaterial, colu
2727 const theme = useTheme ( ) ;
2828
2929 const rows : BomRow [ ] = noAssemblyMaterials . map ( ( material : Material , idx : number ) => materialToRow ( material , idx ) ) ;
30+
3031 const isAssemblyOpen = ( row : BomRow ) => {
3132 return ! row . assemblyId || row . assemblyId === '' || openRows . includes ( row . assemblyId ) || row . id . startsWith ( 'assembly' ) ;
3233 } ;
@@ -44,6 +45,7 @@ const BOMTable: React.FC<BOMTableProps> = ({ setHideColumn, assignMaterial, colu
4445
4546 assemblies . forEach ( ( assembly ) => {
4647 const assemblyMaterials = materials . filter ( ( material ) => material . assemblyId === assembly . assemblyId ) ;
48+
4749 materialsWithAssemblies . push ( {
4850 reimbursementRequestId : undefined ,
4951 id : `assembly-${ assembly . name } ` ,
@@ -63,11 +65,11 @@ const BOMTable: React.FC<BOMTableProps> = ({ setHideColumn, assignMaterial, colu
6365 notes : '' ,
6466 assemblyId : assembly . assemblyId
6567 } ) ;
68+
6669 assemblyMaterials . forEach ( ( material , indx ) => materialsWithAssemblies . push ( materialToRow ( material , indx ) ) ) ;
6770 } ) ;
6871
6972 // drag and drop mechanics
70-
7173 const handleDragStart = ( materialId : string ) => {
7274 const material = materials . find ( ( m ) => m . materialId === materialId ) ;
7375 if ( material ) {
@@ -82,6 +84,7 @@ const BOMTable: React.FC<BOMTableProps> = ({ setHideColumn, assignMaterial, colu
8284 const handleDrop = ( event : React . DragEvent , targetAssemblyId ?: string ) => {
8385 event . preventDefault ( ) ;
8486 if ( ! draggedMaterial ) return ;
87+
8588 assignMaterial ( draggedMaterial . materialId , targetAssemblyId ) ( ) . finally ( ( ) => {
8689 setDraggedMaterial ( null ) ;
8790 } ) ;
@@ -92,13 +95,27 @@ const BOMTable: React.FC<BOMTableProps> = ({ setHideColumn, assignMaterial, colu
9295 sx = { {
9396 height : 'calc(100vh - 200px)' ,
9497 width : '100%' ,
98+
9599 '& .super-app-theme--header' : {
96100 backgroundColor : '#ef4345'
97101 } ,
102+
103+ '& .super-app-theme--even' : {
104+ backgroundColor : theme . palette . background . paper ,
105+ border : `1px solid ${ theme . palette . mode === 'light' ? '#f0f0f0' : '#303030' } `
106+ } ,
107+ '& .super-app-theme--odd' : {
108+ border : `1px solid ${ theme . palette . mode === 'light' ? '#f0f0f0' : '#303030' } `
109+ } ,
110+
111+ '& .MuiDataGrid-row:hover' : {
112+ backgroundColor : 'rgba(239, 67, 69, 0.6)'
113+ } ,
114+
98115 '& .super-app-theme--assembly' : {
99116 backgroundColor : theme . palette . grey [ 600 ] ,
100117 '&:hover' : {
101- backgroundColor : theme . palette . grey [ 700 ]
118+ backgroundColor : 'rgba(239, 67, 69, 0.6)'
102119 } ,
103120 '&:focus' : {
104121 backgroundColor : '#997570'
@@ -113,14 +130,17 @@ const BOMTable: React.FC<BOMTableProps> = ({ setHideColumn, assignMaterial, colu
113130 Object . keys ( model ) . forEach ( ( toDelete ) => {
114131 tempColumns . push ( ! model [ toDelete ] ) ;
115132 } ) ;
133+
116134 setHideColumn ( tempColumns ) ;
117135 localStorage . setItem ( 'hideColumn' , JSON . stringify ( tempColumns ) ) ;
118136 } }
119137 columns = { columns as GridColumns < GridValidRowModel > }
120138 rows = { rows . concat ( materialsWithAssemblies . filter ( isAssemblyOpen ) ) }
121- getRowClassName = { ( params ) =>
122- `super-app-theme--${ String ( params . row . id ) . includes ( 'assembly' ) ? 'assembly' : 'material' } `
123- }
139+ getRowClassName = { ( params ) => {
140+ const stripe = params . indexRelativeToCurrentPage % 2 === 0 ? 'even' : 'odd' ;
141+ const isAssemblyRow = String ( params . row . id ) . startsWith ( 'assembly-' ) ;
142+ return `super-app-theme--${ stripe } ${ isAssemblyRow ? ' super-app-theme--assembly' : '' } ` ;
143+ } }
124144 rowsPerPageOptions = { [ 100 ] }
125145 sx = { bomTableStyles . datagrid }
126146 disableSelectionOnClick
@@ -142,6 +162,7 @@ const BOMTable: React.FC<BOMTableProps> = ({ setHideColumn, assignMaterial, colu
142162 const rowIndex = parseInt ( event . currentTarget . getAttribute ( 'data-rowindex' ) || '0' ) ;
143163 const materials = rows . concat ( materialsWithAssemblies . filter ( isAssemblyOpen ) ) ;
144164 const { assemblyId } = materials [ rowIndex ] ;
165+
145166 if ( assemblyId === 'assembly-misc' ) {
146167 handleDrop ( event ) ;
147168 } else {
@@ -164,4 +185,5 @@ const BOMTable: React.FC<BOMTableProps> = ({ setHideColumn, assignMaterial, colu
164185 </ Box >
165186 ) ;
166187} ;
188+
167189export default BOMTable ;
0 commit comments