@@ -142,7 +142,7 @@ export class ImportController {
142
142
const importPreviewRows : ImportPreviewRow [ ] = [ ] ;
143
143
144
144
const usagersRows : UsagersImportUsager [ ] = [ ] ;
145
-
145
+ const previewUsagersRow : UsagersImportUsager [ ] = [ ] ;
146
146
const maxErrors = 20 ;
147
147
148
148
processTracker . read . end = new Date ( ) ;
@@ -174,6 +174,9 @@ export class ImportController {
174
174
} ) ;
175
175
if ( errors . length || importMode === "preview" ) {
176
176
importErrors = importErrors . concat ( errors ) ;
177
+ if ( usagerRow && usagerRow . statutDom === "VALIDE" ) {
178
+ previewUsagersRow . push ( usagerRow ) ;
179
+ }
177
180
importPreviewRows . push ( {
178
181
isValid : errors . length === 0 ,
179
182
rowNumber,
@@ -228,7 +231,7 @@ export class ImportController {
228
231
structureId : user . structureId ,
229
232
role : user . role ,
230
233
context : {
231
- nombreActifs : extractUsagersNumber ( usagersRows ) ,
234
+ nombreActifs : previewUsagersRow . length ,
232
235
nombreErreurs : importErrors . length ,
233
236
nombreTotal : importPreviewRows . length ,
234
237
} ,
@@ -252,12 +255,12 @@ export class ImportController {
252
255
} ;
253
256
254
257
await this . appLogsService . create < SuccessfulUsagerImportLogContext > ( {
255
- action : "IMPORT_USAGERS_SUCCESS " ,
258
+ action : "IMPORT_USAGERS_PREVIEW " ,
256
259
userId : user . id ,
257
260
role : user . role ,
258
261
structureId : user . structureId ,
259
262
context : {
260
- nombreActifs : extractUsagersNumber ( usagersRows ) ,
263
+ nombreActifs : previewUsagersRow . length ,
261
264
nombreTotal : importPreviewRows . length ,
262
265
} ,
263
266
} ) ;
@@ -297,16 +300,6 @@ export class ImportController {
297
300
errorsCount : importErrors . length ,
298
301
rows : [ ] , // don't return rows
299
302
} ;
300
- await this . appLogsService . create < SuccessfulUsagerImportLogContext > ( {
301
- action : "IMPORT_USAGERS_SUCCESS" ,
302
- userId : user . id ,
303
- structureId : user . structureId ,
304
- role : user . role ,
305
- context : {
306
- nombreActifs : extractUsagersNumber ( usagersRows ) ,
307
- nombreTotal : usagersRows . length ,
308
- } ,
309
- } ) ;
310
303
return res . status ( HttpStatus . OK ) . json ( {
311
304
importMode,
312
305
previewTable,
@@ -331,8 +324,3 @@ export class ImportController {
331
324
} ) ;
332
325
}
333
326
}
334
-
335
- export const extractUsagersNumber = (
336
- usagersImportRow : UsagersImportUsager [ ]
337
- ) : number =>
338
- usagersImportRow . filter ( ( row ) => row . statutDom === "VALIDE" ) . length ;
0 commit comments