datakeen-session-react 1.1.195-dev.2 → 1.1.195-dev.4
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/session/EndFlow.js +15 -5
- package/dist/cjs/components/session/EndFlow.js.map +1 -1
- package/dist/cjs/components/session/SessionContent.js +5 -3
- package/dist/cjs/components/session/SessionContent.js.map +1 -1
- package/dist/cjs/components/template/ExternalVerificationNodeHandler.js +4 -2
- package/dist/cjs/components/template/ExternalVerificationNodeHandler.js.map +1 -1
- package/dist/cjs/components/template/TemplateNodeRenderer.js +5 -3
- package/dist/cjs/components/template/TemplateNodeRenderer.js.map +1 -1
- package/dist/cjs/hooks/useStepNavigation.js +6 -4
- package/dist/cjs/hooks/useStepNavigation.js.map +1 -1
- package/dist/cjs/utils/sessionStatus.js +28 -0
- package/dist/cjs/utils/sessionStatus.js.map +1 -0
- package/dist/esm/components/session/EndFlow.js +15 -5
- package/dist/esm/components/session/EndFlow.js.map +1 -1
- package/dist/esm/components/session/SessionContent.js +5 -3
- package/dist/esm/components/session/SessionContent.js.map +1 -1
- package/dist/esm/components/template/ExternalVerificationNodeHandler.js +4 -2
- package/dist/esm/components/template/ExternalVerificationNodeHandler.js.map +1 -1
- package/dist/esm/components/template/TemplateNodeRenderer.js +5 -3
- package/dist/esm/components/template/TemplateNodeRenderer.js.map +1 -1
- package/dist/esm/hooks/useStepNavigation.js +4 -2
- package/dist/esm/hooks/useStepNavigation.js.map +1 -1
- package/dist/esm/utils/sessionStatus.js +26 -0
- package/dist/esm/utils/sessionStatus.js.map +1 -0
- package/docs/JOURNEY_NODE_BUILDER.md +9 -0
- package/docs/navigation-history.md +8 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStepNavigation.js","sources":["../../../../src/hooks/useStepNavigation.ts"],"sourcesContent":["import { useState, useEffect, useRef } from \"react\";\nimport {\n updateSessionCurrentStep,\n getNextStepIndex,\n getOrderedJourneySteps,\n reconstructHistoryToStep,\n} from \"../services/sessionService\";\nimport type { SessionTemplate } from \"../types/session\";\n\n/** Node types that auto-execute and should be skipped when going back */\nconst AUTO_EXECUTING_TYPES = new Set([\"external-verification\", \"condition\", \"complementary-mandate\"]);\nconst COMMITTED_NODE_TYPES = new Set([\"selfie-capture\", \"biometric-capture\"]);\n\nconst getNodeTypeAtStep = (\n step: number,\n template: SessionTemplate,\n): string | undefined => getOrderedJourneySteps(template)[step - 1]?.type;\n\n/**\n * Rebuilds only the reversible part of a path after a committed node.\n * Auto-executing nodes immediately following the commit are excluded so the\n * first interactive destination remains the history boundary after reload.\n */\nconst trimHistoryAfterCommittedNode = (\n reconstructedHistory: number[],\n template: SessionTemplate,\n): number[] => {\n let committedHistoryIndex = -1;\n\n for (let index = reconstructedHistory.length - 2; index >= 0; index -= 1) {\n const nodeType = getNodeTypeAtStep(reconstructedHistory[index], template);\n if (nodeType && COMMITTED_NODE_TYPES.has(nodeType)) {\n committedHistoryIndex = index;\n break;\n }\n }\n\n if (committedHistoryIndex === -1) {\n return reconstructedHistory;\n }\n\n let reversibleHistoryStart = committedHistoryIndex + 1;\n while (reversibleHistoryStart < reconstructedHistory.length - 1) {\n const nodeType = getNodeTypeAtStep(\n reconstructedHistory[reversibleHistoryStart],\n template,\n );\n if (!nodeType || !AUTO_EXECUTING_TYPES.has(nodeType)) {\n break;\n }\n reversibleHistoryStart += 1;\n }\n\n return reconstructedHistory.slice(reversibleHistoryStart);\n};\n\nexport const useStepNavigation = (\n sessionId: string,\n sessionStatus?: string,\n initialStep?: number,\n template?: SessionTemplate,\n) => {\n const [step, setStepState] = useState(initialStep ?? 0);\n const [history, setHistory] = useState<number[]>(initialStep !== undefined ? [initialStep] : [0]);\n const hasInitialized = useRef(false);\n const committedNavigationPending = useRef(false);\n\n const setStep = (newStep: number, skipHistory = false) => {\n if (!skipHistory && newStep !== step) {\n setHistory((prev) => {\n if (prev[prev.length - 1] === newStep) return prev;\n return [...prev, newStep];\n });\n }\n setStepState(newStep);\n\n // Update current step in database\n if (sessionId) {\n updateSessionCurrentStep(sessionId, newStep).catch((error) => {\n console.error(\"Failed to update current step in database:\", error);\n // Non-blocking error - the step is still updated locally\n });\n }\n };\n\n const goBack = () => {\n if (history.length > 1) {\n let newHistory = [...history];\n newHistory.pop(); // Remove current step\n\n // Skip auto-executing nodes when going back\n if (template) {\n const orderedNodes = getOrderedJourneySteps(template);\n while (newHistory.length > 1) {\n const candidateStep = newHistory[newHistory.length - 1];\n // steps are 1-indexed (step 0 = start, step 1 = first node, etc.)\n const nodeIndex = candidateStep - 1;\n const candidateNode = orderedNodes[nodeIndex];\n if (candidateNode && AUTO_EXECUTING_TYPES.has(candidateNode.type)) {\n newHistory.pop();\n } else {\n break;\n }\n }\n }\n\n const previousStep = newHistory[newHistory.length - 1];\n setHistory(newHistory);\n setStep(previousStep, true);\n } else {\n console.warn(\"[goBack] BLOCKED — history.length <= 1, history:\", [...history]);\n }\n };\n\n /**\n * Retour arrière vers un nœud précis (ex: bouton \"Corriger ma saisie\").\n * Contrairement à `setStep`, on TRONQUE l'historique jusqu'à la dernière\n * occurrence de `targetStep` au lieu de l'empiler : le nœud cible cesse\n * ainsi d'être compté comme un \"revisit\" (runIndex 0 côté\n * TemplateNodeRenderer → formulaire pré-rempli). Si la cible n'est pas dans\n * l'historique, on retombe sur un `setStep` classique.\n */\n const goBackToStep = (targetStep: number) => {\n const idx = history.lastIndexOf(targetStep);\n if (idx !== -1) {\n const newHistory = history.slice(0, idx + 1);\n setHistory(newHistory);\n setStep(targetStep, true);\n } else {\n console.warn(\"[goBackToStep] target not in history — pushing instead:\", targetStep);\n setStep(targetStep);\n }\n };\n\n const goToNextStep = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string\n ) => {\n const nextStepIndex = getNextStepIndex(currentNodeId, template, handle);\n\n if (nextStepIndex !== null) {\n if (committedNavigationPending.current) {\n const destinationType = getNodeTypeAtStep(nextStepIndex, template);\n committedNavigationPending.current = Boolean(\n destinationType && AUTO_EXECUTING_TYPES.has(destinationType),\n );\n setHistory([nextStepIndex]);\n setStep(nextStepIndex, true);\n } else {\n setStep(nextStepIndex);\n }\n } else {\n committedNavigationPending.current = false;\n console.warn(\n `[useStepNavigation] Could not find next step for node ${currentNodeId}. Staying on current step.`\n );\n }\n };\n\n /**\n * Navigates through the graph and makes the destination a point of no return.\n * The destination remains persisted by setStep, while prior history is discarded.\n */\n const goToNextStepCommitted = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n ) => {\n const nextStepIndex = getNextStepIndex(currentNodeId, template, handle);\n\n if (nextStepIndex !== null) {\n const destinationType = getNodeTypeAtStep(nextStepIndex, template);\n committedNavigationPending.current = Boolean(\n destinationType && AUTO_EXECUTING_TYPES.has(destinationType),\n );\n setHistory([nextStepIndex]);\n setStep(nextStepIndex, true);\n } else {\n committedNavigationPending.current = false;\n console.warn(\n `[useStepNavigation] Could not find next step for node ${currentNodeId}. Staying on current step.`,\n );\n }\n };\n\n // Initialize step from session data or status\n useEffect(() => {\n if (!sessionId) {\n return;\n }\n\n // Check if session is already ended\n if (sessionStatus === \"ended\") {\n setStepState(100);\n return;\n }\n\n // Only initialize once when initialStep becomes available\n if (initialStep !== undefined && !hasInitialized.current) {\n setStepState(initialStep);\n setHistory((prev) => {\n // Preserve history if the user already navigated past the initial step\n if (prev.length > 1 && prev[prev.length - 1] === initialStep) {\n return prev;\n }\n // Reconstruct history by following the graph from step 0\n const reconstructed = template\n ? trimHistoryAfterCommittedNode(\n reconstructHistoryToStep(initialStep, template),\n template,\n )\n : initialStep > 0 ? [0, initialStep] : [initialStep];\n return reconstructed;\n });\n hasInitialized.current = true;\n }\n }, [sessionId, sessionStatus, initialStep]);\n\n const stepObject = {\n setStep,\n goBack,\n goBackToStep,\n goToNextStep,\n goToNextStepCommitted,\n step,\n canGoBack: history.length > 1,\n };\n\n return {\n step,\n setStep,\n goBack,\n goBackToStep,\n goToNextStep,\n goToNextStepCommitted,\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CAAC,OAAO,GAAG,IAAI;QAC/B;IACF,CAAC,EAAE,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;AAE3C,IAAA,IAAM,UAAU,GAAG;AACjB,QAAA,OAAO,EAAA,OAAA;AACP,QAAA,MAAM,EAAA,MAAA;AACN,QAAA,YAAY,EAAA,YAAA;AACZ,QAAA,YAAY,EAAA,YAAA;AACZ,QAAA,qBAAqB,EAAA,qBAAA;AACrB,QAAA,IAAI,EAAA,IAAA;AACJ,QAAA,SAAS,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC;KAC9B;IAED,OAAO;AACL,QAAA,IAAI,EAAA,IAAA;AACJ,QAAA,OAAO,EAAA,OAAA;AACP,QAAA,MAAM,EAAA,MAAA;AACN,QAAA,YAAY,EAAA,YAAA;AACZ,QAAA,YAAY,EAAA,YAAA;AACZ,QAAA,qBAAqB,EAAA,qBAAA;AACrB,QAAA,UAAU,EAAA,UAAA;AACV,QAAA,OAAO,EAAA,OAAA;KACR;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"useStepNavigation.js","sources":["../../../../src/hooks/useStepNavigation.ts"],"sourcesContent":["import { useState, useEffect, useRef } from \"react\";\nimport {\n updateSessionCurrentStep,\n getNextStepIndex,\n getOrderedJourneySteps,\n reconstructHistoryToStep,\n} from \"../services/sessionService\";\nimport type { SessionTemplate } from \"../types/session\";\nimport { isSessionFinished } from \"../utils/sessionStatus\";\n\n/** Node types that auto-execute and should be skipped when going back */\nconst AUTO_EXECUTING_TYPES = new Set([\"external-verification\", \"condition\", \"complementary-mandate\"]);\nconst COMMITTED_NODE_TYPES = new Set([\"selfie-capture\", \"biometric-capture\"]);\n\nconst getNodeTypeAtStep = (\n step: number,\n template: SessionTemplate,\n): string | undefined => getOrderedJourneySteps(template)[step - 1]?.type;\n\n/**\n * Rebuilds only the reversible part of a path after a committed node.\n * Auto-executing nodes immediately following the commit are excluded so the\n * first interactive destination remains the history boundary after reload.\n */\nconst trimHistoryAfterCommittedNode = (\n reconstructedHistory: number[],\n template: SessionTemplate,\n): number[] => {\n let committedHistoryIndex = -1;\n\n for (let index = reconstructedHistory.length - 2; index >= 0; index -= 1) {\n const nodeType = getNodeTypeAtStep(reconstructedHistory[index], template);\n if (nodeType && COMMITTED_NODE_TYPES.has(nodeType)) {\n committedHistoryIndex = index;\n break;\n }\n }\n\n if (committedHistoryIndex === -1) {\n return reconstructedHistory;\n }\n\n let reversibleHistoryStart = committedHistoryIndex + 1;\n while (reversibleHistoryStart < reconstructedHistory.length - 1) {\n const nodeType = getNodeTypeAtStep(\n reconstructedHistory[reversibleHistoryStart],\n template,\n );\n if (!nodeType || !AUTO_EXECUTING_TYPES.has(nodeType)) {\n break;\n }\n reversibleHistoryStart += 1;\n }\n\n return reconstructedHistory.slice(reversibleHistoryStart);\n};\n\nexport const useStepNavigation = (\n sessionId: string,\n sessionStatus?: string,\n initialStep?: number,\n template?: SessionTemplate,\n) => {\n const [step, setStepState] = useState(initialStep ?? 0);\n const [history, setHistory] = useState<number[]>(initialStep !== undefined ? [initialStep] : [0]);\n const hasInitialized = useRef(false);\n const committedNavigationPending = useRef(false);\n\n const setStep = (newStep: number, skipHistory = false) => {\n if (!skipHistory && newStep !== step) {\n setHistory((prev) => {\n if (prev[prev.length - 1] === newStep) return prev;\n return [...prev, newStep];\n });\n }\n setStepState(newStep);\n\n // Update current step in database\n if (sessionId) {\n updateSessionCurrentStep(sessionId, newStep).catch((error) => {\n console.error(\"Failed to update current step in database:\", error);\n // Non-blocking error - the step is still updated locally\n });\n }\n };\n\n const goBack = () => {\n if (history.length > 1) {\n let newHistory = [...history];\n newHistory.pop(); // Remove current step\n\n // Skip auto-executing nodes when going back\n if (template) {\n const orderedNodes = getOrderedJourneySteps(template);\n while (newHistory.length > 1) {\n const candidateStep = newHistory[newHistory.length - 1];\n // steps are 1-indexed (step 0 = start, step 1 = first node, etc.)\n const nodeIndex = candidateStep - 1;\n const candidateNode = orderedNodes[nodeIndex];\n if (candidateNode && AUTO_EXECUTING_TYPES.has(candidateNode.type)) {\n newHistory.pop();\n } else {\n break;\n }\n }\n }\n\n const previousStep = newHistory[newHistory.length - 1];\n setHistory(newHistory);\n setStep(previousStep, true);\n } else {\n console.warn(\"[goBack] BLOCKED — history.length <= 1, history:\", [...history]);\n }\n };\n\n /**\n * Retour arrière vers un nœud précis (ex: bouton \"Corriger ma saisie\").\n * Contrairement à `setStep`, on TRONQUE l'historique jusqu'à la dernière\n * occurrence de `targetStep` au lieu de l'empiler : le nœud cible cesse\n * ainsi d'être compté comme un \"revisit\" (runIndex 0 côté\n * TemplateNodeRenderer → formulaire pré-rempli). Si la cible n'est pas dans\n * l'historique, on retombe sur un `setStep` classique.\n */\n const goBackToStep = (targetStep: number) => {\n const idx = history.lastIndexOf(targetStep);\n if (idx !== -1) {\n const newHistory = history.slice(0, idx + 1);\n setHistory(newHistory);\n setStep(targetStep, true);\n } else {\n console.warn(\"[goBackToStep] target not in history — pushing instead:\", targetStep);\n setStep(targetStep);\n }\n };\n\n const goToNextStep = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string\n ) => {\n const nextStepIndex = getNextStepIndex(currentNodeId, template, handle);\n\n if (nextStepIndex !== null) {\n if (committedNavigationPending.current) {\n const destinationType = getNodeTypeAtStep(nextStepIndex, template);\n committedNavigationPending.current = Boolean(\n destinationType && AUTO_EXECUTING_TYPES.has(destinationType),\n );\n setHistory([nextStepIndex]);\n setStep(nextStepIndex, true);\n } else {\n setStep(nextStepIndex);\n }\n } else {\n committedNavigationPending.current = false;\n console.warn(\n `[useStepNavigation] Could not find next step for node ${currentNodeId}. Staying on current step.`\n );\n }\n };\n\n /**\n * Navigates through the graph and makes the destination a point of no return.\n * The destination remains persisted by setStep, while prior history is discarded.\n */\n const goToNextStepCommitted = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n ) => {\n const nextStepIndex = getNextStepIndex(currentNodeId, template, handle);\n\n if (nextStepIndex !== null) {\n const destinationType = getNodeTypeAtStep(nextStepIndex, template);\n committedNavigationPending.current = Boolean(\n destinationType && AUTO_EXECUTING_TYPES.has(destinationType),\n );\n setHistory([nextStepIndex]);\n setStep(nextStepIndex, true);\n } else {\n committedNavigationPending.current = false;\n console.warn(\n `[useStepNavigation] Could not find next step for node ${currentNodeId}. Staying on current step.`,\n );\n }\n };\n\n // Initialize step from session data or status\n useEffect(() => {\n if (!sessionId) {\n return;\n }\n\n // Check if session is already finished (raw \"ended\" or a consolidated\n // result status the backend wrote once the session became terminal).\n if (isSessionFinished(sessionStatus)) {\n setStepState(100);\n return;\n }\n\n // Only initialize once when initialStep becomes available\n if (initialStep !== undefined && !hasInitialized.current) {\n setStepState(initialStep);\n setHistory((prev) => {\n // Preserve history if the user already navigated past the initial step\n if (prev.length > 1 && prev[prev.length - 1] === initialStep) {\n return prev;\n }\n // Reconstruct history by following the graph from step 0\n const reconstructed = template\n ? trimHistoryAfterCommittedNode(\n reconstructHistoryToStep(initialStep, template),\n template,\n )\n : initialStep > 0 ? [0, initialStep] : [initialStep];\n return reconstructed;\n });\n hasInitialized.current = true;\n }\n }, [sessionId, sessionStatus, initialStep]);\n\n const stepObject = {\n setStep,\n goBack,\n goBackToStep,\n goToNextStep,\n goToNextStepCommitted,\n step,\n canGoBack: history.length > 1,\n };\n\n return {\n step,\n setStep,\n goBack,\n goBackToStep,\n goToNextStep,\n goToNextStepCommitted,\n stepObject,\n history,\n };\n};\n"],"names":[],"mappings":";;;;;AAUA;AACA,IAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,uBAAuB,EAAE,WAAW,EAAE,uBAAuB,CAAC,CAAC;AACrG,IAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,CAAC;AAE7E,IAAM,iBAAiB,GAAG,UACxB,IAAY,EACZ,QAAyB,EAAA,EAAA,IAAA,EAAA,CAAA,CACF,OAAA,CAAA,EAAA,GAAA,sBAAsB,CAAC,QAAQ,CAAC,CAAC,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AC9B;IAED,OAAO;AACL,QAAA,IAAI,EAAA,IAAA;AACJ,QAAA,OAAO,EAAA,OAAA;AACP,QAAA,MAAM,EAAA,MAAA;AACN,QAAA,YAAY,EAAA,YAAA;AACZ,QAAA,YAAY,EAAA,YAAA;AACZ,QAAA,qBAAqB,EAAA,qBAAA;AACrB,QAAA,UAAU,EAAA,UAAA;AACV,QAAA,OAAO,EAAA,OAAA;KACR;AACH;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Statuts de résultat consolidé : le backend réécrit sessions.status avec le
|
|
2
|
+
// résultat consolidé une fois la session terminale (voir
|
|
3
|
+
// ResultUpdaterHelper.updateResult côté backend). Une session rouverte après
|
|
4
|
+
// coup porte donc l'un de ces statuts en base, pas "ended".
|
|
5
|
+
var CONSOLIDATED_RESULT_STATUSES = new Set([
|
|
6
|
+
"verify",
|
|
7
|
+
"ai_approved",
|
|
8
|
+
"ai_rejected",
|
|
9
|
+
"user_approved",
|
|
10
|
+
"user_rejected",
|
|
11
|
+
]);
|
|
12
|
+
/**
|
|
13
|
+
* true si la session est terminée (écran de fin), qu'elle porte encore le
|
|
14
|
+
* statut brut "ended" ou déjà un statut de résultat consolidé.
|
|
15
|
+
*
|
|
16
|
+
* Ne PAS confondre avec "conform" : posé par SignatureElectronic juste après
|
|
17
|
+
* la signature, avant le vrai nœud "end" — ce n'est pas une fin de parcours.
|
|
18
|
+
*/
|
|
19
|
+
var isSessionFinished = function (status) {
|
|
20
|
+
if (!status)
|
|
21
|
+
return false;
|
|
22
|
+
return status === "ended" || CONSOLIDATED_RESULT_STATUSES.has(status);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { isSessionFinished };
|
|
26
|
+
//# sourceMappingURL=sessionStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionStatus.js","sources":["../../../../src/utils/sessionStatus.ts"],"sourcesContent":["// Statuts de résultat consolidé : le backend réécrit sessions.status avec le\n// résultat consolidé une fois la session terminale (voir\n// ResultUpdaterHelper.updateResult côté backend). Une session rouverte après\n// coup porte donc l'un de ces statuts en base, pas \"ended\".\nconst CONSOLIDATED_RESULT_STATUSES = new Set([\n \"verify\",\n \"ai_approved\",\n \"ai_rejected\",\n \"user_approved\",\n \"user_rejected\",\n]);\n\n/**\n * true si la session est terminée (écran de fin), qu'elle porte encore le\n * statut brut \"ended\" ou déjà un statut de résultat consolidé.\n *\n * Ne PAS confondre avec \"conform\" : posé par SignatureElectronic juste après\n * la signature, avant le vrai nœud \"end\" — ce n'est pas une fin de parcours.\n */\nexport const isSessionFinished = (status?: string | null): boolean => {\n if (!status) return false;\n return status === \"ended\" || CONSOLIDATED_RESULT_STATUSES.has(status);\n};\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,IAAM,4BAA4B,GAAG,IAAI,GAAG,CAAC;IAC3C,QAAQ;IACR,aAAa;IACb,aAAa;IACb,eAAe;IACf,eAAe;AAChB,CAAA,CAAC;AAEF;;;;;;AAMG;AACI,IAAM,iBAAiB,GAAG,UAAC,MAAsB,EAAA;AACtD,IAAA,IAAI,CAAC,MAAM;AAAE,QAAA,OAAO,KAAK;IACzB,OAAO,MAAM,KAAK,OAAO,IAAI,4BAA4B,CAAC,GAAG,CAAC,MAAM,CAAC;AACvE;;;;"}
|
|
@@ -211,3 +211,12 @@ le comportement de synchronisation.
|
|
|
211
211
|
## Mandat complémentaire
|
|
212
212
|
|
|
213
213
|
Le nœud auto-exécutant `complementary-mandate` route sur le verdict serveur (`same_signer`, `new_signer`, `no_mandate`). Toute erreur bloque le routage et propose de réessayer. Voir [COMPLEMENTARY_MANDATE.md](COMPLEMENTARY_MANDATE.md).
|
|
214
|
+
|
|
215
|
+
## Vérification INPI — écran « Identité non confirmée »
|
|
216
|
+
|
|
217
|
+
Sur `person_mismatch`, le nœud `external-verification` (`INPI_RBE`) liste les personnes déclarées au registre, selon `comparisonConfig.compareTargets` :
|
|
218
|
+
|
|
219
|
+
- **Mode personne physique** (`personType` absent ou `PHYSIQUE`) : **tous** les mandataires sont affichés, individus (`NOM Prénoms`) **et sociétés** (`DÉNOMINATION (SIREN xxx)`), ainsi que les bénéficiaires effectifs si ciblés. Une société mandataire (ex. holding présidente) explique pourquoi la personne saisie, dirigeante de cette holding, n'apparaît pas en direct : la comparaison backend ne porte que sur les mandataires personnes physiques directs et les bénéficiaires effectifs.
|
|
220
|
+
- **Mode personne morale** (`personType: 'MORALE'`) : seuls les mandataires sociétés sont affichés (un RBE est toujours une personne physique).
|
|
221
|
+
|
|
222
|
+
Affichage uniquement : le statut `person_mismatch` et le routage ne changent pas.
|
|
@@ -143,6 +143,14 @@ const goOnPreviousStep = () => goBack();
|
|
|
143
143
|
|
|
144
144
|
Préférer `goToNextStep(node.id, template)` qui résout automatiquement l'index suivant via le graphe. `setStep` est réservé aux cas où l'index de destination est déjà connu (ex: reprise de session, `goBack`).
|
|
145
145
|
|
|
146
|
+
### Reprise d'une session déjà terminée : ne jamais rejouer un nœud `end`
|
|
147
|
+
|
|
148
|
+
La reprise se fait **par index** (`currentStep`) sur `getOrderedJourneySteps()` (nœuds triés par `order`, puis par `id`). Si le parcours est modifié après coup — par exemple un nœud `end` ajouté avec le même `order` qu'une étape existante — l'index persisté peut désigner un autre nœud qu'au moment de la sauvegarde. Une session rouverte peut alors « atterrir » sur une fin jamais empruntée, et `EndFlow` enverrait `ended` + l'id de cette fin au montage (incident Quadient, sept. 2026 : dossiers signés passés en `ai_rejected`).
|
|
149
|
+
|
|
150
|
+
Protection : `isSessionFinished(status)` (`src/utils/sessionStatus.ts`) — vrai pour `ended` et les statuts consolidés (`verify`, `ai_approved`, `ai_rejected`, `user_approved`, `user_rejected`), **faux pour `conform`** (posé après la signature, avant le vrai nœud `end`). `useStepNavigation`, `TemplateNodeRenderer` et `SessionContent` l'utilisent pour afficher directement l'écran de fin ; pour un statut consolidé, `EndFlow` reçoit `alreadyFinished` : **aucun PATCH** au montage, écran calculé depuis le statut connu. Le backend ignore de son côté un second `ended` sur une session déjà terminée (voir `backend/docs/SESSION_STATUS_CALCULATION.md`).
|
|
151
|
+
|
|
152
|
+
La reprise par index reste une limite connue : la remplacer par une reprise par id de nœud est un chantier séparé.
|
|
153
|
+
|
|
146
154
|
---
|
|
147
155
|
|
|
148
156
|
## Fichiers de référence
|