@@ -6,6 +6,7 @@ import { manipulateAsync, SaveFormat } from 'expo-image-manipulator';
6
6
7
7
import { useCallback , useEffect , useMemo , useState } from 'react' ;
8
8
import { Platform } from 'react-native' ;
9
+ import { useTranslation } from 'react-i18next' ;
9
10
import Actions from '../../actions' ;
10
11
import Constants from '../../const' ;
11
12
import log from '../../utils/log' ;
@@ -304,9 +305,9 @@ export function useStartUploadAsync({
304
305
} , [ uploads , inspectionId , sights . state , mapTasksToSights , task , onFinish , endTour ] ) ;
305
306
}
306
307
307
- export function useUploadAdditionalDamage ( {
308
- inspectionId ,
309
- } ) {
308
+ export function useUploadAdditionalDamage ( { inspectionId , addDamageParts } ) {
309
+ const { t , i18n } = useTranslation ( ) ;
310
+
310
311
return useCallback ( async ( { picture, parts } ) => {
311
312
if ( ! inspectionId ) {
312
313
throw Error ( `Please provide a valid "inspectionId". Got ${ inspectionId } .` ) ;
@@ -322,6 +323,15 @@ export function useUploadAdditionalDamage({
322
323
filename,
323
324
} ;
324
325
326
+ const part = addDamageParts [ 0 ] ;
327
+ const resources = Object . keys ( i18n . options . resources ) ;
328
+ const metadata = {
329
+ category : 'exterior' ,
330
+ label : resources . reduce ( ( accumulator , lng ) => {
331
+ accumulator [ lng ] = t ( `partSelector.parts.${ part } ` , { lng } ) ;
332
+ return accumulator ;
333
+ } , { } ) ,
334
+ } ;
325
335
const json = JSON . stringify ( {
326
336
acquisition : {
327
337
strategy : 'upload_multipart_form_keys' ,
@@ -336,6 +346,7 @@ export function useUploadAdditionalDamage({
336
346
tasks : [ 'damage_detection' ] ,
337
347
image_type : 'close_up' ,
338
348
additional_data : {
349
+ ...metadata ,
339
350
overlay : undefined ,
340
351
createdAt : new Date ( ) ,
341
352
} ,
@@ -375,7 +386,7 @@ export function useUploadAdditionalDamage({
375
386
376
387
throw err ;
377
388
}
378
- } , [ inspectionId ] ) ;
389
+ } , [ inspectionId , addDamageParts ] ) ;
379
390
}
380
391
381
392
/**
0 commit comments