55 FormLabel ,
66 Grid ,
77 IconButton ,
8+ Link ,
89 MenuItem ,
910 Select ,
1011 TextField ,
@@ -27,9 +28,11 @@ import ReimbursementProductTable from './ReimbursementProductTable';
2728import NERFailButton from '../../../components/NERFailButton' ;
2829import NERSuccessButton from '../../../components/NERSuccessButton' ;
2930import { ReimbursementRequestFormInput } from './ReimbursementRequestForm' ;
30- import { useState } from 'react' ;
31+ import { useState , useEffect } from 'react' ;
3132import { useToast } from '../../../hooks/toasts.hooks' ;
3233import { expenseTypePipe } from '../../../utils/pipes' ;
34+ import { Link as RouterLink } from 'react-router-dom' ;
35+ import { routes } from '../../../utils/routes' ;
3336
3437interface ReimbursementRequestFormViewProps {
3538 allVendors : Vendor [ ] ;
@@ -52,6 +55,7 @@ interface ReimbursementRequestFormViewProps {
5255 submitText : string ;
5356 previousPage : string ;
5457 setValue : UseFormSetValue < ReimbursementRequestFormInput > ;
58+ hasSecureSettingsSet : boolean ;
5559}
5660
5761const ReimbursementRequestFormView : React . FC < ReimbursementRequestFormViewProps > = ( {
@@ -71,13 +75,21 @@ const ReimbursementRequestFormView: React.FC<ReimbursementRequestFormViewProps>
7175 watch,
7276 submitText,
7377 previousPage,
74- setValue
78+ setValue,
79+ hasSecureSettingsSet
7580} ) => {
7681 const [ datePickerOpen , setDatePickerOpen ] = useState ( false ) ;
7782 const toast = useToast ( ) ;
7883 const products = watch ( `reimbursementProducts` ) ;
7984 const calculatedTotalCost = products . reduce ( ( acc , product ) => acc + Number ( product . cost ) , 0 ) . toFixed ( 2 ) ;
8085
86+ useEffect ( ( ) => {
87+ if ( ! hasSecureSettingsSet ) {
88+ //<Link component={RouterLink} to={routes.SETTINGS}> </Link>
89+ toast . warning ( 'Your secure settings must be set to create a reimbursement request, you can set them here.' , Infinity ) ;
90+ }
91+ } , [ ] ) ;
92+
8193 const wbsElementAutocompleteOptions = allWbsElements . map ( ( wbsElement ) => ( {
8294 label : wbsPipe ( wbsElement . wbsNum ) + ' - ' + wbsElement . wbsName ,
8395 id : wbsPipe ( wbsElement . wbsNum )
@@ -257,7 +269,7 @@ const ReimbursementRequestFormView: React.FC<ReimbursementRequestFormViewProps>
257269 < NERFailButton variant = "contained" href = { previousPage } sx = { { mx : 1 } } >
258270 Cancel
259271 </ NERFailButton >
260- < NERSuccessButton variant = "contained" type = "submit" >
272+ < NERSuccessButton variant = "contained" type = "submit" disabled = { ! hasSecureSettingsSet } >
261273 { submitText }
262274 </ NERSuccessButton >
263275 </ Box >
0 commit comments