@@ -14,7 +14,7 @@ import {
1414} from '@mui/material' ;
1515import { Box } from '@mui/system' ;
1616import { Control , Controller , FieldErrors , UseFormHandleSubmit , UseFormSetValue , UseFormWatch } from 'react-hook-form' ;
17- import { Assembly , Manufacturer , MaterialType , Unit } from 'shared' ;
17+ import { Assembly , Manufacturer , MaterialType , ReimbursementRequest , Unit } from 'shared' ;
1818import ReactHookTextField from '../../../../../components/ReactHookTextField' ;
1919import { MaterialFormInput } from './MaterialForm' ;
2020import NERFormModal from '../../../../../components/NERFormModal' ;
@@ -44,6 +44,7 @@ export interface MaterialFormViewProps {
4444 setValue : UseFormSetValue < MaterialFormInput > ;
4545 copyFromExistingBomAction ?: React . ReactNode ;
4646 fromRRForm ?: boolean ;
47+ reimbursementRequests ?: any [ ] ;
4748}
4849
4950const manufacturersToAutocomplete = ( manufacturer : Manufacturer ) : { label : string ; id : string } => {
@@ -69,7 +70,8 @@ const MaterialFormView: React.FC<MaterialFormViewProps> = ({
6970 watch,
7071 createManufacturer,
7172 setValue,
72- fromRRForm = false
73+ fromRRForm = false ,
74+ reimbursementRequests = [ ]
7375} ) => {
7476 const [ additionalDetailsOpen , setAdditionalDetailsOpen ] = useState ( ! fromRRForm ) ;
7577
@@ -504,6 +506,78 @@ const MaterialFormView: React.FC<MaterialFormViewProps> = ({
504506 ) }
505507 </ Grid >
506508 </ Grid >
509+ < Grid item xs = { 12 } >
510+ < Grid item xs = { 12 } mt = { 2 } >
511+ < FormControl fullWidth >
512+ < Controller
513+ name = "reimbursementRequestId"
514+ control = { control }
515+ defaultValue = { control . _defaultValues . reimbursementRequestId }
516+ render = { ( { field } ) => (
517+ < TextField
518+ { ...field }
519+ select
520+ variant = "outlined"
521+ error = { ! ! errors . reimbursementRequestId }
522+ helperText = { errors . reimbursementRequestId ?. message }
523+ SelectProps = { {
524+ displayEmpty : true ,
525+ renderValue : ( selected ) =>
526+ selected ? (
527+ reimbursementRequests . find ( ( rr ) => rr . reimbursementRequestId === selected ) ?. identifier
528+ ) : (
529+ < Typography sx = { { fontSize : '1rem' , color : 'lightgray' , opacity : 0.6 } } >
530+ Select Corresponding Reimbursement Request Number
531+ </ Typography >
532+ )
533+ } }
534+ >
535+ { reimbursementRequests . map ( ( rr : ReimbursementRequest ) => (
536+ < MenuItem key = { rr . reimbursementRequestId } value = { rr . reimbursementRequestId } >
537+ { rr . identifier }
538+ </ MenuItem >
539+ ) ) }
540+ </ TextField >
541+ ) }
542+ />
543+ </ FormControl >
544+ </ Grid >
545+ < Box display = { 'flex' } justifyContent = { 'flex-end' } mt = { 2 } >
546+ < FormControl fullWidth >
547+ < Controller
548+ name = "assemblyId"
549+ control = { control }
550+ defaultValue = { control . _defaultValues . assemblyId }
551+ render = { ( { field } ) => (
552+ < TextField
553+ { ...field }
554+ select
555+ variant = "outlined"
556+ error = { ! ! errors . assemblyId }
557+ helperText = { errors . assemblyId ?. message }
558+ SelectProps = { {
559+ displayEmpty : true ,
560+ renderValue : ( selected ) =>
561+ selected ? (
562+ assemblies ?. find ( ( a ) => a . assemblyId === selected ) ?. name
563+ ) : (
564+ < Typography sx = { { fontSize : '1rem' , color : 'lightgray' , opacity : 0.6 } } >
565+ Enter Assembly Details
566+ </ Typography >
567+ )
568+ } }
569+ >
570+ { assemblies ?. map ( ( assembly ) => (
571+ < MenuItem key = { assembly . assemblyId } value = { assembly . assemblyId } >
572+ { assembly . name }
573+ </ MenuItem >
574+ ) ) }
575+ </ TextField >
576+ ) }
577+ />
578+ </ FormControl >
579+ </ Box >
580+ </ Grid >
507581 { submitText === 'Add' && (
508582 < Grid item xs = { 12 } sx = { { pl : 0 , pr : 0 } } >
509583 < Box
0 commit comments