datakeen-session-react 1.1.202-rc.5 → 1.1.202-rc.7
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.
|
@@ -13,6 +13,7 @@ var labelToKey = require('../utils/labelToKey.js');
|
|
|
13
13
|
var session = require('../types/session.js');
|
|
14
14
|
var useI18n = require('./useI18n.js');
|
|
15
15
|
var auditTrailService = require('../services/auditTrailService.js');
|
|
16
|
+
var sessionService = require('../services/sessionService.js');
|
|
16
17
|
|
|
17
18
|
var useUserInputForm = function (_a) {
|
|
18
19
|
var stepObject = _a.stepObject, setUserInput = _a.setUserInput, initialUserInput = _a.initialUserInput, node = _a.node, template = _a.template, contactInfo = _a.contactInfo, setContactInfo = _a.setContactInfo, onContinueCallback = _a.onContinueCallback, sessionId = _a.sessionId;
|
|
@@ -269,6 +270,60 @@ var useUserInputForm = function (_a) {
|
|
|
269
270
|
form.phoneNumber,
|
|
270
271
|
form.companyName,
|
|
271
272
|
]);
|
|
273
|
+
// APP3-2020 — le serveur reporte prénom, nom et date de naissance lus sur la pièce
|
|
274
|
+
// à la racine de userInput après l'analyse : absents de la mémoire du SDK, on les
|
|
275
|
+
// relit à l'ouverture du formulaire personne physique (une fois par nœud, remount
|
|
276
|
+
// par key). Seules les clés vides sont complétées, en mémoire ET dans le formulaire :
|
|
277
|
+
// l'effet ci-dessus ne re-synchronise pas dès qu'un champ (email de contactInfo) est rempli.
|
|
278
|
+
React.useEffect(function () {
|
|
279
|
+
var _a;
|
|
280
|
+
if (informationType !== "identity" ||
|
|
281
|
+
!sessionId ||
|
|
282
|
+
(initialUserInput === null || initialUserInput === void 0 ? void 0 : initialUserInput.firstName) ||
|
|
283
|
+
(initialUserInput === null || initialUserInput === void 0 ? void 0 : initialUserInput.lastName) ||
|
|
284
|
+
!((_a = template === null || template === void 0 ? void 0 : template.nodes) !== null && _a !== void 0 ? _a : []).some(function (n) {
|
|
285
|
+
return (n.type === "controle-jdi" || n.type === "identity-control") &&
|
|
286
|
+
n.copyIdentityToUserInput === true;
|
|
287
|
+
})) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
var cancelled = false;
|
|
291
|
+
sessionService.fetchSessionById(sessionId)
|
|
292
|
+
.then(function (fresh) {
|
|
293
|
+
var _a;
|
|
294
|
+
var server = ((_a = fresh === null || fresh === void 0 ? void 0 : fresh.userInput) !== null && _a !== void 0 ? _a : {});
|
|
295
|
+
var fill = ["firstName", "lastName", "birthDate"].filter(function (key) { return typeof server[key] === "string" && server[key]; });
|
|
296
|
+
if (cancelled || !fill.length)
|
|
297
|
+
return;
|
|
298
|
+
setUserInput(function (prev) {
|
|
299
|
+
var next = tslib_es6.__assign({}, prev);
|
|
300
|
+
for (var _i = 0, fill_1 = fill; _i < fill_1.length; _i++) {
|
|
301
|
+
var key = fill_1[_i];
|
|
302
|
+
if (!next[key])
|
|
303
|
+
next[key] = server[key];
|
|
304
|
+
}
|
|
305
|
+
return next;
|
|
306
|
+
});
|
|
307
|
+
setForm(function (prev) {
|
|
308
|
+
var next = tslib_es6.__assign({}, prev);
|
|
309
|
+
if (!prev.firstName && server.firstName)
|
|
310
|
+
next.firstName = server.firstName;
|
|
311
|
+
if (!prev.lastName && server.lastName)
|
|
312
|
+
next.lastName = server.lastName;
|
|
313
|
+
if (!prev.birthDate && !prev.day && !prev.month && !prev.year && server.birthDate) {
|
|
314
|
+
next.birthDate = server.birthDate;
|
|
315
|
+
Object.assign(next, userInputForm.parseBirthDate(next.birthDate));
|
|
316
|
+
}
|
|
317
|
+
return next;
|
|
318
|
+
});
|
|
319
|
+
})
|
|
320
|
+
.catch(function (error) {
|
|
321
|
+
console.warn("[UserInputForm] Identité reportée indisponible", error);
|
|
322
|
+
});
|
|
323
|
+
return function () {
|
|
324
|
+
cancelled = true;
|
|
325
|
+
};
|
|
326
|
+
}, []); // Une seule relecture à l'ouverture du nœud.
|
|
272
327
|
// Re-synchronise customFormData depuis initialUserInput quand on (ré)affiche un
|
|
273
328
|
// nœud DIFFÉRENT sur une instance réutilisée (retour arrière sans remount).
|
|
274
329
|
// Le champ form standard a déjà son propre effet de re-sync ci-dessus ; le
|
|
@@ -11,6 +11,7 @@ import { labelToKey } from '../utils/labelToKey.js';
|
|
|
11
11
|
import { DEFAULT_DATE_DISPLAY_FORMAT } from '../types/session.js';
|
|
12
12
|
import { useI18n } from './useI18n.js';
|
|
13
13
|
import { logFormValidated } from '../services/auditTrailService.js';
|
|
14
|
+
import { fetchSessionById } from '../services/sessionService.js';
|
|
14
15
|
|
|
15
16
|
var useUserInputForm = function (_a) {
|
|
16
17
|
var stepObject = _a.stepObject, setUserInput = _a.setUserInput, initialUserInput = _a.initialUserInput, node = _a.node, template = _a.template, contactInfo = _a.contactInfo, setContactInfo = _a.setContactInfo, onContinueCallback = _a.onContinueCallback, sessionId = _a.sessionId;
|
|
@@ -267,6 +268,60 @@ var useUserInputForm = function (_a) {
|
|
|
267
268
|
form.phoneNumber,
|
|
268
269
|
form.companyName,
|
|
269
270
|
]);
|
|
271
|
+
// APP3-2020 — le serveur reporte prénom, nom et date de naissance lus sur la pièce
|
|
272
|
+
// à la racine de userInput après l'analyse : absents de la mémoire du SDK, on les
|
|
273
|
+
// relit à l'ouverture du formulaire personne physique (une fois par nœud, remount
|
|
274
|
+
// par key). Seules les clés vides sont complétées, en mémoire ET dans le formulaire :
|
|
275
|
+
// l'effet ci-dessus ne re-synchronise pas dès qu'un champ (email de contactInfo) est rempli.
|
|
276
|
+
useEffect(function () {
|
|
277
|
+
var _a;
|
|
278
|
+
if (informationType !== "identity" ||
|
|
279
|
+
!sessionId ||
|
|
280
|
+
(initialUserInput === null || initialUserInput === void 0 ? void 0 : initialUserInput.firstName) ||
|
|
281
|
+
(initialUserInput === null || initialUserInput === void 0 ? void 0 : initialUserInput.lastName) ||
|
|
282
|
+
!((_a = template === null || template === void 0 ? void 0 : template.nodes) !== null && _a !== void 0 ? _a : []).some(function (n) {
|
|
283
|
+
return (n.type === "controle-jdi" || n.type === "identity-control") &&
|
|
284
|
+
n.copyIdentityToUserInput === true;
|
|
285
|
+
})) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
var cancelled = false;
|
|
289
|
+
fetchSessionById(sessionId)
|
|
290
|
+
.then(function (fresh) {
|
|
291
|
+
var _a;
|
|
292
|
+
var server = ((_a = fresh === null || fresh === void 0 ? void 0 : fresh.userInput) !== null && _a !== void 0 ? _a : {});
|
|
293
|
+
var fill = ["firstName", "lastName", "birthDate"].filter(function (key) { return typeof server[key] === "string" && server[key]; });
|
|
294
|
+
if (cancelled || !fill.length)
|
|
295
|
+
return;
|
|
296
|
+
setUserInput(function (prev) {
|
|
297
|
+
var next = __assign({}, prev);
|
|
298
|
+
for (var _i = 0, fill_1 = fill; _i < fill_1.length; _i++) {
|
|
299
|
+
var key = fill_1[_i];
|
|
300
|
+
if (!next[key])
|
|
301
|
+
next[key] = server[key];
|
|
302
|
+
}
|
|
303
|
+
return next;
|
|
304
|
+
});
|
|
305
|
+
setForm(function (prev) {
|
|
306
|
+
var next = __assign({}, prev);
|
|
307
|
+
if (!prev.firstName && server.firstName)
|
|
308
|
+
next.firstName = server.firstName;
|
|
309
|
+
if (!prev.lastName && server.lastName)
|
|
310
|
+
next.lastName = server.lastName;
|
|
311
|
+
if (!prev.birthDate && !prev.day && !prev.month && !prev.year && server.birthDate) {
|
|
312
|
+
next.birthDate = server.birthDate;
|
|
313
|
+
Object.assign(next, parseBirthDate(next.birthDate));
|
|
314
|
+
}
|
|
315
|
+
return next;
|
|
316
|
+
});
|
|
317
|
+
})
|
|
318
|
+
.catch(function (error) {
|
|
319
|
+
console.warn("[UserInputForm] Identité reportée indisponible", error);
|
|
320
|
+
});
|
|
321
|
+
return function () {
|
|
322
|
+
cancelled = true;
|
|
323
|
+
};
|
|
324
|
+
}, []); // Une seule relecture à l'ouverture du nœud.
|
|
270
325
|
// Re-synchronise customFormData depuis initialUserInput quand on (ré)affiche un
|
|
271
326
|
// nœud DIFFÉRENT sur une instance réutilisée (retour arrière sans remount).
|
|
272
327
|
// Le champ form standard a déjà son propre effet de re-sync ci-dessus ; le
|