datakeen-session-react 1.1.172 → 1.1.174
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-collection/DocumentCollection.js +17 -15
- package/dist/cjs/components/document-collection/DocumentCollection.js.map +1 -1
- package/dist/cjs/components/session/EndFlow.js +76 -7
- package/dist/cjs/components/session/EndFlow.js.map +1 -1
- package/dist/cjs/components/session/SessionContent.js +3 -3
- package/dist/cjs/components/session/SessionContent.js.map +1 -1
- package/dist/cjs/components/session/endScreenIcons.js +28 -0
- package/dist/cjs/components/session/endScreenIcons.js.map +1 -0
- package/dist/cjs/components/start-flow/CGU.js +1 -1
- package/dist/cjs/components/start-flow/Start.js +1 -1
- package/dist/cjs/components/template/TemplateNodeRenderer.js +5 -5
- package/dist/cjs/components/template/TemplateNodeRenderer.js.map +1 -1
- package/dist/cjs/i18n/en.json.js +6 -1
- package/dist/cjs/i18n/en.json.js.map +1 -1
- package/dist/cjs/i18n/fr.json.js +6 -1
- package/dist/cjs/i18n/fr.json.js.map +1 -1
- package/dist/cjs/index.css.js +1 -1
- package/dist/cjs/services/sessionService.js +8 -6
- package/dist/cjs/services/sessionService.js.map +1 -1
- package/dist/cjs/types/session.js.map +1 -1
- package/dist/esm/components/document-collection/DocumentCollection.js +17 -15
- package/dist/esm/components/document-collection/DocumentCollection.js.map +1 -1
- package/dist/esm/components/session/EndFlow.js +76 -7
- package/dist/esm/components/session/EndFlow.js.map +1 -1
- package/dist/esm/components/session/SessionContent.js +3 -3
- package/dist/esm/components/session/SessionContent.js.map +1 -1
- package/dist/esm/components/session/endScreenIcons.js +26 -0
- package/dist/esm/components/session/endScreenIcons.js.map +1 -0
- package/dist/esm/components/start-flow/CGU.js +1 -1
- package/dist/esm/components/start-flow/Start.js +1 -1
- package/dist/esm/components/template/TemplateNodeRenderer.js +5 -5
- package/dist/esm/components/template/TemplateNodeRenderer.js.map +1 -1
- package/dist/esm/i18n/en.json.js +6 -1
- package/dist/esm/i18n/en.json.js.map +1 -1
- package/dist/esm/i18n/fr.json.js +6 -1
- package/dist/esm/i18n/fr.json.js.map +1 -1
- package/dist/esm/index.css.js +1 -1
- package/dist/esm/services/sessionService.js +9 -7
- package/dist/esm/services/sessionService.js.map +1 -1
- package/dist/esm/types/session.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionService.js","sources":["../../../../src/services/sessionService.ts"],"sourcesContent":["/**\n * Session Service\n *\n * Service for interacting with the Datakeen Session API.\n * Handles fetching session data by ID.\n */\n\nimport type {\n ClientInfo,\n SessionData,\n SessionTemplate,\n SessionTemplateNode,\n} from \"../types/session\";\nimport { apiService } from \"./api\";\nimport { logStatusModified } from \"./auditTrailService\";\nimport { clearSessionMemory } from \"./sessionMemoryStore\";\n\n/**\n * Fetches session data by ID from the Datakeen backend\n *\n * @param sessionId - The unique identifier of the session\n * @returns The session data\n */\nexport const fetchSessionById = async (\n sessionId: string,\n): Promise<SessionData> => {\n try {\n const response = await apiService.get(`/session/sdk/${sessionId}`);\n return response.data;\n } catch (error) {\n console.error(\"Error fetching session data:\", error);\n throw error;\n }\n};\n\n/** Sends client information (IP, device, browser, OS) to the backend for a specific session\n *\n * @param sessionId - The unique identifier of the session\n * @param clientInfo - The client information to send\n */\nexport const sendClientInfo = async (\n sessionId: string,\n clientInfo: ClientInfo,\n): Promise<void> => {\n try {\n await apiService.post(`/session/sdk/${sessionId}/client-info`, clientInfo);\n } catch (error) {\n console.error(\"Error sending client info:\", error);\n throw error;\n }\n};\n\n/**\n * Determines if the session template has a specific type of node\n *\n * @param template - The session template\n * @param nodeType - The type of node to check for\n * @returns true if the template has a node of the specified type, false otherwise\n */\nexport const hasNodeType = (\n template: SessionTemplate,\n nodeType: string,\n): boolean => {\n return template.nodes.some((node) => node.type === nodeType);\n};\n\n/**\n * Determines if the session template has a node with a specific requiredDocumentType\n *\n * @param template - The session template\n * @param requiredDocumentType - The requiredDocumentType to check for\n * @returns true if the template has a node with the specified requiredDocumentType, false otherwise\n */\nexport const hasDocumentTypeNode = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): boolean => {\n return template.nodes.some(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n};\n\n/**\n * Gets all nodes of a specific type\n *\n * @param template - The session template\n * @param nodeType - The type of node to get\n * @returns Array of nodes matching the type\n */\nexport const getNodesByType = (\n template: SessionTemplate,\n nodeType: string,\n): SessionTemplateNode[] => {\n return template.nodes.filter((node) => node.type === nodeType);\n};\n\n/**\n * Gets all nodes with a specific requiredDocumentType\n *\n * @param template - The session template\n * @param requiredDocumentType - The requiredDocumentType to get\n * @returns Array of nodes matching the requiredDocumentType\n */\nexport const getNodesByDocumentType = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): SessionTemplateNode[] => {\n return template.nodes.filter(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n};\n\n/**\n * Get document options for a specific document type\n *\n * @param template - The session template\n * @param requiredDocumentType - The document type to get options for\n * @returns Array of document options (empty if none found)\n */\nexport const getDocumentOptions = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): string[] => {\n const node = template.nodes.find(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n return node?.selectedOptions || [];\n};\n\n/**\n * Determines if the session template has a selfie step\n *\n * @param template - The session template\n * @returns true if the template has a selfie step, false otherwise\n */\nexport const hasSelfieCaptureStep = (template: SessionTemplate): boolean => {\n return hasNodeType(template, \"selfie-capture\");\n};\n\n/**\n * Determines if the session template has an ID document step\n *\n * @param template - The session template\n * @returns true if the template has an ID document step, false otherwise\n */\nexport const hasDocumentStep = (template: SessionTemplate): boolean => {\n // Check if there's any document-selection node with requiredDocumentType \"id-card\"\n // or if none specified, just check for document-selection nodes\n const hasIDCard = hasDocumentTypeNode(template, \"id-card\");\n return hasIDCard || hasNodeType(template, \"document-selection\");\n};\n\n/**\n * Determines if the session template has a JDD (proof of address) step\n *\n * @param template - The session template\n * @returns true if the template has a JDD step, false otherwise\n */\nexport const hasJDDStep = (template: SessionTemplate): boolean => {\n return hasDocumentTypeNode(template, \"jdd\");\n};\n\n/**\n * Determines if the session template has a proof of funds step\n *\n * @param template - The session template\n * @returns true if the template has a proof of funds step, false otherwise\n */\nexport const hasProofOfFundsStep = (template: SessionTemplate): boolean => {\n return hasDocumentTypeNode(template, \"income-proof\");\n};\n\n/**\n * Determines if the session template has a document collection step\n *\n * @param template - The session template\n * @returns true if the template has a document collection step, false otherwise\n */\nexport const hasDocumentCollectionStep = (\n template: SessionTemplate,\n): boolean => {\n return hasNodeType(template, \"document-collection\");\n};\n\n/**\n * Gets all node types in the template\n *\n * @param template - The session template\n * @returns Array of node types in the template\n */\nexport const getNodeTypes = (template: SessionTemplate): string[] => {\n return Array.from(new Set(template.nodes.map((node) => node.type)));\n};\n\n/**\n * Gets all document types required in the template\n *\n * @param template - The session template\n * @returns Array of document types required in the template\n */\nexport const getRequiredDocumentTypes = (\n template: SessionTemplate,\n): string[] => {\n return Array.from(\n new Set(\n template.nodes\n .filter((node) => node.requiredDocumentType)\n .map((node) => node.requiredDocumentType!),\n ),\n );\n};\n\n/**\n * Converts template document type to internal document type\n * This helps standardize document types between the template and the application\n *\n * @param templateDocType - The document type as defined in the template\n * @returns The internal document type used by the application\n */\nexport const convertTemplateDocTypeToInternal = (\n templateDocType: string,\n): string => {\n if (!templateDocType) return \"\";\n\n // Mapping between template document types and internal document types\n const typeMap: Record<string, string> = {\n \"id-card\": \"id-card\",\n jdd: \"jdd\",\n \"income-proof\": \"income-proof\", // Using consistent naming\n };\n\n return typeMap[templateDocType] || templateDocType;\n};\n\n/**\n * Converts internal document type to template document type\n *\n * @param internalDocType - The document type used internally by the application\n * @returns The document type as expected in the template\n */\nexport const convertInternalDocTypeToTemplate = (\n internalDocType: string,\n): string => {\n if (!internalDocType) return \"\";\n\n // Mapping between internal document types and template document types\n const typeMap: Record<string, string> = {\n \"id-card\": \"id-card\",\n jdd: \"jdd\",\n funds: \"income-proof\", // Map funds to income-proof for backwards compatibility\n \"income-proof\": \"income-proof\",\n };\n\n return typeMap[internalDocType] || internalDocType;\n};\n\n/**\n * Updates session data with user input information\n *\n * @param sessionId - The unique identifier of the session\n * @param userInput - The user input data (firstName, lastName, birthDate)\n * @returns The updated session data\n */\nexport const updateSessionUserInput = async (\n sessionId: string,\n userInput: {\n firstName?: string;\n lastName?: string;\n birthDate?: string;\n [key: string]: unknown;\n },\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n userInput,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating session data:\", error);\n throw error;\n }\n};\n\n/**\n * Updates session data with contact information\n *\n * @param sessionId - The unique identifier of the session\n * @param contactInfo - The contact information data (email, phoneNumber)\n * @returns The updated session data\n */\nexport const updateSessionContactInfo = async (\n sessionId: string,\n contactInfo: {\n email: string;\n phoneNumber: string;\n [key: string]: unknown;\n },\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n contactInfo,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating contact information:\", error);\n throw error;\n }\n};\n\n/**\n * Updates session status\n *\n * @param sessionId - The unique identifier of the session\n * @param status - The new status for the session\n * @returns The updated session data\n */\nexport const updateSessionStatus = async (\n sessionId: string,\n status: string,\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n status,\n });\n\n // Log status modification in audit trail\n if (response.data && response.data.analysisId) {\n try {\n await logStatusModified(\n sessionId,\n status,\n response.data.clientInfoId || undefined,\n );\n } catch (err) {\n console.error(\"Failed to log status modification in audit trail:\", err);\n // Non-blocking error - continue session\n }\n }\n\n return response.data;\n } catch (error) {\n console.error(\"Error updating session status:\", error);\n throw error;\n }\n};\n\n/**\n * Updates the current step in the session\n *\n * @param sessionId - The unique identifier of the session\n * @param currentStep - The current step index in the workflow\n * @returns The updated session data\n */\nexport const updateSessionCurrentStep = async (\n sessionId: string,\n currentStep: number,\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n currentStep,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating session current step:\", error);\n throw error;\n }\n};\n\n/**\n * Gets the journey steps from the template in order\n *\n * @param template - The session template\n * @returns Array of ordered steps\n */\nexport const getOrderedJourneySteps = (\n template: SessionTemplate,\n): SessionTemplateNode[] => {\n // Filter out only start nodes, keep end nodes for proper journey completion, then sort by order\n return template.nodes\n .filter((node) => node.type !== \"start\")\n .sort((a, b) => a.order - b.order);\n};\n\nconst normalizeHandle = (value?: string): string => {\n return (value || \"\").trim().toLowerCase();\n};\n\n/**\n * Finds the outgoing edge to follow from a node.\n *\n * Resolution order:\n * 1. Exact handle match via sourceHandle/conditionValue.\n * 2. For condition:false loops, fallback to targetHandle=right.\n * 3. First outgoing edge as final fallback.\n */\nexport const findOutgoingEdge = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n): SessionTemplate[\"edges\"][number] | null => {\n const outgoingEdges = (template.edges || []).filter(\n (edge) => edge.source === currentNodeId,\n );\n\n if (outgoingEdges.length === 0) {\n return null;\n }\n\n if (!handle) {\n return outgoingEdges[0];\n }\n\n const normalizedHandle = normalizeHandle(handle);\n const edgeByHandle = outgoingEdges.find((edge) => {\n return (\n normalizeHandle(edge.sourceHandle) === normalizedHandle ||\n normalizeHandle(edge.conditionValue) === normalizedHandle\n );\n });\n\n if (edgeByHandle) {\n return edgeByHandle;\n }\n\n const currentNode = template.nodes.find((node) => node.id === currentNodeId);\n if (currentNode?.type === \"condition\" && normalizedHandle === \"false\") {\n const rightHandleLoopEdge = outgoingEdges.find(\n (edge) => normalizeHandle(edge.targetHandle) === \"right\",\n );\n if (rightHandleLoopEdge) {\n return rightHandleLoopEdge;\n }\n }\n\n return outgoingEdges[0];\n};\n\n/**\n * Gets the next step index by following the graph edge from the current node\n *\n * @param currentNodeId - The ID of the current node\n * @param template - The session template\n * @returns The next step index (1-based) or null if no edge found\n */\nexport const getNextStepIndex = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n): number | null => {\n const orderedNodes = getOrderedJourneySteps(template);\n const edge = findOutgoingEdge(currentNodeId, template, handle);\n\n if (!edge) {\n console.debug(\n `[sessionService] No outgoing edge found for node ${currentNodeId}${handle ? ` with handle ${handle}` : \"\"}`,\n );\n return null;\n }\n\n const targetId = edge.target;\n const targetIndex = orderedNodes.findIndex((n) => n.id === targetId);\n\n if (targetIndex === -1) {\n console.debug(\n `[sessionService] Target node ${targetId} not found in ordered steps`,\n );\n return null;\n }\n\n // steps are 1-indexed in the SDK (0 is StartSession)\n return 1 + targetIndex;\n};\n\n/**\n * Reconstructs the navigation history by following the graph from step 0\n * up to (and including) targetStep. Returns [0, ...stepIndices].\n * If the graph path cannot reach targetStep, falls back to [0, targetStep].\n */\nexport const reconstructHistoryToStep = (\n targetStep: number,\n template: SessionTemplate,\n): number[] => {\n if (targetStep <= 0) return [0];\n\n const orderedNodes = getOrderedJourneySteps(template);\n const history: number[] = [0];\n let currentStep = 1; // first node is step 1\n\n // Follow the default (first) edge from each node in sequence\n for (let safetyLimit = 0; safetyLimit < orderedNodes.length + 1; safetyLimit++) {\n if (currentStep === targetStep) {\n history.push(currentStep);\n break;\n }\n if (currentStep > targetStep) break;\n\n const nodeIndex = currentStep - 1;\n const currentNode = orderedNodes[nodeIndex];\n if (!currentNode) break;\n\n history.push(currentStep);\n\n const nextStep = getNextStepIndex(currentNode.id, template);\n if (nextStep === null) break;\n currentStep = nextStep;\n }\n\n // Fallback: if we couldn't reach targetStep via graph, use simple seed\n if (history[history.length - 1] !== targetStep) {\n return [0, targetStep];\n }\n\n return history;\n};\n\n/**\n * Maps a template node type to a step component type\n *\n * @param node - The session template node\n * @returns The step component type\n */\nexport const getStepComponentType = (node: SessionTemplateNode): string => {\n // Map from template node types to component types\n const typeMap: Record<string, string> = {\n \"document-selection\": \"document\",\n \"document-collection\": \"document-collection\",\n \"selfie-capture\": \"selfie\",\n \"contact-info\": \"contact-info\",\n \"user-input\": \"user-input\",\n \"otp-verification\": \"otp\",\n };\n\n // First check the node type\n if (node.type in typeMap) {\n return typeMap[node.type];\n }\n\n // Then check the requiredDocumentType\n if (node.requiredDocumentType) {\n return node.requiredDocumentType;\n }\n\n // Default fallback\n return node.type;\n};\n\n/**\n * Checks if a session has expired\n *\n * @param session - The session data to check\n * @returns true if the session has expired, false otherwise\n */\nexport const isSessionExpired = (session: SessionData): boolean => {\n if (!session.expireTime) {\n return false;\n }\n\n const currentTime = Date.now();\n return currentTime > session.expireTime;\n};\n\n/**\n * Stores document options in localStorage for a specific document type\n *\n * @param sessionId - The session ID\n * @param documentTypeId - The document type ID (e.g., 'jdd', 'income-proof')\n * @param options - The options to store\n */\nexport const storeDocumentOptions = (\n sessionId: string,\n documentTypeId: string,\n options: string[],\n): void => {\n if (!sessionId || !documentTypeId || !options || options.length === 0) {\n console.warn(\"Missing data for storeDocumentOptions:\", {\n sessionId,\n documentTypeId,\n options,\n });\n return;\n }\n\n // Create a consistent key format based on document type\n let storageKey = \"\";\n\n switch (documentTypeId) {\n case \"jdd\":\n storageKey = `jddOptions_${sessionId}`;\n break;\n case \"income-proof\":\n storageKey = `fundsOptions_${sessionId}`;\n break;\n case \"id-card\":\n storageKey = `idOptions_${sessionId}`;\n break;\n case \"document-collection\":\n storageKey = `documentCollectionOptions_${sessionId}`;\n break;\n default:\n storageKey = `${documentTypeId}Options_${sessionId}`;\n }\n\n localStorage.setItem(storageKey, JSON.stringify(options));\n};\n\n/**\n * Retrieves document options from localStorage for a specific document type\n *\n * @param sessionId - The session ID\n * @param documentTypeId - The document type ID (e.g., 'jdd', 'income-proof')\n * @returns Array of options or default options if none found\n */\nexport const retrieveDocumentOptions = (\n sessionId: string,\n documentTypeId: string,\n): string[] => {\n if (!sessionId || !documentTypeId) {\n console.warn(\"Missing data for retrieveDocumentOptions:\", {\n sessionId,\n documentTypeId,\n });\n return [];\n }\n\n // Create consistent key formats to check\n const possibleKeys = [\n `${documentTypeId}Options_${sessionId}`,\n documentTypeId === \"jdd\" ? `jddOptions_${sessionId}` : \"\",\n documentTypeId === \"income-proof\" ? `fundsOptions_${sessionId}` : \"\",\n documentTypeId === \"id-card\" ? `idOptions_${sessionId}` : \"\",\n documentTypeId === \"document-collection\"\n ? `documentCollectionOptions_${sessionId}`\n : \"\",\n ].filter(Boolean);\n\n // Try each possible key\n for (const key of possibleKeys) {\n const savedOptions = localStorage.getItem(key);\n if (savedOptions) {\n try {\n const parsedOptions = JSON.parse(savedOptions);\n\n return parsedOptions;\n } catch (e) {\n console.error(\n `Error parsing options for ${documentTypeId} with key ${key}:`,\n e,\n );\n }\n }\n }\n\n // Return default options if none found\n console.warn(`No options found for ${documentTypeId}, using defaults`);\n if (documentTypeId === \"jdd\") {\n return [\n \"Facture d'électricité (< 3 mois)\",\n \"Facture de gaz (< 3 mois)\",\n \"Facture d'eau (< 3 mois)\",\n \"Quittance de loyer (< 3 mois)\",\n \"Facture téléphone/internet (< 3 mois)\",\n \"Attestation d'assurance habitation (< 3 mois)\",\n ];\n } else if (documentTypeId === \"income-proof\") {\n return [\n \"Bulletin de salaire\",\n \"Avis d'imposition\",\n \"Relevé de compte bancaire\",\n \"Attestation de revenus\",\n \"Contrat de travail\",\n ];\n } else if (documentTypeId === \"id-card\") {\n return [\"Carte nationale d'identité\", \"Passeport\", \"Permis de conduire\"];\n } else if (documentTypeId === \"document-collection\") {\n return [\"Document administratif\", \"Justificatif\", \"Attestation\"];\n }\n\n return [];\n};\n\nconst clearStorageBySessionId = (sessionId: string): void => {\n const scopedKeys = [\n `userInput_${sessionId}`,\n `contactInfo_${sessionId}`,\n `sessionData_${sessionId}`,\n ];\n\n scopedKeys.forEach((key) => {\n localStorage.removeItem(key);\n sessionStorage.removeItem(key);\n });\n\n for (let i = localStorage.length - 1; i >= 0; i -= 1) {\n const key = localStorage.key(i);\n if (!key) {\n continue;\n }\n if (key.endsWith(`_${sessionId}`)) {\n localStorage.removeItem(key);\n }\n }\n\n for (let i = sessionStorage.length - 1; i >= 0; i -= 1) {\n const key = sessionStorage.key(i);\n if (!key) {\n continue;\n }\n if (key.endsWith(`_${sessionId}`)) {\n sessionStorage.removeItem(key);\n }\n }\n\n if (localStorage.getItem(\"sessionId\") === sessionId) {\n localStorage.removeItem(\"sessionId\");\n }\n if (sessionStorage.getItem(\"sessionId\") === sessionId) {\n sessionStorage.removeItem(\"sessionId\");\n }\n};\n\n/**\n * Clears all client-side session traces (memory + browser storage)\n * for a given session. This is intentionally aggressive for security.\n */\nexport const clearSessionSensitiveData = (sessionId?: string): void => {\n clearSessionMemory(sessionId);\n\n if (sessionId) {\n clearStorageBySessionId(sessionId);\n return;\n }\n\n localStorage.removeItem(\"sessionId\");\n sessionStorage.removeItem(\"sessionId\");\n\n for (let i = localStorage.length - 1; i >= 0; i -= 1) {\n const key = localStorage.key(i);\n if (!key) {\n continue;\n }\n if (\n key.startsWith(\"userInput_\") ||\n key.startsWith(\"contactInfo_\") ||\n key.includes(\"Options_\")\n ) {\n localStorage.removeItem(key);\n }\n }\n\n for (let i = sessionStorage.length - 1; i >= 0; i -= 1) {\n const key = sessionStorage.key(i);\n if (!key) {\n continue;\n }\n if (\n key.startsWith(\"userInput_\") ||\n key.startsWith(\"contactInfo_\") ||\n key.includes(\"Options_\")\n ) {\n sessionStorage.removeItem(key);\n }\n }\n};\n\n/**\n * Returns the pre-fill data for a given run index from a `userInput` object\n * that contains a `_list` array.\n *\n * Convention: when the integrator wants to pre-fill different data per run\n * (e.g. multiple persons in a loop), they pass `userInput: { _list: [...] }`\n * at session creation. Each element in `_list` corresponds to a run (0-indexed).\n *\n * @param userInput - The session's userInput object\n * @param runIndex - The current run index (0 = first pass, 1 = second pass, …)\n * @returns The pre-fill data for that run, or null if not defined\n */\nexport const getRunPrefillData = (\n userInput: Record<string, unknown>,\n runIndex: number,\n): Record<string, unknown> | null => {\n const list = userInput?._list;\n if (!Array.isArray(list)) return null;\n return (list[runIndex] as Record<string, unkn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.js","sources":["../../../../src/services/sessionService.ts"],"sourcesContent":["/**\n * Session Service\n *\n * Service for interacting with the Datakeen Session API.\n * Handles fetching session data by ID.\n */\n\nimport type {\n ClientInfo,\n SessionData,\n SessionTemplate,\n SessionTemplateNode,\n} from \"../types/session\";\nimport { apiService } from \"./api\";\nimport { logStatusModified } from \"./auditTrailService\";\nimport { clearSessionMemory } from \"./sessionMemoryStore\";\n\n/**\n * Fetches session data by ID from the Datakeen backend\n *\n * @param sessionId - The unique identifier of the session\n * @returns The session data\n */\nexport const fetchSessionById = async (\n sessionId: string,\n): Promise<SessionData> => {\n try {\n const response = await apiService.get(`/session/sdk/${sessionId}`);\n return response.data;\n } catch (error) {\n console.error(\"Error fetching session data:\", error);\n throw error;\n }\n};\n\n/** Sends client information (IP, device, browser, OS) to the backend for a specific session\n *\n * @param sessionId - The unique identifier of the session\n * @param clientInfo - The client information to send\n */\nexport const sendClientInfo = async (\n sessionId: string,\n clientInfo: ClientInfo,\n): Promise<void> => {\n try {\n await apiService.post(`/session/sdk/${sessionId}/client-info`, clientInfo);\n } catch (error) {\n console.error(\"Error sending client info:\", error);\n throw error;\n }\n};\n\n/**\n * Determines if the session template has a specific type of node\n *\n * @param template - The session template\n * @param nodeType - The type of node to check for\n * @returns true if the template has a node of the specified type, false otherwise\n */\nexport const hasNodeType = (\n template: SessionTemplate,\n nodeType: string,\n): boolean => {\n return template.nodes.some((node) => node.type === nodeType);\n};\n\n/**\n * Determines if the session template has a node with a specific requiredDocumentType\n *\n * @param template - The session template\n * @param requiredDocumentType - The requiredDocumentType to check for\n * @returns true if the template has a node with the specified requiredDocumentType, false otherwise\n */\nexport const hasDocumentTypeNode = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): boolean => {\n return template.nodes.some(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n};\n\n/**\n * Gets all nodes of a specific type\n *\n * @param template - The session template\n * @param nodeType - The type of node to get\n * @returns Array of nodes matching the type\n */\nexport const getNodesByType = (\n template: SessionTemplate,\n nodeType: string,\n): SessionTemplateNode[] => {\n return template.nodes.filter((node) => node.type === nodeType);\n};\n\n/**\n * Gets all nodes with a specific requiredDocumentType\n *\n * @param template - The session template\n * @param requiredDocumentType - The requiredDocumentType to get\n * @returns Array of nodes matching the requiredDocumentType\n */\nexport const getNodesByDocumentType = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): SessionTemplateNode[] => {\n return template.nodes.filter(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n};\n\n/**\n * Get document options for a specific document type\n *\n * @param template - The session template\n * @param requiredDocumentType - The document type to get options for\n * @returns Array of document options (empty if none found)\n */\nexport const getDocumentOptions = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): string[] => {\n const node = template.nodes.find(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n return node?.selectedOptions || [];\n};\n\n/**\n * Determines if the session template has a selfie step\n *\n * @param template - The session template\n * @returns true if the template has a selfie step, false otherwise\n */\nexport const hasSelfieCaptureStep = (template: SessionTemplate): boolean => {\n return hasNodeType(template, \"selfie-capture\");\n};\n\n/**\n * Determines if the session template has an ID document step\n *\n * @param template - The session template\n * @returns true if the template has an ID document step, false otherwise\n */\nexport const hasDocumentStep = (template: SessionTemplate): boolean => {\n // Check if there's any document-selection node with requiredDocumentType \"id-card\"\n // or if none specified, just check for document-selection nodes\n const hasIDCard = hasDocumentTypeNode(template, \"id-card\");\n return hasIDCard || hasNodeType(template, \"document-selection\");\n};\n\n/**\n * Determines if the session template has a JDD (proof of address) step\n *\n * @param template - The session template\n * @returns true if the template has a JDD step, false otherwise\n */\nexport const hasJDDStep = (template: SessionTemplate): boolean => {\n return hasDocumentTypeNode(template, \"jdd\");\n};\n\n/**\n * Determines if the session template has a proof of funds step\n *\n * @param template - The session template\n * @returns true if the template has a proof of funds step, false otherwise\n */\nexport const hasProofOfFundsStep = (template: SessionTemplate): boolean => {\n return hasDocumentTypeNode(template, \"income-proof\");\n};\n\n/**\n * Determines if the session template has a document collection step\n *\n * @param template - The session template\n * @returns true if the template has a document collection step, false otherwise\n */\nexport const hasDocumentCollectionStep = (\n template: SessionTemplate,\n): boolean => {\n return hasNodeType(template, \"document-collection\");\n};\n\n/**\n * Gets all node types in the template\n *\n * @param template - The session template\n * @returns Array of node types in the template\n */\nexport const getNodeTypes = (template: SessionTemplate): string[] => {\n return Array.from(new Set(template.nodes.map((node) => node.type)));\n};\n\n/**\n * Gets all document types required in the template\n *\n * @param template - The session template\n * @returns Array of document types required in the template\n */\nexport const getRequiredDocumentTypes = (\n template: SessionTemplate,\n): string[] => {\n return Array.from(\n new Set(\n template.nodes\n .filter((node) => node.requiredDocumentType)\n .map((node) => node.requiredDocumentType!),\n ),\n );\n};\n\n/**\n * Converts template document type to internal document type\n * This helps standardize document types between the template and the application\n *\n * @param templateDocType - The document type as defined in the template\n * @returns The internal document type used by the application\n */\nexport const convertTemplateDocTypeToInternal = (\n templateDocType: string,\n): string => {\n if (!templateDocType) return \"\";\n\n // Mapping between template document types and internal document types\n const typeMap: Record<string, string> = {\n \"id-card\": \"id-card\",\n jdd: \"jdd\",\n \"income-proof\": \"income-proof\", // Using consistent naming\n };\n\n return typeMap[templateDocType] || templateDocType;\n};\n\n/**\n * Converts internal document type to template document type\n *\n * @param internalDocType - The document type used internally by the application\n * @returns The document type as expected in the template\n */\nexport const convertInternalDocTypeToTemplate = (\n internalDocType: string,\n): string => {\n if (!internalDocType) return \"\";\n\n // Mapping between internal document types and template document types\n const typeMap: Record<string, string> = {\n \"id-card\": \"id-card\",\n jdd: \"jdd\",\n funds: \"income-proof\", // Map funds to income-proof for backwards compatibility\n \"income-proof\": \"income-proof\",\n };\n\n return typeMap[internalDocType] || internalDocType;\n};\n\n/**\n * Updates session data with user input information\n *\n * @param sessionId - The unique identifier of the session\n * @param userInput - The user input data (firstName, lastName, birthDate)\n * @returns The updated session data\n */\nexport const updateSessionUserInput = async (\n sessionId: string,\n userInput: {\n firstName?: string;\n lastName?: string;\n birthDate?: string;\n [key: string]: unknown;\n },\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n userInput,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating session data:\", error);\n throw error;\n }\n};\n\n/**\n * Updates session data with contact information\n *\n * @param sessionId - The unique identifier of the session\n * @param contactInfo - The contact information data (email, phoneNumber)\n * @returns The updated session data\n */\nexport const updateSessionContactInfo = async (\n sessionId: string,\n contactInfo: {\n email: string;\n phoneNumber: string;\n [key: string]: unknown;\n },\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n contactInfo,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating contact information:\", error);\n throw error;\n }\n};\n\n/**\n * Updates session status\n *\n * @param sessionId - The unique identifier of the session\n * @param status - The new status for the session\n * @param reachedEndNodeId - Id of the end node actually reached (when status is \"ended\"),\n * so the backend can force the correct final status with multiple end nodes.\n * @returns The updated session data\n */\nexport const updateSessionStatus = async (\n sessionId: string,\n status: string,\n reachedEndNodeId?: string,\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n status,\n ...(reachedEndNodeId ? { reachedEndNodeId } : {}),\n });\n\n // Log status modification in audit trail\n if (response.data && response.data.analysisId) {\n try {\n await logStatusModified(\n sessionId,\n status,\n response.data.clientInfoId || undefined,\n );\n } catch (err) {\n console.error(\"Failed to log status modification in audit trail:\", err);\n // Non-blocking error - continue session\n }\n }\n\n return response.data;\n } catch (error) {\n console.error(\"Error updating session status:\", error);\n throw error;\n }\n};\n\n/**\n * Updates the current step in the session\n *\n * @param sessionId - The unique identifier of the session\n * @param currentStep - The current step index in the workflow\n * @returns The updated session data\n */\nexport const updateSessionCurrentStep = async (\n sessionId: string,\n currentStep: number,\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n currentStep,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating session current step:\", error);\n throw error;\n }\n};\n\n/**\n * Gets the journey steps from the template in order\n *\n * @param template - The session template\n * @returns Array of ordered steps\n */\nexport const getOrderedJourneySteps = (\n template: SessionTemplate,\n): SessionTemplateNode[] => {\n // Filter out only start nodes, keep end nodes for proper journey completion, then sort by order.\n // Tiebreaker on id keeps the ordering deterministic when several nodes share the same `order`\n // (e.g. parallel branches of a condition), independently of their position in template.nodes.\n return template.nodes\n .filter((node) => node.type !== \"start\")\n .sort((a, b) => a.order - b.order || a.id.localeCompare(b.id));\n};\n\nconst normalizeHandle = (value?: string): string => {\n return (value || \"\").trim().toLowerCase();\n};\n\n/**\n * Finds the outgoing edge to follow from a node.\n *\n * Resolution order:\n * 1. Exact handle match via sourceHandle/conditionValue.\n * 2. For condition:false loops, fallback to targetHandle=right.\n * 3. First outgoing edge as final fallback.\n */\nexport const findOutgoingEdge = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n): SessionTemplate[\"edges\"][number] | null => {\n const outgoingEdges = (template.edges || []).filter(\n (edge) => edge.source === currentNodeId,\n );\n\n if (outgoingEdges.length === 0) {\n return null;\n }\n\n if (!handle) {\n return outgoingEdges[0];\n }\n\n const normalizedHandle = normalizeHandle(handle);\n const edgeByHandle = outgoingEdges.find((edge) => {\n return (\n normalizeHandle(edge.sourceHandle) === normalizedHandle ||\n normalizeHandle(edge.conditionValue) === normalizedHandle\n );\n });\n\n if (edgeByHandle) {\n return edgeByHandle;\n }\n\n const currentNode = template.nodes.find((node) => node.id === currentNodeId);\n if (currentNode?.type === \"condition\" && normalizedHandle === \"false\") {\n const rightHandleLoopEdge = outgoingEdges.find(\n (edge) => normalizeHandle(edge.targetHandle) === \"right\",\n );\n if (rightHandleLoopEdge) {\n return rightHandleLoopEdge;\n }\n }\n\n return outgoingEdges[0];\n};\n\n/**\n * Gets the next step index by following the graph edge from the current node\n *\n * @param currentNodeId - The ID of the current node\n * @param template - The session template\n * @returns The next step index (1-based) or null if no edge found\n */\nexport const getNextStepIndex = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n): number | null => {\n const orderedNodes = getOrderedJourneySteps(template);\n const edge = findOutgoingEdge(currentNodeId, template, handle);\n\n if (!edge) {\n console.debug(\n `[sessionService] No outgoing edge found for node ${currentNodeId}${handle ? ` with handle ${handle}` : \"\"}`,\n );\n return null;\n }\n\n const targetId = edge.target;\n const targetIndex = orderedNodes.findIndex((n) => n.id === targetId);\n\n if (targetIndex === -1) {\n console.debug(\n `[sessionService] Target node ${targetId} not found in ordered steps`,\n );\n return null;\n }\n\n // steps are 1-indexed in the SDK (0 is StartSession)\n return 1 + targetIndex;\n};\n\n/**\n * Reconstructs the navigation history by following the graph from step 0\n * up to (and including) targetStep. Returns [0, ...stepIndices].\n * If the graph path cannot reach targetStep, falls back to [0, targetStep].\n */\nexport const reconstructHistoryToStep = (\n targetStep: number,\n template: SessionTemplate,\n): number[] => {\n if (targetStep <= 0) return [0];\n\n const orderedNodes = getOrderedJourneySteps(template);\n const history: number[] = [0];\n let currentStep = 1; // first node is step 1\n\n // Follow the default (first) edge from each node in sequence\n for (let safetyLimit = 0; safetyLimit < orderedNodes.length + 1; safetyLimit++) {\n if (currentStep === targetStep) {\n history.push(currentStep);\n break;\n }\n if (currentStep > targetStep) break;\n\n const nodeIndex = currentStep - 1;\n const currentNode = orderedNodes[nodeIndex];\n if (!currentNode) break;\n\n history.push(currentStep);\n\n const nextStep = getNextStepIndex(currentNode.id, template);\n if (nextStep === null) break;\n currentStep = nextStep;\n }\n\n // Fallback: if we couldn't reach targetStep via graph, use simple seed\n if (history[history.length - 1] !== targetStep) {\n return [0, targetStep];\n }\n\n return history;\n};\n\n/**\n * Maps a template node type to a step component type\n *\n * @param node - The session template node\n * @returns The step component type\n */\nexport const getStepComponentType = (node: SessionTemplateNode): string => {\n // Map from template node types to component types\n const typeMap: Record<string, string> = {\n \"document-selection\": \"document\",\n \"document-collection\": \"document-collection\",\n \"selfie-capture\": \"selfie\",\n \"contact-info\": \"contact-info\",\n \"user-input\": \"user-input\",\n \"otp-verification\": \"otp\",\n };\n\n // First check the node type\n if (node.type in typeMap) {\n return typeMap[node.type];\n }\n\n // Then check the requiredDocumentType\n if (node.requiredDocumentType) {\n return node.requiredDocumentType;\n }\n\n // Default fallback\n return node.type;\n};\n\n/**\n * Checks if a session has expired\n *\n * @param session - The session data to check\n * @returns true if the session has expired, false otherwise\n */\nexport const isSessionExpired = (session: SessionData): boolean => {\n if (!session.expireTime) {\n return false;\n }\n\n const currentTime = Date.now();\n return currentTime > session.expireTime;\n};\n\n/**\n * Stores document options in localStorage for a specific document type\n *\n * @param sessionId - The session ID\n * @param documentTypeId - The document type ID (e.g., 'jdd', 'income-proof')\n * @param options - The options to store\n */\nexport const storeDocumentOptions = (\n sessionId: string,\n documentTypeId: string,\n options: string[],\n): void => {\n if (!sessionId || !documentTypeId || !options || options.length === 0) {\n console.warn(\"Missing data for storeDocumentOptions:\", {\n sessionId,\n documentTypeId,\n options,\n });\n return;\n }\n\n // Create a consistent key format based on document type\n let storageKey = \"\";\n\n switch (documentTypeId) {\n case \"jdd\":\n storageKey = `jddOptions_${sessionId}`;\n break;\n case \"income-proof\":\n storageKey = `fundsOptions_${sessionId}`;\n break;\n case \"id-card\":\n storageKey = `idOptions_${sessionId}`;\n break;\n case \"document-collection\":\n storageKey = `documentCollectionOptions_${sessionId}`;\n break;\n default:\n storageKey = `${documentTypeId}Options_${sessionId}`;\n }\n\n localStorage.setItem(storageKey, JSON.stringify(options));\n};\n\n/**\n * Retrieves document options from localStorage for a specific document type\n *\n * @param sessionId - The session ID\n * @param documentTypeId - The document type ID (e.g., 'jdd', 'income-proof')\n * @returns Array of options or default options if none found\n */\nexport const retrieveDocumentOptions = (\n sessionId: string,\n documentTypeId: string,\n): string[] => {\n if (!sessionId || !documentTypeId) {\n console.warn(\"Missing data for retrieveDocumentOptions:\", {\n sessionId,\n documentTypeId,\n });\n return [];\n }\n\n // Create consistent key formats to check\n const possibleKeys = [\n `${documentTypeId}Options_${sessionId}`,\n documentTypeId === \"jdd\" ? `jddOptions_${sessionId}` : \"\",\n documentTypeId === \"income-proof\" ? `fundsOptions_${sessionId}` : \"\",\n documentTypeId === \"id-card\" ? `idOptions_${sessionId}` : \"\",\n documentTypeId === \"document-collection\"\n ? `documentCollectionOptions_${sessionId}`\n : \"\",\n ].filter(Boolean);\n\n // Try each possible key\n for (const key of possibleKeys) {\n const savedOptions = localStorage.getItem(key);\n if (savedOptions) {\n try {\n const parsedOptions = JSON.parse(savedOptions);\n\n return parsedOptions;\n } catch (e) {\n console.error(\n `Error parsing options for ${documentTypeId} with key ${key}:`,\n e,\n );\n }\n }\n }\n\n // Return default options if none found\n console.warn(`No options found for ${documentTypeId}, using defaults`);\n if (documentTypeId === \"jdd\") {\n return [\n \"Facture d'électricité (< 3 mois)\",\n \"Facture de gaz (< 3 mois)\",\n \"Facture d'eau (< 3 mois)\",\n \"Quittance de loyer (< 3 mois)\",\n \"Facture téléphone/internet (< 3 mois)\",\n \"Attestation d'assurance habitation (< 3 mois)\",\n ];\n } else if (documentTypeId === \"income-proof\") {\n return [\n \"Bulletin de salaire\",\n \"Avis d'imposition\",\n \"Relevé de compte bancaire\",\n \"Attestation de revenus\",\n \"Contrat de travail\",\n ];\n } else if (documentTypeId === \"id-card\") {\n return [\"Carte nationale d'identité\", \"Passeport\", \"Permis de conduire\"];\n } else if (documentTypeId === \"document-collection\") {\n return [\"Document administratif\", \"Justificatif\", \"Attestation\"];\n }\n\n return [];\n};\n\nconst clearStorageBySessionId = (sessionId: string): void => {\n const scopedKeys = [\n `userInput_${sessionId}`,\n `contactInfo_${sessionId}`,\n `sessionData_${sessionId}`,\n ];\n\n scopedKeys.forEach((key) => {\n localStorage.removeItem(key);\n sessionStorage.removeItem(key);\n });\n\n for (let i = localStorage.length - 1; i >= 0; i -= 1) {\n const key = localStorage.key(i);\n if (!key) {\n continue;\n }\n if (key.endsWith(`_${sessionId}`)) {\n localStorage.removeItem(key);\n }\n }\n\n for (let i = sessionStorage.length - 1; i >= 0; i -= 1) {\n const key = sessionStorage.key(i);\n if (!key) {\n continue;\n }\n if (key.endsWith(`_${sessionId}`)) {\n sessionStorage.removeItem(key);\n }\n }\n\n if (localStorage.getItem(\"sessionId\") === sessionId) {\n localStorage.removeItem(\"sessionId\");\n }\n if (sessionStorage.getItem(\"sessionId\") === sessionId) {\n sessionStorage.removeItem(\"sessionId\");\n }\n};\n\n/**\n * Clears all client-side session traces (memory + browser storage)\n * for a given session. This is intentionally aggressive for security.\n */\nexport const clearSessionSensitiveData = (sessionId?: string): void => {\n clearSessionMemory(sessionId);\n\n if (sessionId) {\n clearStorageBySessionId(sessionId);\n return;\n }\n\n localStorage.removeItem(\"sessionId\");\n sessionStorage.removeItem(\"sessionId\");\n\n for (let i = localStorage.length - 1; i >= 0; i -= 1) {\n const key = localStorage.key(i);\n if (!key) {\n continue;\n }\n if (\n key.startsWith(\"userInput_\") ||\n key.startsWith(\"contactInfo_\") ||\n key.includes(\"Options_\")\n ) {\n localStorage.removeItem(key);\n }\n }\n\n for (let i = sessionStorage.length - 1; i >= 0; i -= 1) {\n const key = sessionStorage.key(i);\n if (!key) {\n continue;\n }\n if (\n key.startsWith(\"userInput_\") ||\n key.startsWith(\"contactInfo_\") ||\n key.includes(\"Options_\")\n ) {\n sessionStorage.removeItem(key);\n }\n }\n};\n\n/**\n * Returns the pre-fill data for a given run index from a `userInput` object\n * that contains a `_list` array.\n *\n * Convention: when the integrator wants to pre-fill different data per run\n * (e.g. multiple persons in a loop), they pass `userInput: { _list: [...] }`\n * at session creation. Each element in `_list` corresponds to a run (0-indexed).\n *\n * @param userInput - The session's userInput object\n * @param runIndex - The current run index (0 = first pass, 1 = second pass, …)\n * @returns The pre-fill data for that run, or null if not defined\n */\nexport const getRunPrefillData = (\n userInput: Record<string, unknown>,\n runIndex: number,\n): Record<string, unknown> | null => {\n const list = userInput?._list;\n if (!Array.isArray(list)) return null;\n return (list[runIndex] as Record<string, unknown>) ?? null;\n};\n"],"names":["__awaiter","apiService","__assign","logStatusMod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A,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAI,IAAI;AAC5D;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sources":["../../../../src/types/session.ts"],"sourcesContent":["import type React from \"react\";\n\nexport interface SessionConfig {\n selfie?: boolean;\n requireMobile?: boolean;\n}\n\nexport interface DatakeenSessionProps {\n sessionId: string;\n sessionConfig?: SessionConfig;\n apiBaseUrl?: string; // Optional API base URL for dynamic environment configuration\n}\n\nexport interface UseSessionReturn {\n SessionComponent: React.ReactElement;\n}\n\nexport type stepObject = {\n setStep: (step: number) => void;\n goBack: () => void;\n /** Retour arrière vers un nœud précis (ex: \"Corriger ma saisie\") :\n * tronque l'historique jusqu'à `targetStep` au lieu de l'empiler. */\n goBackToStep: (targetStep: number) => void;\n goToNextStep: (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n ) => void;\n step: number;\n canGoBack: boolean;\n};\n\nexport interface ProcessingStep {\n title: string;\n subtitle: string;\n hasError?: boolean;\n}\n\nexport type ConditionTokenType = \"variable\" | \"control\" | \"operator\" | \"input\";\n\nexport interface ConditionToken {\n type: ConditionTokenType;\n value: string;\n label?: string;\n sourceNodeId?: string;\n}\n\n/**\n * Type for custom field value types\n */\nexport type CustomFieldValueType =\n | \"text\"\n | \"enum\"\n | \"number\"\n | \"boolean\"\n | \"date\"\n | \"email\"\n | \"address\"\n | \"list\";\n\n/**\n * Display formats supported for date fields (top-level and list columns).\n */\nexport type DateDisplayFormat = \"dd/mm/yyyy\" | \"mm/dd/yyyy\" | \"yyyy-mm-dd\";\n\nexport const DEFAULT_DATE_DISPLAY_FORMAT: DateDisplayFormat = \"dd/mm/yyyy\";\n\n/**\n * Column definition for a list-type custom field\n */\nexport interface ListColumn {\n label: string;\n type: \"text\" | \"enum\" | \"date\" | \"email\";\n options?: string[]; // required when type === 'enum'\n placeholder?: string; // text/email/date — shown to the end user\n regex?: string; // text — JS regex source (without slashes)\n regexErrorMessage?: string; // text — message displayed when regex fails\n dateFormat?: DateDisplayFormat; // date — display format expected\n}\n\n/**\n * Interface for custom field definition\n */\nexport interface CustomField {\n id: string;\n label: string;\n placeholder?: string;\n description?: string;\n valueType: CustomFieldValueType;\n enumOptions?: string[];\n listColumns?: ListColumn[]; // for list type: column definitions\n minRows?: number; // for list type: minimum rows expected\n required?: boolean;\n regex?: string; // text — JS regex source (without slashes)\n regexErrorMessage?: string; // text — message displayed when regex fails\n dateFormat?: DateDisplayFormat; // date — display format expected\n lockedFromApi?: boolean;\n userInputKey?: string;\n}\n\n/**\n * Interface for session template node\n */\nexport interface SessionTemplateNode {\n id: string;\n type: string;\n title: string;\n description: string;\n informationType?:\n | \"identity\"\n | \"identity-legal\"\n | \"contact\"\n | \"address\"\n | \"nationality\"\n | \"custom\";\n position: {\n x: number;\n y: number;\n };\n options: unknown[];\n selectedOptions: string[];\n requiredDocumentType?: string;\n isRequired: boolean;\n order: number;\n optionalFields?: string[];\n requiredFields?: string[];\n pageTitle?: string;\n pageDescription?: string;\n // Properties for document-collection node type\n allowedDocumentTypes?: Array<{\n id: string;\n name: string;\n /**\n * Optional side information coming from the template.\n * When provided and equals to two (\"two\", 2, \"double\", \"recto-verso\"),\n * consumers should allow uploading two sides (front/back).\n */\n side?: string | number;\n }>;\n allowedAddingMethods?: string[];\n introductionPage?: {\n title?: string;\n description?: string;\n };\n documentSelection?: {\n title?: string;\n description?: string;\n };\n // Start node specific properties\n welcomeTitle?: string;\n welcomeSubtitle?: string;\n welcomeDescription?: string;\n welcomeImage?: string;\n qrCodeTitle?: string;\n qrCodeDescription?: string;\n showLegacyCGU?: boolean; // default: true — rétrocompatibilité\n\n // Legal consent node specific properties\n consentDescription?: string;\n consentDescription2?: string;\n cguUrl?: string;\n privacyPolicyUrl?: string;\n checkboxText?: string;\n // Identity control specific properties\n automaticPhotoCapture?: boolean;\n acceptedCountries?: AcceptedCountry[];\n // End node specific properties\n callbackURL?: string | null;\n // Condition node specific properties\n conditionExpression?: string;\n conditionTokens?: ConditionToken[];\n conditionFalseErrorMessage?: string;\n conditionMaxRetries?: number;\n conditionMaxRetryAction?: \"end-journey\" | \"force-true\";\n conditionFalseMode?: \"retry\" | \"loop\";\n\n // External verification specific properties\n targetApi?: \"INSEE\";\n referenceNodeId?: string;\n referenceNodeType?:\n | \"information-input\"\n | \"document-collection\"\n | \"identity-control\";\n referenceField?: \"siren\" | \"siret\";\n referenceVariable?: string;\n // Custom form fields (for information-input with type 'custom')\n customFields?: CustomField[];\n\n // Electronic signature specific properties\n templateId?: string;\n external_id?: string;\n fieldMappings?: Array<{\n sourceFieldId: string;\n label: string;\n docusealType: string;\n readonly: boolean;\n role?: string;\n sourceNodeId?: string;\n }>;\n /** If set, the generated PDF from this upstream pdf-generation node will be used as the document to sign */\n sourcePdfNodeId?: string;\n\n // PDF generation node specific properties\n // Note: htmlTemplate is intentionally NOT included — it is server-side only and never sent to the client\n pdfMode?: \"upload\" | \"html-template\";\n sourceNodeIds?: string[];\n\n // retry properties\n allowResubmission: boolean;\n maxResubmissionAttempts?: number;\n}\n\n/**\n * Interface for accepted countries\n */\nexport interface AcceptedCountry {\n code: string;\n documents: {\n passport: string[];\n idCard: string[];\n driverLicense: string[];\n residencePermit: string[];\n pinkDriverLicense: string[];\n };\n}\n\n/**\n * Interface for session template edge\n */\nexport interface SessionTemplateEdge {\n id: string;\n source: string;\n target: string;\n sourceHandle?: string;\n targetHandle?: string;\n conditionValue?: string;\n}\n\n/**\n * Interface for platform information\n */\nexport interface PlatformInfo {\n mobile: boolean;\n desktop: boolean;\n backoffice: boolean;\n}\n\n/**\n * Interface for session template\n */\nexport interface SessionTemplate {\n id: string;\n name: string;\n description: string;\n version: string;\n languages: string[];\n nodes: SessionTemplateNode[];\n edges: SessionTemplateEdge[];\n groupId: string;\n userId: string | null;\n created_at: string;\n updated_at: string;\n platforms?: PlatformInfo;\n logo?: string;\n showQRCode?: boolean;\n buttonBgColor?: string;\n buttonTextColor?: string;\n}\n\n/**\n * Interface for session data\n */\nexport interface SessionData {\n id: string;\n userId: string | null;\n token: string;\n templateId: string;\n templateKey: string;\n expireTime: number;\n status: string;\n result: Record<string, unknown>;\n landingPage: unknown;\n withSelfie: boolean | null;\n groupId: string | null;\n userInput: Record<string, unknown>;\n contactInfo?: {\n email: string;\n phoneNumber: string;\n };\n callbackURL?: string | null;\n webhookURL: string;\n analysisTemplateId: string | null;\n userAgent: unknown[];\n mobile: boolean;\n analysisId: string | null;\n currentStep?: number;\n createdAt: string;\n updatedAt: string;\n auditTrail: unknown[];\n user: unknown | null;\n analysis: unknown[];\n documents: unknown[];\n template: SessionTemplate;\n retryCounts?: Record<string, number>; // nodeId -> retry count\n}\n\nexport interface ClientInfo {\n ip?: string;\n location?: string;\n device: string;\n browser: string;\n os: string;\n}\n"],"names":[],"mappings":";;AAiEO,IAAM,2BAA2B,GAAsB;;;;"}
|
|
1
|
+
{"version":3,"file":"session.js","sources":["../../../../src/types/session.ts"],"sourcesContent":["import type React from \"react\";\n\nexport interface SessionConfig {\n selfie?: boolean;\n requireMobile?: boolean;\n}\n\nexport interface DatakeenSessionProps {\n sessionId: string;\n sessionConfig?: SessionConfig;\n apiBaseUrl?: string; // Optional API base URL for dynamic environment configuration\n}\n\nexport interface UseSessionReturn {\n SessionComponent: React.ReactElement;\n}\n\nexport type stepObject = {\n setStep: (step: number) => void;\n goBack: () => void;\n /** Retour arrière vers un nœud précis (ex: \"Corriger ma saisie\") :\n * tronque l'historique jusqu'à `targetStep` au lieu de l'empiler. */\n goBackToStep: (targetStep: number) => void;\n goToNextStep: (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n ) => void;\n step: number;\n canGoBack: boolean;\n};\n\nexport interface ProcessingStep {\n title: string;\n subtitle: string;\n hasError?: boolean;\n}\n\nexport type ConditionTokenType = \"variable\" | \"control\" | \"operator\" | \"input\";\n\nexport interface ConditionToken {\n type: ConditionTokenType;\n value: string;\n label?: string;\n sourceNodeId?: string;\n}\n\n/**\n * Type for custom field value types\n */\nexport type CustomFieldValueType =\n | \"text\"\n | \"enum\"\n | \"number\"\n | \"boolean\"\n | \"date\"\n | \"email\"\n | \"address\"\n | \"list\";\n\n/**\n * Display formats supported for date fields (top-level and list columns).\n */\nexport type DateDisplayFormat = \"dd/mm/yyyy\" | \"mm/dd/yyyy\" | \"yyyy-mm-dd\";\n\nexport const DEFAULT_DATE_DISPLAY_FORMAT: DateDisplayFormat = \"dd/mm/yyyy\";\n\n/**\n * Column definition for a list-type custom field\n */\nexport interface ListColumn {\n label: string;\n type: \"text\" | \"enum\" | \"date\" | \"email\";\n options?: string[]; // required when type === 'enum'\n placeholder?: string; // text/email/date — shown to the end user\n regex?: string; // text — JS regex source (without slashes)\n regexErrorMessage?: string; // text — message displayed when regex fails\n dateFormat?: DateDisplayFormat; // date — display format expected\n}\n\n/**\n * Interface for custom field definition\n */\nexport interface CustomField {\n id: string;\n label: string;\n placeholder?: string;\n description?: string;\n valueType: CustomFieldValueType;\n enumOptions?: string[];\n listColumns?: ListColumn[]; // for list type: column definitions\n minRows?: number; // for list type: minimum rows expected\n required?: boolean;\n regex?: string; // text — JS regex source (without slashes)\n regexErrorMessage?: string; // text — message displayed when regex fails\n dateFormat?: DateDisplayFormat; // date — display format expected\n lockedFromApi?: boolean;\n userInputKey?: string;\n}\n\n/**\n * Interface for session template node\n */\nexport interface SessionTemplateNode {\n id: string;\n type: string;\n title: string;\n description: string;\n informationType?:\n | \"identity\"\n | \"identity-legal\"\n | \"contact\"\n | \"address\"\n | \"nationality\"\n | \"custom\";\n position: {\n x: number;\n y: number;\n };\n options: unknown[];\n selectedOptions: string[];\n requiredDocumentType?: string;\n isRequired: boolean;\n order: number;\n optionalFields?: string[];\n requiredFields?: string[];\n pageTitle?: string;\n pageDescription?: string;\n // Properties for document-collection node type\n allowedDocumentTypes?: Array<{\n id: string;\n name: string;\n /**\n * Optional side information coming from the template.\n * When provided and equals to two (\"two\", 2, \"double\", \"recto-verso\"),\n * consumers should allow uploading two sides (front/back).\n */\n side?: string | number;\n }>;\n allowedAddingMethods?: string[];\n introductionPage?: {\n title?: string;\n description?: string;\n };\n documentSelection?: {\n title?: string;\n description?: string;\n };\n // Start node specific properties\n welcomeTitle?: string;\n welcomeSubtitle?: string;\n welcomeDescription?: string;\n welcomeImage?: string;\n qrCodeTitle?: string;\n qrCodeDescription?: string;\n showLegacyCGU?: boolean; // default: true — rétrocompatibilité\n\n // Legal consent node specific properties\n consentDescription?: string;\n consentDescription2?: string;\n cguUrl?: string;\n privacyPolicyUrl?: string;\n checkboxText?: string;\n // Identity control specific properties\n automaticPhotoCapture?: boolean;\n acceptedCountries?: AcceptedCountry[];\n // End node specific properties\n callbackURL?: string | null;\n // Résultat forcé par le nœud `end` (configuré dans le builder). Sert au SDK à\n // afficher la variante « erreur conservée » de l'écran de fin quand la branche\n // fausse d'une condition pointe directement vers un end non_compliant.\n expectedResult?: string;\n // Condition node specific properties\n conditionExpression?: string;\n conditionTokens?: ConditionToken[];\n conditionFalseErrorMessage?: string;\n conditionMaxRetries?: number;\n conditionMaxRetryAction?: \"end-journey\" | \"force-true\";\n conditionFalseMode?: \"retry\" | \"loop\";\n\n // External verification specific properties\n targetApi?: \"INSEE\";\n referenceNodeId?: string;\n referenceNodeType?:\n | \"information-input\"\n | \"document-collection\"\n | \"identity-control\";\n referenceField?: \"siren\" | \"siret\";\n referenceVariable?: string;\n // Custom form fields (for information-input with type 'custom')\n customFields?: CustomField[];\n\n // Electronic signature specific properties\n templateId?: string;\n external_id?: string;\n fieldMappings?: Array<{\n sourceFieldId: string;\n label: string;\n docusealType: string;\n readonly: boolean;\n role?: string;\n sourceNodeId?: string;\n }>;\n /** If set, the generated PDF from this upstream pdf-generation node will be used as the document to sign */\n sourcePdfNodeId?: string;\n\n // PDF generation node specific properties\n // Note: htmlTemplate is intentionally NOT included — it is server-side only and never sent to the client\n pdfMode?: \"upload\" | \"html-template\";\n sourceNodeIds?: string[];\n\n // retry properties\n allowResubmission: boolean;\n maxResubmissionAttempts?: number;\n}\n\n/**\n * Interface for accepted countries\n */\nexport interface AcceptedCountry {\n code: string;\n documents: {\n passport: string[];\n idCard: string[];\n driverLicense: string[];\n residencePermit: string[];\n pinkDriverLicense: string[];\n };\n}\n\n/**\n * Interface for session template edge\n */\nexport interface SessionTemplateEdge {\n id: string;\n source: string;\n target: string;\n sourceHandle?: string;\n targetHandle?: string;\n conditionValue?: string;\n}\n\n/**\n * Interface for platform information\n */\nexport interface PlatformInfo {\n mobile: boolean;\n desktop: boolean;\n backoffice: boolean;\n}\n\n/**\n * Interface for session template\n */\n/** Clé du catalogue d'icônes des écrans de fin (mappée vers lucide-react au rendu). */\nexport type EndScreenIcon =\n | \"thanks\"\n | \"send\"\n | \"mail\"\n | \"check\"\n | \"clock\"\n | \"shield\"\n | \"user\"\n | \"info\";\n\nexport interface EndScreenItem {\n icon: EndScreenIcon;\n text: string;\n}\n\nexport interface EndScreenCase {\n title?: string;\n items: EndScreenItem[];\n}\n\n/** Textes de fin personnalisés (config globale du journey). Vide → fallback standard. */\nexport interface EndScreenConfig {\n compliant?: EndScreenCase;\n nonCompliant?: EndScreenCase;\n}\n\nexport interface SessionTemplate {\n id: string;\n name: string;\n description: string;\n version: string;\n languages: string[];\n nodes: SessionTemplateNode[];\n edges: SessionTemplateEdge[];\n groupId: string;\n userId: string | null;\n created_at: string;\n updated_at: string;\n platforms?: PlatformInfo;\n logo?: string;\n showQRCode?: boolean;\n buttonBgColor?: string;\n buttonTextColor?: string;\n endScreenConfig?: EndScreenConfig;\n}\n\n/**\n * Interface for session data\n */\nexport interface SessionData {\n id: string;\n userId: string | null;\n token: string;\n templateId: string;\n templateKey: string;\n expireTime: number;\n status: string;\n result: Record<string, unknown>;\n landingPage: unknown;\n withSelfie: boolean | null;\n groupId: string | null;\n userInput: Record<string, unknown>;\n contactInfo?: {\n email: string;\n phoneNumber: string;\n };\n callbackURL?: string | null;\n webhookURL: string;\n analysisTemplateId: string | null;\n userAgent: unknown[];\n mobile: boolean;\n analysisId: string | null;\n currentStep?: number;\n createdAt: string;\n updatedAt: string;\n auditTrail: unknown[];\n user: unknown | null;\n analysis: unknown[];\n documents: unknown[];\n template: SessionTemplate;\n retryCounts?: Record<string, number>; // nodeId -> retry count\n}\n\nexport interface ClientInfo {\n ip?: string;\n location?: string;\n device: string;\n browser: string;\n os: string;\n}\n"],"names":[],"mappings":";;AAiEO,IAAM,2BAA2B,GAAsB;;;;"}
|
|
@@ -187,6 +187,8 @@ var DocumentCollection = function (_a) {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
if (success) {
|
|
190
|
+
// Always follow the graph edges. Arithmetic fallback only when no template is available
|
|
191
|
+
// (out of the normal TemplateNodeRenderer flow).
|
|
190
192
|
if (template) {
|
|
191
193
|
stepObject.goToNextStep(node.id, template);
|
|
192
194
|
}
|
|
@@ -247,35 +249,35 @@ var DocumentCollection = function (_a) {
|
|
|
247
249
|
}
|
|
248
250
|
return true;
|
|
249
251
|
};
|
|
252
|
+
// Node progression must follow the graph edges. `onContinueOnPC` is reserved for the
|
|
253
|
+
// QR / mobile→PC redirection and must NOT drive node progression (it navigates by raw step
|
|
254
|
+
// arithmetic, which breaks when several nodes share the same `order`).
|
|
250
255
|
var handleContinueAnyway = function () {
|
|
251
|
-
if (
|
|
256
|
+
if (template) {
|
|
257
|
+
stepObject.goToNextStep(node.id, template);
|
|
258
|
+
}
|
|
259
|
+
else if (onContinueOnPC) {
|
|
252
260
|
onContinueOnPC();
|
|
253
261
|
}
|
|
254
262
|
else {
|
|
255
|
-
|
|
256
|
-
stepObject.goToNextStep(node.id, template);
|
|
257
|
-
}
|
|
258
|
-
else {
|
|
259
|
-
stepObject.setStep(stepObject.step + 1);
|
|
260
|
-
}
|
|
263
|
+
stepObject.setStep(stepObject.step + 1);
|
|
261
264
|
}
|
|
262
265
|
};
|
|
263
266
|
var handleSuccessContinue = function () {
|
|
264
|
-
if (
|
|
267
|
+
if (template) {
|
|
268
|
+
stepObject.goToNextStep(node.id, template);
|
|
269
|
+
}
|
|
270
|
+
else if (onContinueOnPC) {
|
|
265
271
|
onContinueOnPC();
|
|
266
272
|
}
|
|
267
273
|
else {
|
|
268
|
-
|
|
269
|
-
stepObject.goToNextStep(node.id, template);
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
stepObject.setStep(stepObject.step + 1);
|
|
273
|
-
}
|
|
274
|
+
stepObject.setStep(stepObject.step + 1);
|
|
274
275
|
}
|
|
275
276
|
};
|
|
276
277
|
var handleBack = function () {
|
|
277
278
|
if (currentStep === 0) {
|
|
278
|
-
|
|
279
|
+
// Inter-node back navigation goes through the history-aware goBack(), never raw arithmetic.
|
|
280
|
+
stepObject.goBack();
|
|
279
281
|
}
|
|
280
282
|
else {
|
|
281
283
|
setCurrentStep(currentStep - 1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentCollection.js","sources":["../../../../../src/components/document-collection/DocumentCollection.tsx"],"sourcesContent":["import { useState, useEffect } from \"react\";\nimport {\n SessionTemplate,\n SessionTemplateNode,\n stepObject,\n} from \"../../types/session\";\nimport type { onUploadFiles } from \"../../types/uploadFiles\";\nimport type { Prediction } from \"../../utils/apiAnalysis\";\nimport DocumentCollectionIntroduction from \"./DocumentCollectionIntroduction\";\nimport DocumentCollectionSelection from \"./DocumentCollectionSelection\";\nimport DocumentCollectionUpload from \"./DocumentCollectionUpload\";\nimport DocumentCollectionMethodSelection from \"./DocumentCollectionMethodSelection\";\nimport { DocumentError, DocumentProcessing, DocumentSuccess } from \".\";\nimport JDIProcessing from \"../jdi/JDIProcessing\";\nimport JDISuccess from \"../jdi/JDISuccess\";\nimport JDIError from \"../jdi/JDIError\";\nimport BeforePhoto from \"../id-check/BeforePhoto\";\nimport BeforeVersoPhoto from \"../id-check/BeforeVersoPhoto\";\nimport Photo from \"../id-check/Photo\";\nimport PhotoConfirmation from \"../id-check/PhotoConfirmation\";\nimport { useI18n } from \"../../hooks/useI18n\";\nimport ButtonDesktop from \"../ui/ButtonDesktop\";\nimport { updateSessionCurrentStep } from \"../../services/sessionService\";\nimport { analyzeFiles } from \"../../services/analysis\";\nimport {\n getNodeRetryCount,\n incrementNodeRetryCount,\n} from \"../../services/retryService\";\nimport { getSession } from \"../../context/SessionContext\";\nimport {\n resizeAfterCapture,\n dataUrlToBlob,\n blobToDataUrl,\n} from \"../../utils/imageProcessing\";\n\nexport type DocumentTypeSide = \"ONE_FILE\" | \"RECTO_VERSO\";\n\nexport interface NodeDocumentCollection {\n id: string;\n allowedDocumentTypes: Array<{\n name: string;\n id: string;\n collectOnly?: boolean;\n }>;\n allowedAddingMethods: Array<'download' | 'picture'>;\n introductionPage: {\n title: string;\n description: string;\n };\n documentSelection: {\n title: string;\n description: string;\n };\n allowResubmission: boolean;\n maxResubmissionAttempts?: number;\n}\n\ninterface AllowedDocumentType {\n id: string;\n name: string;\n side?: DocumentTypeSide;\n collectOnly?: boolean;\n}\n\ninterface DocumentCollectionProps {\n stepObject: stepObject;\n sessionId: string;\n node: NodeDocumentCollection;\n onContinueOnPC?: () => void;\n allowedDocumentTypes: AllowedDocumentType[];\n allowedAddingMethods: string[];\n template?: SessionTemplate;\n introductionPage?: {\n title?: string;\n description?: string;\n };\n documentSelection?: {\n title?: string;\n description?: string;\n };\n allowResubmission?: boolean;\n maxResubmissionAttempts?: number;\n}\n\n/**\n * DocumentCollection component manages the multi-step document collection flow.\n * It handles document type selection, document upload, processing, and error/success handling.\n *\n * @component\n * @param {Object} props - Component props.\n * @param {stepObject} props.stepObject - Object managing the current step in the parent flow, with setStep and step properties.\n * @param {string} props.sessionId - Unique identifier for the current session.\n * @param {NodeDocumentCollection} props.node - Node configuration containing allowed document types and page content.\n * @param {() => void} [props.onContinueOnPC] - Optional callback to continue the process on a PC.\n * @param {AllowedDocumentType[]} props.allowedDocumentTypes - List of document types accepted for collection.\n * @param {string[]} props.allowedAddingMethods - List of allowed methods for adding documents (download, picture, etc.).\n * @param {Object} [props.introductionPage] - Optional introduction page configuration with title and description.\n * @param {Object} [props.documentSelection] - Optional document selection page configuration with title and description.\n *\n * @returns {JSX.Element} Multi-step document collection UI, rendering different subcomponents based on the current step.\n *\n * @remarks\n * - Manages internal state for step navigation, document selection, file uploads, and error handling.\n * - Displays error messages and fallback UI for invalid navigation.\n * - Uses translation hooks for internationalization support.\n */\nconst DocumentCollection = ({\n stepObject,\n sessionId,\n node,\n template,\n onContinueOnPC,\n allowedDocumentTypes,\n allowedAddingMethods,\n introductionPage,\n documentSelection,\n allowResubmission,\n maxResubmissionAttempts,\n}: DocumentCollectionProps) => {\n const { t } = useI18n();\n const { session } = getSession();\n\n const [currentStep, setCurrentStep] = useState(introductionPage?.title ? 0 : 1);\n const [fileUploaded, setFileUploaded] = useState<onUploadFiles | null>(null);\n const [selectedDocumentType, setSelectedDocumentType] = useState<string>(\"\");\n const [analysisData, setAnalysisData] = useState<Prediction[] | null>(null);\n const [errorCode, setErrorCode] = useState<string | null>(null);\n const [selectedMethod, setSelectedMethod] = useState<\"download\" | \"picture\" | null>(null);\n const [photoSubStep, setPhotoSubStep] = useState<\"before-recto\" | \"recto\" | \"before-verso\" | \"verso\" | \"confirmation\">(\"before-recto\");\n const [capturedImages, setCapturedImages] = useState<Record<string, string>>({});\n\n // Initialize retry count from session data\n const [retryCount, setRetryCount] = useState(() => {\n return getNodeRetryCount(session, node.id);\n });\n\n // Update retry count when session loads/changes\n useEffect(() => {\n if (session) {\n const sessionRetryCount = getNodeRetryCount(session, node.id);\n setRetryCount(sessionRetryCount);\n }\n }, [session, node.id]);\n\n // Check retry limits on mount/reload - if retries exhausted, show error page\n useEffect(() => {\n // Special case: if allowResubmission is false and retryCount > 0, show error immediately\n if (allowResubmission === false && retryCount > 0) {\n setCurrentStep(6);\n return;\n }\n\n // Normal case: check against maxResubmissionAttempts\n if (retryCount > 0 && !isRetryAllowed()) {\n // User has exhausted retries, redirect to error page\n setCurrentStep(6);\n }\n }, [retryCount, allowResubmission]);\n\n const handleContinueFromIntroduction = () => {\n setCurrentStep(1);\n };\n\n const handleDocumentTypeSelect = (docType: string, files?: onUploadFiles) => {\n setSelectedDocumentType(docType);\n\n if (files) {\n handleDocumentUpload(files);\n return;\n }\n\n const isPictureAllowed = allowedAddingMethods.includes(\"picture\");\n const isDownloadAllowed = allowedAddingMethods.includes(\"download\");\n\n if (isPictureAllowed && isDownloadAllowed) {\n setCurrentStep(2); // Method selection\n } else {\n const method = isPictureAllowed ? \"picture\" : \"download\";\n handleMethodSelect(method);\n }\n };\n\n const handleMethodSelect = (method: \"download\" | \"picture\") => {\n setSelectedMethod(method);\n if (method === \"picture\") {\n setPhotoSubStep(\"before-recto\");\n setCapturedImages({});\n }\n setCurrentStep(3); // Go to action (Upload screen or Photo flow)\n };\n\n const handlePhotoCapture = async (imageData: string, side: \"recto\" | \"verso\") => {\n try {\n const imageBlob = dataUrlToBlob(imageData);\n const processedBlob = await resizeAfterCapture(imageBlob);\n const processedDataUrl = await blobToDataUrl(processedBlob);\n\n setCapturedImages((prev) => ({ ...prev, [side]: processedDataUrl }));\n\n if (side === \"recto\") {\n const selected = allowedDocumentTypes.find((d) => d.id === selectedDocumentType);\n const requiresTwoSides = selected?.side === \"RECTO_VERSO\";\n setPhotoSubStep(requiresTwoSides ? \"before-verso\" : \"confirmation\");\n } else {\n setPhotoSubStep(\"confirmation\");\n }\n } catch (error) {\n console.error(`[DocumentCollection] Failed to process photo for ${side}:`, error);\n setCapturedImages((prev) => ({ ...prev, [side]: imageData }));\n if (side === \"recto\") {\n const selected = allowedDocumentTypes.find((d) => d.id === selectedDocumentType);\n const requiresTwoSides = selected?.side === \"RECTO_VERSO\";\n setPhotoSubStep(requiresTwoSides ? \"before-verso\" : \"confirmation\");\n } else {\n setPhotoSubStep(\"confirmation\");\n }\n }\n };\n\n const handlePhotoConfirmation = () => {\n if (capturedImages.recto) {\n const files: onUploadFiles = {\n front: capturedImages.recto,\n back: capturedImages.verso || null,\n };\n setFileUploaded(files);\n setCurrentStep(4);\n }\n };\n\n const handleDocumentUpload = (files: onUploadFiles) => {\n setFileUploaded(files);\n\n // Check if the selected document type is collectOnly — skip processing step\n const selectedDoc = allowedDocumentTypes.find((d) => d.id === selectedDocumentType);\n if (selectedDoc?.collectOnly) {\n handleCollectOnlyUpload(files);\n return;\n }\n\n // Check if retry limit is reached before processing\n if (!isRetryAllowed() && retryCount > 0) {\n // Skip processing and go directly to error page\n setCurrentStep(6);\n } else {\n // Proceed to processing\n setCurrentStep(4);\n }\n };\n\n const handleProcessingComplete = (\n success: boolean,\n currentRetryCount?: number,\n apiAnalysisData?: Prediction[] | null\n ) => {\n if (apiAnalysisData) {\n setAnalysisData(apiAnalysisData);\n if (apiAnalysisData.length > 0) {\n setErrorCode(apiAnalysisData[0].code);\n }\n }\n\n if (success) {\n if (template) {\n stepObject.goToNextStep(node.id, template);\n } else {\n stepObject.setStep(stepObject.step + 1);\n }\n setCurrentStep(5);\n } else {\n setRetryCount((prev) => {\n const newCount = prev + 1;\n incrementNodeRetryCount(sessionId, node.id, prev).catch((error) => {\n console.error(\"Failed to update retry count in session:\", error);\n });\n return newCount;\n });\n setCurrentStep(6);\n }\n };\n\n const handleCollectOnlyUpload = async (files: onUploadFiles) => {\n try {\n await analyzeFiles(sessionId, node.id, files, selectedDocumentType, {\n documentTypeKey: selectedDocumentType,\n collectOnly: true,\n enablePolling: false,\n });\n handleProcessingComplete(true, retryCount, null);\n } catch (error) {\n console.error(\"[DocumentCollection] collectOnly upload failed:\", error);\n handleProcessingComplete(false, retryCount, null);\n }\n };\n\n const handleRetryFromError = () => {\n setCurrentStep(1);\n setSelectedMethod(null);\n setCapturedImages({});\n setFileUploaded(null);\n };\n\n // Check if retry is allowed based on configuration\n const isRetryAllowed = () => {\n if (allowResubmission === undefined) return true;\n if (!allowResubmission) return false;\n if (maxResubmissionAttempts !== undefined) {\n return retryCount <= maxResubmissionAttempts;\n }\n return true;\n };\n\n const handleContinueAnyway = () => {\n if (onContinueOnPC) {\n onContinueOnPC();\n } else {\n if (template) {\n stepObject.goToNextStep(node.id, template);\n } else {\n stepObject.setStep(stepObject.step + 1);\n }\n }\n };\n\n const handleSuccessContinue = () => {\n if (onContinueOnPC) {\n onContinueOnPC();\n } else {\n if (template) {\n stepObject.goToNextStep(node.id, template);\n } else {\n stepObject.setStep(stepObject.step + 1);\n }\n }\n };\n\n const handleBack = () => {\n if (currentStep === 0) {\n stepObject.setStep(stepObject.step - 1);\n } else {\n setCurrentStep(currentStep - 1);\n }\n };\n\n switch (currentStep) {\n case 0:\n return (\n <DocumentCollectionIntroduction\n onContinue={handleContinueFromIntroduction}\n onBack={handleBack}\n introductionPage={introductionPage}\n />\n );\n case 1:\n return (\n <DocumentCollectionSelection\n onContinue={handleDocumentTypeSelect}\n onBack={handleBack}\n allowedDocumentTypes={allowedDocumentTypes}\n allowedAddingMethods={allowedAddingMethods}\n stepObject={stepObject}\n documentSelection={documentSelection}\n />\n );\n case 2:\n return (\n <DocumentCollectionMethodSelection\n onMethodSelect={handleMethodSelect}\n onBack={handleBack}\n title={documentSelection?.title}\n description={documentSelection?.description}\n />\n );\n case 3:\n if (selectedMethod === \"download\") {\n return (\n <DocumentCollectionUpload\n selectedDocumentType={selectedDocumentType}\n allowedDocumentTypes={allowedDocumentTypes}\n onUpload={handleDocumentUpload}\n onBack={handleBack}\n documentSelection={documentSelection}\n sessionId={sessionId}\n />\n );\n } else {\n // Photo flow\n const requiresTwoSides = allowedDocumentTypes.find((dt) => dt.id === selectedDocumentType)?.side === \"RECTO_VERSO\";\n\n switch (photoSubStep) {\n case \"before-recto\":\n return <BeforePhoto setStep={() => setPhotoSubStep(\"recto\")} isSingleSided={!requiresTwoSides} onBack={handleBack} />;\n case \"recto\":\n return <Photo onCapture={(img) => handlePhotoCapture(img, \"recto\")} automaticCapture={false} maskType=\"document\" />;\n case \"before-verso\":\n return <BeforeVersoPhoto setStep={() => setPhotoSubStep(\"verso\")} />;\n case \"verso\":\n return <Photo onCapture={(img) => handlePhotoCapture(img, \"verso\")} automaticCapture={false} maskType=\"document\" />;\n case \"confirmation\":\n return (\n <PhotoConfirmation\n imageUrl={capturedImages.recto}\n versoImageUrl={capturedImages.verso}\n requiresTwoSides={requiresTwoSides}\n onConfirm={handlePhotoConfirmation}\n onRetry={() => {\n setPhotoSubStep(\"before-recto\");\n setCapturedImages({});\n }}\n onRetryAfterProcessing={() => {\n setCurrentStep(1);\n setPhotoSubStep(\"before-recto\");\n setCapturedImages({});\n }}\n fileUploaded={fileUploaded}\n isSingleSided={!requiresTwoSides}\n />\n );\n }\n }\n return null;\n\n case 4:\n return (\n <DocumentProcessing\n documentType={selectedDocumentType}\n onProcessingComplete={handleProcessingComplete}\n fileUploaded={fileUploaded}\n documentTypeId={selectedDocumentType}\n retryCount={retryCount}\n nodeId={node.id}\n />\n );\n case 5:\n return (\n <DocumentSuccess\n documentType={selectedDocumentType}\n documentTypeLabel={t(allowedDocumentTypes.find((dt) => dt.id === selectedDocumentType)?.name || \"\")}\n onContinue={handleSuccessContinue}\n errorCode={errorCode || undefined}\n successDetails={{\n nextSteps: {\n title: t(\"success.next_steps\", \"Prochaines étapes\"),\n description: t(\n \"success.next_steps_description\",\n \"Vous pouvez maintenant continuer le processus de vérification en suivant les instructions à l'écran.\"\n ),\n },\n }}\n />\n );\n case 6:\n return (\n <DocumentError\n documentType={selectedDocumentType}\n onRetry={handleRetryFromError}\n onContinueAnyway={handleContinueAnyway}\n retryCount={retryCount}\n predictions={analysisData || undefined}\n errorCode={errorCode || undefined}\n allowResubmission={allowResubmission}\n maxResubmissionAttempts={maxResubmissionAttempts}\n isRetryAllowed={isRetryAllowed()}\n />\n );\n\n default:\n console.error(`Invalid document collection step: ${currentStep} `);\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n {t(\"document_collection.navigation_error.title\", \"Erreur de navigation\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">\n {t(\"document_collection.navigation_error.description\", \"Étape non valide. Veuillez recommencer.\")}\n </p>\n <ButtonDesktop\n type=\"back\"\n className=\"w-full\"\n onClick={() => setCurrentStep(0)}\n >\n {t(\"document_collection.navigation_error.back\", \"Retour au début\")}\n </ButtonDesktop>\n </div>\n );\n }\n};\n\nexport default DocumentCollection;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoFA;;;;;;;;;;;;;;;;;;;;;AAqBG;AACH,IAAM,kBAAkB,GAAG,UAAC,EAYF,EAAA;;AAXxB,IAAA,IAAA,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,IAAI,GAAA,EAAA,CAAA,IAAA,EACJ,QAAQ,GAAA,EAAA,CAAA,QAAA,EACR,cAAc,oBAAA,EACd,oBAAoB,GAAA,EAAA,CAAA,oBAAA,EACpB,oBAAoB,GAAA,EAAA,CAAA,oBAAA,EACpB,gBAAgB,GAAA,EAAA,CAAA,gBAAA,EAChB,iBAAiB,GAAA,EAAA,CAAA,iBAAA,EACjB,iBAAiB,GAAA,EAAA,CAAA,iBAAA,EACjB,uBAAuB,GAAA,EAAA,CAAA,uBAAA;AAEf,IAAA,IAAA,CAAC,GAAK,OAAO,EAAE,EAAd;AACD,IAAA,IAAA,OAAO,GAAK,UAAU,EAAE,QAAjB;IAET,IAAA,EAAA,GAAgC,QAAQ,CAAC,CAAA,gBAAgB,KAAA,IAAA,IAAhB,gBAAgB,KAAA,MAAA,GAAA,MAAA,GAAhB,gBAAgB,CAAE,KAAK,IAAG,CAAC,GAAG,CAAC,CAAC,EAAxE,WAAW,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,cAAc,GAAA,EAAA,CAAA,CAAA,CAA6C;IACzE,IAAA,EAAA,GAAkC,QAAQ,CAAuB,IAAI,CAAC,EAArE,YAAY,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,eAAe,GAAA,EAAA,CAAA,C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BAAiB,CAAC,EAAA,CACpD,CAAA,EAAA,CACZ;;AAGd;;;;"}
|
|
1
|
+
{"version":3,"file":"DocumentCollection.js","sources":["../../../../../src/components/document-collection/DocumentCollection.tsx"],"sourcesContent":["import { useState, useEffect } from \"react\";\nimport {\n SessionTemplate,\n SessionTemplateNode,\n stepObject,\n} from \"../../types/session\";\nimport type { onUploadFiles } from \"../../types/uploadFiles\";\nimport type { Prediction } from \"../../utils/apiAnalysis\";\nimport DocumentCollectionIntroduction from \"./DocumentCollectionIntroduction\";\nimport DocumentCollectionSelection from \"./DocumentCollectionSelection\";\nimport DocumentCollectionUpload from \"./DocumentCollectionUpload\";\nimport DocumentCollectionMethodSelection from \"./DocumentCollectionMethodSelection\";\nimport { DocumentError, DocumentProcessing, DocumentSuccess } from \".\";\nimport JDIProcessing from \"../jdi/JDIProcessing\";\nimport JDISuccess from \"../jdi/JDISuccess\";\nimport JDIError from \"../jdi/JDIError\";\nimport BeforePhoto from \"../id-check/BeforePhoto\";\nimport BeforeVersoPhoto from \"../id-check/BeforeVersoPhoto\";\nimport Photo from \"../id-check/Photo\";\nimport PhotoConfirmation from \"../id-check/PhotoConfirmation\";\nimport { useI18n } from \"../../hooks/useI18n\";\nimport ButtonDesktop from \"../ui/ButtonDesktop\";\nimport { updateSessionCurrentStep } from \"../../services/sessionService\";\nimport { analyzeFiles } from \"../../services/analysis\";\nimport {\n getNodeRetryCount,\n incrementNodeRetryCount,\n} from \"../../services/retryService\";\nimport { getSession } from \"../../context/SessionContext\";\nimport {\n resizeAfterCapture,\n dataUrlToBlob,\n blobToDataUrl,\n} from \"../../utils/imageProcessing\";\n\nexport type DocumentTypeSide = \"ONE_FILE\" | \"RECTO_VERSO\";\n\nexport interface NodeDocumentCollection {\n id: string;\n allowedDocumentTypes: Array<{\n name: string;\n id: string;\n collectOnly?: boolean;\n }>;\n allowedAddingMethods: Array<'download' | 'picture'>;\n introductionPage: {\n title: string;\n description: string;\n };\n documentSelection: {\n title: string;\n description: string;\n };\n allowResubmission: boolean;\n maxResubmissionAttempts?: number;\n}\n\ninterface AllowedDocumentType {\n id: string;\n name: string;\n side?: DocumentTypeSide;\n collectOnly?: boolean;\n}\n\ninterface DocumentCollectionProps {\n stepObject: stepObject;\n sessionId: string;\n node: NodeDocumentCollection;\n onContinueOnPC?: () => void;\n allowedDocumentTypes: AllowedDocumentType[];\n allowedAddingMethods: string[];\n template?: SessionTemplate;\n introductionPage?: {\n title?: string;\n description?: string;\n };\n documentSelection?: {\n title?: string;\n description?: string;\n };\n allowResubmission?: boolean;\n maxResubmissionAttempts?: number;\n}\n\n/**\n * DocumentCollection component manages the multi-step document collection flow.\n * It handles document type selection, document upload, processing, and error/success handling.\n *\n * @component\n * @param {Object} props - Component props.\n * @param {stepObject} props.stepObject - Object managing the current step in the parent flow, with setStep and step properties.\n * @param {string} props.sessionId - Unique identifier for the current session.\n * @param {NodeDocumentCollection} props.node - Node configuration containing allowed document types and page content.\n * @param {() => void} [props.onContinueOnPC] - Optional callback to continue the process on a PC.\n * @param {AllowedDocumentType[]} props.allowedDocumentTypes - List of document types accepted for collection.\n * @param {string[]} props.allowedAddingMethods - List of allowed methods for adding documents (download, picture, etc.).\n * @param {Object} [props.introductionPage] - Optional introduction page configuration with title and description.\n * @param {Object} [props.documentSelection] - Optional document selection page configuration with title and description.\n *\n * @returns {JSX.Element} Multi-step document collection UI, rendering different subcomponents based on the current step.\n *\n * @remarks\n * - Manages internal state for step navigation, document selection, file uploads, and error handling.\n * - Displays error messages and fallback UI for invalid navigation.\n * - Uses translation hooks for internationalization support.\n */\nconst DocumentCollection = ({\n stepObject,\n sessionId,\n node,\n template,\n onContinueOnPC,\n allowedDocumentTypes,\n allowedAddingMethods,\n introductionPage,\n documentSelection,\n allowResubmission,\n maxResubmissionAttempts,\n}: DocumentCollectionProps) => {\n const { t } = useI18n();\n const { session } = getSession();\n\n const [currentStep, setCurrentStep] = useState(introductionPage?.title ? 0 : 1);\n const [fileUploaded, setFileUploaded] = useState<onUploadFiles | null>(null);\n const [selectedDocumentType, setSelectedDocumentType] = useState<string>(\"\");\n const [analysisData, setAnalysisData] = useState<Prediction[] | null>(null);\n const [errorCode, setErrorCode] = useState<string | null>(null);\n const [selectedMethod, setSelectedMethod] = useState<\"download\" | \"picture\" | null>(null);\n const [photoSubStep, setPhotoSubStep] = useState<\"before-recto\" | \"recto\" | \"before-verso\" | \"verso\" | \"confirmation\">(\"before-recto\");\n const [capturedImages, setCapturedImages] = useState<Record<string, string>>({});\n\n // Initialize retry count from session data\n const [retryCount, setRetryCount] = useState(() => {\n return getNodeRetryCount(session, node.id);\n });\n\n // Update retry count when session loads/changes\n useEffect(() => {\n if (session) {\n const sessionRetryCount = getNodeRetryCount(session, node.id);\n setRetryCount(sessionRetryCount);\n }\n }, [session, node.id]);\n\n // Check retry limits on mount/reload - if retries exhausted, show error page\n useEffect(() => {\n // Special case: if allowResubmission is false and retryCount > 0, show error immediately\n if (allowResubmission === false && retryCount > 0) {\n setCurrentStep(6);\n return;\n }\n\n // Normal case: check against maxResubmissionAttempts\n if (retryCount > 0 && !isRetryAllowed()) {\n // User has exhausted retries, redirect to error page\n setCurrentStep(6);\n }\n }, [retryCount, allowResubmission]);\n\n const handleContinueFromIntroduction = () => {\n setCurrentStep(1);\n };\n\n const handleDocumentTypeSelect = (docType: string, files?: onUploadFiles) => {\n setSelectedDocumentType(docType);\n\n if (files) {\n handleDocumentUpload(files);\n return;\n }\n\n const isPictureAllowed = allowedAddingMethods.includes(\"picture\");\n const isDownloadAllowed = allowedAddingMethods.includes(\"download\");\n\n if (isPictureAllowed && isDownloadAllowed) {\n setCurrentStep(2); // Method selection\n } else {\n const method = isPictureAllowed ? \"picture\" : \"download\";\n handleMethodSelect(method);\n }\n };\n\n const handleMethodSelect = (method: \"download\" | \"picture\") => {\n setSelectedMethod(method);\n if (method === \"picture\") {\n setPhotoSubStep(\"before-recto\");\n setCapturedImages({});\n }\n setCurrentStep(3); // Go to action (Upload screen or Photo flow)\n };\n\n const handlePhotoCapture = async (imageData: string, side: \"recto\" | \"verso\") => {\n try {\n const imageBlob = dataUrlToBlob(imageData);\n const processedBlob = await resizeAfterCapture(imageBlob);\n const processedDataUrl = await blobToDataUrl(processedBlob);\n\n setCapturedImages((prev) => ({ ...prev, [side]: processedDataUrl }));\n\n if (side === \"recto\") {\n const selected = allowedDocumentTypes.find((d) => d.id === selectedDocumentType);\n const requiresTwoSides = selected?.side === \"RECTO_VERSO\";\n setPhotoSubStep(requiresTwoSides ? \"before-verso\" : \"confirmation\");\n } else {\n setPhotoSubStep(\"confirmation\");\n }\n } catch (error) {\n console.error(`[DocumentCollection] Failed to process photo for ${side}:`, error);\n setCapturedImages((prev) => ({ ...prev, [side]: imageData }));\n if (side === \"recto\") {\n const selected = allowedDocumentTypes.find((d) => d.id === selectedDocumentType);\n const requiresTwoSides = selected?.side === \"RECTO_VERSO\";\n setPhotoSubStep(requiresTwoSides ? \"before-verso\" : \"confirmation\");\n } else {\n setPhotoSubStep(\"confirmation\");\n }\n }\n };\n\n const handlePhotoConfirmation = () => {\n if (capturedImages.recto) {\n const files: onUploadFiles = {\n front: capturedImages.recto,\n back: capturedImages.verso || null,\n };\n setFileUploaded(files);\n setCurrentStep(4);\n }\n };\n\n const handleDocumentUpload = (files: onUploadFiles) => {\n setFileUploaded(files);\n\n // Check if the selected document type is collectOnly — skip processing step\n const selectedDoc = allowedDocumentTypes.find((d) => d.id === selectedDocumentType);\n if (selectedDoc?.collectOnly) {\n handleCollectOnlyUpload(files);\n return;\n }\n\n // Check if retry limit is reached before processing\n if (!isRetryAllowed() && retryCount > 0) {\n // Skip processing and go directly to error page\n setCurrentStep(6);\n } else {\n // Proceed to processing\n setCurrentStep(4);\n }\n };\n\n const handleProcessingComplete = (\n success: boolean,\n currentRetryCount?: number,\n apiAnalysisData?: Prediction[] | null\n ) => {\n if (apiAnalysisData) {\n setAnalysisData(apiAnalysisData);\n if (apiAnalysisData.length > 0) {\n setErrorCode(apiAnalysisData[0].code);\n }\n }\n\n if (success) {\n // Always follow the graph edges. Arithmetic fallback only when no template is available\n // (out of the normal TemplateNodeRenderer flow).\n if (template) {\n stepObject.goToNextStep(node.id, template);\n } else {\n stepObject.setStep(stepObject.step + 1);\n }\n setCurrentStep(5);\n } else {\n setRetryCount((prev) => {\n const newCount = prev + 1;\n incrementNodeRetryCount(sessionId, node.id, prev).catch((error) => {\n console.error(\"Failed to update retry count in session:\", error);\n });\n return newCount;\n });\n setCurrentStep(6);\n }\n };\n\n const handleCollectOnlyUpload = async (files: onUploadFiles) => {\n try {\n await analyzeFiles(sessionId, node.id, files, selectedDocumentType, {\n documentTypeKey: selectedDocumentType,\n collectOnly: true,\n enablePolling: false,\n });\n handleProcessingComplete(true, retryCount, null);\n } catch (error) {\n console.error(\"[DocumentCollection] collectOnly upload failed:\", error);\n handleProcessingComplete(false, retryCount, null);\n }\n };\n\n const handleRetryFromError = () => {\n setCurrentStep(1);\n setSelectedMethod(null);\n setCapturedImages({});\n setFileUploaded(null);\n };\n\n // Check if retry is allowed based on configuration\n const isRetryAllowed = () => {\n if (allowResubmission === undefined) return true;\n if (!allowResubmission) return false;\n if (maxResubmissionAttempts !== undefined) {\n return retryCount <= maxResubmissionAttempts;\n }\n return true;\n };\n\n // Node progression must follow the graph edges. `onContinueOnPC` is reserved for the\n // QR / mobile→PC redirection and must NOT drive node progression (it navigates by raw step\n // arithmetic, which breaks when several nodes share the same `order`).\n const handleContinueAnyway = () => {\n if (template) {\n stepObject.goToNextStep(node.id, template);\n } else if (onContinueOnPC) {\n onContinueOnPC();\n } else {\n stepObject.setStep(stepObject.step + 1);\n }\n };\n\n const handleSuccessContinue = () => {\n if (template) {\n stepObject.goToNextStep(node.id, template);\n } else if (onContinueOnPC) {\n onContinueOnPC();\n } else {\n stepObject.setStep(stepObject.step + 1);\n }\n };\n\n const handleBack = () => {\n if (currentStep === 0) {\n // Inter-node back navigation goes through the history-aware goBack(), never raw arithmetic.\n stepObject.goBack();\n } else {\n setCurrentStep(currentStep - 1);\n }\n };\n\n switch (currentStep) {\n case 0:\n return (\n <DocumentCollectionIntroduction\n onContinue={handleContinueFromIntroduction}\n onBack={handleBack}\n introductionPage={introductionPage}\n />\n );\n case 1:\n return (\n <DocumentCollectionSelection\n onContinue={handleDocumentTypeSelect}\n onBack={handleBack}\n allowedDocumentTypes={allowedDocumentTypes}\n allowedAddingMethods={allowedAddingMethods}\n stepObject={stepObject}\n documentSelection={documentSelection}\n />\n );\n case 2:\n return (\n <DocumentCollectionMethodSelection\n onMethodSelect={handleMethodSelect}\n onBack={handleBack}\n title={documentSelection?.title}\n description={documentSelection?.description}\n />\n );\n case 3:\n if (selectedMethod === \"download\") {\n return (\n <DocumentCollectionUpload\n selectedDocumentType={selectedDocumentType}\n allowedDocumentTypes={allowedDocumentTypes}\n onUpload={handleDocumentUpload}\n onBack={handleBack}\n documentSelection={documentSelection}\n sessionId={sessionId}\n />\n );\n } else {\n // Photo flow\n const requiresTwoSides = allowedDocumentTypes.find((dt) => dt.id === selectedDocumentType)?.side === \"RECTO_VERSO\";\n\n switch (photoSubStep) {\n case \"before-recto\":\n return <BeforePhoto setStep={() => setPhotoSubStep(\"recto\")} isSingleSided={!requiresTwoSides} onBack={handleBack} />;\n case \"recto\":\n return <Photo onCapture={(img) => handlePhotoCapture(img, \"recto\")} automaticCapture={false} maskType=\"document\" />;\n case \"before-verso\":\n return <BeforeVersoPhoto setStep={() => setPhotoSubStep(\"verso\")} />;\n case \"verso\":\n return <Photo onCapture={(img) => handlePhotoCapture(img, \"verso\")} automaticCapture={false} maskType=\"document\" />;\n case \"confirmation\":\n return (\n <PhotoConfirmation\n imageUrl={capturedImages.recto}\n versoImageUrl={capturedImages.verso}\n requiresTwoSides={requiresTwoSides}\n onConfirm={handlePhotoConfirmation}\n onRetry={() => {\n setPhotoSubStep(\"before-recto\");\n setCapturedImages({});\n }}\n onRetryAfterProcessing={() => {\n setCurrentStep(1);\n setPhotoSubStep(\"before-recto\");\n setCapturedImages({});\n }}\n fileUploaded={fileUploaded}\n isSingleSided={!requiresTwoSides}\n />\n );\n }\n }\n return null;\n\n case 4:\n return (\n <DocumentProcessing\n documentType={selectedDocumentType}\n onProcessingComplete={handleProcessingComplete}\n fileUploaded={fileUploaded}\n documentTypeId={selectedDocumentType}\n retryCount={retryCount}\n nodeId={node.id}\n />\n );\n case 5:\n return (\n <DocumentSuccess\n documentType={selectedDocumentType}\n documentTypeLabel={t(allowedDocumentTypes.find((dt) => dt.id === selectedDocumentType)?.name || \"\")}\n onContinue={handleSuccessContinue}\n errorCode={errorCode || undefined}\n successDetails={{\n nextSteps: {\n title: t(\"success.next_steps\", \"Prochaines étapes\"),\n description: t(\n \"success.next_steps_description\",\n \"Vous pouvez maintenant continuer le processus de vérification en suivant les instructions à l'écran.\"\n ),\n },\n }}\n />\n );\n case 6:\n return (\n <DocumentError\n documentType={selectedDocumentType}\n onRetry={handleRetryFromError}\n onContinueAnyway={handleContinueAnyway}\n retryCount={retryCount}\n predictions={analysisData || undefined}\n errorCode={errorCode || undefined}\n allowResubmission={allowResubmission}\n maxResubmissionAttempts={maxResubmissionAttempts}\n isRetryAllowed={isRetryAllowed()}\n />\n );\n\n default:\n console.error(`Invalid document collection step: ${currentStep} `);\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n {t(\"document_collection.navigation_error.title\", \"Erreur de navigation\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">\n {t(\"document_collection.navigation_error.description\", \"Étape non valide. Veuillez recommencer.\")}\n </p>\n <ButtonDesktop\n type=\"back\"\n className=\"w-full\"\n onClick={() => setCurrentStep(0)}\n >\n {t(\"document_collection.navigation_error.back\", \"Retour au début\")}\n </ButtonDesktop>\n </div>\n );\n }\n};\n\nexport default DocumentCollection;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoFA;;;;;;;;;;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,WAAW,EAAE,YAAY,IAAI,SAAS,EACtC,SAAS,EAAE,SAAS,IAAI,SAAS,EACjC,iBAAiB,EAAE,iBAAiB,EACpC,uBAAuB,EAAE,uBAAuB,EAChD,cAAc,EAAE,cAAc,EAAE,EAAA,CAChC;AAGN,QAAA;AACE,YAAA,OAAO,CAAC,KAAK,CAAC,4CAAqC,WAAW,EAAA,GAAA,CAAG,CAAC;AAClE,YAAA,QACEC,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,kEAAkE,EAAA,QAAA,EAAA,CAC/ED,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,4BAA4B,EAAA,QAAA,EAAA,cAAA,EAAA,CAAS,EACpDA,GAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAC,qCAAqC,EAAA,QAAA,EAChD,CAAC,CAAC,4CAA4C,EAAE,sBAAsB,CAAC,EAAA,CACrE,EACLA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAC9B,CAAC,CAAC,kDAAkD,EAAE,yCAAyC,CAAC,EAAA,CAC/F,EACJA,GAAA,CAAC,aAAa,IACZ,IAAI,EAAC,MAAM,EACX,SAAS,EAAC,QAAQ,EAClB,OAAO,EAAE,YAAA,EAAM,OAAA,cAAc,CAAC,CAAC,CAAC,CAAA,CAAjB,CAAiB,EAAA,QAAA,EAE/B,CAAC,CAAC,2CAA2C,EAAE,iBAAiB,CAAC,EAAA,CACpD,CAAA,EAAA,CACZ;;AAGd;;;;"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { __awaiter, __generator } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { useState, useEffect } from 'react';
|
|
4
|
+
import { HeartHandshake, Send, Mail } from 'lucide-react';
|
|
4
5
|
import img from '../../assets/check.svg.js';
|
|
6
|
+
import LoadingState from '../states/LoadingState.js';
|
|
5
7
|
import Button from '../ui/Button.js';
|
|
6
8
|
import PageActions from '../ui/PageActions.js';
|
|
7
9
|
import Title from '../ui/Title.js';
|
|
@@ -10,7 +12,11 @@ import { updateSessionStatus, clearSessionSensitiveData } from '../../services/s
|
|
|
10
12
|
import { logSessionEnded } from '../../services/auditTrailService.js';
|
|
11
13
|
import MobilePageLayout from '../ui/MobilePageLayout.js';
|
|
12
14
|
import { useI18n } from '../../hooks/useI18n.js';
|
|
15
|
+
import useIsMobile from '../../hooks/useIsMobile.js';
|
|
16
|
+
import { resolveEndScreenIcon } from './endScreenIcons.js';
|
|
13
17
|
|
|
18
|
+
// Couleur des icônes = couleur du bouton choisie pour le journey (buttonBgColor).
|
|
19
|
+
var ICON_COLOR = "var(--dk-btn-bg, #11e5c5)";
|
|
14
20
|
/**
|
|
15
21
|
* EndFlow Component
|
|
16
22
|
*
|
|
@@ -22,18 +28,43 @@ import { useI18n } from '../../hooks/useI18n.js';
|
|
|
22
28
|
* @param {string} props.sessionStatus - Le statut actuel de la session
|
|
23
29
|
* @returns {JSX.Element} Le composant EndFlow
|
|
24
30
|
*/
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
26
31
|
var EndFlow = function (_a) {
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
32
|
+
var _b, _c;
|
|
33
|
+
var sessionId = _a.sessionId, sessionStatus = _a.sessionStatus, callbackURL = _a.callbackURL, endNodeId = _a.endNodeId, expectedResult = _a.expectedResult, compliantCase = _a.compliantCase, nonCompliantCase = _a.nonCompliantCase;
|
|
34
|
+
var _d = useState(false), isEnding = _d[0], setIsEnding = _d[1];
|
|
35
|
+
var _e = useState(false), isRedirecting = _e[0], setIsRedirecting = _e[1];
|
|
36
|
+
var _f = useState(false), shouldRedirect = _f[0], setShouldRedirect = _f[1];
|
|
37
|
+
// Statut consolidé renvoyé par le backend après updateSessionStatus —
|
|
38
|
+
// sert à détecter un échec « poursuivre quand même » non porté par expectedResult.
|
|
39
|
+
var _g = useState(undefined), backendStatus = _g[0], setBackendStatus = _g[1];
|
|
40
|
+
// Le verdict backend arrive de façon asynchrone (~1-2s). On le marque résolu
|
|
41
|
+
// pour éviter de flasher l'écran succès puis basculer sur l'écran erreur.
|
|
42
|
+
var _h = useState(false), statusResolved = _h[0], setStatusResolved = _h[1];
|
|
31
43
|
var t = useI18n().t;
|
|
44
|
+
var isMobile = useIsMobile(768);
|
|
45
|
+
// Décalage horizontal du bloc d'items réservé au desktop. On le pilote en JS
|
|
46
|
+
// (useIsMobile, cohérent avec le composant Button) plutôt que via `md:` Tailwind :
|
|
47
|
+
// les variantes responsive `md:translate-*` ne sont pas fiables dans le bundle SDK.
|
|
48
|
+
var desktopTranslateX = isMobile ? "" : "translate-x-10";
|
|
49
|
+
// Le nœud end peut déjà forcer un résultat non conforme : dans ce cas on
|
|
50
|
+
// connaît l'issue sans attendre le backend.
|
|
51
|
+
var expectedError = expectedResult === "non_compliant" || expectedResult === "error";
|
|
52
|
+
// L'écran « erreur conservée » s'affiche si le nœud end force un résultat
|
|
53
|
+
// non conforme, OU si le backend a consolidé un statut d'échec/vérification.
|
|
54
|
+
var isError = expectedError ||
|
|
55
|
+
backendStatus === "ai_rejected" ||
|
|
56
|
+
backendStatus === "verify";
|
|
57
|
+
// Tant que le verdict n'est pas connu (ni forcé par le nœud, ni renvoyé par
|
|
58
|
+
// le backend), on affiche un état neutre plutôt que de présumer le succès.
|
|
59
|
+
var isResolving = !expectedError && !statusResolved;
|
|
32
60
|
// Trigger session end as soon as the user reaches this screen,
|
|
33
61
|
// regardless of whether they click the button (e.g. tab close)
|
|
34
62
|
useEffect(function () {
|
|
35
|
-
updateSessionStatus(sessionId, "ended")
|
|
63
|
+
updateSessionStatus(sessionId, "ended", endNodeId)
|
|
36
64
|
.then(function (updatedSession) {
|
|
65
|
+
if (updatedSession === null || updatedSession === void 0 ? void 0 : updatedSession.status) {
|
|
66
|
+
setBackendStatus(updatedSession.status);
|
|
67
|
+
}
|
|
37
68
|
if (updatedSession && updatedSession.analysisId) {
|
|
38
69
|
logSessionEnded(sessionId).catch(function (err) {
|
|
39
70
|
console.error("Failed to log session end in audit trail:", err);
|
|
@@ -42,6 +73,10 @@ var EndFlow = function (_a) {
|
|
|
42
73
|
})
|
|
43
74
|
.catch(function (error) {
|
|
44
75
|
console.error("Error updating session status on EndFlow mount:", error);
|
|
76
|
+
})
|
|
77
|
+
.finally(function () {
|
|
78
|
+
// Verdict connu (ou échec d'appel) : on peut afficher l'écran final.
|
|
79
|
+
setStatusResolved(true);
|
|
45
80
|
});
|
|
46
81
|
}, []);
|
|
47
82
|
var handleEndSession = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -165,11 +200,45 @@ var EndFlow = function (_a) {
|
|
|
165
200
|
}
|
|
166
201
|
}, 500);
|
|
167
202
|
};
|
|
203
|
+
// Rendu d'un jeu de textes de fin personnalisé (titre ancré en haut,
|
|
204
|
+
// items centrés verticalement, icônes à la couleur du bouton du journey).
|
|
205
|
+
var renderCustomCase = function (config, fallbackTitle) {
|
|
206
|
+
var _a;
|
|
207
|
+
return (jsxs("div", { className: "flex flex-1 flex-col items-center h-full px-4 pt-10 pb-8 md:px-8", children: [jsx(Title, { className: "text-2xl md:text-3xl text-center", children: ((_a = config.title) === null || _a === void 0 ? void 0 : _a.trim()) || fallbackTitle }), jsx("div", { className: "flex flex-1 items-center w-full max-w-md mx-auto", children: jsx("div", { className: "flex w-full flex-col items-start gap-7 -translate-y-20 ".concat(desktopTranslateX), children: config.items.map(function (item, index) {
|
|
208
|
+
var Icon = resolveEndScreenIcon(item.icon);
|
|
209
|
+
return (jsxs("div", { className: "flex w-full items-center gap-4 text-left", children: [jsx(Icon, { className: "w-7 h-7 shrink-0", style: { color: ICON_COLOR } }), jsx("span", { className: "flex-1 text-base md:text-lg text-[#3C3C40]", children: item.text })] }, index));
|
|
210
|
+
}) }) })] }));
|
|
211
|
+
};
|
|
212
|
+
var hasCustomError = !!((_b = nonCompliantCase === null || nonCompliantCase === void 0 ? void 0 : nonCompliantCase.items) === null || _b === void 0 ? void 0 : _b.length);
|
|
213
|
+
var hasCustomSuccess = !!((_c = compliantCase === null || compliantCase === void 0 ? void 0 : compliantCase.items) === null || _c === void 0 ? void 0 : _c.length);
|
|
214
|
+
// En attente du verdict backend : éviter le flash de l'écran succès.
|
|
215
|
+
if (isResolving) {
|
|
216
|
+
return (jsx(LoadingState, { message: t("session.end.finalizing", "Finalisation du parcours..."), subtitle: "" }));
|
|
217
|
+
}
|
|
168
218
|
return (jsx(MobilePageLayout, { footer: jsx(PageActions, { primary: jsx(Button, { onClick: handleEndSession, disabled: isEnding || isRedirecting, children: isRedirecting
|
|
169
219
|
? t("session.end.button_redirecting", "Redirection...")
|
|
170
220
|
: isEnding
|
|
171
221
|
? t("session.end.button_finalizing", "Finalisation...")
|
|
172
|
-
: t("session.end.button_end", "Terminer") }) }), children:
|
|
222
|
+
: t("session.end.button_end", "Terminer") }) }), children: isError ? (hasCustomError ? (renderCustomCase(nonCompliantCase, t("session.end.error_title", "Les prochaines étapes"))) : (jsxs("div", { className: "flex flex-1 flex-col items-center h-full px-4 pt-10 pb-8 md:px-8", children: [jsx(Title, { className: "text-2xl md:text-3xl text-center", children: t("session.end.error_title", "Les prochaines étapes") }), jsx("div", { className: "flex flex-1 items-center w-full max-w-md mx-auto", children: jsx("div", { className: "flex w-full flex-col items-start gap-7 -translate-y-20 ".concat(desktopTranslateX), children: [
|
|
223
|
+
{
|
|
224
|
+
Icon: HeartHandshake,
|
|
225
|
+
key: "session.end.error_step_thanks",
|
|
226
|
+
fallback: "Nous vous remercions pour ces informations",
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
Icon: Send,
|
|
230
|
+
key: "session.end.error_step_transmitted",
|
|
231
|
+
fallback: "Votre dossier a été transmis à notre équipe",
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
Icon: Mail,
|
|
235
|
+
key: "session.end.error_step_contact",
|
|
236
|
+
fallback: "Nous vous recontacterons si nécessaire",
|
|
237
|
+
},
|
|
238
|
+
].map(function (_a) {
|
|
239
|
+
var Icon = _a.Icon, key = _a.key, fallback = _a.fallback;
|
|
240
|
+
return (jsxs("div", { className: "flex w-full items-center gap-4 text-left", children: [jsx(Icon, { className: "w-7 h-7 shrink-0", style: { color: ICON_COLOR } }), jsx("span", { className: "flex-1 text-base md:text-lg text-[#3C3C40]", children: t(key, fallback) })] }, key));
|
|
241
|
+
}) }) })] }))) : hasCustomSuccess ? (renderCustomCase(compliantCase, t("session.end.title", "C'est tout bon !"))) : (jsx("div", { className: "flex flex-1 flex-col items-center justify-center h-full px-4 py-8 md:px-8", children: jsxs("div", { className: "w-full max-w-md mx-auto text-center space-y-6", children: [jsx("div", { className: "flex justify-center", children: jsx("img", { src: img, alt: t("session.end.image_alt", "Vérification terminée"), className: "w-48 h-48" }) }), jsxs("div", { className: "space-y-4", children: [jsx(Title, { className: "text-xl md:text-2xl lg:text-3xl", children: t("session.end.title", "C'est tout bon !") }), jsx(Subtitle, { className: "text-sm md:text-base text-gray-600 leading-relaxed", children: t("session.end.subtitle", "Merci d'avoir terminé ce parcours, vous pouvez quitter cette fenêtre.") })] })] }) })) }));
|
|
173
242
|
};
|
|
174
243
|
|
|
175
244
|
export { EndFlow as default };
|