@@ -11,7 +11,7 @@ import { useToast } from '../../../../hooks/toasts.hooks';
1111import { useAssignMaterialToAssembly , useDeleteAssembly , useDeleteMaterial } from '../../../../hooks/bom.hooks' ;
1212import LoadingIndicator from '../../../../components/LoadingIndicator' ;
1313import EditMaterialModal from './MaterialForm/EditMaterialModal' ;
14- import { Link , Typography } from '@mui/material' ;
14+ import { Button , Link , Typography } from '@mui/material' ;
1515import { bomBaseColDef } from '../../../../utils/bom.utils' ;
1616import NERModal from '../../../../components/NERModal' ;
1717import { renderStatusBOM } from './BOMTableCustomCells' ;
@@ -217,20 +217,54 @@ const BOMTableWrapper: React.FC<BOMTableWrapperProps> = ({
217217 hide : hideColumn [ 0 ] ,
218218 renderCell : ( params ) => {
219219 const material = materials . find ( ( m ) => m . materialId === params . row . materialId ) ;
220- const reimbursementRequest = material ?. reimbursementRequest ;
220+ if ( ! material ) return null ;
221221
222- if ( ! reimbursementRequest ) return null ;
222+ const { reimbursementRequest } = material ;
223+
224+ // case 1 (if reimbursement request exists): link to the reimbursement request page
225+ if ( reimbursementRequest ) {
226+ return (
227+ < Link
228+ component = { RouterLink }
229+ to = { `${ routes . REIMBURSEMENT_REQUESTS } /view/${ reimbursementRequest . reimbursementRequestId } ` }
230+ underline = "hover"
231+ sx = { { color : '#dd514c' , fontWeight : 'bold' , cursor : 'pointer' } }
232+ onClick = { ( e ) => e . stopPropagation ( ) }
233+ >
234+ { reimbursementRequest . identifier }
235+ </ Link >
236+ ) ;
237+ }
238+
239+ // case 2 (if reimbursement request does not exist): link to the create reimbursement request page with pre-filled info
240+ const { quantity, price } = material ;
241+
242+ const prefillCost = quantity != null && price != null ? ( Number ( quantity ) * Number ( price ) ) / 100 : undefined ;
223243
224244 return (
225- < Link
245+ < Button
226246 component = { RouterLink }
227- to = { `${ routes . REIMBURSEMENT_REQUESTS } /view/${ reimbursementRequest . reimbursementRequestId } ` }
228- underline = "hover"
229- sx = { { color : '#dd514c' , fontWeight : 'bold' , cursor : 'pointer' } }
230- onClick = { ( e ) => e . stopPropagation ( ) }
247+ to = { {
248+ pathname : routes . NEW_REIMBURSEMENT_REQUEST ,
249+ state : {
250+ projectWbsNum : project . wbsNum ,
251+ materialId : material . materialId ,
252+ materialName : material . name ,
253+ prefillCost
254+ }
255+ } }
256+ variant = "contained"
257+ size = "small"
258+ onClick = { ( e : React . MouseEvent < HTMLElement > ) => e . stopPropagation ( ) }
259+ sx = { {
260+ backgroundColor : '#dd514c' ,
261+ textTransform : 'none' ,
262+ fontWeight : 600 ,
263+ '&:hover' : { backgroundColor : '#c7443f' }
264+ } }
231265 >
232- { reimbursementRequest . identifier }
233- </ Link >
266+ Create RR
267+ </ Button >
234268 ) ;
235269 }
236270 } ,
0 commit comments