File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed 
frontend/src/components/forms Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -125,18 +125,15 @@ export class FoodRequestsController {
125125  async  confirmDelivery ( 
126126    @Param ( 'requestId' ,  ParseIntPipe )  requestId : number , 
127127    @Body ( )  body : {  dateReceived : string ;  feedback : string  } , 
128-     @UploadedFiles ( )  photos : Express . Multer . File [ ] , 
128+     @UploadedFiles ( )  photos ? : Express . Multer . File [ ] , 
129129  ) : Promise < FoodRequest >  { 
130-     if  ( ! photos  ||  photos . length  ===  0 )  { 
131-       throw  new  Error ( 'No photos uploaded' ) ; 
132-     } 
133- 
134130    const  formattedDate  =  new  Date ( body . dateReceived ) ; 
135131    if  ( isNaN ( formattedDate . getTime ( ) ) )  { 
136132      throw  new  Error ( 'Invalid date format for deliveryDate' ) ; 
137133    } 
138134
139-     const  uploadedPhotoUrls  =  await  this . awsS3Service . upload ( photos ) ; 
135+     const  uploadedPhotoUrls  = 
136+       photos  &&  photos . length  >  0  ? await  this . awsS3Service . upload ( photos )  : [ ] ; 
140137
141138    return  this . requestsService . updateDeliveryDetails ( 
142139      requestId , 
Original file line number Diff line number Diff line change @@ -149,9 +149,11 @@ export const submitDeliveryConfirmationFormModal: ActionFunction = async ({
149149
150150  confirmDeliveryData . append ( 'feedback' ,  form . get ( 'feedback' )  as  string ) ; 
151151
152-   globalPhotos . forEach ( ( photo )  =>  { 
153-     confirmDeliveryData . append ( 'photos' ,  photo ) ; 
154-   } ) ; 
152+   if  ( globalPhotos . length  >  0 )  { 
153+     globalPhotos . forEach ( ( photo )  =>  { 
154+       confirmDeliveryData . append ( 'photos' ,  photo ) ; 
155+     } ) ; 
156+   } 
155157
156158  try  { 
157159    const  response  =  await  fetch ( 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments