datakeen-session-react 1.1.140-rc.86 → 1.1.140-rc.88
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/.gitlab-ci.yml +115 -46
- package/dist/cjs/components/document-collection/DocumentCollection.js +3 -1
- package/dist/cjs/components/document-collection/DocumentCollection.js.map +1 -1
- package/dist/cjs/components/document-collection/DocumentError.js +1 -1
- package/dist/cjs/components/document-collection/DocumentError.js.map +1 -1
- package/dist/cjs/components/jdi/JDIError.js +1 -1
- package/dist/cjs/components/jdi/JDIError.js.map +1 -1
- package/dist/cjs/components/session/DocumentCheck.js +3 -1
- package/dist/cjs/components/session/DocumentCheck.js.map +1 -1
- package/dist/cjs/components/session/Selfie.js +3 -1
- package/dist/cjs/components/session/Selfie.js.map +1 -1
- package/dist/cjs/components/session/UserInputForm/LegalRepFields.js +5 -1
- package/dist/cjs/components/session/UserInputForm/LegalRepFields.js.map +1 -1
- package/dist/cjs/components/signature-electronic/SignatureElectronic.js +7 -4
- package/dist/cjs/components/signature-electronic/SignatureElectronic.js.map +1 -1
- package/dist/cjs/components/signature-electronic/SignedDocumentPreview.js +60 -37
- package/dist/cjs/components/signature-electronic/SignedDocumentPreview.js.map +1 -1
- package/dist/cjs/components/template/ExternalVerificationNodeHandler.js +74 -36
- package/dist/cjs/components/template/ExternalVerificationNodeHandler.js.map +1 -1
- package/dist/cjs/constants/userInputForm.js.map +1 -1
- package/dist/cjs/hooks/useUserInputForm.js +11 -1
- package/dist/cjs/hooks/useUserInputForm.js.map +1 -1
- package/dist/cjs/index.css.js +1 -1
- package/dist/cjs/types/session.js.map +1 -1
- package/dist/esm/components/document-collection/DocumentCollection.js +3 -1
- package/dist/esm/components/document-collection/DocumentCollection.js.map +1 -1
- package/dist/esm/components/document-collection/DocumentError.js +1 -1
- package/dist/esm/components/document-collection/DocumentError.js.map +1 -1
- package/dist/esm/components/jdi/JDIError.js +1 -1
- package/dist/esm/components/jdi/JDIError.js.map +1 -1
- package/dist/esm/components/session/DocumentCheck.js +3 -1
- package/dist/esm/components/session/DocumentCheck.js.map +1 -1
- package/dist/esm/components/session/Selfie.js +3 -1
- package/dist/esm/components/session/Selfie.js.map +1 -1
- package/dist/esm/components/session/UserInputForm/LegalRepFields.js +5 -1
- package/dist/esm/components/session/UserInputForm/LegalRepFields.js.map +1 -1
- package/dist/esm/components/signature-electronic/SignatureElectronic.js +7 -4
- package/dist/esm/components/signature-electronic/SignatureElectronic.js.map +1 -1
- package/dist/esm/components/signature-electronic/SignedDocumentPreview.js +61 -38
- package/dist/esm/components/signature-electronic/SignedDocumentPreview.js.map +1 -1
- package/dist/esm/components/template/ExternalVerificationNodeHandler.js +75 -37
- package/dist/esm/components/template/ExternalVerificationNodeHandler.js.map +1 -1
- package/dist/esm/constants/userInputForm.js.map +1 -1
- package/dist/esm/hooks/useUserInputForm.js +11 -1
- package/dist/esm/hooks/useUserInputForm.js.map +1 -1
- package/dist/esm/index.css.js +1 -1
- package/dist/esm/types/session.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignatureElectronic.js","sources":["../../../../../src/components/signature-electronic/SignatureElectronic.tsx"],"sourcesContent":["import React, { useState, useMemo, useEffect } from \"react\";\nimport type { stepObject, SessionTemplateNode, SessionData } from \"../../types/session\";\nimport type { UserInput } from \"../../types/userInput\";\nimport type { ContactInfo } from \"../../types/contactInfo\";\nimport { useTranslation } from \"react-i18next\";\nimport sdkI18n from \"../../i18n\";\nimport SignatureElectronicIntroduction from \"./SignatureElectronicIntroduction\";\nimport DocusealSignature from \"./DocusealSignature\";\nimport SignedDocumentPreview from \"./SignedDocumentPreview\";\nimport { updateSessionStatus } from \"../../services/sessionService\";\n\n/**\n * Maps an InformationFieldKey (journey field) to the corresponding UserInput key.\n * This bridges the admin-defined field names to the actual data collected in the SDK.\n */\nconst FIELD_KEY_TO_USER_INPUT: Record<string, (ui: UserInput, ci?: ContactInfo) => string | undefined> = {\n nom: (ui) => ui.lastName,\n denomination_sociale: (ui) => ui.companyName,\n prenom: (ui) => ui.firstName,\n date_naissance: (ui) => ui.birthDate,\n email: (ui, ci) => ui.email || ci?.email,\n sms: (ui, ci) => ui.sms || ui.phoneNumber || ci?.phoneNumber,\n adresse: (ui) => [ui.addressLine1, ui.addressLine2, ui.postalCode, ui.city, ui.countryCode].filter(Boolean).join(', '),\n nationalite: (ui) => ui.nationality,\n siret: (ui) => ui.siret,\n tva: (ui) => ui.tva,\n};\n\ninterface SignatureElectronicProps {\n sessionId: string;\n stepObject: stepObject;\n node: SessionTemplateNode;\n session: SessionData;\n title?: string;\n description?: string;\n external_id?: string;\n fieldMappings?: SessionTemplateNode['fieldMappings'];\n userInput?: UserInput;\n contactInfo?: ContactInfo;\n}\n\nconst SignatureElectronic: React.FC<SignatureElectronicProps> = ({\n sessionId,\n stepObject,\n node,\n session,\n title,\n description,\n external_id,\n fieldMappings,\n userInput,\n contactInfo,\n}) => {\n const { t } = useTranslation(\"translation\", { i18n: sdkI18n });\n const signatureViewStorageKey = useMemo(() => `dk-signature-open:${sessionId}:${external_id ?? \"no-template\"}`, [sessionId, external_id]);\n const [showSignature, setShowSignature] = useState<boolean>(() => {\n if (typeof window === \"undefined\") return false;\n return window.sessionStorage.getItem(signatureViewStorageKey) === \"1\";\n });\n const [showSignedDocumentPreview, setShowSignedDocumentPreview] = useState<boolean>(false);\n\n useEffect(() => {\n if (typeof window === \"undefined\") return;\n\n if (showSignature) {\n window.sessionStorage.setItem(signatureViewStorageKey, \"1\");\n } else {\n window.sessionStorage.removeItem(signatureViewStorageKey);\n }\n }, [showSignature, signatureViewStorageKey]);\n\n /**\n * Build the pre-fill values object from userInput + fieldMappings.\n * Maps each configured field to its value from userInput.\n * Used by DocusealForm's `values` prop for client-side pre-filling.\n */\n const prefillValues = useMemo<Record<string, string> | undefined>(() => {\n if (!fieldMappings || !userInput) return undefined;\n\n const values: Record<string, string> = {};\n\n fieldMappings.forEach(mapping => {\n const resolver = FIELD_KEY_TO_USER_INPUT[mapping.sourceFieldId];\n let value: string | undefined;\n\n if (resolver) {\n value = resolver(userInput, contactInfo);\n } else if (userInput.customFormData) {\n const raw = userInput.customFormData[mapping.sourceFieldId];\n value = raw != null ? String(raw) : undefined;\n }\n\n if (value !== undefined && value !== '') {\n values[mapping.sourceFieldId] = value;\n }\n });\n\n return Object.keys(values).length > 0 ? values : undefined;\n }, [fieldMappings, userInput, contactInfo]);\n\n /**\n * Build the list of field names that should be read-only in the signing form.\n * Only includes fields that are both mapped AND marked as readonly by the admin.\n */\n const readonlyFieldNames = useMemo<string[] | undefined>(() => {\n if (!fieldMappings) return undefined;\n\n const names = fieldMappings\n .filter(m => m.readonly)\n .map(m => m.sourceFieldId);\n\n return names.length > 0 ? names : undefined;\n }, [fieldMappings]);\n\n const handleContinue = () => {\n setShowSignature(true);\n };\n\n const handleComplete = async () => {\n if (typeof window !== \"undefined\") {\n window.sessionStorage.removeItem(signatureViewStorageKey);\n }\n try {\n await updateSessionStatus(sessionId, \"conform\");\n } catch (err) {\n console.error(\"[SignatureElectronic] Failed to update session status:\", err);\n // Non-bloquant : l'utilisateur avance quoi qu'il arrive\n }\n // Toujours montrer le document réellement signé avant de continuer\n // (rassure l'utilisateur — pas de bascule directe vers l'étape suivante).\n setShowSignedDocumentPreview(true);\n };\n\n const handleContinueFromPreview = () => {\n // Progress to the next step via graph edges (pas d'arithmétique — évite de sauter dans la mauvaise branche)\n stepObject.goToNextStep(node.id, session.template);\n };\n\n const handleBack = () => {\n if (showSignature) {\n setShowSignature(false);\n } else {\n if (typeof window !== \"undefined\") {\n window.sessionStorage.removeItem(signatureViewStorageKey);\n }\n stepObject.goBack();\n }\n };\n\n if (showSignedDocumentPreview) {\n return (\n <SignedDocumentPreview\n sessionId={sessionId}\n nodeId={node.id}\n onContinue={handleContinueFromPreview}\n />\n );\n }\n\n if (showSignature && external_id) {\n return (\n <DocusealSignature\n sessionId={sessionId}\n templateId={external_id}\n templateName={title}\n onComplete={handleComplete}\n onBack={handleBack}\n prefillValues={prefillValues}\n readonlyFieldNames={readonlyFieldNames}\n />\n );\n }\n\n if (showSignature && !external_id) {\n // No template configured — show error instead of silently falling back to intro\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(\"signature.error_title\", \"Erreur\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">\n {t(\"signature.no_template\", \"Le modèle de signature n'est pas configuré.\")}\n </p>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={handleBack}\n >\n {t(\"buttons.back\", \"Retour\")}\n </button>\n </div>\n );\n }\n\n return (\n <SignatureElectronicIntroduction\n onContinue={handleContinue}\n onBack={handleBack}\n title={title}\n description={description}\n />\n );\n};\n\nexport default SignatureElectronic;\n"],"names":["useTranslation","sdkI18n","useMemo","useState","useEffect","__awaiter","updateSessionStatus","_jsx","SignedDocumentPreview","DocusealSignature","_jsxs","SignatureElectronicIntroduction"],"mappings":";;;;;;;;;;;;;;AAWA;;;AAGG;AACH,IAAM,uBAAuB,GAA4E;IACrG,GAAG,EAAE,UAAC,EAAE,EAAA,EAAK,OAAA,EAAE,CAAC,QAAQ,CAAA,CAAX,CAAW;IACxB,oBAAoB,EAAE,UAAC,EAAE,EAAA,EAAK,OAAA,EAAE,CAAC,WAAW,CAAA,CAAd,CAAc;IAC5C,MAAM,EAAE,UAAC,EAAE,EAAA,EAAK,OAAA,EAAE,CAAC,SAAS,CAAA,CAAZ,CAAY;IAC5B,cAAc,EAAE,UAAC,EAAE,EAAA,EAAK,OAAA,EAAE,CAAC,SAAS,CAAA,CAAZ,CAAY;IACpC,KAAK,EAAE,UAAC,EAAE,EAAE,EAAE,EAAA,EAAK,OAAA,EAAE,CAAC,KAAK,KAAI,EAAE,KAAA,IAAA,IAAF,EAAE,KAAA,MAAA,GAA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c,EAC1B,MAAM,EAAE,UAAU,EAClB,aAAa,EAAE,aAAa,EAC5B,kBAAkB,EAAE,kBAAkB,EAAA,CACxC;IAEV;AAEA,IAAA,IAAI,aAAa,IAAI,CAAC,WAAW,EAAE;;QAE/B,QACIC,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,kEAAkE,EAAA,QAAA,EAAA,CAC7EH,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,4BAA4B,EAAA,QAAA,EAAA,cAAA,EAAA,CAAS,EACpDA,cAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAC,qCAAqC,EAAA,QAAA,EAC9C,CAAC,CAAC,uBAAuB,EAAE,QAAQ,CAAC,EAAA,CACpC,EACLA,cAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAC5B,CAAC,CAAC,uBAAuB,EAAE,6CAA6C,CAAC,EAAA,CAC1E,EACJA,cAAA,CAAA,QAAA,EAAA,EACI,SAAS,EAAC,iFAAiF,EAC3F,OAAO,EAAE,UAAU,EAAA,QAAA,EAElB,CAAC,CAAC,cAAc,EAAE,QAAQ,CAAC,EAAA,CACvB,CAAA,EAAA,CACP;IAEd;IAEA,QACIA,eAACI,uCAA+B,EAAA,EAC5B,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EAAA,CAC1B;AAEV;;;;"}
|
|
1
|
+
{"version":3,"file":"SignatureElectronic.js","sources":["../../../../../src/components/signature-electronic/SignatureElectronic.tsx"],"sourcesContent":["import React, { useState, useMemo, useEffect } from \"react\";\nimport type { stepObject, SessionTemplateNode, SessionData } from \"../../types/session\";\nimport type { UserInput } from \"../../types/userInput\";\nimport type { ContactInfo } from \"../../types/contactInfo\";\nimport { useTranslation } from \"react-i18next\";\nimport sdkI18n from \"../../i18n\";\nimport SignatureElectronicIntroduction from \"./SignatureElectronicIntroduction\";\nimport DocusealSignature from \"./DocusealSignature\";\nimport SignedDocumentPreview from \"./SignedDocumentPreview\";\nimport { updateSessionStatus } from \"../../services/sessionService\";\n\n/**\n * Maps an InformationFieldKey (journey field) to the corresponding UserInput key.\n * This bridges the admin-defined field names to the actual data collected in the SDK.\n */\nconst FIELD_KEY_TO_USER_INPUT: Record<string, (ui: UserInput, ci?: ContactInfo) => string | undefined> = {\n nom: (ui) => ui.lastName,\n denomination_sociale: (ui) => ui.companyName,\n prenom: (ui) => ui.firstName,\n date_naissance: (ui) => ui.birthDate,\n email: (ui, ci) => ui.email || ci?.email,\n sms: (ui, ci) => ui.sms || ui.phoneNumber || ci?.phoneNumber,\n adresse: (ui) => [ui.addressLine1, ui.addressLine2, ui.postalCode, ui.city, ui.countryCode].filter(Boolean).join(', '),\n nationalite: (ui) => ui.nationality,\n siret: (ui) => ui.siret,\n tva: (ui) => ui.tva,\n};\n\ninterface SignatureElectronicProps {\n sessionId: string;\n stepObject: stepObject;\n node: SessionTemplateNode;\n session: SessionData;\n title?: string;\n description?: string;\n external_id?: string;\n fieldMappings?: SessionTemplateNode['fieldMappings'];\n userInput?: UserInput;\n contactInfo?: ContactInfo;\n}\n\nconst SignatureElectronic: React.FC<SignatureElectronicProps> = ({\n sessionId,\n stepObject,\n node,\n session,\n title,\n description,\n external_id,\n fieldMappings,\n userInput,\n contactInfo,\n}) => {\n const { t } = useTranslation(\"translation\", { i18n: sdkI18n });\n const signatureViewStorageKey = useMemo(() => `dk-signature-open:${sessionId}:${external_id ?? \"no-template\"}`, [sessionId, external_id]);\n const [showSignature, setShowSignature] = useState<boolean>(() => {\n if (typeof window === \"undefined\") return false;\n return window.sessionStorage.getItem(signatureViewStorageKey) === \"1\";\n });\n const [showSignedDocumentPreview, setShowSignedDocumentPreview] = useState<boolean>(false);\n const [signedAt, setSignedAt] = useState<string | null>(null);\n\n useEffect(() => {\n if (typeof window === \"undefined\") return;\n\n if (showSignature) {\n window.sessionStorage.setItem(signatureViewStorageKey, \"1\");\n } else {\n window.sessionStorage.removeItem(signatureViewStorageKey);\n }\n }, [showSignature, signatureViewStorageKey]);\n\n /**\n * Build the pre-fill values object from userInput + fieldMappings.\n * Maps each configured field to its value from userInput.\n * Used by DocusealForm's `values` prop for client-side pre-filling.\n */\n const prefillValues = useMemo<Record<string, string> | undefined>(() => {\n if (!fieldMappings || !userInput) return undefined;\n\n const values: Record<string, string> = {};\n\n fieldMappings.forEach(mapping => {\n const resolver = FIELD_KEY_TO_USER_INPUT[mapping.sourceFieldId];\n let value: string | undefined;\n\n if (resolver) {\n value = resolver(userInput, contactInfo);\n } else if (userInput.customFormData) {\n const raw = userInput.customFormData[mapping.sourceFieldId];\n value = raw != null ? String(raw) : undefined;\n }\n\n if (value !== undefined && value !== '') {\n values[mapping.sourceFieldId] = value;\n }\n });\n\n return Object.keys(values).length > 0 ? values : undefined;\n }, [fieldMappings, userInput, contactInfo]);\n\n /**\n * Build the list of field names that should be read-only in the signing form.\n * Only includes fields that are both mapped AND marked as readonly by the admin.\n */\n const readonlyFieldNames = useMemo<string[] | undefined>(() => {\n if (!fieldMappings) return undefined;\n\n const names = fieldMappings\n .filter(m => m.readonly)\n .map(m => m.sourceFieldId);\n\n return names.length > 0 ? names : undefined;\n }, [fieldMappings]);\n\n const handleContinue = () => {\n setShowSignature(true);\n };\n\n const handleComplete = async () => {\n if (typeof window !== \"undefined\") {\n window.sessionStorage.removeItem(signatureViewStorageKey);\n }\n try {\n await updateSessionStatus(sessionId, \"conform\");\n } catch (err) {\n console.error(\"[SignatureElectronic] Failed to update session status:\", err);\n // Non-bloquant : l'utilisateur avance quoi qu'il arrive\n }\n // Toujours montrer le document réellement signé avant de continuer\n // (rassure l'utilisateur — pas de bascule directe vers l'étape suivante).\n setSignedAt(new Date().toISOString());\n setShowSignedDocumentPreview(true);\n };\n\n const handleContinueFromPreview = () => {\n // Progress to the next step via graph edges (pas d'arithmétique — évite de sauter dans la mauvaise branche)\n stepObject.goToNextStep(node.id, session.template);\n };\n\n const handleBack = () => {\n if (showSignature) {\n setShowSignature(false);\n } else {\n if (typeof window !== \"undefined\") {\n window.sessionStorage.removeItem(signatureViewStorageKey);\n }\n stepObject.goBack();\n }\n };\n\n if (showSignedDocumentPreview) {\n return (\n <SignedDocumentPreview\n sessionId={sessionId}\n nodeId={node.id}\n nodeTitle={node.pageTitle || node.title}\n completedAt={signedAt}\n logo={session?.template?.logo}\n onContinue={handleContinueFromPreview}\n />\n );\n }\n\n if (showSignature && external_id) {\n return (\n <DocusealSignature\n sessionId={sessionId}\n templateId={external_id}\n templateName={title}\n onComplete={handleComplete}\n onBack={handleBack}\n prefillValues={prefillValues}\n readonlyFieldNames={readonlyFieldNames}\n />\n );\n }\n\n if (showSignature && !external_id) {\n // No template configured — show error instead of silently falling back to intro\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(\"signature.error_title\", \"Erreur\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">\n {t(\"signature.no_template\", \"Le modèle de signature n'est pas configuré.\")}\n </p>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={handleBack}\n >\n {t(\"buttons.back\", \"Retour\")}\n </button>\n </div>\n );\n }\n\n return (\n <SignatureElectronicIntroduction\n onContinue={handleContinue}\n onBack={handleBack}\n title={title}\n description={description}\n />\n );\n};\n\nexport default SignatureElectronic;\n"],"names":["useTranslation","sdkI18n","useMemo","useState","useEffect","__awaiter","updateSessionStatus","_jsx","SignedDocumentPreview","DocusealSignature","_jsxs","SignatureElectronicIntroduction"],"mappings":";;;;;;;;;;;;;;AAWA;;;AAGG;AACH,IAAM,uBAAuB,GAA4E;IACrG,GAAG,EAAE,UAAC,EAAE,EAAA,EAAK,OAAA,EAAE,CAAC,QAAQ,CAAA,CAAX,CAAW;IACxB,oBAAoB,EAAE,UAAC,EAAE,EAAA,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AAA,EAAG,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAC5B,CAAC,CAAC,uBAAuB,EAAE,6CAA6C,CAAC,EAAA,CAC1E,EACJA,cAAA,CAAA,QAAA,EAAA,EACI,SAAS,EAAC,iFAAiF,EAC3F,OAAO,EAAE,UAAU,EAAA,QAAA,EAElB,CAAC,CAAC,cAAc,EAAE,QAAQ,CAAC,EAAA,CACvB,CAAA,EAAA,CACP;IAEd;IAEA,QACIA,eAACI,uCAA+B,EAAA,EAC5B,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EAAA,CAC1B;AAEV;;;;"}
|
|
@@ -5,38 +5,45 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var tslib_es6 = require('../../node_modules/tslib/tslib.es6.js');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var React = require('react');
|
|
8
|
+
var lucideReact = require('lucide-react');
|
|
8
9
|
var reactI18next = require('react-i18next');
|
|
9
10
|
var index = require('../../i18n/index.js');
|
|
10
11
|
var api = require('../../services/api.js');
|
|
11
12
|
var LoadingState = require('../states/LoadingState.js');
|
|
12
|
-
var PDFPreview = require('../ui/PDFPreview.js');
|
|
13
13
|
var MobilePageLayout = require('../ui/MobilePageLayout.js');
|
|
14
14
|
var PageActions = require('../ui/PageActions.js');
|
|
15
15
|
var Button = require('../ui/Button.js');
|
|
16
16
|
|
|
17
17
|
var STATUS_POLL_INTERVAL_MS = 2000;
|
|
18
|
-
|
|
18
|
+
// DocuSeal flags a submission "completed" before generating the flattened
|
|
19
|
+
// signed PDF — 15 attempts (30s) leaves enough margin for that async step.
|
|
20
|
+
var MAX_STATUS_POLL_ATTEMPTS = 15;
|
|
19
21
|
var SignedDocumentPreview = function (_a) {
|
|
20
|
-
var sessionId = _a.sessionId, nodeId = _a.nodeId, onContinue = _a.onContinue;
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var
|
|
22
|
+
var sessionId = _a.sessionId, nodeId = _a.nodeId, nodeTitle = _a.nodeTitle, completedAt = _a.completedAt, logo = _a.logo, onContinue = _a.onContinue;
|
|
23
|
+
var _b = reactI18next.useTranslation("translation", { i18n: index.default }), t = _b.t, i18n = _b.i18n;
|
|
24
|
+
var _c = React.useState("polling"), status = _c[0], setStatus = _c[1];
|
|
25
|
+
var _d = React.useState(null), viewUrl = _d[0], setViewUrl = _d[1];
|
|
24
26
|
var cancelledRef = React.useRef(false);
|
|
25
27
|
React.useEffect(function () {
|
|
26
28
|
cancelledRef.current = false;
|
|
27
29
|
var attempts = 0;
|
|
28
30
|
var timer;
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
var fetchAccessLink = function () { return tslib_es6.__awaiter(void 0, void 0, void 0, function () {
|
|
32
|
+
var response, token, baseURL, path;
|
|
33
|
+
var _a, _b;
|
|
34
|
+
return tslib_es6.__generator(this, function (_c) {
|
|
35
|
+
switch (_c.label) {
|
|
36
|
+
case 0: return [4 /*yield*/, api.apiService.get("/session/sdk/".concat(sessionId, "/signed-document/").concat(nodeId, "/access-link"))];
|
|
34
37
|
case 1:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
response = _c.sent();
|
|
39
|
+
token = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.token;
|
|
40
|
+
if (!token) {
|
|
41
|
+
throw new Error("Missing signed document access token");
|
|
42
|
+
}
|
|
43
|
+
baseURL = (api.apiService.getRawClient().defaults.baseURL || "").replace(/\/+$/, "");
|
|
44
|
+
path = "/session/sdk/".concat(sessionId, "/signed-document/").concat(nodeId, "/view?token=").concat(token);
|
|
38
45
|
if (!cancelledRef.current) {
|
|
39
|
-
|
|
46
|
+
setViewUrl(baseURL ? "".concat(baseURL).concat(path) : path);
|
|
40
47
|
setStatus("ready");
|
|
41
48
|
}
|
|
42
49
|
return [2 /*return*/];
|
|
@@ -44,28 +51,49 @@ var SignedDocumentPreview = function (_a) {
|
|
|
44
51
|
});
|
|
45
52
|
}); };
|
|
46
53
|
var poll = function () { return tslib_es6.__awaiter(void 0, void 0, void 0, function () {
|
|
47
|
-
var statusResponse, ready, error, err_1;
|
|
54
|
+
var statusResponse, ready, error, err_1, err_2;
|
|
48
55
|
var _a, _b, _c, _d;
|
|
49
56
|
return tslib_es6.__generator(this, function (_e) {
|
|
50
57
|
switch (_e.label) {
|
|
51
58
|
case 0:
|
|
52
|
-
_e.trys.push([0,
|
|
59
|
+
_e.trys.push([0, 6, , 7]);
|
|
53
60
|
return [4 /*yield*/, api.apiService.get("/session/sdk/".concat(sessionId, "/signed-document/").concat(nodeId, "/status"))];
|
|
54
61
|
case 1:
|
|
55
62
|
statusResponse = _e.sent();
|
|
56
63
|
ready = !!((_b = (_a = statusResponse.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.ready);
|
|
57
64
|
error = (_d = (_c = statusResponse.data) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.error;
|
|
58
|
-
if (
|
|
59
|
-
|
|
65
|
+
if (error === "declined" || error === "expired") {
|
|
66
|
+
if (!cancelledRef.current)
|
|
67
|
+
setStatus(error);
|
|
68
|
+
return [2 /*return*/];
|
|
69
|
+
}
|
|
70
|
+
if (!ready) return [3 /*break*/, 5];
|
|
71
|
+
_e.label = 2;
|
|
60
72
|
case 2:
|
|
73
|
+
_e.trys.push([2, 4, , 5]);
|
|
74
|
+
return [4 /*yield*/, fetchAccessLink()];
|
|
75
|
+
case 3:
|
|
61
76
|
_e.sent();
|
|
62
77
|
return [2 /*return*/];
|
|
63
|
-
case
|
|
64
|
-
|
|
78
|
+
case 4:
|
|
79
|
+
err_1 = _e.sent();
|
|
80
|
+
// DocuSeal can report the submission "completed" before the
|
|
81
|
+
// signed document is actually linked — treat like "not ready
|
|
82
|
+
// yet" instead of failing permanently on the first miss.
|
|
83
|
+
console.error("[SignedDocumentPreview] Failed to fetch access link:", err_1);
|
|
84
|
+
return [3 /*break*/, 5];
|
|
85
|
+
case 5:
|
|
86
|
+
attempts += 1;
|
|
87
|
+
if (attempts >= MAX_STATUS_POLL_ATTEMPTS) {
|
|
65
88
|
if (!cancelledRef.current)
|
|
66
|
-
setStatus(error);
|
|
89
|
+
setStatus("error");
|
|
67
90
|
return [2 /*return*/];
|
|
68
91
|
}
|
|
92
|
+
timer = setTimeout(poll, STATUS_POLL_INTERVAL_MS);
|
|
93
|
+
return [3 /*break*/, 7];
|
|
94
|
+
case 6:
|
|
95
|
+
err_2 = _e.sent();
|
|
96
|
+
console.error("[SignedDocumentPreview] Failed to poll signed document status:", err_2);
|
|
69
97
|
attempts += 1;
|
|
70
98
|
if (attempts >= MAX_STATUS_POLL_ATTEMPTS) {
|
|
71
99
|
if (!cancelledRef.current)
|
|
@@ -73,14 +101,8 @@ var SignedDocumentPreview = function (_a) {
|
|
|
73
101
|
return [2 /*return*/];
|
|
74
102
|
}
|
|
75
103
|
timer = setTimeout(poll, STATUS_POLL_INTERVAL_MS);
|
|
76
|
-
return [3 /*break*/,
|
|
77
|
-
case
|
|
78
|
-
err_1 = _e.sent();
|
|
79
|
-
console.error("[SignedDocumentPreview] Failed to load signed document:", err_1);
|
|
80
|
-
if (!cancelledRef.current)
|
|
81
|
-
setStatus("error");
|
|
82
|
-
return [3 /*break*/, 5];
|
|
83
|
-
case 5: return [2 /*return*/];
|
|
104
|
+
return [3 /*break*/, 7];
|
|
105
|
+
case 7: return [2 /*return*/];
|
|
84
106
|
}
|
|
85
107
|
});
|
|
86
108
|
}); };
|
|
@@ -91,16 +113,17 @@ var SignedDocumentPreview = function (_a) {
|
|
|
91
113
|
clearTimeout(timer);
|
|
92
114
|
};
|
|
93
115
|
}, [sessionId, nodeId]);
|
|
94
|
-
React.useEffect(function () {
|
|
95
|
-
return function () {
|
|
96
|
-
if (pdfSrc)
|
|
97
|
-
URL.revokeObjectURL(pdfSrc);
|
|
98
|
-
};
|
|
99
|
-
}, [pdfSrc]);
|
|
100
116
|
if (status === "polling") {
|
|
101
117
|
return (jsxRuntime.jsx(LoadingState.default, { message: t("signed_document.loading", "Préparation du document signé..."), subtitle: "" }));
|
|
102
118
|
}
|
|
103
|
-
|
|
119
|
+
var formattedDate = completedAt
|
|
120
|
+
? new Intl.DateTimeFormat(i18n.language || "fr", {
|
|
121
|
+
day: "numeric",
|
|
122
|
+
month: "long",
|
|
123
|
+
year: "numeric",
|
|
124
|
+
}).format(new Date(completedAt))
|
|
125
|
+
: null;
|
|
126
|
+
return (jsxRuntime.jsx(MobilePageLayout.default, { footer: jsxRuntime.jsx(PageActions.default, { primary: jsxRuntime.jsx(Button.default, { onClick: onContinue, type: "button", children: t("buttons.continue", "Continuer") }) }), children: jsxRuntime.jsxs("div", { className: "flex flex-col items-center h-full px-4 py-8 md:px-8 text-center gap-6", children: [logo && jsxRuntime.jsx("img", { src: logo, alt: "", className: "h-12 max-w-[200px] object-contain" }), status === "ready" && viewUrl && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "w-full max-w-md bg-gray-50 rounded-lg p-4 flex items-start gap-3 text-left", children: [jsxRuntime.jsx(lucideReact.PenTool, { className: "w-5 h-5 shrink-0 mt-0.5 text-gray-500" }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("p", { className: "font-semibold text-gray-900 break-all", children: nodeTitle }), formattedDate && (jsxRuntime.jsxs("p", { className: "text-xs text-gray-500 mt-1", children: [t("signed_document.submitted_on", "Soumis le"), " ", formattedDate] }))] })] }), jsxRuntime.jsx("p", { className: "text-sm text-gray-600", children: t("signed_document.ready_text", "Merci d'avoir signé le document, vous pouvez le consulter en cliquant ci-dessous :") }), jsxRuntime.jsx("a", { href: viewUrl, target: "_blank", rel: "noopener noreferrer", className: "text-primary underline font-medium", children: t("signed_document.view_link", "Consulter le document ↗") })] })), status === "error" && (jsxRuntime.jsx("p", { className: "text-sm text-gray-600 py-8", children: t("signed_document.error", "Le document n'a pas pu être chargé, mais votre signature est bien enregistrée. Vous pouvez continuer.") })), status === "declined" && (jsxRuntime.jsx("p", { className: "text-sm text-gray-600 py-8", children: t("signed_document.declined", "Vous avez refusé de signer ce document.") })), status === "expired" && (jsxRuntime.jsx("p", { className: "text-sm text-gray-600 py-8", children: t("signed_document.expired", "Le lien de signature a expiré.") }))] }) }));
|
|
104
127
|
};
|
|
105
128
|
|
|
106
129
|
exports.default = SignedDocumentPreview;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignedDocumentPreview.js","sources":["../../../../../src/components/signature-electronic/SignedDocumentPreview.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport sdkI18n from \"../../i18n\";\nimport { apiService } from \"../../services/api\";\nimport LoadingState from \"../states/LoadingState\";\nimport PDFPreview from \"../ui/PDFPreview\";\nimport MobilePageLayout from \"../ui/MobilePageLayout\";\nimport PageActions from \"../ui/PageActions\";\nimport Button from \"../ui/Button\";\n\ninterface SignedDocumentPreviewProps {\n sessionId: string;\n nodeId: string;\n onContinue: () => void;\n}\n\nconst STATUS_POLL_INTERVAL_MS = 2000;\nconst MAX_STATUS_POLL_ATTEMPTS = 5;\n\nconst SignedDocumentPreview: React.FC<SignedDocumentPreviewProps> = ({\n sessionId,\n nodeId,\n onContinue,\n}) => {\n const { t } = useTranslation(\"translation\", { i18n: sdkI18n });\n const [status, setStatus] = useState<\"polling\" | \"ready\" | \"error\" | \"declined\" | \"expired\">(\n \"polling\",\n );\n const [pdfSrc, setPdfSrc] = useState<string | null>(null);\n const cancelledRef = useRef(false);\n\n useEffect(() => {\n cancelledRef.current = false;\n let attempts = 0;\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const fetchSignedDocument = async () => {\n const pdfResponse = await apiService.get(\n `/session/sdk/${sessionId}/signed-document/${nodeId}.pdf`,\n { responseType: \"arraybuffer\" },\n );\n const blob = new Blob([pdfResponse.data], { type: \"application/pdf\" });\n const url = URL.createObjectURL(blob);\n if (!cancelledRef.current) {\n setPdfSrc(url);\n setStatus(\"ready\");\n }\n };\n\n const poll = async () => {\n try {\n const statusResponse = await apiService.get(\n `/session/sdk/${sessionId}/signed-document/${nodeId}/status`,\n );\n const ready = !!statusResponse.data?.data?.ready;\n const error = statusResponse.data?.data?.error as\n | \"declined\"\n | \"expired\"\n | undefined;\n\n if (ready) {\n await fetchSignedDocument();\n return;\n }\n\n if (error === \"declined\" || error === \"expired\") {\n if (!cancelledRef.current) setStatus(error);\n return;\n }\n\n attempts += 1;\n if (attempts >= MAX_STATUS_POLL_ATTEMPTS) {\n if (!cancelledRef.current) setStatus(\"error\");\n return;\n }\n timer = setTimeout(poll, STATUS_POLL_INTERVAL_MS);\n } catch (err) {\n console.error(\"[SignedDocumentPreview] Failed to load signed document:\", err);\n if (!cancelledRef.current) setStatus(\"error\");\n }\n };\n\n poll();\n\n return () => {\n cancelledRef.current = true;\n if (timer) clearTimeout(timer);\n };\n }, [sessionId, nodeId]);\n\n useEffect(() => {\n return () => {\n if (pdfSrc) URL.revokeObjectURL(pdfSrc);\n };\n }, [pdfSrc]);\n\n if (status === \"polling\") {\n return (\n <LoadingState\n message={t(\"signed_document.loading\", \"Préparation du document signé...\")}\n subtitle=\"\"\n />\n );\n }\n\n return (\n <MobilePageLayout\n footer={\n <PageActions\n primary={\n <Button onClick={onContinue} type=\"button\">\n {t(\"buttons.continue\", \"Continuer\")}\n </Button>\n }\n />\n }\n >\n <div className=\"flex flex-col h-full px-4 py-4 md:px-8\">\n {status === \"ready\" && pdfSrc && (\n <PDFPreview src={pdfSrc} className=\"flex-1\" />\n )}\n {status === \"error\" && (\n <p className=\"text-sm text-gray-600 text-center py-8\">\n {t(\n \"signed_document.error\",\n \"Le document n'a pas pu être chargé, mais votre signature est bien enregistrée. Vous pouvez continuer.\",\n )}\n </p>\n )}\n {status === \"declined\" && (\n <p className=\"text-sm text-gray-600 text-center py-8\">\n {t(\n \"signed_document.declined\",\n \"Vous avez refusé de signer ce document.\",\n )}\n </p>\n )}\n {status === \"expired\" && (\n <p className=\"text-sm text-gray-600 text-center py-8\">\n {t(\n \"signed_document.expired\",\n \"Le lien de signature a expiré.\",\n )}\n </p>\n )}\n </div>\n </MobilePageLayout>\n );\n};\n\nexport default SignedDocumentPreview;\n"],"names":["useTranslation","sdkI18n","useState","useRef","useEffect","__awaiter","apiService","_jsx","LoadingState","MobilePageLayout","PageActions","Button","_jsxs","PDFPreview"],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAM,uBAAuB,GAAG,IAAI;AACpC,IAAM,wBAAwB,GAAG,CAAC;AAElC,IAAM,qBAAqB,GAAyC,UAAC,EAIpE,EAAA;AAHG,IAAA,IAAA,SAAS,eAAA,EACT,MAAM,GAAA,EAAA,CAAA,MAAA,EACN,UAAU,GAAA,EAAA,CAAA,UAAA;AAEF,IAAA,IAAA,CAAC,GAAKA,2BAAc,CAAC,aAAa,EAAE,EAAE,IAAI,EAAEC,aAAO,EAAE,CAAC,EAArD;IACH,IAAA,EAAA,GAAsBC,cAAQ,CAChC,SAAS,CACZ,EAFM,MAAM,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,SAAS,GAAA,EAAA,CAAA,CAAA,CAEvB;IACK,IAAA,EAAA,GAAsBA,cAAQ,CAAgB,IAAI,CAAC,EAAlD,MAAM,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,SAAS,GAAA,EAAA,CAAA,CAAA,CAAiC;AACzD,IAAA,IAAM,YAAY,GAAGC,YAAM,CAAC,KAAK,CAAC;AAElC,IAAAC,eAAS,CAAC,YAAA;AACN,QAAA,YAAY,CAAC,OAAO,GAAG,KAAK;QAC5B,IAAI,QAAQ,GAAG,CAAC;AAChB,QAAA,IAAI,KAAgD;AAEpD,QAAA,IAAM,mBAAmB,GAAG,YAAA,EAAA,OAAAC,mBAAA,CAAA,MAAA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AA,CACS;AAE3B;;;;"}
|
|
1
|
+
{"version":3,"file":"SignedDocumentPreview.js","sources":["../../../../../src/components/signature-electronic/SignedDocumentPreview.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { PenTool } from \"lucide-react\";\nimport { useTranslation } from \"react-i18next\";\nimport sdkI18n from \"../../i18n\";\nimport { apiService } from \"../../services/api\";\nimport LoadingState from \"../states/LoadingState\";\nimport MobilePageLayout from \"../ui/MobilePageLayout\";\nimport PageActions from \"../ui/PageActions\";\nimport Button from \"../ui/Button\";\n\ninterface SignedDocumentPreviewProps {\n sessionId: string;\n nodeId: string;\n nodeTitle: string;\n completedAt: string | null;\n logo?: string;\n onContinue: () => void;\n}\n\nconst STATUS_POLL_INTERVAL_MS = 2000;\n// DocuSeal flags a submission \"completed\" before generating the flattened\n// signed PDF — 15 attempts (30s) leaves enough margin for that async step.\nconst MAX_STATUS_POLL_ATTEMPTS = 15;\n\nconst SignedDocumentPreview: React.FC<SignedDocumentPreviewProps> = ({\n sessionId,\n nodeId,\n nodeTitle,\n completedAt,\n logo,\n onContinue,\n}) => {\n const { t, i18n } = useTranslation(\"translation\", { i18n: sdkI18n });\n const [status, setStatus] = useState<\"polling\" | \"ready\" | \"error\" | \"declined\" | \"expired\">(\n \"polling\",\n );\n const [viewUrl, setViewUrl] = useState<string | null>(null);\n const cancelledRef = useRef(false);\n\n useEffect(() => {\n cancelledRef.current = false;\n let attempts = 0;\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const fetchAccessLink = async () => {\n const response = await apiService.get(\n `/session/sdk/${sessionId}/signed-document/${nodeId}/access-link`,\n );\n const token = response.data?.data?.token;\n if (!token) {\n throw new Error(\"Missing signed document access token\");\n }\n\n const baseURL = (apiService.getRawClient().defaults.baseURL || \"\").replace(\n /\\/+$/,\n \"\",\n );\n const path = `/session/sdk/${sessionId}/signed-document/${nodeId}/view?token=${token}`;\n\n if (!cancelledRef.current) {\n setViewUrl(baseURL ? `${baseURL}${path}` : path);\n setStatus(\"ready\");\n }\n };\n\n const poll = async () => {\n try {\n const statusResponse = await apiService.get(\n `/session/sdk/${sessionId}/signed-document/${nodeId}/status`,\n );\n const ready = !!statusResponse.data?.data?.ready;\n const error = statusResponse.data?.data?.error as\n | \"declined\"\n | \"expired\"\n | undefined;\n\n if (error === \"declined\" || error === \"expired\") {\n if (!cancelledRef.current) setStatus(error);\n return;\n }\n\n if (ready) {\n try {\n await fetchAccessLink();\n return;\n } catch (err) {\n // DocuSeal can report the submission \"completed\" before the\n // signed document is actually linked — treat like \"not ready\n // yet\" instead of failing permanently on the first miss.\n console.error(\n \"[SignedDocumentPreview] Failed to fetch access link:\",\n err,\n );\n }\n }\n\n attempts += 1;\n if (attempts >= MAX_STATUS_POLL_ATTEMPTS) {\n if (!cancelledRef.current) setStatus(\"error\");\n return;\n }\n timer = setTimeout(poll, STATUS_POLL_INTERVAL_MS);\n } catch (err) {\n console.error(\"[SignedDocumentPreview] Failed to poll signed document status:\", err);\n attempts += 1;\n if (attempts >= MAX_STATUS_POLL_ATTEMPTS) {\n if (!cancelledRef.current) setStatus(\"error\");\n return;\n }\n timer = setTimeout(poll, STATUS_POLL_INTERVAL_MS);\n }\n };\n\n poll();\n\n return () => {\n cancelledRef.current = true;\n if (timer) clearTimeout(timer);\n };\n }, [sessionId, nodeId]);\n\n if (status === \"polling\") {\n return (\n <LoadingState\n message={t(\"signed_document.loading\", \"Préparation du document signé...\")}\n subtitle=\"\"\n />\n );\n }\n\n const formattedDate = completedAt\n ? new Intl.DateTimeFormat(i18n.language || \"fr\", {\n day: \"numeric\",\n month: \"long\",\n year: \"numeric\",\n }).format(new Date(completedAt))\n : null;\n\n return (\n <MobilePageLayout\n footer={\n <PageActions\n primary={\n <Button onClick={onContinue} type=\"button\">\n {t(\"buttons.continue\", \"Continuer\")}\n </Button>\n }\n />\n }\n >\n <div className=\"flex flex-col items-center h-full px-4 py-8 md:px-8 text-center gap-6\">\n {logo && <img src={logo} alt=\"\" className=\"h-12 max-w-[200px] object-contain\" />}\n\n {status === \"ready\" && viewUrl && (\n <>\n <div className=\"w-full max-w-md bg-gray-50 rounded-lg p-4 flex items-start gap-3 text-left\">\n <PenTool className=\"w-5 h-5 shrink-0 mt-0.5 text-gray-500\" />\n <div>\n <p className=\"font-semibold text-gray-900 break-all\">{nodeTitle}</p>\n {formattedDate && (\n <p className=\"text-xs text-gray-500 mt-1\">\n {t(\"signed_document.submitted_on\", \"Soumis le\")} {formattedDate}\n </p>\n )}\n </div>\n </div>\n\n <p className=\"text-sm text-gray-600\">\n {t(\n \"signed_document.ready_text\",\n \"Merci d'avoir signé le document, vous pouvez le consulter en cliquant ci-dessous :\",\n )}\n </p>\n\n <a\n href={viewUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"text-primary underline font-medium\"\n >\n {t(\"signed_document.view_link\", \"Consulter le document ↗\")}\n </a>\n </>\n )}\n\n {status === \"error\" && (\n <p className=\"text-sm text-gray-600 py-8\">\n {t(\n \"signed_document.error\",\n \"Le document n'a pas pu être chargé, mais votre signature est bien enregistrée. Vous pouvez continuer.\",\n )}\n </p>\n )}\n {status === \"declined\" && (\n <p className=\"text-sm text-gray-600 py-8\">\n {t(\"signed_document.declined\", \"Vous avez refusé de signer ce document.\")}\n </p>\n )}\n {status === \"expired\" && (\n <p className=\"text-sm text-gray-600 py-8\">\n {t(\"signed_document.expired\", \"Le lien de signature a expiré.\")}\n </p>\n )}\n </div>\n </MobilePageLayout>\n );\n};\n\nexport default SignedDocumentPreview;\n"],"names":["useTranslation","sdkI18n","useState","useRef","useEffect","__awaiter","apiService","_jsx","LoadingState","MobilePageLayout","PageActions","Button","_jsxs","_Fragment","PenTool"],"mappings":";;;;;;;;;;;;;;;;AAmBA,IAAM,uBAAuB,GAAG,IAAI;AACpC;AACA;AACA,IAAM,wBAAwB,GAAG,EAAE;AAEnC,IAAM,qBAAqB,GAAyC,UAAC,EAOpE,EAAA;AANG,IAAA,IAAA,SAAS,GAAA,EA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['firstName', 'first_name', 'prenom'],
|
|
24
24
|
nom: ['lastName', 'last_name', 'surname', 'familyName', 'nom'],
|
|
25
25
|
date_naissance: ['birthDate', 'birth_date', 'dateOfBirth', 'date_naissance'],
|
|
26
|
+
// Champs d'un nœud identity-legal-rep (RL) : la clé de config (builder) diffère
|
|
27
|
+
// de la clé réellement soumise par LegalRepFields — sans cet alias, la
|
|
28
|
+
// résolution échouait silencieusement dès qu'un nœud identity-legal-rep était
|
|
29
|
+
// choisi comme "Nœud source Nom/Prénom" (compareTargets ne trouvait jamais la
|
|
30
|
+
// valeur, causant un person_mismatch systématique).
|
|
31
|
+
legalRepresentativePrenom: ['legalRepresentativeFirstName', 'legalRepresentativePrenom'],
|
|
32
|
+
legalRepresentativeNom: ['legalRepresentativeLastName', 'legalRepresentativeNom'],
|
|
26
33
|
};
|
|
27
34
|
var normalizeReferenceField = function (field) {
|
|
28
35
|
if (!field)
|
|
@@ -62,6 +69,9 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
62
69
|
var nodeData = node;
|
|
63
70
|
var apiType = String(nodeData.targetApi || 'INSEE');
|
|
64
71
|
var isInpiRbe = apiType === 'INPI_RBE';
|
|
72
|
+
// Paramétrable depuis le journey builder (panneau "Configuration de la base
|
|
73
|
+
// externe"), par nœud. Absent/true = comportement actuel inchangé.
|
|
74
|
+
var allowContinueOnFailure = nodeData.allowContinueOnFailure !== false;
|
|
65
75
|
var _o = React.useState('loading'), phase = _o[0], setPhase = _o[1];
|
|
66
76
|
var _p = React.useState(null), errorScreenData = _p[0], setErrorScreenData = _p[1];
|
|
67
77
|
var _q = React.useState(function () {
|
|
@@ -108,10 +118,10 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
108
118
|
React.useEffect(function () {
|
|
109
119
|
var abortController = new AbortController();
|
|
110
120
|
var run = function () { return tslib_es6.__awaiter(void 0, void 0, void 0, function () {
|
|
111
|
-
var result, referenceField, referenceValueMasked, resolvedReferenceValue, referenceNodeId, referenceVariable, submittedFirstName, submittedLastName, nodeInput, userInputFlat, lookupKeys, referenceValue, allCustomFields, _i, _a, _b, value, str, comparisonConfig, cfg, personNodeInput, flat, firstNameKeys, lastNameKeys, birthDateKeys, dateOfBirth, response, res, apiErr_1, apiResult, inpi, cfg;
|
|
112
|
-
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
113
|
-
return tslib_es6.__generator(this, function (
|
|
114
|
-
switch (
|
|
121
|
+
var result, referenceField, referenceValueMasked, resolvedReferenceValue, referenceNodeId, referenceVariable, submittedFirstName, submittedLastName, submittedSiren, nodeInput, userInputFlat, lookupKeys, referenceValue, allCustomFields, _i, _a, _b, value, str, comparisonConfig, cfg, personNodeInput, flat, isPersonneMorale, sirenKeys, firstNameKeys, lastNameKeys, birthDateKeys, dateOfBirth, response, res, apiErr_1, apiResult, inpi, cfg, isPersonneMorale_1;
|
|
122
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
123
|
+
return tslib_es6.__generator(this, function (_v) {
|
|
124
|
+
switch (_v.label) {
|
|
115
125
|
case 0:
|
|
116
126
|
result = {
|
|
117
127
|
isVerified: false,
|
|
@@ -124,9 +134,10 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
124
134
|
referenceVariable = String(nodeData.referenceVariable || '');
|
|
125
135
|
submittedFirstName = '';
|
|
126
136
|
submittedLastName = '';
|
|
127
|
-
|
|
137
|
+
submittedSiren = '';
|
|
138
|
+
_v.label = 1;
|
|
128
139
|
case 1:
|
|
129
|
-
|
|
140
|
+
_v.trys.push([1, 9, , 10]);
|
|
130
141
|
if (!(session === null || session === void 0 ? void 0 : session.id))
|
|
131
142
|
throw new Error('Session ID is missing');
|
|
132
143
|
referenceField = normalizeReferenceField(String(nodeData.referenceField || referenceVariable || ''));
|
|
@@ -176,45 +187,62 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
176
187
|
cfg = nodeData.comparisonConfig;
|
|
177
188
|
personNodeInput = (_d = userInput[cfg.personReferenceNodeId]) !== null && _d !== void 0 ? _d : {};
|
|
178
189
|
flat = userInput;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
190
|
+
isPersonneMorale = cfg.personType === 'MORALE';
|
|
191
|
+
if (isPersonneMorale) {
|
|
192
|
+
sirenKeys = expandFieldKey((_e = cfg.personSirenField) !== null && _e !== void 0 ? _e : '').filter(Boolean);
|
|
193
|
+
submittedSiren = (_f = resolveFieldValue(personNodeInput, flat, sirenKeys)) !== null && _f !== void 0 ? _f : '';
|
|
194
|
+
if (submittedSiren) {
|
|
195
|
+
comparisonConfig = {
|
|
196
|
+
personType: 'MORALE',
|
|
197
|
+
siren: submittedSiren,
|
|
198
|
+
// Un RBE est toujours une personne physique en droit
|
|
199
|
+
// français : forcé à 'mandataires' quel que soit le
|
|
200
|
+
// contenu de cfg.compareTargets (défense en profondeur).
|
|
201
|
+
compareTargets: ['mandataires'],
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
firstNameKeys = expandFieldKey((_g = cfg.personFirstNameField) !== null && _g !== void 0 ? _g : '').filter(Boolean);
|
|
207
|
+
lastNameKeys = expandFieldKey((_h = cfg.personLastNameField) !== null && _h !== void 0 ? _h : '').filter(Boolean);
|
|
208
|
+
birthDateKeys = cfg.personBirthDateField
|
|
209
|
+
? expandFieldKey(cfg.personBirthDateField).filter(Boolean)
|
|
210
|
+
: [];
|
|
211
|
+
submittedFirstName = (_j = resolveFieldValue(personNodeInput, flat, firstNameKeys)) !== null && _j !== void 0 ? _j : '';
|
|
212
|
+
submittedLastName = (_k = resolveFieldValue(personNodeInput, flat, lastNameKeys)) !== null && _k !== void 0 ? _k : '';
|
|
213
|
+
dateOfBirth = cfg.compareBirthDate && birthDateKeys.length
|
|
214
|
+
? resolveFieldValue(personNodeInput, flat, birthDateKeys)
|
|
215
|
+
: undefined;
|
|
216
|
+
if (submittedFirstName && submittedLastName) {
|
|
217
|
+
comparisonConfig = tslib_es6.__assign({ firstName: submittedFirstName, lastName: submittedLastName, compareTargets: (_l = cfg.compareTargets) !== null && _l !== void 0 ? _l : ['mandataires'] }, (dateOfBirth ? { dateOfBirth: dateOfBirth } : {}));
|
|
218
|
+
}
|
|
191
219
|
}
|
|
192
220
|
}
|
|
193
221
|
if (isInpiRbe)
|
|
194
222
|
advanceStep(1);
|
|
195
|
-
|
|
223
|
+
_v.label = 4;
|
|
196
224
|
case 4:
|
|
197
|
-
|
|
225
|
+
_v.trys.push([4, 7, , 8]);
|
|
198
226
|
return [4 /*yield*/, api.apiService.post("/session/sdk/".concat(session.id, "/verify-external/").concat(node.id), tslib_es6.__assign({ apiType: apiType, referenceValue: referenceValue, referenceField: referenceField, enableRnaFallback: isInpiRbe && nodeData.rnaFallbackEnabled === true }, (comparisonConfig ? { comparisonConfig: comparisonConfig } : {})), { signal: abortController.signal })];
|
|
199
227
|
case 5:
|
|
200
|
-
response =
|
|
228
|
+
response = _v.sent();
|
|
201
229
|
if (isInpiRbe)
|
|
202
230
|
advanceStep(2);
|
|
203
231
|
return [4 /*yield*/, new Promise(function (r) { return setTimeout(r, 600); })];
|
|
204
232
|
case 6:
|
|
205
|
-
|
|
206
|
-
res = (
|
|
233
|
+
_v.sent();
|
|
234
|
+
res = (_m = response.data) === null || _m === void 0 ? void 0 : _m.data;
|
|
207
235
|
if (res && typeof res.isVerified === 'boolean') {
|
|
208
236
|
result = res;
|
|
209
237
|
}
|
|
210
238
|
return [3 /*break*/, 8];
|
|
211
239
|
case 7:
|
|
212
|
-
apiErr_1 =
|
|
240
|
+
apiErr_1 = _v.sent();
|
|
213
241
|
if (abortController.signal.aborted)
|
|
214
242
|
return [2 /*return*/];
|
|
215
243
|
if (isInpiRbe)
|
|
216
244
|
advanceStep(2);
|
|
217
|
-
apiResult = (
|
|
245
|
+
apiResult = (_p = (_o = apiErr_1 === null || apiErr_1 === void 0 ? void 0 : apiErr_1.response) === null || _o === void 0 ? void 0 : _o.data) === null || _p === void 0 ? void 0 : _p.data;
|
|
218
246
|
if (apiResult && typeof apiResult.isVerified === 'boolean') {
|
|
219
247
|
result = apiResult;
|
|
220
248
|
}
|
|
@@ -229,7 +257,7 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
229
257
|
return [3 /*break*/, 8];
|
|
230
258
|
case 8: return [3 /*break*/, 10];
|
|
231
259
|
case 9:
|
|
232
|
-
|
|
260
|
+
_v.sent();
|
|
233
261
|
result = {
|
|
234
262
|
isVerified: false,
|
|
235
263
|
status: 'external_error',
|
|
@@ -259,13 +287,21 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
259
287
|
if (result.status === 'person_mismatch') {
|
|
260
288
|
inpi = result.inpiData;
|
|
261
289
|
cfg = nodeData.comparisonConfig;
|
|
290
|
+
isPersonneMorale_1 = (cfg === null || cfg === void 0 ? void 0 : cfg.personType) === 'MORALE';
|
|
262
291
|
setErrorScreenData({
|
|
263
292
|
submittedLastName: submittedLastName,
|
|
264
293
|
submittedFirstName: submittedFirstName,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
294
|
+
submittedSiren: isPersonneMorale_1 ? submittedSiren : undefined,
|
|
295
|
+
// En mode personne morale, seuls les mandataires personne morale ont
|
|
296
|
+
// un sens (un RBE est toujours une personne physique) ; en mode
|
|
297
|
+
// physique, comportement inchangé (mandataires individus uniquement).
|
|
298
|
+
mandataires: ((_q = inpi === null || inpi === void 0 ? void 0 : inpi.mandataires) !== null && _q !== void 0 ? _q : []).filter(function (m) {
|
|
299
|
+
return isPersonneMorale_1 ? m.type === 'personne_morale' : m.type === 'individu';
|
|
300
|
+
}),
|
|
301
|
+
beneficiairesEffectifs: (_r = inpi === null || inpi === void 0 ? void 0 : inpi.beneficiairesEffectifs) !== null && _r !== void 0 ? _r : [],
|
|
302
|
+
compareTargets: isPersonneMorale_1 ? ['mandataires'] : ((_s = cfg === null || cfg === void 0 ? void 0 : cfg.compareTargets) !== null && _s !== void 0 ? _s : ['mandataires']),
|
|
303
|
+
personNodeId: (_t = cfg === null || cfg === void 0 ? void 0 : cfg.personReferenceNodeId) !== null && _t !== void 0 ? _t : '',
|
|
304
|
+
targetDenomination: (_u = inpi === null || inpi === void 0 ? void 0 : inpi.identite) === null || _u === void 0 ? void 0 : _u.denomination,
|
|
269
305
|
siren: resolvedReferenceValue,
|
|
270
306
|
sirenNodeId: referenceNodeId,
|
|
271
307
|
source: inpi === null || inpi === void 0 ? void 0 : inpi.source,
|
|
@@ -340,20 +376,22 @@ var ExternalVerificationNodeHandler = function (_a) {
|
|
|
340
376
|
: ((_l = d === null || d === void 0 ? void 0 : d.compareTargets) === null || _l === void 0 ? void 0 : _l.includes('mandataires')) && !((_m = d === null || d === void 0 ? void 0 : d.compareTargets) === null || _m === void 0 ? void 0 : _m.includes('beneficiairesEffectifs'))
|
|
341
377
|
? t('inpi_verification.mandataires_label', 'Mandataires renseignés au RNE')
|
|
342
378
|
: t('inpi_verification.persons_label', 'Personnes renseignées au RNE');
|
|
343
|
-
return (jsxRuntime.jsxs("div", { className: "flex flex-col justify-between h-full w-full", children: [jsxRuntime.jsx("div", { className: "flex-1 px-4 py-6 pt-11 md:px-8 md:py-8", children: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto space-y-6", children: [jsxRuntime.jsx("div", { className: "text-center", children: jsxRuntime.jsx("div", { className: "mx-auto w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mb-4", children: jsxRuntime.jsx("div", { className: "w-8 h-8 bg-red-500 rounded-full flex items-center justify-center", children: jsxRuntime.jsx("span", { className: "text-white text-lg", children: "\u2715" }) }) }) }), jsxRuntime.jsxs("div", { className: "text-center space-y-4", children: [jsxRuntime.jsx(Title.default, { className: "text-xl md:text-2xl lg:text-3xl text-red-600", children: t('inpi_verification.mismatch_title', 'Identité non confirmée') }), jsxRuntime.jsx(Subtitle.default, { className: "text-sm text-gray-600 leading-relaxed", children:
|
|
344
|
-
|
|
345
|
-
|
|
379
|
+
return (jsxRuntime.jsxs("div", { className: "flex flex-col justify-between h-full w-full", children: [jsxRuntime.jsx("div", { className: "flex-1 px-4 py-6 pt-11 md:px-8 md:py-8", children: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto space-y-6", children: [jsxRuntime.jsx("div", { className: "text-center", children: jsxRuntime.jsx("div", { className: "mx-auto w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mb-4", children: jsxRuntime.jsx("div", { className: "w-8 h-8 bg-red-500 rounded-full flex items-center justify-center", children: jsxRuntime.jsx("span", { className: "text-white text-lg", children: "\u2715" }) }) }) }), jsxRuntime.jsxs("div", { className: "text-center space-y-4", children: [jsxRuntime.jsx(Title.default, { className: "text-xl md:text-2xl lg:text-3xl text-red-600", children: t('inpi_verification.mismatch_title', 'Identité non confirmée') }), jsxRuntime.jsx(Subtitle.default, { className: "text-sm text-gray-600 leading-relaxed", children: (d === null || d === void 0 ? void 0 : d.targetDenomination)
|
|
380
|
+
? t('inpi_verification.mismatch_desc_denomination', "Le responsable l\u00E9gal saisi ne fait pas partie des responsables l\u00E9gaux ou b\u00E9n\u00E9ficiaires effectifs de la soci\u00E9t\u00E9 ".concat(d.targetDenomination))
|
|
381
|
+
: t('inpi_verification.mismatch_desc', "Les informations saisies ne correspondent à aucune personne déclarée à l'INPI pour cette société.") })] }), d && (d.submittedLastName || d.submittedFirstName || d.submittedSiren) && (jsxRuntime.jsxs("div", { className: "bg-red-50 border border-red-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-red-900 mb-2", children: t('errors.problems_detected', 'Problèmes détectés') }), jsxRuntime.jsxs("div", { className: "text-sm text-red-800 space-y-1", children: [d.submittedSiren && (jsxRuntime.jsxs("p", { children: [t('inpi_verification.submitted_siren', 'SIREN saisi'), ' : ', jsxRuntime.jsx("strong", { children: d.submittedSiren })] })), d.submittedLastName && (jsxRuntime.jsxs("p", { children: [t('inpi_verification.submitted_last_name', 'Nom saisi'), ' : ', jsxRuntime.jsx("strong", { children: d.submittedLastName })] })), d.submittedFirstName && (jsxRuntime.jsxs("p", { children: [t('inpi_verification.submitted_first_name', 'Prénom saisi'), ' : ', jsxRuntime.jsx("strong", { children: d.submittedFirstName })] }))] })] })), (showMandataires || showBeneficiaires) && (jsxRuntime.jsxs("div", { className: "bg-blue-50 border border-blue-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-blue-900 mb-2", children: personListLabel }), jsxRuntime.jsxs("div", { className: "text-sm text-blue-800 space-y-1", children: [showMandataires && d.mandataires.map(function (m, i) {
|
|
382
|
+
var _a, _b, _c;
|
|
383
|
+
return (jsxRuntime.jsx("p", { children: m.type === 'personne_morale' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("strong", { children: (_a = m.denominationSociale) !== null && _a !== void 0 ? _a : '—' }), m.siren && " (SIREN ".concat(m.siren, ")")] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("strong", { children: (_b = m.nom) !== null && _b !== void 0 ? _b : '—' }), ((_c = m.prenoms) !== null && _c !== void 0 ? _c : []).length > 0 && " ".concat(m.prenoms.join(' '))] })) }, "m-".concat(i)));
|
|
346
384
|
}), showBeneficiaires && d.beneficiairesEffectifs.map(function (b, i) {
|
|
347
385
|
var _a, _b;
|
|
348
386
|
return (jsxRuntime.jsxs("p", { children: [jsxRuntime.jsx("strong", { children: (_a = b.nom) !== null && _a !== void 0 ? _a : '—' }), ((_b = b.prenoms) !== null && _b !== void 0 ? _b : []).length > 0 && " ".concat(b.prenoms.join(' '))] }, "b-".concat(i)));
|
|
349
|
-
})] })] }))] }) }), jsxRuntime.jsx("div", { className: "sticky bottom-0 md:static bg-white border-t md:border-t-0 p-4 md:p-0 md:pb-8", children: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto", children: [jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3 md:hidden", children: [jsxRuntime.jsx(Button.default, { variant: "secondary", onClick: handleCorrect, "data-cy": "inpi-mismatch-go-back", children: t('inpi_verification.mismatch_correct', 'Corriger ma saisie') }), jsxRuntime.jsx(Button.default, { onClick: onNext, "data-cy": "inpi-mismatch-continue", children: t('inpi_verification.mismatch_continue', 'Continuer quand même') })] }), jsxRuntime.jsxs("div", { className: "hidden md:flex justify-center space-x-3", children: [jsxRuntime.jsx(Button.default, { variant: "secondary", onClick: handleCorrect, "data-cy": "inpi-mismatch-go-back", children: t('inpi_verification.mismatch_correct', 'Corriger ma saisie') }), jsxRuntime.jsx(Button.default, { onClick: onNext, "data-cy": "inpi-mismatch-continue", children: t('inpi_verification.mismatch_continue', 'Continuer quand même') })] })] }) })] }));
|
|
387
|
+
})] })] }))] }) }), jsxRuntime.jsx("div", { className: "sticky bottom-0 md:static bg-white border-t md:border-t-0 p-4 md:p-0 md:pb-8", children: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto", children: [jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3 md:hidden", children: [jsxRuntime.jsx(Button.default, { variant: "secondary", onClick: handleCorrect, "data-cy": "inpi-mismatch-go-back", children: t('inpi_verification.mismatch_correct', 'Corriger ma saisie') }), allowContinueOnFailure && (jsxRuntime.jsx(Button.default, { onClick: onNext, "data-cy": "inpi-mismatch-continue", children: t('inpi_verification.mismatch_continue', 'Continuer quand même') }))] }), jsxRuntime.jsxs("div", { className: "hidden md:flex justify-center space-x-3", children: [jsxRuntime.jsx(Button.default, { variant: "secondary", onClick: handleCorrect, "data-cy": "inpi-mismatch-go-back", children: t('inpi_verification.mismatch_correct', 'Corriger ma saisie') }), allowContinueOnFailure && (jsxRuntime.jsx(Button.default, { onClick: onNext, "data-cy": "inpi-mismatch-continue", children: t('inpi_verification.mismatch_continue', 'Continuer quand même') }))] })] }) })] }));
|
|
350
388
|
}
|
|
351
389
|
// ─── Not found phase ───────────────────────────────────────────────────────
|
|
352
390
|
if (phase === 'not_found') {
|
|
353
391
|
var d = errorScreenData;
|
|
354
|
-
return (jsxRuntime.jsxs("div", { className: "flex flex-col justify-between h-full w-full", children: [jsxRuntime.jsx("div", { className: "flex-1 px-4 py-6 pt-11 md:px-8 md:py-8", children: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto space-y-6", children: [jsxRuntime.jsx("div", { className: "text-center", children: jsxRuntime.jsx("div", { className: "mx-auto w-16 h-16 bg-orange-100 rounded-full flex items-center justify-center mb-4", children: jsxRuntime.jsx("div", { className: "w-8 h-8 bg-orange-500 rounded-full flex items-center justify-center", children: jsxRuntime.jsx("span", { className: "text-white text-lg font-bold", children: "!" }) }) }) }), jsxRuntime.jsxs("div", { className: "text-center space-y-4", children: [jsxRuntime.jsx(Title.default, { className: "text-xl md:text-2xl lg:text-3xl text-orange-600", children: t('inpi_verification.not_found_title', 'Société introuvable') }), jsxRuntime.jsx(Subtitle.default, { className: "text-sm text-gray-600 leading-relaxed", children: t('inpi_verification.not_found_desc', "Le numéro saisi ne correspond à aucune société enregistrée dans le Registre National des Entreprises.") })] }), jsxRuntime.jsxs("div", { className: "bg-orange-50 border border-orange-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-orange-900 mb-2", children: t('errors.problems_detected', 'Problèmes détectés') }), jsxRuntime.jsxs("div", { className: "text-sm text-orange-800 space-y-1", children: [(d === null || d === void 0 ? void 0 : d.siren) && (jsxRuntime.jsxs("p", { children: [t('inpi_verification.siren_label', 'SIREN'), ' : ', jsxRuntime.jsx("strong", { children: d.siren })] })), jsxRuntime.jsx("p", { children: (d === null || d === void 0 ? void 0 : d.isDoubleNotFound)
|
|
392
|
+
return (jsxRuntime.jsxs("div", { className: "flex flex-col justify-between h-full w-full", children: [jsxRuntime.jsx("div", { className: "flex-1 px-4 py-6 pt-11 md:px-8 md:py-8", children: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto space-y-6", children: [jsxRuntime.jsx("div", { className: "text-center", children: jsxRuntime.jsx("div", { className: "mx-auto w-16 h-16 bg-orange-100 rounded-full flex items-center justify-center mb-4", children: jsxRuntime.jsx("div", { className: "w-8 h-8 bg-orange-500 rounded-full flex items-center justify-center", children: jsxRuntime.jsx("span", { className: "text-white text-lg font-bold", children: "!" }) }) }) }), jsxRuntime.jsxs("div", { className: "text-center space-y-4", children: [jsxRuntime.jsx(Title.default, { className: "text-xl md:text-2xl lg:text-3xl text-orange-600", children: t('inpi_verification.not_found_title', 'Société introuvable') }), jsxRuntime.jsx(Subtitle.default, { className: "text-sm text-gray-600 leading-relaxed", children: t('inpi_verification.not_found_desc', "Le numéro saisi ne correspond à aucune société enregistrée dans le Registre National des Entreprises.") }), jsxRuntime.jsx("span", { className: "inline-block rounded-full bg-red-100 px-3 py-1 text-xs font-semibold text-red-700", children: t('inpi_verification.not_found_rejected_label', 'Dossier rejeté') })] }), jsxRuntime.jsxs("div", { className: "bg-orange-50 border border-orange-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-orange-900 mb-2", children: t('errors.problems_detected', 'Problèmes détectés') }), jsxRuntime.jsxs("div", { className: "text-sm text-orange-800 space-y-1", children: [(d === null || d === void 0 ? void 0 : d.siren) && (jsxRuntime.jsxs("p", { children: [t('inpi_verification.siren_label', 'SIREN'), ' : ', jsxRuntime.jsx("strong", { children: d.siren })] })), jsxRuntime.jsx("p", { children: (d === null || d === void 0 ? void 0 : d.isDoubleNotFound)
|
|
355
393
|
? t('inpi_verification.not_found_detail_rne_rna', "Aucune société ni association trouvée, ni dans le Registre National des Entreprises (RNE), ni dans le Répertoire National des Associations (RNA).")
|
|
356
|
-
: t('inpi_verification.not_found_detail', 'Aucune société trouvée dans le Registre National des Entreprises.') })] })] })] }) }), jsxRuntime.jsx("div", { className: "sticky bottom-0 md:static bg-white border-t md:border-t-0 p-4 md:p-0 md:pb-8", children: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto", children: [jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3 md:hidden", children: [jsxRuntime.jsx(Button.default, { variant: "secondary", onClick: handleCorrect, "data-cy": "inpi-not-found-go-back", children: t('inpi_verification.mismatch_correct', 'Corriger ma saisie') }), jsxRuntime.jsx(Button.default, { onClick: onNext, "data-cy": "inpi-not-found-continue", children: t('inpi_verification.mismatch_continue', 'Continuer quand même') })] }), jsxRuntime.jsxs("div", { className: "hidden md:flex justify-center space-x-3", children: [jsxRuntime.jsx(Button.default, { variant: "secondary", onClick: handleCorrect, "data-cy": "inpi-not-found-go-back", children: t('inpi_verification.mismatch_correct', 'Corriger ma saisie') }), jsxRuntime.jsx(Button.default, { onClick: onNext, "data-cy": "inpi-not-found-continue", children: t('inpi_verification.mismatch_continue', 'Continuer quand même') })] })] }) })] }));
|
|
394
|
+
: t('inpi_verification.not_found_detail', 'Aucune société trouvée dans le Registre National des Entreprises.') })] })] })] }) }), jsxRuntime.jsx("div", { className: "sticky bottom-0 md:static bg-white border-t md:border-t-0 p-4 md:p-0 md:pb-8", children: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto", children: [jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3 md:hidden", children: [jsxRuntime.jsx(Button.default, { variant: "secondary", onClick: handleCorrect, "data-cy": "inpi-not-found-go-back", children: t('inpi_verification.mismatch_correct', 'Corriger ma saisie') }), allowContinueOnFailure && (jsxRuntime.jsx(Button.default, { onClick: onNext, "data-cy": "inpi-not-found-continue", children: t('inpi_verification.mismatch_continue', 'Continuer quand même') }))] }), jsxRuntime.jsxs("div", { className: "hidden md:flex justify-center space-x-3", children: [jsxRuntime.jsx(Button.default, { variant: "secondary", onClick: handleCorrect, "data-cy": "inpi-not-found-go-back", children: t('inpi_verification.mismatch_correct', 'Corriger ma saisie') }), allowContinueOnFailure && (jsxRuntime.jsx(Button.default, { onClick: onNext, "data-cy": "inpi-not-found-continue", children: t('inpi_verification.mismatch_continue', 'Continuer quand même') }))] })] }) })] }));
|
|
357
395
|
}
|
|
358
396
|
// ─── Error / fallback ─────────────────────────────────────────────────────
|
|
359
397
|
return (jsxRuntime.jsx(LoadingState.default, { message: t('verification_node.verifying_title', 'Vérification en cours…'), subtitle: t('verification_node.verifying_desc', 'Vérification en cours…') }));
|