datakeen-session-react 1.1.140-dev.129 → 1.1.140-dev.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/document-video/DocumentVideoCapture.js +2 -2
- package/dist/cjs/components/document-video/DocumentVideoCapture.js.map +1 -1
- package/dist/cjs/components/document-video/document-video-flow/DocumentVideoProcessing.js +10 -11
- package/dist/cjs/components/document-video/document-video-flow/DocumentVideoProcessing.js.map +1 -1
- package/dist/cjs/components/jdi/JDIProcessing.js +136 -147
- package/dist/cjs/components/jdi/JDIProcessing.js.map +1 -1
- package/dist/cjs/components/session/DocumentCheck.js +36 -11
- package/dist/cjs/components/session/DocumentCheck.js.map +1 -1
- package/dist/cjs/components/session/EndFlow.js +10 -1
- package/dist/cjs/components/session/EndFlow.js.map +1 -1
- package/dist/cjs/components/session/controleJdiPolicy.js +47 -0
- package/dist/cjs/components/session/controleJdiPolicy.js.map +1 -0
- package/dist/cjs/index.css.js +1 -1
- package/dist/cjs/services/sessionService.js +15 -0
- package/dist/cjs/services/sessionService.js.map +1 -1
- package/dist/cjs/types/session.js.map +1 -1
- package/dist/cjs/utils/jdiCodes.js +57 -0
- package/dist/cjs/utils/jdiCodes.js.map +1 -0
- package/dist/esm/components/document-video/DocumentVideoCapture.js +2 -2
- package/dist/esm/components/document-video/DocumentVideoCapture.js.map +1 -1
- package/dist/esm/components/document-video/document-video-flow/DocumentVideoProcessing.js +10 -11
- package/dist/esm/components/document-video/document-video-flow/DocumentVideoProcessing.js.map +1 -1
- package/dist/esm/components/jdi/JDIProcessing.js +136 -147
- package/dist/esm/components/jdi/JDIProcessing.js.map +1 -1
- package/dist/esm/components/session/DocumentCheck.js +37 -12
- package/dist/esm/components/session/DocumentCheck.js.map +1 -1
- package/dist/esm/components/session/EndFlow.js +10 -1
- package/dist/esm/components/session/EndFlow.js.map +1 -1
- package/dist/esm/components/session/controleJdiPolicy.js +42 -0
- package/dist/esm/components/session/controleJdiPolicy.js.map +1 -0
- package/dist/esm/index.css.js +1 -1
- package/dist/esm/services/sessionService.js +15 -1
- package/dist/esm/services/sessionService.js.map +1 -1
- package/dist/esm/types/session.js.map +1 -1
- package/dist/esm/utils/jdiCodes.js +53 -0
- package/dist/esm/utils/jdiCodes.js.map +1 -0
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ import { isPng, dataUrlToFile, isJpeg, convertJpegToPng, isPdf, convertPdfToPng
|
|
|
9
9
|
import { useI18n } from '../../hooks/useI18n.js';
|
|
10
10
|
import { requiresTwoSides } from '../../utils/documentLabels.js';
|
|
11
11
|
import { isS3UploadNotConfirmedError } from '../../utils/analysisErrors.js';
|
|
12
|
+
import { isBlockingCode } from '../../utils/jdiCodes.js';
|
|
12
13
|
|
|
13
14
|
// Fonction pour obtenir les étapes de traitement traduites
|
|
14
15
|
var getProcessingSteps = function (t) { return [
|
|
@@ -34,7 +35,7 @@ var getProcessingSteps = function (t) { return [
|
|
|
34
35
|
},
|
|
35
36
|
]; };
|
|
36
37
|
var JDIProcessing = memo(function (_a) {
|
|
37
|
-
var onProcessingComplete = _a.onProcessingComplete, documentType = _a.documentType, fileUploaded = _a.fileUploaded, documentTypeId = _a.documentTypeId, _b = _a.retryCount, retryCount = _b === void 0 ? 0 : _b, documentTemplateId = _a.documentTemplateId, nodeId = _a.nodeId;
|
|
38
|
+
var onProcessingComplete = _a.onProcessingComplete, documentType = _a.documentType, fileUploaded = _a.fileUploaded, documentTypeId = _a.documentTypeId, _b = _a.retryCount, retryCount = _b === void 0 ? 0 : _b, documentTemplateId = _a.documentTemplateId, nodeId = _a.nodeId, blockingCodes = _a.blockingCodes;
|
|
38
39
|
var t = useI18n().t;
|
|
39
40
|
var _c = useState(false), isProcessing = _c[0], setIsProcessing = _c[1];
|
|
40
41
|
var _d = useState(0), currentStep = _d[0], setCurrentStep = _d[1];
|
|
@@ -127,139 +128,87 @@ var JDIProcessing = memo(function (_a) {
|
|
|
127
128
|
});
|
|
128
129
|
}); };
|
|
129
130
|
var processFiles = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
130
|
-
var
|
|
131
|
+
var i, response, extractedCode, codeName, codeDescription, predictions, isSuccess, canRetry, error_2, failedStepIndex_1, errorMessage, isNetworkError, isUploadNotConfirmed;
|
|
131
132
|
return __generator(this, function (_a) {
|
|
132
133
|
switch (_a.label) {
|
|
133
134
|
case 0:
|
|
134
|
-
_a.trys.push([0,
|
|
135
|
+
_a.trys.push([0, 9, 10, 11]);
|
|
135
136
|
// Marquer le début du traitement
|
|
136
137
|
setIsProcessing(true);
|
|
137
138
|
processingStartedRef.current = true;
|
|
138
139
|
processedFilesRef.current = filesKey;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
else if (status.progress === 100) {
|
|
195
|
-
// Analysis complete - move to final step
|
|
196
|
-
setCurrentStep(processingSteps.length - 1);
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
onComplete: function (status) {
|
|
200
|
-
// Update final progress state
|
|
201
|
-
setAnalysisProgress({
|
|
202
|
-
progress: status.progress,
|
|
203
|
-
currentStep: status.currentStep,
|
|
204
|
-
message: status.message,
|
|
205
|
-
});
|
|
206
|
-
// Ensure we're at the final step
|
|
207
|
-
setCurrentStep(processingSteps.length - 1);
|
|
208
|
-
// Mark the final step based on analysis result
|
|
209
|
-
var isFailed = status.currentStep === "failed" ||
|
|
210
|
-
status.currentStep === "error";
|
|
211
|
-
if (isFailed) {
|
|
212
|
-
setProcessingSteps(function (prev) {
|
|
213
|
-
return prev.map(function (step, index) {
|
|
214
|
-
return index === processingSteps.length - 1
|
|
215
|
-
? __assign(__assign({}, step), { hasError: true }) : step;
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
onFailed: function (status, error) {
|
|
221
|
-
console.error("❌ [JDIProcessing] Analysis polling failed:", error);
|
|
222
|
-
// Update error state
|
|
223
|
-
setAnalysisProgress({
|
|
224
|
-
progress: 100,
|
|
225
|
-
currentStep: "failed",
|
|
226
|
-
message: "Analysis failed: ".concat(error),
|
|
227
|
-
});
|
|
228
|
-
// Mark current step as error
|
|
229
|
-
setProcessingSteps(function (prev) {
|
|
230
|
-
return prev.map(function (step, index) {
|
|
231
|
-
return index === currentStep
|
|
232
|
-
? __assign(__assign({}, step), { hasError: true }) : step;
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
})];
|
|
238
|
-
case 4:
|
|
239
|
-
response = _b.sent();
|
|
240
|
-
extractedCode_1 = String(response.code);
|
|
241
|
-
codeName = response === null || response === void 0 ? void 0 : response.codeName;
|
|
242
|
-
codeDescription = response === null || response === void 0 ? void 0 : response.codeDescription;
|
|
243
|
-
predictions = [];
|
|
244
|
-
if (extractedCode_1 && codeName) {
|
|
245
|
-
predictions.push({
|
|
246
|
-
code: extractedCode_1,
|
|
247
|
-
codeName: codeName,
|
|
248
|
-
codeDescription: codeDescription || "",
|
|
249
|
-
type: "document",
|
|
250
|
-
});
|
|
140
|
+
i = 0;
|
|
141
|
+
_a.label = 1;
|
|
142
|
+
case 1:
|
|
143
|
+
if (!(i < processingSteps.length)) return [3 /*break*/, 8];
|
|
144
|
+
setCurrentStep(i);
|
|
145
|
+
if (!(i < processingSteps.length - 1)) return [3 /*break*/, 3];
|
|
146
|
+
// Délai entre les étapes (sauf la dernière)
|
|
147
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 800); })];
|
|
148
|
+
case 2:
|
|
149
|
+
// Délai entre les étapes (sauf la dernière)
|
|
150
|
+
_a.sent();
|
|
151
|
+
return [3 /*break*/, 7];
|
|
152
|
+
case 3:
|
|
153
|
+
// Dernière étape : conversion et upload si nécessaire, puis appel API réel
|
|
154
|
+
return [4 /*yield*/, handleFileConversionAndUpload(sessionId, fileUploaded)];
|
|
155
|
+
case 4:
|
|
156
|
+
// Dernière étape : conversion et upload si nécessaire, puis appel API réel
|
|
157
|
+
_a.sent();
|
|
158
|
+
return [4 /*yield*/, analyzeFiles(sessionId, nodeId, fileUploaded, documentTemplateId || "", {
|
|
159
|
+
save: false, // don't save to session yet
|
|
160
|
+
incrementAnalysis: false, // don't auto-progress session
|
|
161
|
+
documentTypeKey: documentType,
|
|
162
|
+
requiresTwoSides: requiresTwoSides(documentType),
|
|
163
|
+
enablePolling: true, // Enable polling for progress
|
|
164
|
+
pollingOptions: {
|
|
165
|
+
interval: 2000, // Poll every 2 seconds (backend optimized timing)
|
|
166
|
+
maxAttempts: 30, // 30 * 2s = max 60s polling duration
|
|
167
|
+
timeout: 600000,
|
|
168
|
+
onProgress: function (status) {
|
|
169
|
+
// Update analysis progress state for display
|
|
170
|
+
setAnalysisProgress({
|
|
171
|
+
progress: status.progress,
|
|
172
|
+
currentStep: status.currentStep,
|
|
173
|
+
message: status.message,
|
|
174
|
+
});
|
|
175
|
+
// Update UI based on progress percentage
|
|
176
|
+
// 50% = Analyzing (steps 0-2)
|
|
177
|
+
// 100% = Completed (step 3)
|
|
178
|
+
if (status.progress === 50) {
|
|
179
|
+
// Analysis in progress - show steps 0-2 progressively
|
|
180
|
+
var elapsed = Date.now() -
|
|
181
|
+
(Date.parse(status.startedAt || "") || Date.now());
|
|
182
|
+
var elapsedSeconds = elapsed / 1000;
|
|
183
|
+
// Progress through first 3 steps based on elapsed time
|
|
184
|
+
if (elapsedSeconds < 3) {
|
|
185
|
+
setCurrentStep(function (prev) { return Math.max(prev, 0); });
|
|
186
|
+
}
|
|
187
|
+
else if (elapsedSeconds < 6) {
|
|
188
|
+
setCurrentStep(function (prev) { return Math.max(prev, 1); });
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
setCurrentStep(function (prev) { return Math.max(prev, 2); });
|
|
192
|
+
}
|
|
251
193
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
194
|
+
else if (status.progress === 100) {
|
|
195
|
+
// Analysis complete - move to final step
|
|
196
|
+
setCurrentStep(processingSteps.length - 1);
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
onComplete: function (status) {
|
|
200
|
+
// Update final progress state
|
|
201
|
+
setAnalysisProgress({
|
|
202
|
+
progress: status.progress,
|
|
203
|
+
currentStep: status.currentStep,
|
|
204
|
+
message: status.message,
|
|
260
205
|
});
|
|
206
|
+
// Ensure we're at the final step
|
|
207
|
+
setCurrentStep(processingSteps.length - 1);
|
|
261
208
|
// Mark the final step based on analysis result
|
|
262
|
-
|
|
209
|
+
var isFailed = status.currentStep === "failed" ||
|
|
210
|
+
status.currentStep === "error";
|
|
211
|
+
if (isFailed) {
|
|
263
212
|
setProcessingSteps(function (prev) {
|
|
264
213
|
return prev.map(function (step, index) {
|
|
265
214
|
return index === processingSteps.length - 1
|
|
@@ -267,32 +216,71 @@ var JDIProcessing = memo(function (_a) {
|
|
|
267
216
|
});
|
|
268
217
|
});
|
|
269
218
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
//
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
219
|
+
},
|
|
220
|
+
onFailed: function (status, error) {
|
|
221
|
+
console.error("❌ [JDIProcessing] Analysis polling failed:", error);
|
|
222
|
+
// Update error state
|
|
223
|
+
setAnalysisProgress({
|
|
224
|
+
progress: 100,
|
|
225
|
+
currentStep: "failed",
|
|
226
|
+
message: "Analysis failed: ".concat(error),
|
|
227
|
+
});
|
|
228
|
+
// Mark current step as error
|
|
229
|
+
setProcessingSteps(function (prev) {
|
|
230
|
+
return prev.map(function (step, index) {
|
|
231
|
+
return index === currentStep
|
|
232
|
+
? __assign(__assign({}, step), { hasError: true }) : step;
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
})];
|
|
238
|
+
case 5:
|
|
239
|
+
response = _a.sent();
|
|
240
|
+
extractedCode = String(response.code);
|
|
241
|
+
codeName = response === null || response === void 0 ? void 0 : response.codeName;
|
|
242
|
+
codeDescription = response === null || response === void 0 ? void 0 : response.codeDescription;
|
|
243
|
+
predictions = [];
|
|
244
|
+
if (extractedCode && codeName) {
|
|
245
|
+
predictions.push({
|
|
246
|
+
code: extractedCode,
|
|
247
|
+
codeName: codeName,
|
|
248
|
+
codeDescription: codeDescription || "",
|
|
249
|
+
type: "document",
|
|
278
250
|
});
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
251
|
+
}
|
|
252
|
+
isSuccess = !isBlockingCode(extractedCode, blockingCodes);
|
|
253
|
+
canRetry = isSuccess === false;
|
|
254
|
+
setAnalysisResult({
|
|
255
|
+
success: isSuccess,
|
|
256
|
+
code: extractedCode,
|
|
257
|
+
canRetry: canRetry,
|
|
258
|
+
data: response,
|
|
259
|
+
predictions: predictions,
|
|
260
|
+
});
|
|
261
|
+
// Mark the final step based on analysis result
|
|
262
|
+
if (!isSuccess) {
|
|
263
|
+
setProcessingSteps(function (prev) {
|
|
264
|
+
return prev.map(function (step, index) {
|
|
265
|
+
return index === processingSteps.length - 1
|
|
266
|
+
? __assign(__assign({}, step), { hasError: true }) : step;
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
// délai pour voir le résultat
|
|
271
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 500); })];
|
|
272
|
+
case 6:
|
|
273
|
+
// délai pour voir le résultat
|
|
286
274
|
_a.sent();
|
|
287
|
-
_a.label =
|
|
288
|
-
case
|
|
275
|
+
_a.label = 7;
|
|
276
|
+
case 7:
|
|
289
277
|
i++;
|
|
290
278
|
return [3 /*break*/, 1];
|
|
291
|
-
case
|
|
279
|
+
case 8:
|
|
292
280
|
setCurrentStep(processingSteps.length);
|
|
293
281
|
setIsComplete(true);
|
|
294
|
-
return [3 /*break*/,
|
|
295
|
-
case
|
|
282
|
+
return [3 /*break*/, 11];
|
|
283
|
+
case 9:
|
|
296
284
|
error_2 = _a.sent();
|
|
297
285
|
console.error("❌ Erreur lors de l'analyse des fichiers:", error_2);
|
|
298
286
|
failedStepIndex_1 = currentStep;
|
|
@@ -320,11 +308,11 @@ var JDIProcessing = memo(function (_a) {
|
|
|
320
308
|
blockContinue: isUploadNotConfirmed,
|
|
321
309
|
});
|
|
322
310
|
setIsComplete(true);
|
|
323
|
-
return [3 /*break*/,
|
|
324
|
-
case
|
|
311
|
+
return [3 /*break*/, 11];
|
|
312
|
+
case 10:
|
|
325
313
|
setIsProcessing(false);
|
|
326
314
|
return [7 /*endfinally*/];
|
|
327
|
-
case
|
|
315
|
+
case 11: return [2 /*return*/];
|
|
328
316
|
}
|
|
329
317
|
});
|
|
330
318
|
}); };
|
|
@@ -339,6 +327,7 @@ var JDIProcessing = memo(function (_a) {
|
|
|
339
327
|
stableOnProcessingComplete,
|
|
340
328
|
processingSteps.length,
|
|
341
329
|
currentStep,
|
|
330
|
+
blockingCodes,
|
|
342
331
|
]);
|
|
343
332
|
// Auto-complete when analysis is done
|
|
344
333
|
useEffect(function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JDIProcessing.js","sources":["../../../../../src/components/jdi/JDIProcessing.tsx"],"sourcesContent":["import { useEffect, useRef, useState, useMemo, useCallback, memo } from \"react\";\nimport Title from \"../ui/Title\";\nimport Subtitle from \"../ui/Subtitle\";\nimport type { onUploadFiles } from \"../../types/uploadFiles\";\nimport type { ProcessingStep } from \"../../types/session\";\nimport type { Prediction } from \"../../utils/apiAnalysis\";\nimport type { JDIProcessingResult } from \"./types\";\nimport {\n analyzeFiles,\n uploadConvertedIdCardImage,\n} from \"../../services/analysis\";\nimport { getActiveSessionId } from \"../../services/sessionMemoryStore\";\nimport {\n convertPdfToPng,\n convertJpegToPng,\n dataUrlToFile,\n isPdf,\n isJpeg,\n isPng,\n} from \"../../utils/imageConverter\";\nimport { useI18n } from \"../../hooks/useI18n\";\nimport { requiresTwoSides } from \"../../utils/documentLabels\";\nimport { isS3UploadNotConfirmedError } from \"../../utils/analysisErrors\";\n\ninterface JDIProcessingProps {\n onProcessingComplete: (\n success: boolean,\n retryCount?: number,\n analysisData?: Prediction[] | null,\n blockContinue?: boolean,\n ) => void;\n documentType: string;\n fileUploaded: onUploadFiles | null; // Fichiers uploadés\n documentTypeId: string; // ID du type de document (jdd, income-proof, etc.)\n retryCount?: number; // Nombre de tentatives de retry déjà effectuées\n documentTemplateId?: string; // ID du modèle de document associé\n nodeId: string; // ID du nœud associé\n}\n\ninterface AnalysisProgress {\n progress: number;\n currentStep: string;\n message: string;\n}\n\n// Fonction pour obtenir les étapes de traitement traduites\nconst getProcessingSteps = (t: (key: string) => string): ProcessingStep[] => [\n {\n title: t(\"jdi.processing.steps.document_reception.title\"),\n subtitle: t(\"jdi.processing.steps.document_reception.subtitle\"),\n hasError: false,\n },\n {\n title: t(\"jdi.processing.steps.quality_analysis.title\"),\n subtitle: t(\"jdi.processing.steps.quality_analysis.subtitle\"),\n hasError: false,\n },\n {\n title: t(\"jdi.processing.steps.data_extraction.title\"),\n subtitle: t(\"jdi.processing.steps.data_extraction.subtitle\"),\n hasError: false,\n },\n {\n title: t(\"jdi.processing.steps.final_verification.title\"),\n subtitle: t(\"jdi.processing.steps.final_verification.subtitle\"),\n hasError: false,\n },\n];\n\nconst JDIProcessing = memo(\n ({\n onProcessingComplete,\n documentType,\n fileUploaded,\n documentTypeId,\n retryCount = 0,\n documentTemplateId,\n nodeId,\n }: JDIProcessingProps) => {\n const { t } = useI18n();\n const [isProcessing, setIsProcessing] = useState(false);\n const [currentStep, setCurrentStep] = useState(0);\n const [processingSteps, setProcessingSteps] = useState<ProcessingStep[]>(\n () => getProcessingSteps(t),\n );\n const [isComplete, setIsComplete] = useState(false);\n const [analysisResult, setAnalysisResult] =\n useState<JDIProcessingResult | null>(null);\n const [analysisProgress, setAnalysisProgress] = useState<AnalysisProgress>({\n progress: 0,\n currentStep: \"\",\n message: \"\",\n });\n\n const processingStartedRef = useRef(false);\n const processedFilesRef = useRef<string | null>(null);\n\n // Créer une clé stable pour les fichiers uploadés\n const filesKey = useMemo(() => {\n if (!fileUploaded) return null;\n return `${fileUploaded.front?.substring(0, 50) || \"no-front\"}-${\n fileUploaded.back?.substring(0, 50) || \"no-back\"\n }`;\n }, [fileUploaded]);\n\n // Callback stable pour onProcessingComplete\n const stableOnProcessingComplete = useCallback(\n (\n success: boolean,\n retryCount?: number,\n analysisData?: Prediction[] | null,\n blockContinue?: boolean,\n ) => {\n if (blockContinue === true) {\n onProcessingComplete(success, retryCount, analysisData, true);\n } else {\n onProcessingComplete(success, retryCount, analysisData);\n }\n },\n [onProcessingComplete],\n );\n\n useEffect(() => {\n // Empêcher les appels multiples\n if (\n !fileUploaded ||\n !filesKey ||\n isProcessing ||\n processingStartedRef.current\n ) {\n return;\n }\n\n const sessionId = getActiveSessionId();\n if (!sessionId) {\n stableOnProcessingComplete(false);\n return;\n }\n\n // Vérifier si on a déjà traité ces mêmes fichiers\n if (processedFilesRef.current === filesKey) {\n return;\n }\n\n // Fonction pour gérer la conversion et l'upload des fichiers\n const handleFileConversionAndUpload = async (\n sessionId: string,\n fileUploaded: onUploadFiles,\n ) => {\n const frontImage = fileUploaded.front;\n if (!frontImage) return;\n\n try {\n if (isPdf(frontImage)) {\n const convertedFile = await convertPdfToPng(frontImage);\n await uploadConvertedIdCardImage(sessionId, convertedFile);\n } else if (isJpeg(frontImage)) {\n const convertedFile = await convertJpegToPng(frontImage);\n await uploadConvertedIdCardImage(sessionId, convertedFile);\n } else if (isPng(frontImage)) {\n const file = dataUrlToFile(frontImage, \"converted_id_card.png\");\n await uploadConvertedIdCardImage(sessionId, file);\n }\n } catch (error) {\n console.error(\"Erreur lors de la conversion/upload:\", error);\n // Ne pas bloquer le processus, continuer avec l'analyse normale\n }\n };\n\n const processFiles = async () => {\n try {\n // Marquer le début du traitement\n setIsProcessing(true);\n processingStartedRef.current = true;\n processedFilesRef.current = filesKey;\n\n // Animation des étapes avec appel API réel à la fin\n for (let i = 0; i < processingSteps.length; i++) {\n setCurrentStep(i);\n\n if (i < processingSteps.length - 1) {\n // Délai entre les étapes (sauf la dernière)\n await new Promise((resolve) => setTimeout(resolve, 800));\n } else {\n // Dernière étape : conversion et upload si nécessaire, puis appel API réel\n await handleFileConversionAndUpload(sessionId, fileUploaded);\n\n const response = await analyzeFiles(\n sessionId,\n nodeId,\n fileUploaded,\n documentTemplateId || \"\",\n {\n save: false, // don't save to session yet\n incrementAnalysis: false, // don't auto-progress session\n documentTypeKey: documentType,\n requiresTwoSides: requiresTwoSides(documentType),\n enablePolling: true, // Enable polling for progress\n pollingOptions: {\n interval: 2000, // Poll every 2 seconds (backend optimized timing)\n maxAttempts: 30, // 30 * 2s = max 60s polling duration\n timeout: 600000,\n onProgress: (status) => {\n // Update analysis progress state for display\n setAnalysisProgress({\n progress: status.progress,\n currentStep: status.currentStep,\n message: status.message,\n });\n\n // Update UI based on progress percentage\n // 50% = Analyzing (steps 0-2)\n // 100% = Completed (step 3)\n if (status.progress === 50) {\n // Analysis in progress - show steps 0-2 progressively\n const elapsed =\n Date.now() -\n (Date.parse(status.startedAt || \"\") || Date.now());\n const elapsedSeconds = elapsed / 1000;\n\n // Progress through first 3 steps based on elapsed time\n if (elapsedSeconds < 3) {\n setCurrentStep((prev) => Math.max(prev, 0));\n } else if (elapsedSeconds < 6) {\n setCurrentStep((prev) => Math.max(prev, 1));\n } else {\n setCurrentStep((prev) => Math.max(prev, 2));\n }\n } else if (status.progress === 100) {\n // Analysis complete - move to final step\n setCurrentStep(processingSteps.length - 1);\n }\n },\n onComplete: (status) => {\n // Update final progress state\n setAnalysisProgress({\n progress: status.progress,\n currentStep: status.currentStep,\n message: status.message,\n });\n\n // Ensure we're at the final step\n setCurrentStep(processingSteps.length - 1);\n\n // Mark the final step based on analysis result\n const isFailed =\n status.currentStep === \"failed\" ||\n status.currentStep === \"error\";\n\n if (isFailed) {\n setProcessingSteps((prev) =>\n prev.map((step, index) =>\n index === processingSteps.length - 1\n ? { ...step, hasError: true }\n : step,\n ),\n );\n }\n },\n onFailed: (status, error) => {\n console.error(\n \"❌ [JDIProcessing] Analysis polling failed:\",\n error,\n );\n\n // Update error state\n setAnalysisProgress({\n progress: 100,\n currentStep: \"failed\",\n message: `Analysis failed: ${error}`,\n });\n\n // Mark current step as error\n setProcessingSteps((prev) =>\n prev.map((step, index) =>\n index === currentStep\n ? { ...step, hasError: true }\n : step,\n ),\n );\n },\n },\n },\n );\n\n const extractedCode = String(response.code);\n const codeName = response?.codeName;\n const codeDescription = response?.codeDescription;\n\n // Construct predictions array from the response\n const predictions: Prediction[] = [];\n if (extractedCode && codeName) {\n predictions.push({\n code: extractedCode,\n codeName: codeName,\n codeDescription: codeDescription || \"\",\n type: \"document\",\n });\n }\n\n // Determine success based on code\n // Code 8.x (specimen) is blocking — treated as failure\n const isSuccess = [\"1.\", \"4.\", \"5.\", \"6.\", \"9.\"].some(\n (prefix) => extractedCode.startsWith(prefix),\n );\n const canRetry = isSuccess === false;\n\n setAnalysisResult({\n success: isSuccess,\n code: extractedCode,\n canRetry,\n data: response,\n predictions: predictions,\n });\n\n // Mark the final step based on analysis result\n if (!isSuccess) {\n setProcessingSteps((prev) =>\n prev.map((step, index) =>\n index === processingSteps.length - 1\n ? { ...step, hasError: true }\n : step,\n ),\n );\n }\n\n // délai pour voir le résultat\n await new Promise((resolve) => setTimeout(resolve, 500));\n }\n }\n\n setCurrentStep(processingSteps.length);\n setIsComplete(true);\n } catch (error) {\n console.error(\"❌ Erreur lors de l'analyse des fichiers:\", error);\n\n // Determine which step failed\n let failedStepIndex = currentStep;\n\n // If error occurred during analysis, mark the final verification step as failed\n if (currentStep >= processingSteps.length - 1) {\n failedStepIndex = processingSteps.length - 1;\n }\n\n // Mark the failed step as error\n setProcessingSteps((prev) =>\n prev.map((step, index) =>\n index === failedStepIndex ? { ...step, hasError: true } : step,\n ),\n );\n\n // Move to the failed step to show error\n setCurrentStep(failedStepIndex);\n\n // Determine if retry is allowed based on error type\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n const isNetworkError =\n errorMessage.includes(\"network\") ||\n errorMessage.includes(\"CORS\") ||\n errorMessage.includes(\"timeout\");\n const isUploadNotConfirmed = isS3UploadNotConfirmedError(error);\n\n setAnalysisResult({\n success: false,\n data: null,\n canRetry: isNetworkError || isUploadNotConfirmed,\n blockContinue: isUploadNotConfirmed,\n });\n setIsComplete(true);\n } finally {\n setIsProcessing(false);\n }\n };\n\n processFiles();\n }, [\n fileUploaded,\n filesKey,\n documentTypeId,\n documentTemplateId,\n documentType,\n isProcessing,\n stableOnProcessingComplete,\n processingSteps.length,\n currentStep,\n ]);\n\n // Auto-complete when analysis is done\n useEffect(() => {\n if (isComplete && analysisResult) {\n setTimeout(() => {\n const allowRetry =\n analysisResult.success || analysisResult.canRetry === true;\n // Pass predictions array instead of raw data\n stableOnProcessingComplete(\n analysisResult.success,\n allowRetry ? retryCount : undefined,\n analysisResult.predictions || null,\n analysisResult.blockContinue,\n );\n }, 1000);\n }\n }, [isComplete, analysisResult, stableOnProcessingComplete, retryCount]);\n\n return (\n <div className=\"flex flex-col justify-between h-full w-full\">\n {/* Main content area */}\n <div className=\"flex-1 px-4 py-6 pt-11 md:px-8 md:py-8\">\n <div className=\"w-full max-w-md mx-auto space-y-6\">\n {/* Header */}\n <div className=\"text-center space-y-4\">\n <Title className=\"text-xl md:text-2xl lg:text-3xl\">\n {t(\"jdi.processing.title\")}\n </Title>\n <Subtitle className=\"text-sm text-gray-600 leading-relaxed\">\n {t(\"jdi.processing.subtitle\", {\n document: t(\"documentTypes.\" + documentType),\n })}\n </Subtitle>\n </div>\n\n {/* Processing steps with status indicators */}\n <div className=\"w-full flex justify-center\">\n <div className=\"space-y-5\">\n {processingSteps.map((step, index: number) => (\n <div key={index} className=\"flex items-start\">\n {/* Status indicator */}\n <div className=\"mr-4 mt-1 flex-shrink-0\">\n {index < currentStep ? (\n step.hasError ? (\n // Error indicator - Red X\n <div className=\"flex items-center justify-center w-6 h-6 rounded-full bg-red-500 text-white text-xs\">\n ✕\n </div>\n ) : (\n // Success indicator - Green checkmark\n <div className=\"flex items-center justify-center w-6 h-6 rounded-full bg-[#11E5C5] text-white text-xs\">\n ✓\n </div>\n )\n ) : index === currentStep ? (\n // Loading spinner only for the current step\n <div className=\"w-6 h-6 rounded-full border-2 border-t-[#11E5C5] border-r-[#11E5C5] border-b-[#11E5C5] border-l-transparent animate-spin\"></div>\n ) : (\n // Empty circle for future steps\n <div className=\"w-6 h-6 rounded-full border-2 border-gray-300\"></div>\n )}\n </div>\n\n {/* Step content */}\n <div className=\"flex-1 min-w-0\">\n <p className=\"font-medium text-[#3C3C40] text-sm\">\n {step.title}\n </p>\n <p className=\"text-xs text-gray-500 mt-1\">\n {step.subtitle}\n </p>\n </div>\n </div>\n ))}\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n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"version":3,"file":"JDIProcessing.js","sources":["../../../../../src/components/jdi/JDIProcessing.tsx"],"sourcesContent":["import { useEffect, useRef, useState, useMemo, useCallback, memo } from \"react\";\nimport Title from \"../ui/Title\";\nimport Subtitle from \"../ui/Subtitle\";\nimport type { onUploadFiles } from \"../../types/uploadFiles\";\nimport type { ProcessingStep } from \"../../types/session\";\nimport type { Prediction } from \"../../utils/apiAnalysis\";\nimport type { JDIProcessingResult } from \"./types\";\nimport {\n analyzeFiles,\n uploadConvertedIdCardImage,\n} from \"../../services/analysis\";\nimport { getActiveSessionId } from \"../../services/sessionMemoryStore\";\nimport {\n convertPdfToPng,\n convertJpegToPng,\n dataUrlToFile,\n isPdf,\n isJpeg,\n isPng,\n} from \"../../utils/imageConverter\";\nimport { useI18n } from \"../../hooks/useI18n\";\nimport { requiresTwoSides } from \"../../utils/documentLabels\";\nimport { isS3UploadNotConfirmedError } from \"../../utils/analysisErrors\";\nimport { isBlockingCode } from \"../../utils/jdiCodes\";\n\ninterface JDIProcessingProps {\n onProcessingComplete: (\n success: boolean,\n retryCount?: number,\n analysisData?: Prediction[] | null,\n blockContinue?: boolean,\n ) => void;\n documentType: string;\n fileUploaded: onUploadFiles | null; // Fichiers uploadés\n documentTypeId: string; // ID du type de document (jdd, income-proof, etc.)\n retryCount?: number; // Nombre de tentatives de retry déjà effectuées\n documentTemplateId?: string; // ID du modèle de document associé\n nodeId: string; // ID du nœud associé\n /** Codes JDI exacts considérés comme bloquants pour ce nœud (cf. node.blockingCodes). Absent = liste par défaut. */\n blockingCodes?: string[];\n}\n\ninterface AnalysisProgress {\n progress: number;\n currentStep: string;\n message: string;\n}\n\n// Fonction pour obtenir les étapes de traitement traduites\nconst getProcessingSteps = (t: (key: string) => string): ProcessingStep[] => [\n {\n title: t(\"jdi.processing.steps.document_reception.title\"),\n subtitle: t(\"jdi.processing.steps.document_reception.subtitle\"),\n hasError: false,\n },\n {\n title: t(\"jdi.processing.steps.quality_analysis.title\"),\n subtitle: t(\"jdi.processing.steps.quality_analysis.subtitle\"),\n hasError: false,\n },\n {\n title: t(\"jdi.processing.steps.data_extraction.title\"),\n subtitle: t(\"jdi.processing.steps.data_extraction.subtitle\"),\n hasError: false,\n },\n {\n title: t(\"jdi.processing.steps.final_verification.title\"),\n subtitle: t(\"jdi.processing.steps.final_verification.subtitle\"),\n hasError: false,\n },\n];\n\nconst JDIProcessing = memo(\n ({\n onProcessingComplete,\n documentType,\n fileUploaded,\n documentTypeId,\n retryCount = 0,\n documentTemplateId,\n nodeId,\n blockingCodes,\n }: JDIProcessingProps) => {\n const { t } = useI18n();\n const [isProcessing, setIsProcessing] = useState(false);\n const [currentStep, setCurrentStep] = useState(0);\n const [processingSteps, setProcessingSteps] = useState<ProcessingStep[]>(\n () => getProcessingSteps(t),\n );\n const [isComplete, setIsComplete] = useState(false);\n const [analysisResult, setAnalysisResult] =\n useState<JDIProcessingResult | null>(null);\n const [analysisProgress, setAnalysisProgress] = useState<AnalysisProgress>({\n progress: 0,\n currentStep: \"\",\n message: \"\",\n });\n\n const processingStartedRef = useRef(false);\n const processedFilesRef = useRef<string | null>(null);\n\n // Créer une clé stable pour les fichiers uploadés\n const filesKey = useMemo(() => {\n if (!fileUploaded) return null;\n return `${fileUploaded.front?.substring(0, 50) || \"no-front\"}-${\n fileUploaded.back?.substring(0, 50) || \"no-back\"\n }`;\n }, [fileUploaded]);\n\n // Callback stable pour onProcessingComplete\n const stableOnProcessingComplete = useCallback(\n (\n success: boolean,\n retryCount?: number,\n analysisData?: Prediction[] | null,\n blockContinue?: boolean,\n ) => {\n if (blockContinue === true) {\n onProcessingComplete(success, retryCount, analysisData, true);\n } else {\n onProcessingComplete(success, retryCount, analysisData);\n }\n },\n [onProcessingComplete],\n );\n\n useEffect(() => {\n // Empêcher les appels multiples\n if (\n !fileUploaded ||\n !filesKey ||\n isProcessing ||\n processingStartedRef.current\n ) {\n return;\n }\n\n const sessionId = getActiveSessionId();\n if (!sessionId) {\n stableOnProcessingComplete(false);\n return;\n }\n\n // Vérifier si on a déjà traité ces mêmes fichiers\n if (processedFilesRef.current === filesKey) {\n return;\n }\n\n // Fonction pour gérer la conversion et l'upload des fichiers\n const handleFileConversionAndUpload = async (\n sessionId: string,\n fileUploaded: onUploadFiles,\n ) => {\n const frontImage = fileUploaded.front;\n if (!frontImage) return;\n\n try {\n if (isPdf(frontImage)) {\n const convertedFile = await convertPdfToPng(frontImage);\n await uploadConvertedIdCardImage(sessionId, convertedFile);\n } else if (isJpeg(frontImage)) {\n const convertedFile = await convertJpegToPng(frontImage);\n await uploadConvertedIdCardImage(sessionId, convertedFile);\n } else if (isPng(frontImage)) {\n const file = dataUrlToFile(frontImage, \"converted_id_card.png\");\n await uploadConvertedIdCardImage(sessionId, file);\n }\n } catch (error) {\n console.error(\"Erreur lors de la conversion/upload:\", error);\n // Ne pas bloquer le processus, continuer avec l'analyse normale\n }\n };\n\n const processFiles = async () => {\n try {\n // Marquer le début du traitement\n setIsProcessing(true);\n processingStartedRef.current = true;\n processedFilesRef.current = filesKey;\n\n // Animation des étapes avec appel API réel à la fin\n for (let i = 0; i < processingSteps.length; i++) {\n setCurrentStep(i);\n\n if (i < processingSteps.length - 1) {\n // Délai entre les étapes (sauf la dernière)\n await new Promise((resolve) => setTimeout(resolve, 800));\n } else {\n // Dernière étape : conversion et upload si nécessaire, puis appel API réel\n await handleFileConversionAndUpload(sessionId, fileUploaded);\n\n const response = await analyzeFiles(\n sessionId,\n nodeId,\n fileUploaded,\n documentTemplateId || \"\",\n {\n save: false, // don't save to session yet\n incrementAnalysis: false, // don't auto-progress session\n documentTypeKey: documentType,\n requiresTwoSides: requiresTwoSides(documentType),\n enablePolling: true, // Enable polling for progress\n pollingOptions: {\n interval: 2000, // Poll every 2 seconds (backend optimized timing)\n maxAttempts: 30, // 30 * 2s = max 60s polling duration\n timeout: 600000,\n onProgress: (status) => {\n // Update analysis progress state for display\n setAnalysisProgress({\n progress: status.progress,\n currentStep: status.currentStep,\n message: status.message,\n });\n\n // Update UI based on progress percentage\n // 50% = Analyzing (steps 0-2)\n // 100% = Completed (step 3)\n if (status.progress === 50) {\n // Analysis in progress - show steps 0-2 progressively\n const elapsed =\n Date.now() -\n (Date.parse(status.startedAt || \"\") || Date.now());\n const elapsedSeconds = elapsed / 1000;\n\n // Progress through first 3 steps based on elapsed time\n if (elapsedSeconds < 3) {\n setCurrentStep((prev) => Math.max(prev, 0));\n } else if (elapsedSeconds < 6) {\n setCurrentStep((prev) => Math.max(prev, 1));\n } else {\n setCurrentStep((prev) => Math.max(prev, 2));\n }\n } else if (status.progress === 100) {\n // Analysis complete - move to final step\n setCurrentStep(processingSteps.length - 1);\n }\n },\n onComplete: (status) => {\n // Update final progress state\n setAnalysisProgress({\n progress: status.progress,\n currentStep: status.currentStep,\n message: status.message,\n });\n\n // Ensure we're at the final step\n setCurrentStep(processingSteps.length - 1);\n\n // Mark the final step based on analysis result\n const isFailed =\n status.currentStep === \"failed\" ||\n status.currentStep === \"error\";\n\n if (isFailed) {\n setProcessingSteps((prev) =>\n prev.map((step, index) =>\n index === processingSteps.length - 1\n ? { ...step, hasError: true }\n : step,\n ),\n );\n }\n },\n onFailed: (status, error) => {\n console.error(\n \"❌ [JDIProcessing] Analysis polling failed:\",\n error,\n );\n\n // Update error state\n setAnalysisProgress({\n progress: 100,\n currentStep: \"failed\",\n message: `Analysis failed: ${error}`,\n });\n\n // Mark current step as error\n setProcessingSteps((prev) =>\n prev.map((step, index) =>\n index === currentStep\n ? { ...step, hasError: true }\n : step,\n ),\n );\n },\n },\n },\n );\n\n const extractedCode = String(response.code);\n const codeName = response?.codeName;\n const codeDescription = response?.codeDescription;\n\n // Construct predictions array from the response\n const predictions: Prediction[] = [];\n if (extractedCode && codeName) {\n predictions.push({\n code: extractedCode,\n codeName: codeName,\n codeDescription: codeDescription || \"\",\n type: \"document\",\n });\n }\n\n // Determine success based on the node's configured blocking codes\n // (blockingCodes absent → DEFAULT_BLOCKING_CODES, legacy behavior\n // unchanged). Code 8.x (specimen) is always blocking.\n const isSuccess = !isBlockingCode(extractedCode, blockingCodes);\n const canRetry = isSuccess === false;\n\n setAnalysisResult({\n success: isSuccess,\n code: extractedCode,\n canRetry,\n data: response,\n predictions: predictions,\n });\n\n // Mark the final step based on analysis result\n if (!isSuccess) {\n setProcessingSteps((prev) =>\n prev.map((step, index) =>\n index === processingSteps.length - 1\n ? { ...step, hasError: true }\n : step,\n ),\n );\n }\n\n // délai pour voir le résultat\n await new Promise((resolve) => setTimeout(resolve, 500));\n }\n }\n\n setCurrentStep(processingSteps.length);\n setIsComplete(true);\n } catch (error) {\n console.error(\"❌ Erreur lors de l'analyse des fichiers:\", error);\n\n // Determine which step failed\n let failedStepIndex = currentStep;\n\n // If error occurred during analysis, mark the final verification step as failed\n if (currentStep >= processingSteps.length - 1) {\n failedStepIndex = processingSteps.length - 1;\n }\n\n // Mark the failed step as error\n setProcessingSteps((prev) =>\n prev.map((step, index) =>\n index === failedStepIndex ? { ...step, hasError: true } : step,\n ),\n );\n\n // Move to the failed step to show error\n setCurrentStep(failedStepIndex);\n\n // Determine if retry is allowed based on error type\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n const isNetworkError =\n errorMessage.includes(\"network\") ||\n errorMessage.includes(\"CORS\") ||\n errorMessage.includes(\"timeout\");\n const isUploadNotConfirmed = isS3UploadNotConfirmedError(error);\n\n setAnalysisResult({\n success: false,\n data: null,\n canRetry: isNetworkError || isUploadNotConfirmed,\n blockContinue: isUploadNotConfirmed,\n });\n setIsComplete(true);\n } finally {\n setIsProcessing(false);\n }\n };\n\n processFiles();\n }, [\n fileUploaded,\n filesKey,\n documentTypeId,\n documentTemplateId,\n documentType,\n isProcessing,\n stableOnProcessingComplete,\n processingSteps.length,\n currentStep,\n blockingCodes,\n ]);\n\n // Auto-complete when analysis is done\n useEffect(() => {\n if (isComplete && analysisResult) {\n setTimeout(() => {\n const allowRetry =\n analysisResult.success || analysisResult.canRetry === true;\n // Pass predictions array instead of raw data\n stableOnProcessingComplete(\n analysisResult.success,\n allowRetry ? retryCount : undefined,\n analysisResult.predictions || null,\n analysisResult.blockContinue,\n );\n }, 1000);\n }\n }, [isComplete, analysisResult, stableOnProcessingComplete, retryCount]);\n\n return (\n <div className=\"flex flex-col justify-between h-full w-full\">\n {/* Main content area */}\n <div className=\"flex-1 px-4 py-6 pt-11 md:px-8 md:py-8\">\n <div className=\"w-full max-w-md mx-auto space-y-6\">\n {/* Header */}\n <div className=\"text-center space-y-4\">\n <Title className=\"text-xl md:text-2xl lg:text-3xl\">\n {t(\"jdi.processing.title\")}\n </Title>\n <Subtitle className=\"text-sm text-gray-600 leading-relaxed\">\n {t(\"jdi.processing.subtitle\", {\n document: t(\"documentTypes.\" + documentType),\n })}\n </Subtitle>\n </div>\n\n {/* Processing steps with status indicators */}\n <div className=\"w-full flex justify-center\">\n <div className=\"space-y-5\">\n {processingSteps.map((step, index: number) => (\n <div key={index} className=\"flex items-start\">\n {/* Status indicator */}\n <div className=\"mr-4 mt-1 flex-shrink-0\">\n {index < currentStep ? (\n step.hasError ? (\n // Error indicator - Red X\n <div className=\"flex items-center justify-center w-6 h-6 rounded-full bg-red-500 text-white text-xs\">\n ✕\n </div>\n ) : (\n // Success indicator - Green checkmark\n <div className=\"flex items-center justify-center w-6 h-6 rounded-full bg-[#11E5C5] text-white text-xs\">\n ✓\n </div>\n )\n ) : index === currentStep ? (\n // Loading spinner only for the current step\n <div className=\"w-6 h-6 rounded-full border-2 border-t-[#11E5C5] border-r-[#11E5C5] border-b-[#11E5C5] border-l-transparent animate-spin\"></div>\n ) : (\n // Empty circle for future steps\n <div className=\"w-6 h-6 rounded-full border-2 border-gray-300\"></div>\n )}\n </div>\n\n {/* Step content */}\n <div className=\"flex-1 min-w-0\">\n <p className=\"font-medium text-[#3C3C40] text-sm\">\n {step.title}\n </p>\n <p className=\"text-xs text-gray-500 mt-1\">\n {step.subtitle}\n </p>\n </div>\n </div>\n ))}\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n },\n);\n\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AS,EAAC,4BAA4B,YACzCA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,WAAW,EAAA,QAAA,EACvB,eAAe,CAAC,GAAG,CAAC,UAAC,IAAI,EAAE,KAAa,EAAA,EAAK,QAC5CC,IAAA,CAAA,KAAA,EAAA,EAAiB,SAAS,EAAC,kBAAkB,EAAA,QAAA,EAAA,CAE3CD,aAAK,SAAS,EAAC,yBAAyB,EAAA,QAAA,EACrC,KAAK,GAAG,WAAW,IAClB,IAAI,CAAC,QAAQ;;AAEX,wCAAAA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,qFAAqF,uBAE9F;;AAGN,wCAAAA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,uFAAuF,EAAA,QAAA,EAAA,QAAA,EAAA,CAEhG,CACP,IACC,KAAK,KAAK,WAAW;;AAEvB,wCAAAA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,0HAA0H,GAAO;;wCAGhJA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,+CAA+C,EAAA,CAAO,CACtE,EAAA,CACG,EAGNC,cAAK,SAAS,EAAC,gBAAgB,EAAA,QAAA,EAAA,CAC7BD,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,oCAAoC,YAC9C,IAAI,CAAC,KAAK,EAAA,CACT,EACJA,WAAG,SAAS,EAAC,4BAA4B,EAAA,QAAA,EACtC,IAAI,CAAC,QAAQ,EAAA,CACZ,IACA,CAAA,EAAA,EAhCE,KAAK,CAiCT,EACP,CAnC6C,CAmC7C,CAAC,EAAA,CACE,GACF,CAAA,EAAA,CACF,EAAA,CACF,EAAA,CACF;AAEV,CAAC;AAGH,aAAa,CAAC,WAAW,GAAG,eAAe;;;;"}
|
|
@@ -26,10 +26,11 @@ import { getAllDocumentTemplates, getDocumentTemplateId, getDocTypeKey } from '.
|
|
|
26
26
|
import { blobToDataUrl, dataUrlToBlob, resizeAfterCapture } from '../../utils/imageProcessing.js';
|
|
27
27
|
import { getNodeRetryCount, incrementNodeRetryCount } from '../../services/retryService.js';
|
|
28
28
|
import { getSession } from '../../context/SessionContext.js';
|
|
29
|
-
import { updateSessionUserInput, skipNfcWithReason } from '../../services/sessionService.js';
|
|
29
|
+
import { hasOutgoingEdgeForHandle, updateSessionUserInput, skipNfcWithReason } from '../../services/sessionService.js';
|
|
30
30
|
import NfcScanStep from '../nfc-scan/NfcScanNode.js';
|
|
31
31
|
import NfcChipGate from '../nfc-scan/NfcChipGate.js';
|
|
32
32
|
import NfcFallbackSurvey from '../nfc-scan/NfcFallbackSurvey.js';
|
|
33
|
+
import { resolveControleJdiOutcomeRoute, normalizeMaxResubmissionAction, hasExceededResubmissionAttempts } from './controleJdiPolicy.js';
|
|
33
34
|
import { EUROPEAN_COUNTRY_CODES } from '../../utils/europeanCountries.js';
|
|
34
35
|
|
|
35
36
|
var NFC_ELIGIBLE_DOCUMENT_TYPES = new Set([
|
|
@@ -511,6 +512,7 @@ var DocumentCheck = function (_a) {
|
|
|
511
512
|
}
|
|
512
513
|
};
|
|
513
514
|
var handleProcessingComplete = function (success, _retryCount, apiAnalysisData, shouldBlockContinue) {
|
|
515
|
+
var _a;
|
|
514
516
|
setBlockContinue(shouldBlockContinue === true);
|
|
515
517
|
if (apiAnalysisData) {
|
|
516
518
|
setAnalysisData(apiAnalysisData);
|
|
@@ -532,8 +534,10 @@ var DocumentCheck = function (_a) {
|
|
|
532
534
|
}
|
|
533
535
|
// Increment currentStep in database immediately after successful analysis
|
|
534
536
|
// This prevents double analysis if the user refreshes the page
|
|
537
|
+
// Handle "true" explicite : sûr même sur un nœud legacy à une seule
|
|
538
|
+
// arête (findOutgoingEdge retombe sur la première arête existante).
|
|
535
539
|
if (template) {
|
|
536
|
-
stepObject.goToNextStep(node.id, template);
|
|
540
|
+
stepObject.goToNextStep(node.id, template, "true");
|
|
537
541
|
}
|
|
538
542
|
else {
|
|
539
543
|
stepObject.setStep(stepObject.step + 1);
|
|
@@ -541,15 +545,36 @@ var DocumentCheck = function (_a) {
|
|
|
541
545
|
setDocStep(5);
|
|
542
546
|
}
|
|
543
547
|
else {
|
|
548
|
+
var newRetryCount = retryCount + 1;
|
|
544
549
|
// Increment retry count both in state and session
|
|
545
|
-
setRetryCount(
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
incrementNodeRetryCount(sessionId, node.id, prev).catch(function (error) {
|
|
549
|
-
console.error("Failed to update retry count in session:", error);
|
|
550
|
-
});
|
|
551
|
-
return newCount;
|
|
550
|
+
setRetryCount(newRetryCount);
|
|
551
|
+
incrementNodeRetryCount(sessionId, node.id, retryCount).catch(function (error) {
|
|
552
|
+
console.error("Failed to update retry count in session:", error);
|
|
552
553
|
});
|
|
554
|
+
// Routage automatique vers la sortie "false" (nouveau) : uniquement
|
|
555
|
+
// pour un véritable échec de code JDI bloquant (pas un souci d'upload
|
|
556
|
+
// S3 non confirmé — cf. shouldBlockContinue), une fois les
|
|
557
|
+
// resoumissions épuisées ET si l'auteur a câblé une sortie "false".
|
|
558
|
+
// Sinon, comportement legacy inchangé : écran d'erreur (retry et/ou
|
|
559
|
+
// "continuer quand même" selon isRetryAllowed/allowContinueOnFailure).
|
|
560
|
+
if (shouldBlockContinue !== true && template) {
|
|
561
|
+
var currentCode = apiAnalysisData && apiAnalysisData.length > 0
|
|
562
|
+
? apiAnalysisData[0].code
|
|
563
|
+
: (errorCode !== null && errorCode !== void 0 ? errorCode : undefined);
|
|
564
|
+
var effectiveMaxAttempts = (currentCode === null || currentCode === void 0 ? void 0 : currentCode.startsWith("8")) || node.allowResubmission === false
|
|
565
|
+
? 0
|
|
566
|
+
: ((_a = node.maxResubmissionAttempts) !== null && _a !== void 0 ? _a : Infinity);
|
|
567
|
+
var route = resolveControleJdiOutcomeRoute({
|
|
568
|
+
hasExceededAttempts: hasExceededResubmissionAttempts(newRetryCount, effectiveMaxAttempts),
|
|
569
|
+
hasFalseEdge: hasOutgoingEdgeForHandle(node.id, template, "false"),
|
|
570
|
+
action: normalizeMaxResubmissionAction(node.maxResubmissionAction),
|
|
571
|
+
});
|
|
572
|
+
if (!route.showErrorScreen && route.handle) {
|
|
573
|
+
stepObject.goToNextStep(node.id, template, route.handle);
|
|
574
|
+
setDocStep(0);
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
553
578
|
setDocStep(6);
|
|
554
579
|
}
|
|
555
580
|
};
|
|
@@ -606,7 +631,7 @@ var DocumentCheck = function (_a) {
|
|
|
606
631
|
};
|
|
607
632
|
var handleSuccessContinue = function () {
|
|
608
633
|
if (template) {
|
|
609
|
-
stepObject.goToNextStep(node.id, template);
|
|
634
|
+
stepObject.goToNextStep(node.id, template, "true");
|
|
610
635
|
}
|
|
611
636
|
else {
|
|
612
637
|
stepObject.setStep(stepObject.step + 1);
|
|
@@ -729,7 +754,7 @@ var DocumentCheck = function (_a) {
|
|
|
729
754
|
}, nodeId: node.id, sessionId: sessionId, previewOverrides: {
|
|
730
755
|
recto: capturedImages.recto,
|
|
731
756
|
verso: capturedImages.verso,
|
|
732
|
-
} }));
|
|
757
|
+
}, blockingCodes: node.blockingCodes }));
|
|
733
758
|
}
|
|
734
759
|
if (currentPhotoStep === "before-recto") {
|
|
735
760
|
return (jsx(BeforePhoto, { setStep: function () { return setCurrentPhotoStep("recto"); }, isSingleSided: isSingleSided, onBack: function () { return setDocStep(2); } }));
|
|
@@ -761,7 +786,7 @@ var DocumentCheck = function (_a) {
|
|
|
761
786
|
}
|
|
762
787
|
// fall-through volontaire vers case 4 (comportement existant conservé)
|
|
763
788
|
case 4:
|
|
764
|
-
return (jsx(JDIProcessing, { documentType: (selectedDocumentType === null || selectedDocumentType === void 0 ? void 0 : selectedDocumentType.id) || documentTypeId, onProcessingComplete: handleProcessingComplete, fileUploaded: fileUploaded, documentTypeId: documentTypeId, retryCount: retryCount, documentTemplateId: selectedDocumentType === null || selectedDocumentType === void 0 ? void 0 : selectedDocumentType.documentTemplateId, nodeId: node.id }));
|
|
789
|
+
return (jsx(JDIProcessing, { documentType: (selectedDocumentType === null || selectedDocumentType === void 0 ? void 0 : selectedDocumentType.id) || documentTypeId, onProcessingComplete: handleProcessingComplete, fileUploaded: fileUploaded, documentTypeId: documentTypeId, retryCount: retryCount, documentTemplateId: selectedDocumentType === null || selectedDocumentType === void 0 ? void 0 : selectedDocumentType.documentTemplateId, nodeId: node.id, blockingCodes: node.blockingCodes }));
|
|
765
790
|
case 5:
|
|
766
791
|
return (jsx(JDISuccess, { documentType: (selectedDocumentType === null || selectedDocumentType === void 0 ? void 0 : selectedDocumentType.id) || documentTypeId, onContinue: handleSuccessContinue, errorCode: errorCode || undefined }));
|
|
767
792
|
case 6:
|