datakeen-session-react 1.1.140-dev.24 → 1.1.140-dev.26

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.
Files changed (28) hide show
  1. package/README.md +487 -135
  2. package/dist/cjs/components/session/UserInputForm/CustomFormFields.js +1 -1
  3. package/dist/cjs/components/session/UserInputForm/CustomFormFields.js.map +1 -1
  4. package/dist/cjs/components/session/UserInputForm/IdentityFields.js +1 -1
  5. package/dist/cjs/components/session/UserInputForm/IdentityFields.js.map +1 -1
  6. package/dist/cjs/components/signature-electronic/DocusealSignature.js +2 -1
  7. package/dist/cjs/components/signature-electronic/DocusealSignature.js.map +1 -1
  8. package/dist/cjs/hooks/useStepNavigation.js +25 -3
  9. package/dist/cjs/hooks/useStepNavigation.js.map +1 -1
  10. package/dist/cjs/hooks/useUserInputForm.js +3 -2
  11. package/dist/cjs/hooks/useUserInputForm.js.map +1 -1
  12. package/dist/cjs/services/sessionService.js +36 -0
  13. package/dist/cjs/services/sessionService.js.map +1 -1
  14. package/dist/esm/components/session/UserInputForm/CustomFormFields.js +1 -1
  15. package/dist/esm/components/session/UserInputForm/CustomFormFields.js.map +1 -1
  16. package/dist/esm/components/session/UserInputForm/IdentityFields.js +1 -1
  17. package/dist/esm/components/session/UserInputForm/IdentityFields.js.map +1 -1
  18. package/dist/esm/components/signature-electronic/DocusealSignature.js +2 -1
  19. package/dist/esm/components/signature-electronic/DocusealSignature.js.map +1 -1
  20. package/dist/esm/hooks/useStepNavigation.js +26 -4
  21. package/dist/esm/hooks/useStepNavigation.js.map +1 -1
  22. package/dist/esm/hooks/useUserInputForm.js +3 -2
  23. package/dist/esm/hooks/useUserInputForm.js.map +1 -1
  24. package/dist/esm/services/sessionService.js +36 -1
  25. package/dist/esm/services/sessionService.js.map +1 -1
  26. package/docs/README.md +6 -0
  27. package/docs/navigation-history.md +138 -0
  28. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useUserInputForm.js","sources":["../../../../src/hooks/useUserInputForm.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { UserInputFormProps } from \"../types/userInput\";\nimport type {\n AddressSuggestion,\n InformationType,\n RequestedFields,\n UserInputFormErrors,\n UserInputFormState,\n} from \"../types/userInputForm\";\nimport {\n DEFAULT_FIELDS,\n FALLBACK_ADDRESS_SUGGESTIONS,\n GEOCODING_AUTOCOMPLETE_ENDPOINT,\n} from \"../constants/userInputForm\";\nimport { API_BASE_URL } from \"../config/env\";\nimport {\n checkIsMajor,\n parseBirthDate,\n resolveInformationType,\n} from \"../utils/userInputForm\";\nimport {\n countNonEmptyListRows,\n getListFieldMinRows,\n} from \"../utils/listFieldUtils\";\nimport { useI18n } from \"./useI18n\";\n\ninterface UseUserInputFormResult {\n form: UserInputFormState;\n errors: UserInputFormErrors;\n informationType: InformationType;\n requestedFields: RequestedFields;\n pageTitle: string;\n pageDescription: string;\n addressSuggestions: AddressSuggestion[];\n showSuggestions: boolean;\n handleFieldChange: (key: keyof UserInputFormState, value: string) => void;\n handleAddressChange: (value: string) => void;\n handleAddressFocus: () => void;\n handleAddressBlur: () => void;\n applyAddressSuggestion: (suggestion: AddressSuggestion) => void;\n goOnNextStep: () => void;\n goOnPreviousStep: () => void;\n // Custom form fields\n customFormData: Record<string, any>;\n customFormErrors: Record<string, boolean>;\n handleCustomFieldChange: (fieldId: string, value: any) => void;\n}\n\nexport const useUserInputForm = ({\n stepObject,\n setUserInput,\n initialUserInput,\n node,\n template,\n contactInfo,\n setContactInfo,\n onContinueCallback,\n}: UserInputFormProps): UseUserInputFormResult => {\n const { setStep, goToNextStep, step } = stepObject;\n const { t } = useI18n();\n\n const informationType = useMemo<InformationType>(() => {\n const resolved = resolveInformationType(\n node.informationType as string,\n \"identity\",\n );\n console.log(\"🔍 [useUserInputForm] Resolving informationType:\", {\n nodeInformationType: node.informationType,\n resolved,\n hasCustomFields: !!node.customFields,\n customFieldsCount: node.customFields?.length,\n });\n return resolved;\n }, [node.informationType, node.customFields]);\n\n const requestedFields = useMemo<RequestedFields>(() => {\n const defaults = DEFAULT_FIELDS[informationType] || [];\n const optional =\n node.optionalFields && node.optionalFields.length > 0\n ? node.optionalFields\n : defaults;\n const merged = new Set<string>(optional);\n\n if (node.requiredFields) {\n node.requiredFields.forEach((field) => merged.add(field));\n }\n\n return merged;\n }, [node.optionalFields, node.requiredFields, informationType]);\n\n const birthDateParts = useMemo(\n () => parseBirthDate(initialUserInput?.birthDate || \"\"),\n [initialUserInput?.birthDate],\n );\n\n const [form, setForm] = useState<UserInputFormState>({\n lastName: initialUserInput?.lastName || \"\",\n firstName: initialUserInput?.firstName || \"\",\n birthDate: initialUserInput?.birthDate || \"\",\n day: birthDateParts.day,\n month: birthDateParts.month,\n year: birthDateParts.year,\n email: initialUserInput?.email || contactInfo?.email || \"\",\n phoneNumber:\n initialUserInput?.phoneNumber || contactInfo?.phoneNumber || \"\",\n sms: initialUserInput?.sms || \"\",\n addressLine1: initialUserInput?.addressLine1 || \"\",\n addressLine2: initialUserInput?.addressLine2 || \"\",\n postalCode: initialUserInput?.postalCode || \"\",\n city: initialUserInput?.city || \"\",\n countryCode: initialUserInput?.countryCode || \"\",\n nationality: initialUserInput?.nationality || \"\",\n companyName: initialUserInput?.companyName || \"\",\n siret: initialUserInput?.siret || \"\",\n tva: initialUserInput?.tva || \"\",\n });\n\n const [errors, setErrors] = useState<UserInputFormErrors>({});\n\n // Custom form state\n const [customFormData, setCustomFormData] = useState<Record<string, any>>(\n () => {\n if (informationType !== \"custom\" || !node.customFields) return {};\n\n const initial: Record<string, any> = {};\n node.customFields.forEach((field) => {\n const savedValue = initialUserInput?.customFormData?.[field.id];\n if (field.valueType === \"list\") {\n initial[field.id] = Array.isArray(savedValue) ? savedValue : [];\n return;\n }\n\n initial[field.id] = savedValue || \"\";\n });\n return initial;\n },\n );\n const [customFormErrors, setCustomFormErrors] = useState<\n Record<string, boolean>\n >({});\n\n const [addressSuggestions, setAddressSuggestions] = useState<\n AddressSuggestion[]\n >([]);\n const [showSuggestions, setShowSuggestions] = useState(false);\n const isFirstRender = useRef(true);\n const hideSuggestionTimeout = useRef<ReturnType<typeof setTimeout> | null>(\n null,\n );\n const addressRequestState = useRef<{\n debounce: ReturnType<typeof setTimeout> | null;\n controller: AbortController | null;\n }>({\n debounce: null,\n controller: null,\n });\n\n const formTitles = useMemo<Record<InformationType, string>>(\n () => ({\n identity: t(\"user_input_form.titles.identity\"),\n \"identity-legal\": t(\"user_input_form.titles.identity_legal\"),\n contact: t(\"user_input_form.titles.contact\"),\n address: t(\"user_input_form.titles.address\"),\n nationality: t(\"user_input_form.titles.nationality\"),\n custom: t(\"user_input_form.titles.custom\"),\n }),\n [t],\n );\n\n const formDescriptions = useMemo<Record<InformationType, string>>(\n () => ({\n identity: t(\"user_input_form.descriptions.identity\"),\n \"identity-legal\": t(\"user_input_form.descriptions.identity_legal\"),\n contact: t(\"user_input_form.descriptions.contact\"),\n address: t(\"user_input_form.descriptions.address\"),\n nationality: t(\"user_input_form.descriptions.nationality\"),\n custom: t(\"user_input_form.descriptions.custom\"),\n }),\n [t],\n );\n\n const applyAddressSuggestion = (suggestion: AddressSuggestion) => {\n const normalizedCountry =\n suggestion.countryCode?.toUpperCase() || suggestion.country || \"\";\n\n setForm((previous) => ({\n ...previous,\n addressLine1: suggestion.addressLine1 || suggestion.label,\n postalCode: suggestion.postalCode || previous.postalCode,\n city: suggestion.city || previous.city,\n countryCode: normalizedCountry || previous.countryCode,\n }));\n setErrors((previous) => ({\n ...previous,\n addressLine1: false,\n postalCode: false,\n city: false,\n country: false,\n }));\n setShowSuggestions(false);\n setAddressSuggestions([]);\n };\n\n const mapGeoapifyFeature = (feature: any): AddressSuggestion | null => {\n if (!feature || !feature.properties) {\n return null;\n }\n\n const { properties } = feature;\n const label: string =\n properties.formatted ||\n properties.address_line1 ||\n [properties.housenumber, properties.street]\n .filter(Boolean)\n .join(\" \")\n .trim();\n\n if (!label) {\n return null;\n }\n\n const addressLine1 =\n [properties.housenumber, properties.street]\n .filter(Boolean)\n .join(\" \")\n .trim() ||\n properties.address_line1 ||\n label;\n\n const city =\n properties.city ||\n properties.town ||\n properties.village ||\n properties.state ||\n \"\";\n\n return {\n id:\n (properties.place_id && String(properties.place_id)) ||\n feature.id ||\n `${properties.lon ?? \"\"}-${properties.lat ?? \"\"}-${label}`,\n label,\n addressLine1,\n postalCode: properties.postcode || \"\",\n city,\n country: properties.country || \"\",\n countryCode: properties.country_code || undefined,\n };\n };\n\n const requestAddressSuggestions = (\n query: string,\n { autoComplete }: { autoComplete: boolean },\n ) => {\n if (addressRequestState.current.debounce) {\n clearTimeout(addressRequestState.current.debounce);\n addressRequestState.current.debounce = null;\n }\n\n if (query.trim().length < 3) {\n if (addressRequestState.current.controller) {\n addressRequestState.current.controller.abort();\n addressRequestState.current.controller = null;\n }\n setAddressSuggestions([]);\n setShowSuggestions(false);\n return;\n }\n\n addressRequestState.current.debounce = setTimeout(async () => {\n if (addressRequestState.current.controller) {\n addressRequestState.current.controller.abort();\n }\n\n const controller = new AbortController();\n addressRequestState.current.controller = controller;\n\n try {\n const searchParams = new URLSearchParams({\n text: query,\n lang: \"fr\",\n });\n\n const response = await fetch(\n `${API_BASE_URL}${GEOCODING_AUTOCOMPLETE_ENDPOINT}?${searchParams.toString()}`,\n { signal: controller.signal },\n );\n\n if (!response.ok) {\n throw new Error(\n `Geocoding request failed with status ${response.status}`,\n );\n }\n\n const payload = await response.json();\n\n const suggestions: AddressSuggestion[] = Array.isArray(\n payload?.features,\n )\n ? payload.features\n .map((feature: any) => mapGeoapifyFeature(feature))\n .filter(\n (\n suggestion: AddressSuggestion | null,\n ): suggestion is AddressSuggestion => Boolean(suggestion),\n )\n : [];\n\n setAddressSuggestions(suggestions);\n setShowSuggestions(suggestions.length > 0);\n\n if (autoComplete && suggestions.length === 1) {\n const single = suggestions[0];\n const normalizedQuery = query.trim().toLowerCase();\n if (\n normalizedQuery.length >= 6 &&\n single.label.toLowerCase().startsWith(normalizedQuery)\n ) {\n applyAddressSuggestion(single);\n }\n }\n } catch (error) {\n if ((error as Error).name === \"AbortError\") {\n return;\n }\n\n const fallback = FALLBACK_ADDRESS_SUGGESTIONS.filter((suggestion) =>\n suggestion.label.toLowerCase().includes(query.toLowerCase()),\n );\n setAddressSuggestions(fallback);\n setShowSuggestions(fallback.length > 0);\n } finally {\n addressRequestState.current.controller = null;\n }\n }, 250);\n };\n\n useEffect(() => {\n if (!initialUserInput) {\n return;\n }\n\n if (\n isFirstRender.current ||\n (!form.firstName &&\n !form.lastName &&\n !form.email &&\n !form.phoneNumber &&\n !form.companyName)\n ) {\n const nextBirthParts = parseBirthDate(initialUserInput.birthDate || \"\");\n setForm((previous) => ({\n ...previous,\n lastName: initialUserInput.lastName || previous.lastName,\n firstName: initialUserInput.firstName || previous.firstName,\n birthDate: initialUserInput.birthDate || previous.birthDate,\n day: nextBirthParts.day,\n month: nextBirthParts.month,\n year: nextBirthParts.year,\n email: initialUserInput.email || previous.email,\n phoneNumber: initialUserInput.phoneNumber || previous.phoneNumber,\n sms: initialUserInput.sms || previous.sms,\n addressLine1: initialUserInput.addressLine1 || previous.addressLine1,\n addressLine2: initialUserInput.addressLine2 || previous.addressLine2,\n postalCode: initialUserInput.postalCode || previous.postalCode,\n city: initialUserInput.city || previous.city,\n countryCode: initialUserInput.countryCode || previous.countryCode,\n nationality: initialUserInput.nationality || previous.nationality,\n companyName: initialUserInput.companyName || previous.companyName,\n siret: initialUserInput.siret || previous.siret,\n tva: initialUserInput.tva || previous.tva,\n }));\n\n isFirstRender.current = false;\n }\n }, [\n initialUserInput,\n form.firstName,\n form.lastName,\n form.email,\n form.phoneNumber,\n form.companyName,\n ]);\n\n useEffect(() => {\n return () => {\n if (hideSuggestionTimeout.current) {\n clearTimeout(hideSuggestionTimeout.current);\n }\n if (addressRequestState.current.debounce) {\n clearTimeout(addressRequestState.current.debounce);\n }\n if (addressRequestState.current.controller) {\n addressRequestState.current.controller.abort();\n }\n };\n }, []);\n\n const handleFieldChange = (key: keyof UserInputFormState, value: string) => {\n setErrors((previous) => ({\n ...previous,\n [key]: false,\n notMajor: false,\n }));\n\n setForm((previous) => {\n const next = { ...previous, [key]: value };\n if (key === \"day\" || key === \"month\" || key === \"year\") {\n const { day, month, year } = next;\n if (day && month && year) {\n const paddedDay = day.padStart(2, \"0\");\n const paddedMonth = month.padStart(2, \"0\");\n next.birthDate = `${paddedDay}-${paddedMonth}-${year}`;\n } else {\n next.birthDate = \"\";\n }\n }\n return next;\n });\n };\n\n const handleAddressChange = (value: string) => {\n handleFieldChange(\"addressLine1\", value);\n requestAddressSuggestions(value, { autoComplete: true });\n };\n\n const handleAddressFocus = () => {\n requestAddressSuggestions(form.addressLine1, { autoComplete: false });\n };\n\n const handleAddressBlur = () => {\n if (hideSuggestionTimeout.current) {\n clearTimeout(hideSuggestionTimeout.current);\n }\n hideSuggestionTimeout.current = setTimeout(() => {\n setShowSuggestions(false);\n hideSuggestionTimeout.current = null;\n }, 150);\n };\n\n const validateForm = () => {\n const nextErrors: UserInputFormErrors = {};\n let hasError = false;\n\n const markError = (key: string) => {\n nextErrors[key] = true;\n hasError = true;\n };\n\n if (informationType === \"identity\") {\n if (requestedFields.has(\"prenom\") && !form.firstName) {\n markError(\"firstName\");\n }\n if (requestedFields.has(\"nom\") && !form.lastName) {\n markError(\"lastName\");\n }\n if (requestedFields.has(\"date_naissance\")) {\n if (!form.birthDate) {\n markError(\"birthDate\");\n } else if (!checkIsMajor(form.birthDate)) {\n nextErrors.notMajor = true;\n hasError = true;\n }\n }\n }\n\n if (informationType === \"identity-legal\") {\n if (requestedFields.has(\"nom\") && !form.companyName) {\n markError(\"companyName\");\n }\n if (requestedFields.has(\"siret\") && !form.siret) {\n markError(\"siret\");\n }\n if (requestedFields.has(\"tva\") && !form.tva) {\n markError(\"tva\");\n }\n }\n\n if (informationType === \"contact\") {\n if (requestedFields.has(\"email\")) {\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n if (!form.email || !emailRegex.test(form.email)) {\n markError(\"email\");\n }\n }\n if (requestedFields.has(\"sms\")) {\n if (\n !form.phoneNumber ||\n form.phoneNumber.replace(/\\D/g, \"\").length < 6\n ) {\n markError(\"phoneNumber\");\n }\n }\n }\n\n if (\n (informationType === \"address\" || informationType === \"identity-legal\") &&\n requestedFields.has(\"adresse\")\n ) {\n if (!form.addressLine1) {\n markError(\"addressLine1\");\n }\n if (!form.postalCode) {\n markError(\"postalCode\");\n }\n if (!form.city) {\n markError(\"city\");\n }\n if (!form.countryCode) {\n markError(\"country\");\n }\n }\n\n if (\n informationType === \"nationality\" &&\n requestedFields.has(\"nationalite\")\n ) {\n if (!form.nationality) {\n markError(\"nationality\");\n }\n }\n\n setErrors(nextErrors);\n return !hasError;\n };\n\n const validateCustomForm = () => {\n const errors: Record<string, boolean> = {};\n let hasError = false;\n\n node.customFields?.forEach((field) => {\n const value = customFormData[field.id];\n\n if (field.valueType === \"list\") {\n const rows = Array.isArray(value) ? value : [];\n const minRows = getListFieldMinRows(field);\n\n if (field.required && countNonEmptyListRows(rows) < minRows) {\n errors[field.id] = true;\n hasError = true;\n }\n return;\n }\n\n // Check if required field is missing\n if (field.required && !value) {\n errors[field.id] = true;\n hasError = true;\n return;\n }\n\n // Type-specific validation\n if (value) {\n switch (field.valueType) {\n case \"number\":\n if (isNaN(Number(value))) {\n errors[field.id] = true;\n hasError = true;\n }\n break;\n\n case \"date\":\n // Date format: DD-MM-YYYY\n // For required dates, all parts must be filled\n if (field.required) {\n const dateParts = value.split(\"-\");\n if (\n dateParts.length !== 3 ||\n !dateParts[0] ||\n !dateParts[1] ||\n !dateParts[2]\n ) {\n errors[field.id] = true;\n hasError = true;\n break;\n }\n\n // Validate month and day ranges\n const day = parseInt(dateParts[0], 10);\n const month = parseInt(dateParts[1], 10);\n const year = parseInt(dateParts[2], 10);\n\n if (\n isNaN(day) ||\n isNaN(month) ||\n isNaN(year) ||\n month < 1 ||\n month > 12 ||\n day < 1 ||\n day > 31\n ) {\n errors[field.id] = true;\n hasError = true;\n }\n }\n break;\n\n case \"address\":\n // Validate address object if required\n if (field.required && typeof value === \"object\") {\n const addressValue = value as {\n addressLine1?: string;\n postalCode?: string;\n city?: string;\n countryCode?: string;\n };\n if (\n !addressValue.addressLine1 ||\n !addressValue.postalCode ||\n !addressValue.city ||\n !addressValue.countryCode\n ) {\n errors[field.id] = true;\n hasError = true;\n }\n }\n break;\n }\n }\n });\n\n setCustomFormErrors(errors);\n return !hasError;\n };\n\n const handleCustomFieldChange = (fieldId: string, value: any) => {\n setCustomFormData((prev) => ({ ...prev, [fieldId]: value }));\n setCustomFormErrors((prev) => ({ ...prev, [fieldId]: false }));\n };\n\n const goOnNextStep = () => {\n // Handle custom form validation and submission\n if (informationType === \"custom\") {\n if (!validateCustomForm()) {\n return;\n }\n\n setUserInput((prev) => ({\n ...prev,\n customFormData: { ...(prev.customFormData ?? {}), ...customFormData },\n }));\n\n if (onContinueCallback) {\n onContinueCallback();\n } else {\n goToNextStep(node.id, template);\n }\n return;\n }\n\n // Standard form validation\n if (!validateForm()) {\n return;\n }\n\n setUserInput((previous) => ({\n ...previous,\n ...(requestedFields.has(\"nom\") && {\n ...(informationType === \"identity-legal\"\n ? { companyName: form.companyName }\n : { lastName: form.lastName }),\n }),\n ...(requestedFields.has(\"prenom\") && { firstName: form.firstName }),\n ...(requestedFields.has(\"date_naissance\") && {\n birthDate: form.birthDate,\n }),\n ...(requestedFields.has(\"email\") && { email: form.email }),\n ...(requestedFields.has(\"sms\") && {\n phoneNumber: form.phoneNumber,\n sms: form.phoneNumber,\n }),\n ...(requestedFields.has(\"adresse\") && {\n addressLine1: form.addressLine1,\n addressLine2: form.addressLine2,\n postalCode: form.postalCode,\n city: form.city,\n countryCode: form.countryCode,\n }),\n ...(requestedFields.has(\"siret\") && { siret: form.siret }),\n ...(requestedFields.has(\"tva\") && { tva: form.tva }),\n ...(requestedFields.has(\"nationalite\") && {\n nationality: form.nationality,\n }),\n }));\n\n if (informationType === \"contact\" && setContactInfo) {\n setContactInfo((previous) => ({\n ...previous,\n ...(requestedFields.has(\"email\") && { email: form.email }),\n ...(requestedFields.has(\"sms\") && { phoneNumber: form.phoneNumber }),\n }));\n }\n\n if (onContinueCallback) {\n onContinueCallback();\n } else {\n goToNextStep(node.id, template);\n }\n };\n\n const goOnPreviousStep = () => {\n setStep(Math.max(0, step - 1));\n };\n\n const pageTitle = node.pageTitle || formTitles[informationType];\n\n const pageDescription =\n node.pageDescription || formDescriptions[informationType];\n\n return {\n form,\n errors,\n informationType,\n requestedFields,\n pageTitle,\n pageDescription,\n addressSuggestions,\n showSuggestions,\n handleFieldChange,\n handleAddressChange,\n handleAddressFocus,\n handleAddressBlur,\n applyAddressSuggestion,\n goOnNextStep,\n goOnPreviousStep,\n customFormData,\n customFormErrors,\n handleCustomFieldChange,\n };\n};\n"],"names":["useI18n","useMemo","resolveInformationType","DEFAULT_FIELDS","parseBirthDate","useState","useRef","__assign","__awaiter","API_BASE_URL","GEOCODING_AUTOCOMPLETE_ENDPOINT","FALLBACK_ADDRESS_SUGGESTIONS","useEffect","checkIsMajor","getListFieldMinRows","countNonEmptyListRows"],"mappings":";;;;;;;;;;AAgDO,IAAM,gBAAgB,GAAG,UAAC,EASZ,EAAA;QARnB,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,YAAY,GAAA,EAAA,CAAA,YAAA,EACZ,gBAAgB,GAAA,EAAA,CAAA,gBAAA,EAChB,IAAI,GAAA,EAAA,CAAA,IAAA,EACJ,QAAQ,GAAA,EAAA,CAAA,QAAA,EACR,WAAW,GAAA,EAAA,CAAA,WAAA,EACX,cAAc,GAAA,EAAA,CAAA,cAAA,EACd,kBAAkB,GAAA,EAAA,CAAA,kBAAA;AAEV,IAAA,IAAA,OAAO,GAAyB,UAAU,CAAA,OAAnC,EAAE,YAAY,GAAW,UAAU,CAAA,YAArB,EAAE,IAAI,GAAK,UAAU,KAAf;AAC3B,IAAA,IAAA,CAAC,G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AG,IAAI,CAAC,SAAS,IAAI,UAAU,CAAC,eAAe,CAAC;IAE/D,IAAM,eAAe,GACnB,IAAI,CAAC,eAAe,IAAI,gBAAgB,CAAC,eAAe,CAAC;IAE3D,OAAO;AACL,QAAA,IAAI,EAAA,IAAA;AACJ,QAAA,MAAM,EAAA,MAAA;AACN,QAAA,eAAe,EAAA,eAAA;AACf,QAAA,eAAe,EAAA,eAAA;AACf,QAAA,SAAS,EAAA,SAAA;AACT,QAAA,eAAe,EAAA,eAAA;AACf,QAAA,kBAAkB,EAAA,kBAAA;AAClB,QAAA,eAAe,EAAA,eAAA;AACf,QAAA,iBAAiB,EAAA,iBAAA;AACjB,QAAA,mBAAmB,EAAA,mBAAA;AACnB,QAAA,kBAAkB,EAAA,kBAAA;AAClB,QAAA,iBAAiB,EAAA,iBAAA;AACjB,QAAA,sBAAsB,EAAA,sBAAA;AACtB,QAAA,YAAY,EAAA,YAAA;AACZ,QAAA,gBAAgB,EAAA,gBAAA;AAChB,QAAA,cAAc,EAAA,cAAA;AACd,QAAA,gBAAgB,EAAA,gBAAA;AAChB,QAAA,uBAAuB,EAAA,uBAAA;KACxB;AACH;;;;"}
1
+ {"version":3,"file":"useUserInputForm.js","sources":["../../../../src/hooks/useUserInputForm.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { UserInputFormProps } from \"../types/userInput\";\nimport type {\n AddressSuggestion,\n InformationType,\n RequestedFields,\n UserInputFormErrors,\n UserInputFormState,\n} from \"../types/userInputForm\";\nimport {\n DEFAULT_FIELDS,\n FALLBACK_ADDRESS_SUGGESTIONS,\n GEOCODING_AUTOCOMPLETE_ENDPOINT,\n} from \"../constants/userInputForm\";\nimport { API_BASE_URL } from \"../config/env\";\nimport {\n checkIsMajor,\n parseBirthDate,\n resolveInformationType,\n} from \"../utils/userInputForm\";\nimport {\n countNonEmptyListRows,\n getListFieldMinRows,\n} from \"../utils/listFieldUtils\";\nimport { useI18n } from \"./useI18n\";\n\ninterface UseUserInputFormResult {\n form: UserInputFormState;\n errors: UserInputFormErrors;\n informationType: InformationType;\n requestedFields: RequestedFields;\n pageTitle: string;\n pageDescription: string;\n addressSuggestions: AddressSuggestion[];\n showSuggestions: boolean;\n handleFieldChange: (key: keyof UserInputFormState, value: string) => void;\n handleAddressChange: (value: string) => void;\n handleAddressFocus: () => void;\n handleAddressBlur: () => void;\n applyAddressSuggestion: (suggestion: AddressSuggestion) => void;\n goOnNextStep: () => void;\n goOnPreviousStep: () => void;\n // Custom form fields\n customFormData: Record<string, any>;\n customFormErrors: Record<string, boolean>;\n handleCustomFieldChange: (fieldId: string, value: any) => void;\n}\n\nexport const useUserInputForm = ({\n stepObject,\n setUserInput,\n initialUserInput,\n node,\n template,\n contactInfo,\n setContactInfo,\n onContinueCallback,\n}: UserInputFormProps): UseUserInputFormResult => {\n const { setStep, goBack, goToNextStep, step } = stepObject;\n const { t } = useI18n();\n\n const informationType = useMemo<InformationType>(() => {\n const resolved = resolveInformationType(\n node.informationType as string,\n \"identity\",\n );\n console.log(\"🔍 [useUserInputForm] Resolving informationType:\", {\n nodeInformationType: node.informationType,\n resolved,\n hasCustomFields: !!node.customFields,\n customFieldsCount: node.customFields?.length,\n });\n return resolved;\n }, [node.informationType, node.customFields]);\n\n const requestedFields = useMemo<RequestedFields>(() => {\n const defaults = DEFAULT_FIELDS[informationType] || [];\n const optional =\n node.optionalFields && node.optionalFields.length > 0\n ? node.optionalFields\n : defaults;\n const merged = new Set<string>(optional);\n\n if (node.requiredFields) {\n node.requiredFields.forEach((field) => merged.add(field));\n }\n\n return merged;\n }, [node.optionalFields, node.requiredFields, informationType]);\n\n const birthDateParts = useMemo(\n () => parseBirthDate(initialUserInput?.birthDate || \"\"),\n [initialUserInput?.birthDate],\n );\n\n const [form, setForm] = useState<UserInputFormState>({\n lastName: initialUserInput?.lastName || \"\",\n firstName: initialUserInput?.firstName || \"\",\n birthDate: initialUserInput?.birthDate || \"\",\n day: birthDateParts.day,\n month: birthDateParts.month,\n year: birthDateParts.year,\n email: initialUserInput?.email || contactInfo?.email || \"\",\n phoneNumber:\n initialUserInput?.phoneNumber || contactInfo?.phoneNumber || \"\",\n sms: initialUserInput?.sms || \"\",\n addressLine1: initialUserInput?.addressLine1 || \"\",\n addressLine2: initialUserInput?.addressLine2 || \"\",\n postalCode: initialUserInput?.postalCode || \"\",\n city: initialUserInput?.city || \"\",\n countryCode: initialUserInput?.countryCode || \"\",\n nationality: initialUserInput?.nationality || \"\",\n companyName: initialUserInput?.companyName || \"\",\n siret: initialUserInput?.siret || \"\",\n tva: initialUserInput?.tva || \"\",\n });\n\n const [errors, setErrors] = useState<UserInputFormErrors>({});\n\n // Custom form state\n const [customFormData, setCustomFormData] = useState<Record<string, any>>(\n () => {\n if (informationType !== \"custom\" || !node.customFields) return {};\n\n const initial: Record<string, any> = {};\n node.customFields.forEach((field) => {\n const savedValue = initialUserInput?.customFormData?.[field.id];\n if (field.valueType === \"list\") {\n initial[field.id] = Array.isArray(savedValue) ? savedValue : [];\n return;\n }\n\n initial[field.id] = savedValue || \"\";\n });\n return initial;\n },\n );\n const [customFormErrors, setCustomFormErrors] = useState<\n Record<string, boolean>\n >({});\n\n const [addressSuggestions, setAddressSuggestions] = useState<\n AddressSuggestion[]\n >([]);\n const [showSuggestions, setShowSuggestions] = useState(false);\n const isFirstRender = useRef(true);\n const hideSuggestionTimeout = useRef<ReturnType<typeof setTimeout> | null>(\n null,\n );\n const addressRequestState = useRef<{\n debounce: ReturnType<typeof setTimeout> | null;\n controller: AbortController | null;\n }>({\n debounce: null,\n controller: null,\n });\n\n const formTitles = useMemo<Record<InformationType, string>>(\n () => ({\n identity: t(\"user_input_form.titles.identity\"),\n \"identity-legal\": t(\"user_input_form.titles.identity_legal\"),\n contact: t(\"user_input_form.titles.contact\"),\n address: t(\"user_input_form.titles.address\"),\n nationality: t(\"user_input_form.titles.nationality\"),\n custom: t(\"user_input_form.titles.custom\"),\n }),\n [t],\n );\n\n const formDescriptions = useMemo<Record<InformationType, string>>(\n () => ({\n identity: t(\"user_input_form.descriptions.identity\"),\n \"identity-legal\": t(\"user_input_form.descriptions.identity_legal\"),\n contact: t(\"user_input_form.descriptions.contact\"),\n address: t(\"user_input_form.descriptions.address\"),\n nationality: t(\"user_input_form.descriptions.nationality\"),\n custom: t(\"user_input_form.descriptions.custom\"),\n }),\n [t],\n );\n\n const applyAddressSuggestion = (suggestion: AddressSuggestion) => {\n const normalizedCountry =\n suggestion.countryCode?.toUpperCase() || suggestion.country || \"\";\n\n setForm((previous) => ({\n ...previous,\n addressLine1: suggestion.addressLine1 || suggestion.label,\n postalCode: suggestion.postalCode || previous.postalCode,\n city: suggestion.city || previous.city,\n countryCode: normalizedCountry || previous.countryCode,\n }));\n setErrors((previous) => ({\n ...previous,\n addressLine1: false,\n postalCode: false,\n city: false,\n country: false,\n }));\n setShowSuggestions(false);\n setAddressSuggestions([]);\n };\n\n const mapGeoapifyFeature = (feature: any): AddressSuggestion | null => {\n if (!feature || !feature.properties) {\n return null;\n }\n\n const { properties } = feature;\n const label: string =\n properties.formatted ||\n properties.address_line1 ||\n [properties.housenumber, properties.street]\n .filter(Boolean)\n .join(\" \")\n .trim();\n\n if (!label) {\n return null;\n }\n\n const addressLine1 =\n [properties.housenumber, properties.street]\n .filter(Boolean)\n .join(\" \")\n .trim() ||\n properties.address_line1 ||\n label;\n\n const city =\n properties.city ||\n properties.town ||\n properties.village ||\n properties.state ||\n \"\";\n\n return {\n id:\n (properties.place_id && String(properties.place_id)) ||\n feature.id ||\n `${properties.lon ?? \"\"}-${properties.lat ?? \"\"}-${label}`,\n label,\n addressLine1,\n postalCode: properties.postcode || \"\",\n city,\n country: properties.country || \"\",\n countryCode: properties.country_code || undefined,\n };\n };\n\n const requestAddressSuggestions = (\n query: string,\n { autoComplete }: { autoComplete: boolean },\n ) => {\n if (addressRequestState.current.debounce) {\n clearTimeout(addressRequestState.current.debounce);\n addressRequestState.current.debounce = null;\n }\n\n if (query.trim().length < 3) {\n if (addressRequestState.current.controller) {\n addressRequestState.current.controller.abort();\n addressRequestState.current.controller = null;\n }\n setAddressSuggestions([]);\n setShowSuggestions(false);\n return;\n }\n\n addressRequestState.current.debounce = setTimeout(async () => {\n if (addressRequestState.current.controller) {\n addressRequestState.current.controller.abort();\n }\n\n const controller = new AbortController();\n addressRequestState.current.controller = controller;\n\n try {\n const searchParams = new URLSearchParams({\n text: query,\n lang: \"fr\",\n });\n\n const response = await fetch(\n `${API_BASE_URL}${GEOCODING_AUTOCOMPLETE_ENDPOINT}?${searchParams.toString()}`,\n { signal: controller.signal },\n );\n\n if (!response.ok) {\n throw new Error(\n `Geocoding request failed with status ${response.status}`,\n );\n }\n\n const payload = await response.json();\n\n const suggestions: AddressSuggestion[] = Array.isArray(\n payload?.features,\n )\n ? payload.features\n .map((feature: any) => mapGeoapifyFeature(feature))\n .filter(\n (\n suggestion: AddressSuggestion | null,\n ): suggestion is AddressSuggestion => Boolean(suggestion),\n )\n : [];\n\n setAddressSuggestions(suggestions);\n setShowSuggestions(suggestions.length > 0);\n\n if (autoComplete && suggestions.length === 1) {\n const single = suggestions[0];\n const normalizedQuery = query.trim().toLowerCase();\n if (\n normalizedQuery.length >= 6 &&\n single.label.toLowerCase().startsWith(normalizedQuery)\n ) {\n applyAddressSuggestion(single);\n }\n }\n } catch (error) {\n if ((error as Error).name === \"AbortError\") {\n return;\n }\n\n const fallback = FALLBACK_ADDRESS_SUGGESTIONS.filter((suggestion) =>\n suggestion.label.toLowerCase().includes(query.toLowerCase()),\n );\n setAddressSuggestions(fallback);\n setShowSuggestions(fallback.length > 0);\n } finally {\n addressRequestState.current.controller = null;\n }\n }, 250);\n };\n\n useEffect(() => {\n if (!initialUserInput) {\n return;\n }\n\n if (\n isFirstRender.current ||\n (!form.firstName &&\n !form.lastName &&\n !form.email &&\n !form.phoneNumber &&\n !form.companyName)\n ) {\n const nextBirthParts = parseBirthDate(initialUserInput.birthDate || \"\");\n setForm((previous) => ({\n ...previous,\n lastName: initialUserInput.lastName || previous.lastName,\n firstName: initialUserInput.firstName || previous.firstName,\n birthDate: initialUserInput.birthDate || previous.birthDate,\n day: nextBirthParts.day,\n month: nextBirthParts.month,\n year: nextBirthParts.year,\n email: initialUserInput.email || previous.email,\n phoneNumber: initialUserInput.phoneNumber || previous.phoneNumber,\n sms: initialUserInput.sms || previous.sms,\n addressLine1: initialUserInput.addressLine1 || previous.addressLine1,\n addressLine2: initialUserInput.addressLine2 || previous.addressLine2,\n postalCode: initialUserInput.postalCode || previous.postalCode,\n city: initialUserInput.city || previous.city,\n countryCode: initialUserInput.countryCode || previous.countryCode,\n nationality: initialUserInput.nationality || previous.nationality,\n companyName: initialUserInput.companyName || previous.companyName,\n siret: initialUserInput.siret || previous.siret,\n tva: initialUserInput.tva || previous.tva,\n }));\n\n isFirstRender.current = false;\n }\n }, [\n initialUserInput,\n form.firstName,\n form.lastName,\n form.email,\n form.phoneNumber,\n form.companyName,\n ]);\n\n useEffect(() => {\n return () => {\n if (hideSuggestionTimeout.current) {\n clearTimeout(hideSuggestionTimeout.current);\n }\n if (addressRequestState.current.debounce) {\n clearTimeout(addressRequestState.current.debounce);\n }\n if (addressRequestState.current.controller) {\n addressRequestState.current.controller.abort();\n }\n };\n }, []);\n\n const handleFieldChange = (key: keyof UserInputFormState, value: string) => {\n setErrors((previous) => ({\n ...previous,\n [key]: false,\n notMajor: false,\n }));\n\n setForm((previous) => {\n const next = { ...previous, [key]: value };\n if (key === \"day\" || key === \"month\" || key === \"year\") {\n const { day, month, year } = next;\n if (day && month && year) {\n const paddedDay = day.padStart(2, \"0\");\n const paddedMonth = month.padStart(2, \"0\");\n next.birthDate = `${paddedDay}-${paddedMonth}-${year}`;\n } else {\n next.birthDate = \"\";\n }\n }\n return next;\n });\n };\n\n const handleAddressChange = (value: string) => {\n handleFieldChange(\"addressLine1\", value);\n requestAddressSuggestions(value, { autoComplete: true });\n };\n\n const handleAddressFocus = () => {\n requestAddressSuggestions(form.addressLine1, { autoComplete: false });\n };\n\n const handleAddressBlur = () => {\n if (hideSuggestionTimeout.current) {\n clearTimeout(hideSuggestionTimeout.current);\n }\n hideSuggestionTimeout.current = setTimeout(() => {\n setShowSuggestions(false);\n hideSuggestionTimeout.current = null;\n }, 150);\n };\n\n const validateForm = () => {\n const nextErrors: UserInputFormErrors = {};\n let hasError = false;\n\n const markError = (key: string) => {\n nextErrors[key] = true;\n hasError = true;\n };\n\n if (informationType === \"identity\") {\n if (requestedFields.has(\"prenom\") && !form.firstName) {\n markError(\"firstName\");\n }\n if (requestedFields.has(\"nom\") && !form.lastName) {\n markError(\"lastName\");\n }\n if (requestedFields.has(\"date_naissance\")) {\n if (!form.birthDate) {\n markError(\"birthDate\");\n } else if (!checkIsMajor(form.birthDate)) {\n nextErrors.notMajor = true;\n hasError = true;\n }\n }\n }\n\n if (informationType === \"identity-legal\") {\n if (requestedFields.has(\"nom\") && !form.companyName) {\n markError(\"companyName\");\n }\n if (requestedFields.has(\"siret\") && !form.siret) {\n markError(\"siret\");\n }\n if (requestedFields.has(\"tva\") && !form.tva) {\n markError(\"tva\");\n }\n }\n\n if (informationType === \"contact\") {\n if (requestedFields.has(\"email\")) {\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n if (!form.email || !emailRegex.test(form.email)) {\n markError(\"email\");\n }\n }\n if (requestedFields.has(\"sms\")) {\n if (\n !form.phoneNumber ||\n form.phoneNumber.replace(/\\D/g, \"\").length < 6\n ) {\n markError(\"phoneNumber\");\n }\n }\n }\n\n if (\n (informationType === \"address\" || informationType === \"identity-legal\") &&\n requestedFields.has(\"adresse\")\n ) {\n if (!form.addressLine1) {\n markError(\"addressLine1\");\n }\n if (!form.postalCode) {\n markError(\"postalCode\");\n }\n if (!form.city) {\n markError(\"city\");\n }\n if (!form.countryCode) {\n markError(\"country\");\n }\n }\n\n if (\n informationType === \"nationality\" &&\n requestedFields.has(\"nationalite\")\n ) {\n if (!form.nationality) {\n markError(\"nationality\");\n }\n }\n\n setErrors(nextErrors);\n return !hasError;\n };\n\n const validateCustomForm = () => {\n const errors: Record<string, boolean> = {};\n let hasError = false;\n\n node.customFields?.forEach((field) => {\n const value = customFormData[field.id];\n\n if (field.valueType === \"list\") {\n const rows = Array.isArray(value) ? value : [];\n const minRows = getListFieldMinRows(field);\n\n if (field.required && countNonEmptyListRows(rows) < minRows) {\n errors[field.id] = true;\n hasError = true;\n }\n return;\n }\n\n // Check if required field is missing\n if (field.required && !value) {\n errors[field.id] = true;\n hasError = true;\n return;\n }\n\n // Type-specific validation\n if (value) {\n switch (field.valueType) {\n case \"number\":\n if (isNaN(Number(value))) {\n errors[field.id] = true;\n hasError = true;\n }\n break;\n\n case \"date\":\n // Date format: DD-MM-YYYY\n // For required dates, all parts must be filled\n if (field.required) {\n const dateParts = value.split(\"-\");\n if (\n dateParts.length !== 3 ||\n !dateParts[0] ||\n !dateParts[1] ||\n !dateParts[2]\n ) {\n errors[field.id] = true;\n hasError = true;\n break;\n }\n\n // Validate month and day ranges\n const day = parseInt(dateParts[0], 10);\n const month = parseInt(dateParts[1], 10);\n const year = parseInt(dateParts[2], 10);\n\n if (\n isNaN(day) ||\n isNaN(month) ||\n isNaN(year) ||\n month < 1 ||\n month > 12 ||\n day < 1 ||\n day > 31\n ) {\n errors[field.id] = true;\n hasError = true;\n }\n }\n break;\n\n case \"address\":\n // Validate address object if required\n if (field.required && typeof value === \"object\") {\n const addressValue = value as {\n addressLine1?: string;\n postalCode?: string;\n city?: string;\n countryCode?: string;\n };\n if (\n !addressValue.addressLine1 ||\n !addressValue.postalCode ||\n !addressValue.city ||\n !addressValue.countryCode\n ) {\n errors[field.id] = true;\n hasError = true;\n }\n }\n break;\n }\n }\n });\n\n setCustomFormErrors(errors);\n return !hasError;\n };\n\n const handleCustomFieldChange = (fieldId: string, value: any) => {\n setCustomFormData((prev) => ({ ...prev, [fieldId]: value }));\n setCustomFormErrors((prev) => ({ ...prev, [fieldId]: false }));\n };\n\n const goOnNextStep = () => {\n // Handle custom form validation and submission\n if (informationType === \"custom\") {\n if (!validateCustomForm()) {\n return;\n }\n\n setUserInput((prev) => ({\n ...prev,\n customFormData: { ...(prev.customFormData ?? {}), ...customFormData },\n }));\n\n if (onContinueCallback) {\n onContinueCallback();\n } else {\n goToNextStep(node.id, template);\n }\n return;\n }\n\n // Standard form validation\n if (!validateForm()) {\n return;\n }\n\n setUserInput((previous) => ({\n ...previous,\n ...(requestedFields.has(\"nom\") && {\n ...(informationType === \"identity-legal\"\n ? { companyName: form.companyName }\n : { lastName: form.lastName }),\n }),\n ...(requestedFields.has(\"prenom\") && { firstName: form.firstName }),\n ...(requestedFields.has(\"date_naissance\") && {\n birthDate: form.birthDate,\n }),\n ...(requestedFields.has(\"email\") && { email: form.email }),\n ...(requestedFields.has(\"sms\") && {\n phoneNumber: form.phoneNumber,\n sms: form.phoneNumber,\n }),\n ...(requestedFields.has(\"adresse\") && {\n addressLine1: form.addressLine1,\n addressLine2: form.addressLine2,\n postalCode: form.postalCode,\n city: form.city,\n countryCode: form.countryCode,\n }),\n ...(requestedFields.has(\"siret\") && { siret: form.siret }),\n ...(requestedFields.has(\"tva\") && { tva: form.tva }),\n ...(requestedFields.has(\"nationalite\") && {\n nationality: form.nationality,\n }),\n }));\n\n if (informationType === \"contact\" && setContactInfo) {\n setContactInfo((previous) => ({\n ...previous,\n ...(requestedFields.has(\"email\") && { email: form.email }),\n ...(requestedFields.has(\"sms\") && { phoneNumber: form.phoneNumber }),\n }));\n }\n\n if (onContinueCallback) {\n onContinueCallback();\n } else {\n goToNextStep(node.id, template);\n }\n };\n\n const goOnPreviousStep = () => {\n console.log(\"[goOnPreviousStep] called — step:\", step, \"canGoBack:\", stepObject.canGoBack);\n goBack();\n };\n\n const pageTitle = node.pageTitle || formTitles[informationType];\n\n const pageDescription =\n node.pageDescription || formDescriptions[informationType];\n\n return {\n form,\n errors,\n informationType,\n requestedFields,\n pageTitle,\n pageDescription,\n addressSuggestions,\n showSuggestions,\n handleFieldChange,\n handleAddressChange,\n handleAddressFocus,\n handleAddressBlur,\n applyAddressSuggestion,\n goOnNextStep,\n goOnPreviousStep,\n customFormData,\n customFormErrors,\n handleCustomFieldChange,\n };\n};\n"],"names":["useI18n","useMemo","resolveInformationType","DEFAULT_FIELDS","parseBirthDate","useState","useRef","__assign","__awaiter","API_BASE_URL","GEOCODING_AUTOCOMPLETE_ENDPOINT","FALLBACK_ADDRESS_SUGGESTIONS","useEffect","checkIsMajor","getListFieldMinRows","countNonEmptyListRows"],"mappings":";;;;;;;;;;AAgDO,IAAM,gBAAgB,GAAG,UAAC,EASZ,EAAA;QARnB,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,YAAY,GAAA,EAAA,CAAA,YAAA,EACZ,gBAAgB,GAAA,EAAA,CAAA,gBAAA,EAChB,IAAI,GAAA,EAAA,CAAA,IAAA,EACJ,QAAQ,GAAA,EAAA,CAAA,QAAA,EACR,WAAW,GAAA,EAAA,CAAA,WAAA,EACX,cAAc,GAAA,EAAA,CAAA,cAAA,EACd,kBAAkB,GAAA,EAAA,CAAA,kBAAA;AAEV,IAAwC,UAAU,QAA3C,CAAA,KAAE,MAAM,GAAyB,UAAU,CAAA,MAAnC,EAAE,YAAY,GAAW,UAAU,CAAA,YAArB,CAAA,CAAE,IAAI,GAAK,UAAU;AAClD,IAAA,IAAA,CAAC,GAAKA,eAAO,EAAE,EAAd;IAET,IAAM,eAAe,GAAGC,aAAO,CAAkB,YAAA;;QAC/C,IAAM,QAAQ,GAAGC,oCAAsB,CACrC,IAAI,CAAC,eAAyB,EAC9B,UAAU,CACX;AACD,QAAA,OAAO,CAAC,GAAG,CAAC,kDAAkD,EAAE;YAC9D,mBAAmB,EAAE,IAAI,CAAC,eAAe;AACzC,YAAA,QAAQ,EAAA,QAAA;AACR,YAAA,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY;AACpC,YAAA,iBAAiB,EAAE,CAAA,EAAA,GAAA,IAAI,CAAC,YAAY,0CAAE,MAAM;AAC7C,SAAA,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AACf,QAAA,iBAAiB,EAAA,iBAAA;AACjB,QAAA,mBAAmB,EAAA,mBAAA;AACnB,QAAA,kBAAkB,EAAA,kBAAA;AAClB,QAAA,iBAAiB,EAAA,iBAAA;AACjB,QAAA,sBAAsB,EAAA,sBAAA;AACtB,QAAA,YAAY,EAAA,YAAA;AACZ,QAAA,gBAAgB,EAAA,gBAAA;AAChB,QAAA,cAAc,EAAA,cAAA;AACd,QAAA,gBAAgB,EAAA,gBAAA;AAChB,QAAA,uBAAuB,EAAA,uBAAA;KACxB;AACH;;;;"}
@@ -249,6 +249,41 @@ var getNextStepIndex = function (currentNodeId, template, handle) {
249
249
  // steps are 1-indexed in the SDK (0 is StartSession)
250
250
  return 1 + targetIndex;
251
251
  };
252
+ /**
253
+ * Reconstructs the navigation history by following the graph from step 0
254
+ * up to (and including) targetStep. Returns [0, ...stepIndices].
255
+ * If the graph path cannot reach targetStep, falls back to [0, targetStep].
256
+ */
257
+ var reconstructHistoryToStep = function (targetStep, template) {
258
+ if (targetStep <= 0)
259
+ return [0];
260
+ var orderedNodes = getOrderedJourneySteps(template);
261
+ var history = [0];
262
+ var currentStep = 1; // first node is step 1
263
+ // Follow the default (first) edge from each node in sequence
264
+ for (var safetyLimit = 0; safetyLimit < orderedNodes.length + 1; safetyLimit++) {
265
+ if (currentStep === targetStep) {
266
+ history.push(currentStep);
267
+ break;
268
+ }
269
+ if (currentStep > targetStep)
270
+ break;
271
+ var nodeIndex = currentStep - 1;
272
+ var currentNode = orderedNodes[nodeIndex];
273
+ if (!currentNode)
274
+ break;
275
+ history.push(currentStep);
276
+ var nextStep = getNextStepIndex(currentNode.id, template);
277
+ if (nextStep === null)
278
+ break;
279
+ currentStep = nextStep;
280
+ }
281
+ // Fallback: if we couldn't reach targetStep via graph, use simple seed
282
+ if (history[history.length - 1] !== targetStep) {
283
+ return [0, targetStep];
284
+ }
285
+ return history;
286
+ };
252
287
  /**
253
288
  * Checks if a session has expired
254
289
  *
@@ -375,6 +410,7 @@ exports.findOutgoingEdge = findOutgoingEdge;
375
410
  exports.getNextStepIndex = getNextStepIndex;
376
411
  exports.getOrderedJourneySteps = getOrderedJourneySteps;
377
412
  exports.isSessionExpired = isSessionExpired;
413
+ exports.reconstructHistoryToStep = reconstructHistoryToStep;
378
414
  exports.sendClientInfo = sendClientInfo;
379
415
  exports.storeDocumentOptions = storeDocumentOptions;
380
416
  exports.updateSessionContactInfo = updateSessionContactInfo;
@@ -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 * 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"],"names":["__awaiter","apiService","logStatusModified","clearSessionMemory"],"mappings":";;;;;;;AAAA;;;;;AAKG;AAYH;;;;;AAKG;AACI,IAAM,gBAAgB,GAAG,UAC9B,SAAiB,EAAA,EAAA,OAAAA,mBAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,YAAA;;;;;;gBAGE,OAAA,CAAA,CAAA,YAAMC,cAAU,CAAC,GAAG,CAAC,uBAAgB,SAAS,CAAE,CAAC,CAAA;;AAA5D,gBAAA,QAAQ,GAAG,EAAA,CAAA,IAAA,EAAiD;gBAClE,OAAA,CAAA,CAAA,aAAO,QAAQ,CAAC,IAAI,CAAA;;;AAEpB,gBAAA,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,OAAK,CAAC;AACpD,gBAAA,MAAM,OAAK;;;;;AAIf;;;;AAIG;AACI,IAAM,cAAc,GAAG,UAC5B,SAAiB,EACjB,UAAsB,EAAA,EAAA,OAAAD,mBAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,YAAA;;;;;;gBAGpB,OAAA,CAAA,CAAA,YAAMC,cAAU,CAAC,IAAI,CAAC,eAAA,CAAA,MAAA,CAAgB,SAAS,EAAA,cAAA,CAAc,EAAE,UAAU,CAAC,CAAA;;AAA1E,gBAAA,EAAA,CAAA,IAAA,EAA0E;;;;AAE1E,gBAAA,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,OAAK,CAAC;AAClD,gBAAA,MAAM,OAAK;;;;;AAgNf;;;;;;AAMG;AACI,IAAM,sBAAsB,GAAG,UACp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;;;;;;;;"}
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"],"names":["__awaiter","apiService","logStatusModified","clearSessionMemory"],"mappings":";;;;;;;AAAA;;;;;AAKG;AAYH;;;;;AAKG;AACI,IAAM,gBAAgB,GAAG,UAC9B,SAAiB,EAAA,EAAA,OAAAA,mBAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,YAAA;;;;;;gBAGE,OAAA,CAAA,CAAA,YAAMC,cAAU,CAAC,GAAG,CAAC,uBAAgB,SAAS,CAAE,CAAC,CAAA;;AAA5D,gBAAA,QAAQ,GAAG,EAAA,CAAA,IAAA,EAAiD;gBAClE,OAAA,CAAA,CAAA,aAAO,QAAQ,CAAC,IAAI,CAAA;;;AAEpB,gBAAA,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,OAAK,CAAC;AACpD,gBAAA,MAAM,OAAK;;;;;AAIf;;;;AAIG;AACI,IAAM,cAAc,GAAG,UAC5B,SAAiB,EACjB,UAAsB,EAAA,EAAA,OAAAD,mBAAA,CAAA,MAAA,EAA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AAA,GAAG,CAAC,UAAU,CAAC,cAAc,CAAC;AAC9B,YAAA,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,EACxB;AACA,YAAA,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC;QAChC;IACF;AACF;;;;;;;;;;;;;;;;"}
@@ -79,7 +79,7 @@ var CustomFormFields = function (_a) {
79
79
  var dateString = "".concat(newDay, "-").concat(newMonth, "-").concat(newYear);
80
80
  onFieldChange(field.id, dateString);
81
81
  };
82
- return (jsxs("div", { className: "grid grid-cols-3 gap-2 md:gap-3", children: [jsx(Select, { options: DAY_OPTIONS, value: day, onValueChange: function (val) { return handleDateChange_1("day", val); }, placeholder: "DD", error: hasError, allowCustomValue: true, inputMode: "numeric", pattern: "[0-9]*", maxLength: 2 }), jsx(Select, { options: MONTH_OPTIONS_WITH_NUMERIC_LABEL, value: month, onValueChange: function (val) { return handleDateChange_1("month", val); }, placeholder: "MM", error: hasError, allowCustomValue: true, inputMode: "numeric", maxLength: 2 }), jsx(Select, { options: YEAR_OPTIONS, value: year, onValueChange: function (val) { return handleDateChange_1("year", val); }, placeholder: "AAAA", error: hasError, allowCustomValue: true, inputMode: "numeric", pattern: "[0-9]*", maxLength: 4 })] }));
82
+ return (jsxs("div", { className: "grid grid-cols-3 gap-2 md:gap-3", children: [jsx(Select, { options: DAY_OPTIONS, value: day, onValueChange: function (val) { return handleDateChange_1("day", val); }, placeholder: "JJ", error: hasError, allowCustomValue: true, inputMode: "numeric", pattern: "[0-9]*", maxLength: 2 }), jsx(Select, { options: MONTH_OPTIONS_WITH_NUMERIC_LABEL, value: month, onValueChange: function (val) { return handleDateChange_1("month", val); }, placeholder: "MM", error: hasError, allowCustomValue: true, inputMode: "numeric", maxLength: 2 }), jsx(Select, { options: YEAR_OPTIONS, value: year, onValueChange: function (val) { return handleDateChange_1("year", val); }, placeholder: "AAAA", error: hasError, allowCustomValue: true, inputMode: "numeric", pattern: "[0-9]*", maxLength: 4 })] }));
83
83
  case "boolean":
84
84
  return (jsxs("div", { className: "flex items-center gap-2", children: [jsx("input", { id: field.id, type: "checkbox", checked: value || false, onChange: function (e) { return onFieldChange(field.id, e.target.checked); }, className: "h-4 w-4 text-[#11E5C5] border-gray-300 rounded focus:ring-[#11E5C5]" }), field.description && (jsx("span", { className: "text-sm text-gray-600", children: field.description }))] }));
85
85
  case "enum":
@@ -1 +1 @@
1
- {"version":3,"file":"CustomFormFields.js","sources":["../../../../../../src/components/session/UserInputForm/CustomFormFields.tsx"],"sourcesContent":["import { Fragment } from \"react\";\nimport * as Label from \"@radix-ui/react-label\";\nimport clsx from \"clsx\";\nimport { Select } from \"../../ui/SelectComponent\";\nimport type { CustomField, ListColumn } from \"../../../types/session\";\nimport { useI18n } from \"../../../hooks/useI18n\";\nimport AddressFields from \"./AddressFields\";\nimport type { AddressSuggestion } from \"../../../types/userInputForm\";\nimport {\n DAY_OPTIONS,\n MONTH_OPTIONS,\n YEAR_OPTIONS,\n} from \"../../../constants/userInputForm\";\nimport {\n createEmptyListRow,\n ensureMinimumListRows,\n getListFieldMinRows,\n normalizeListColumns,\n} from \"../../../utils/listFieldUtils\";\n\n/**\n * Sous-composant dédié au rendu d'une cellule du tableau dynamique.\n * Nécessaire pour que les hooks internes à Select soient toujours appelés\n * de façon stable (règle des hooks React).\n */\nconst ListCell = ({\n col,\n value,\n hasError,\n cellClasses,\n onChange,\n}: {\n col: ListColumn;\n value: string;\n hasError: boolean;\n cellClasses: string;\n onChange: (val: string) => void;\n}) => {\n if (col.type === \"enum\") {\n return (\n <Select\n options={(col.options ?? []).map((opt) => ({ value: opt, label: opt }))}\n value={value}\n onValueChange={onChange}\n placeholder={col.label}\n error={hasError}\n compact\n />\n );\n }\n return (\n <input\n type=\"text\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n placeholder={col.label}\n className={cellClasses}\n />\n );\n};\n\nconst MONTH_OPTIONS_WITH_NUMERIC_LABEL = MONTH_OPTIONS.map((option, index) => ({\n ...option,\n label: (index + 1).toString().padStart(2, \"0\"),\n}));\n\ninterface CustomFormFieldsProps {\n customFields: CustomField[];\n formData: Record<string, any>;\n errors: Record<string, boolean>;\n onFieldChange: (fieldId: string, value: any) => void;\n // Address autocomplete props (for address field type)\n addressSuggestions?: AddressSuggestion[];\n showSuggestions?: boolean;\n onAddressChange?: (fieldId: string, value: string) => void;\n onAddressFocus?: (fieldId: string) => void;\n onAddressBlur?: (fieldId: string) => void;\n onApplySuggestion?: (fieldId: string, suggestion: AddressSuggestion) => void;\n}\n\nconst CustomFormFields = ({\n customFields,\n formData,\n errors,\n onFieldChange,\n addressSuggestions = [],\n showSuggestions = false,\n onAddressChange,\n onAddressFocus,\n onAddressBlur,\n onApplySuggestion,\n}: CustomFormFieldsProps) => {\n const { t } = useI18n();\n\n console.log(\"🎨 [CustomFormFields] Rendering with:\", {\n fieldsCount: customFields.length,\n fields: customFields.map((f) => ({\n id: f.id,\n label: f.label,\n type: f.valueType,\n })),\n formData,\n errors,\n });\n\n const renderField = (field: CustomField) => {\n const hasError = errors[field.id];\n const value = formData[field.id];\n\n // Classes communes (EXACTEMENT comme IdentityFields/ContactFields)\n const inputClasses = clsx(\n \"w-full px-3 py-3 md:py-4 border rounded-lg text-base transition-colors focus:outline-none focus:ring-2 focus:ring-[#11E5C5] focus:border-transparent\",\n hasError\n ? \"border-red-500 bg-red-50\"\n : \"border-gray-300 hover:border-gray-400\",\n );\n\n switch (field.valueType) {\n case \"text\":\n return (\n <input\n id={field.id}\n type=\"text\"\n value={value || \"\"}\n onChange={(e) => onFieldChange(field.id, e.target.value)}\n placeholder={field.placeholder}\n className={inputClasses}\n autoComplete=\"off\"\n />\n );\n\n case \"number\":\n return (\n <input\n id={field.id}\n type=\"number\"\n inputMode=\"numeric\"\n value={value || \"\"}\n onChange={(e) => onFieldChange(field.id, e.target.value)}\n placeholder={field.placeholder}\n className={inputClasses}\n />\n );\n\n case \"date\":\n // Parse existing date value (DD-MM-YYYY format)\n const dateParts = value ? value.split(\"-\") : [\"\", \"\", \"\"];\n const day = dateParts[0] || \"\";\n const month = dateParts[1] || \"\";\n const year = dateParts[2] || \"\";\n\n const handleDateChange = (\n part: \"day\" | \"month\" | \"year\",\n partValue: string,\n ) => {\n const currentParts = value ? value.split(\"-\") : [\"\", \"\", \"\"];\n const newDay = part === \"day\" ? partValue : currentParts[0] || \"\";\n const newMonth = part === \"month\" ? partValue : currentParts[1] || \"\";\n const newYear = part === \"year\" ? partValue : currentParts[2] || \"\";\n\n // Validate month range (1-12)\n if (part === \"month\" && partValue) {\n const monthNum = parseInt(partValue, 10);\n if (monthNum < 1 || monthNum > 12) {\n // Don't save invalid month\n return;\n }\n }\n\n // Validate day range (1-31) - basic validation\n if (part === \"day\" && partValue) {\n const dayNum = parseInt(partValue, 10);\n if (dayNum < 1 || dayNum > 31) {\n // Don't save invalid day\n return;\n }\n }\n\n // Always store the current state (even partial dates)\n const dateString = `${newDay}-${newMonth}-${newYear}`;\n onFieldChange(field.id, dateString);\n };\n\n return (\n <div className=\"grid grid-cols-3 gap-2 md:gap-3\">\n <Select\n options={DAY_OPTIONS}\n value={day}\n onValueChange={(val) => handleDateChange(\"day\", val)}\n placeholder=\"DD\"\n error={hasError}\n allowCustomValue\n inputMode=\"numeric\"\n pattern=\"[0-9]*\"\n maxLength={2}\n />\n <Select\n options={MONTH_OPTIONS_WITH_NUMERIC_LABEL}\n value={month}\n onValueChange={(val) => handleDateChange(\"month\", val)}\n placeholder=\"MM\"\n error={hasError}\n allowCustomValue\n inputMode=\"numeric\"\n maxLength={2}\n />\n <Select\n options={YEAR_OPTIONS}\n value={year}\n onValueChange={(val) => handleDateChange(\"year\", val)}\n placeholder=\"AAAA\"\n error={hasError}\n allowCustomValue\n inputMode=\"numeric\"\n pattern=\"[0-9]*\"\n maxLength={4}\n />\n </div>\n );\n\n case \"boolean\":\n return (\n <div className=\"flex items-center gap-2\">\n <input\n id={field.id}\n type=\"checkbox\"\n checked={value || false}\n onChange={(e) => onFieldChange(field.id, e.target.checked)}\n className=\"h-4 w-4 text-[#11E5C5] border-gray-300 rounded focus:ring-[#11E5C5]\"\n />\n {field.description && (\n <span className=\"text-sm text-gray-600\">{field.description}</span>\n )}\n </div>\n );\n\n case \"enum\":\n return (\n <Select\n options={(field.enumOptions || []).map((opt) => ({\n value: opt,\n label: opt,\n }))}\n value={value || \"\"}\n onValueChange={(val) => onFieldChange(field.id, val)}\n placeholder={field.placeholder || t(\"custom_form.select_option\")}\n error={hasError}\n />\n );\n\n case \"address\":\n // For address, use the existing AddressFields component\n const addressValue = value || {};\n const addressForm = {\n lastName: \"\",\n firstName: \"\",\n birthDate: \"\",\n day: \"\",\n month: \"\",\n year: \"\",\n email: \"\",\n phoneNumber: \"\",\n sms: \"\",\n addressLine1: addressValue.addressLine1 || \"\",\n addressLine2: addressValue.addressLine2 || \"\",\n postalCode: addressValue.postalCode || \"\",\n city: addressValue.city || \"\",\n countryCode: addressValue.countryCode || \"\",\n nationality: \"\",\n companyName: \"\",\n siret: \"\",\n tva: \"\",\n };\n\n return (\n <AddressFields\n form={addressForm}\n errors={{\n addressLine1: hasError,\n addressLine2: false,\n postalCode: hasError,\n city: hasError,\n country: hasError,\n }}\n requestedFields={new Set([\"adresse\"])}\n onFieldChange={(key, val) => {\n const updatedAddress = {\n ...addressValue,\n [key]: val,\n };\n onFieldChange(field.id, updatedAddress);\n }}\n addressSuggestions={addressSuggestions}\n showSuggestions={showSuggestions}\n onAddressChange={(val) => {\n const updatedAddress = {\n ...addressValue,\n addressLine1: val,\n };\n onFieldChange(field.id, updatedAddress);\n onAddressChange?.(field.id, val);\n }}\n onAddressFocus={() => onAddressFocus?.(field.id)}\n onAddressBlur={() => onAddressBlur?.(field.id)}\n onApplySuggestion={(suggestion) => {\n const updatedAddress = {\n addressLine1: suggestion.label || \"\",\n addressLine2: addressValue.addressLine2 || \"\",\n postalCode: suggestion.postalCode || \"\",\n city: suggestion.city || \"\",\n countryCode: suggestion.countryCode || \"\",\n };\n onFieldChange(field.id, updatedAddress);\n onApplySuggestion?.(field.id, suggestion);\n }}\n />\n );\n\n case \"list\": {\n const persistedRows: Record<string, string>[] = Array.isArray(value)\n ? value\n : [];\n const columns: ListColumn[] = normalizeListColumns(field.listColumns);\n const minRows = getListFieldMinRows(field);\n const rows = ensureMinimumListRows(persistedRows, columns, minRows);\n const gridTemplateColumns = `repeat(${columns.length}, minmax(180px, 1fr)) 32px`;\n const gridMinWidth = `${columns.length * 180 + (columns.length - 1) * 8 + 32}px`;\n\n if (columns.length === 0) {\n return (\n <p className=\"text-sm text-red-600\">\n {t(\n \"custom_form.list_missing_columns\",\n \"Ce tableau n'a pas de colonnes configurées.\",\n )}\n </p>\n );\n }\n\n const handleRowChange = (\n rowIndex: number,\n colName: string,\n colValue: string,\n ) => {\n const updated = [...rows];\n updated[rowIndex] = { ...updated[rowIndex], [colName]: colValue };\n onFieldChange(field.id, updated);\n };\n\n const handleAddRow = () => {\n const emptyRow = createEmptyListRow(columns);\n onFieldChange(field.id, [...rows, emptyRow]);\n };\n\n const handleRemoveRow = (rowIndex: number) => {\n if (rows.length <= minRows) {\n return;\n }\n\n onFieldChange(\n field.id,\n rows.filter((_, i) => i !== rowIndex),\n );\n };\n\n const cellClasses = clsx(\n \"w-full px-2 py-2 border rounded-lg text-sm transition-colors focus:outline-none focus:ring-2 focus:ring-[#11E5C5] focus:border-transparent\",\n hasError\n ? \"border-red-500 bg-red-50\"\n : \"border-gray-300 hover:border-gray-400\",\n );\n\n return (\n <div className=\"space-y-3 overflow-x-auto\">\n {columns.length > 0 && (\n <div\n className=\"grid gap-2 items-center w-full\"\n style={{\n gridTemplateColumns,\n minWidth: gridMinWidth,\n }}\n >\n {columns.map((col) => (\n <span\n key={col.label}\n className=\"text-xs font-semibold text-gray-600 uppercase tracking-wide truncate\"\n >\n {col.label}\n </span>\n ))}\n <span />\n </div>\n )}\n\n {rows.map((row, rowIndex) => (\n <div\n key={rowIndex}\n className=\"grid gap-2 items-center w-full\"\n style={{\n gridTemplateColumns,\n minWidth: gridMinWidth,\n }}\n >\n {columns.map((col) => (\n <ListCell\n key={col.label}\n col={col}\n value={row[col.label] || \"\"}\n hasError={hasError}\n cellClasses={cellClasses}\n onChange={(val) => handleRowChange(rowIndex, col.label, val)}\n />\n ))}\n <button\n type=\"button\"\n onClick={() => handleRemoveRow(rowIndex)}\n className={clsx(\n \"flex items-center justify-center w-8 h-8 rounded-full transition-colors\",\n rows.length <= minRows\n ? \"text-gray-300 cursor-not-allowed\"\n : \"text-gray-400 hover:text-red-500 hover:bg-red-50\",\n )}\n aria-label={t(\"custom_form.remove_row\", \"Supprimer la ligne\")}\n disabled={rows.length <= minRows}\n >\n ✕\n </button>\n </div>\n ))}\n\n <button\n type=\"button\"\n onClick={handleAddRow}\n className=\"flex items-center gap-2 text-sm text-[#11E5C5] hover:underline font-medium\"\n >\n + {t(\"custom_form.add_row\", \"Ajouter une ligne\")}\n </button>\n </div>\n );\n }\n\n default:\n return null;\n }\n };\n\n return (\n <Fragment>\n {customFields.map((field) => (\n <div key={field.id} className=\"space-y-2\">\n <Label.Root\n htmlFor={field.id}\n className=\"block text-sm md:text-base font-semibold text-gray-900\"\n >\n {field.label}\n {field.required && <span className=\"text-red-500 ml-1\">*</span>}\n </Label.Root>\n\n {field.description && field.valueType !== \"boolean\" && (\n <p className=\"text-xs text-gray-500 -mt-1\">{field.description}</p>\n )}\n\n {renderField(field)}\n\n {errors[field.id] && (\n <p className=\"text-red-600 text-sm flex items-center gap-1\">\n <span className=\"text-red-500\">⚠</span>\n {field.required\n ? t(\"custom_form.required_field\")\n : t(\"custom_form.invalid_value\")}\n </p>\n )}\n </div>\n ))}\n </Fragment>\n );\n};\n\nexport default CustomFormFields;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;AAoBA;;;;AAIG;AACH,IAAM,QAAQ,GAAG,UAAC,EAYjB,EAAA;;AAXC,IAAA,IAAA,GAAG,GAAA,EAAA,CAAA,GAAA,EACH,KAAK,GAAA,EAAA,CAAA,KAAA,EACL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AAC,KAAK,CAAC,EAElB,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KACfC,IAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,8CAA8C,EAAA,QAAA,EAAA,CACzDD,cAAM,SAAS,EAAC,cAAc,EAAA,QAAA,EAAA,QAAA,EAAA,CAAS,EACtC,KAAK,CAAC;AACL,8BAAE,CAAC,CAAC,4BAA4B;AAChC,8BAAE,CAAC,CAAC,2BAA2B,CAAC,CAAA,EAAA,CAChC,CACL,CAAA,EAAA,EAtBO,KAAK,CAAC,EAAE,CAuBZ,EACP,CAzB4B,CAyB5B,CAAC,EAAA,CACO;AAEf;;;;"}
1
+ {"version":3,"file":"CustomFormFields.js","sources":["../../../../../../src/components/session/UserInputForm/CustomFormFields.tsx"],"sourcesContent":["import { Fragment } from \"react\";\nimport * as Label from \"@radix-ui/react-label\";\nimport clsx from \"clsx\";\nimport { Select } from \"../../ui/SelectComponent\";\nimport type { CustomField, ListColumn } from \"../../../types/session\";\nimport { useI18n } from \"../../../hooks/useI18n\";\nimport AddressFields from \"./AddressFields\";\nimport type { AddressSuggestion } from \"../../../types/userInputForm\";\nimport {\n DAY_OPTIONS,\n MONTH_OPTIONS,\n YEAR_OPTIONS,\n} from \"../../../constants/userInputForm\";\nimport {\n createEmptyListRow,\n ensureMinimumListRows,\n getListFieldMinRows,\n normalizeListColumns,\n} from \"../../../utils/listFieldUtils\";\n\n/**\n * Sous-composant dédié au rendu d'une cellule du tableau dynamique.\n * Nécessaire pour que les hooks internes à Select soient toujours appelés\n * de façon stable (règle des hooks React).\n */\nconst ListCell = ({\n col,\n value,\n hasError,\n cellClasses,\n onChange,\n}: {\n col: ListColumn;\n value: string;\n hasError: boolean;\n cellClasses: string;\n onChange: (val: string) => void;\n}) => {\n if (col.type === \"enum\") {\n return (\n <Select\n options={(col.options ?? []).map((opt) => ({ value: opt, label: opt }))}\n value={value}\n onValueChange={onChange}\n placeholder={col.label}\n error={hasError}\n compact\n />\n );\n }\n return (\n <input\n type=\"text\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n placeholder={col.label}\n className={cellClasses}\n />\n );\n};\n\nconst MONTH_OPTIONS_WITH_NUMERIC_LABEL = MONTH_OPTIONS.map((option, index) => ({\n ...option,\n label: (index + 1).toString().padStart(2, \"0\"),\n}));\n\ninterface CustomFormFieldsProps {\n customFields: CustomField[];\n formData: Record<string, any>;\n errors: Record<string, boolean>;\n onFieldChange: (fieldId: string, value: any) => void;\n // Address autocomplete props (for address field type)\n addressSuggestions?: AddressSuggestion[];\n showSuggestions?: boolean;\n onAddressChange?: (fieldId: string, value: string) => void;\n onAddressFocus?: (fieldId: string) => void;\n onAddressBlur?: (fieldId: string) => void;\n onApplySuggestion?: (fieldId: string, suggestion: AddressSuggestion) => void;\n}\n\nconst CustomFormFields = ({\n customFields,\n formData,\n errors,\n onFieldChange,\n addressSuggestions = [],\n showSuggestions = false,\n onAddressChange,\n onAddressFocus,\n onAddressBlur,\n onApplySuggestion,\n}: CustomFormFieldsProps) => {\n const { t } = useI18n();\n\n console.log(\"🎨 [CustomFormFields] Rendering with:\", {\n fieldsCount: customFields.length,\n fields: customFields.map((f) => ({\n id: f.id,\n label: f.label,\n type: f.valueType,\n })),\n formData,\n errors,\n });\n\n const renderField = (field: CustomField) => {\n const hasError = errors[field.id];\n const value = formData[field.id];\n\n // Classes communes (EXACTEMENT comme IdentityFields/ContactFields)\n const inputClasses = clsx(\n \"w-full px-3 py-3 md:py-4 border rounded-lg text-base transition-colors focus:outline-none focus:ring-2 focus:ring-[#11E5C5] focus:border-transparent\",\n hasError\n ? \"border-red-500 bg-red-50\"\n : \"border-gray-300 hover:border-gray-400\",\n );\n\n switch (field.valueType) {\n case \"text\":\n return (\n <input\n id={field.id}\n type=\"text\"\n value={value || \"\"}\n onChange={(e) => onFieldChange(field.id, e.target.value)}\n placeholder={field.placeholder}\n className={inputClasses}\n autoComplete=\"off\"\n />\n );\n\n case \"number\":\n return (\n <input\n id={field.id}\n type=\"number\"\n inputMode=\"numeric\"\n value={value || \"\"}\n onChange={(e) => onFieldChange(field.id, e.target.value)}\n placeholder={field.placeholder}\n className={inputClasses}\n />\n );\n\n case \"date\":\n // Parse existing date value (DD-MM-YYYY format)\n const dateParts = value ? value.split(\"-\") : [\"\", \"\", \"\"];\n const day = dateParts[0] || \"\";\n const month = dateParts[1] || \"\";\n const year = dateParts[2] || \"\";\n\n const handleDateChange = (\n part: \"day\" | \"month\" | \"year\",\n partValue: string,\n ) => {\n const currentParts = value ? value.split(\"-\") : [\"\", \"\", \"\"];\n const newDay = part === \"day\" ? partValue : currentParts[0] || \"\";\n const newMonth = part === \"month\" ? partValue : currentParts[1] || \"\";\n const newYear = part === \"year\" ? partValue : currentParts[2] || \"\";\n\n // Validate month range (1-12)\n if (part === \"month\" && partValue) {\n const monthNum = parseInt(partValue, 10);\n if (monthNum < 1 || monthNum > 12) {\n // Don't save invalid month\n return;\n }\n }\n\n // Validate day range (1-31) - basic validation\n if (part === \"day\" && partValue) {\n const dayNum = parseInt(partValue, 10);\n if (dayNum < 1 || dayNum > 31) {\n // Don't save invalid day\n return;\n }\n }\n\n // Always store the current state (even partial dates)\n const dateString = `${newDay}-${newMonth}-${newYear}`;\n onFieldChange(field.id, dateString);\n };\n\n return (\n <div className=\"grid grid-cols-3 gap-2 md:gap-3\">\n <Select\n options={DAY_OPTIONS}\n value={day}\n onValueChange={(val) => handleDateChange(\"day\", val)}\n placeholder=\"JJ\"\n error={hasError}\n allowCustomValue\n inputMode=\"numeric\"\n pattern=\"[0-9]*\"\n maxLength={2}\n />\n <Select\n options={MONTH_OPTIONS_WITH_NUMERIC_LABEL}\n value={month}\n onValueChange={(val) => handleDateChange(\"month\", val)}\n placeholder=\"MM\"\n error={hasError}\n allowCustomValue\n inputMode=\"numeric\"\n maxLength={2}\n />\n <Select\n options={YEAR_OPTIONS}\n value={year}\n onValueChange={(val) => handleDateChange(\"year\", val)}\n placeholder=\"AAAA\"\n error={hasError}\n allowCustomValue\n inputMode=\"numeric\"\n pattern=\"[0-9]*\"\n maxLength={4}\n />\n </div>\n );\n\n case \"boolean\":\n return (\n <div className=\"flex items-center gap-2\">\n <input\n id={field.id}\n type=\"checkbox\"\n checked={value || false}\n onChange={(e) => onFieldChange(field.id, e.target.checked)}\n className=\"h-4 w-4 text-[#11E5C5] border-gray-300 rounded focus:ring-[#11E5C5]\"\n />\n {field.description && (\n <span className=\"text-sm text-gray-600\">{field.description}</span>\n )}\n </div>\n );\n\n case \"enum\":\n return (\n <Select\n options={(field.enumOptions || []).map((opt) => ({\n value: opt,\n label: opt,\n }))}\n value={value || \"\"}\n onValueChange={(val) => onFieldChange(field.id, val)}\n placeholder={field.placeholder || t(\"custom_form.select_option\")}\n error={hasError}\n />\n );\n\n case \"address\":\n // For address, use the existing AddressFields component\n const addressValue = value || {};\n const addressForm = {\n lastName: \"\",\n firstName: \"\",\n birthDate: \"\",\n day: \"\",\n month: \"\",\n year: \"\",\n email: \"\",\n phoneNumber: \"\",\n sms: \"\",\n addressLine1: addressValue.addressLine1 || \"\",\n addressLine2: addressValue.addressLine2 || \"\",\n postalCode: addressValue.postalCode || \"\",\n city: addressValue.city || \"\",\n countryCode: addressValue.countryCode || \"\",\n nationality: \"\",\n companyName: \"\",\n siret: \"\",\n tva: \"\",\n };\n\n return (\n <AddressFields\n form={addressForm}\n errors={{\n addressLine1: hasError,\n addressLine2: false,\n postalCode: hasError,\n city: hasError,\n country: hasError,\n }}\n requestedFields={new Set([\"adresse\"])}\n onFieldChange={(key, val) => {\n const updatedAddress = {\n ...addressValue,\n [key]: val,\n };\n onFieldChange(field.id, updatedAddress);\n }}\n addressSuggestions={addressSuggestions}\n showSuggestions={showSuggestions}\n onAddressChange={(val) => {\n const updatedAddress = {\n ...addressValue,\n addressLine1: val,\n };\n onFieldChange(field.id, updatedAddress);\n onAddressChange?.(field.id, val);\n }}\n onAddressFocus={() => onAddressFocus?.(field.id)}\n onAddressBlur={() => onAddressBlur?.(field.id)}\n onApplySuggestion={(suggestion) => {\n const updatedAddress = {\n addressLine1: suggestion.label || \"\",\n addressLine2: addressValue.addressLine2 || \"\",\n postalCode: suggestion.postalCode || \"\",\n city: suggestion.city || \"\",\n countryCode: suggestion.countryCode || \"\",\n };\n onFieldChange(field.id, updatedAddress);\n onApplySuggestion?.(field.id, suggestion);\n }}\n />\n );\n\n case \"list\": {\n const persistedRows: Record<string, string>[] = Array.isArray(value)\n ? value\n : [];\n const columns: ListColumn[] = normalizeListColumns(field.listColumns);\n const minRows = getListFieldMinRows(field);\n const rows = ensureMinimumListRows(persistedRows, columns, minRows);\n const gridTemplateColumns = `repeat(${columns.length}, minmax(180px, 1fr)) 32px`;\n const gridMinWidth = `${columns.length * 180 + (columns.length - 1) * 8 + 32}px`;\n\n if (columns.length === 0) {\n return (\n <p className=\"text-sm text-red-600\">\n {t(\n \"custom_form.list_missing_columns\",\n \"Ce tableau n'a pas de colonnes configurées.\",\n )}\n </p>\n );\n }\n\n const handleRowChange = (\n rowIndex: number,\n colName: string,\n colValue: string,\n ) => {\n const updated = [...rows];\n updated[rowIndex] = { ...updated[rowIndex], [colName]: colValue };\n onFieldChange(field.id, updated);\n };\n\n const handleAddRow = () => {\n const emptyRow = createEmptyListRow(columns);\n onFieldChange(field.id, [...rows, emptyRow]);\n };\n\n const handleRemoveRow = (rowIndex: number) => {\n if (rows.length <= minRows) {\n return;\n }\n\n onFieldChange(\n field.id,\n rows.filter((_, i) => i !== rowIndex),\n );\n };\n\n const cellClasses = clsx(\n \"w-full px-2 py-2 border rounded-lg text-sm transition-colors focus:outline-none focus:ring-2 focus:ring-[#11E5C5] focus:border-transparent\",\n hasError\n ? \"border-red-500 bg-red-50\"\n : \"border-gray-300 hover:border-gray-400\",\n );\n\n return (\n <div className=\"space-y-3 overflow-x-auto\">\n {columns.length > 0 && (\n <div\n className=\"grid gap-2 items-center w-full\"\n style={{\n gridTemplateColumns,\n minWidth: gridMinWidth,\n }}\n >\n {columns.map((col) => (\n <span\n key={col.label}\n className=\"text-xs font-semibold text-gray-600 uppercase tracking-wide truncate\"\n >\n {col.label}\n </span>\n ))}\n <span />\n </div>\n )}\n\n {rows.map((row, rowIndex) => (\n <div\n key={rowIndex}\n className=\"grid gap-2 items-center w-full\"\n style={{\n gridTemplateColumns,\n minWidth: gridMinWidth,\n }}\n >\n {columns.map((col) => (\n <ListCell\n key={col.label}\n col={col}\n value={row[col.label] || \"\"}\n hasError={hasError}\n cellClasses={cellClasses}\n onChange={(val) => handleRowChange(rowIndex, col.label, val)}\n />\n ))}\n <button\n type=\"button\"\n onClick={() => handleRemoveRow(rowIndex)}\n className={clsx(\n \"flex items-center justify-center w-8 h-8 rounded-full transition-colors\",\n rows.length <= minRows\n ? \"text-gray-300 cursor-not-allowed\"\n : \"text-gray-400 hover:text-red-500 hover:bg-red-50\",\n )}\n aria-label={t(\"custom_form.remove_row\", \"Supprimer la ligne\")}\n disabled={rows.length <= minRows}\n >\n ✕\n </button>\n </div>\n ))}\n\n <button\n type=\"button\"\n onClick={handleAddRow}\n className=\"flex items-center gap-2 text-sm text-[#11E5C5] hover:underline font-medium\"\n >\n + {t(\"custom_form.add_row\", \"Ajouter une ligne\")}\n </button>\n </div>\n );\n }\n\n default:\n return null;\n }\n };\n\n return (\n <Fragment>\n {customFields.map((field) => (\n <div key={field.id} className=\"space-y-2\">\n <Label.Root\n htmlFor={field.id}\n className=\"block text-sm md:text-base font-semibold text-gray-900\"\n >\n {field.label}\n {field.required && <span className=\"text-red-500 ml-1\">*</span>}\n </Label.Root>\n\n {field.description && field.valueType !== \"boolean\" && (\n <p className=\"text-xs text-gray-500 -mt-1\">{field.description}</p>\n )}\n\n {renderField(field)}\n\n {errors[field.id] && (\n <p className=\"text-red-600 text-sm flex items-center gap-1\">\n <span className=\"text-red-500\">⚠</span>\n {field.required\n ? t(\"custom_form.required_field\")\n : t(\"custom_form.invalid_value\")}\n </p>\n )}\n </div>\n ))}\n </Fragment>\n );\n};\n\nexport default CustomFormFields;\n"],"names":["_jsx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D,EAEZ,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,KACjDA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,6BAA6B,YAAE,KAAK,CAAC,WAAW,EAAA,CAAK,CACnE,EAEA,WAAW,CAAC,KAAK,CAAC,EAElB,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KACfC,IAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,8CAA8C,EAAA,QAAA,EAAA,CACzDD,cAAM,SAAS,EAAC,cAAc,EAAA,QAAA,EAAA,QAAA,EAAA,CAAS,EACtC,KAAK,CAAC;AACL,8BAAE,CAAC,CAAC,4BAA4B;AAChC,8BAAE,CAAC,CAAC,2BAA2B,CAAC,CAAA,EAAA,CAChC,CACL,CAAA,EAAA,EAtBO,KAAK,CAAC,EAAE,CAuBZ,EACP,CAzB4B,CAyB5B,CAAC,EAAA,CACO;AAEf;;;;"}
@@ -41,7 +41,7 @@ var IdentityFields = function (_a) {
41
41
  ? "border-red-500 bg-red-50"
42
42
  : "border-gray-300 hover-border-gray-400"), autoComplete: "off" }), errors.firstName && (jsxs("p", { className: "text-red-600 text-sm flex items-center gap-1", children: [jsx("span", { className: "text-red-500", children: "\u26A0" }), t("user_input_form.errors.first_name_required")] }))] })), requestedFields.has("nom") && (jsxs("div", { className: "space-y-2", children: [jsx(Label.Root, { htmlFor: "lastName", className: "block text-sm md:text-base font-semibold text-gray-900", children: t(FIELD_LABELS.nom) }), jsx("input", { id: "lastName", type: "text", value: form.lastName || "", onChange: function (event) { return onFieldChange("lastName", event.target.value); }, placeholder: t("user_input_form.placeholders.last_name"), className: clsx("w-full px-3 py-3 md:py-4 border rounded-lg text-base transition-colors focus:outline-none focus:ring-2 focus:ring-[#11E5C5] focus:border-transparent", errors.lastName
43
43
  ? "border-red-500 bg-red-50"
44
- : "border-gray-300 hover-border-gray-400"), autoComplete: "off" }), errors.lastName && (jsxs("p", { className: "text-red-600 text-sm flex items-center gap-1", children: [jsx("span", { className: "text-red-500", children: "\u26A0" }), t("user_input_form.errors.last_name_required")] }))] })), requestedFields.has("date_naissance") && (jsxs("div", { className: "space-y-2", children: [jsx(Label.Root, { className: "block text-sm md:text-base font-semibold text-gray-900", children: t(FIELD_LABELS.date_naissance) }), jsxs("div", { className: "grid grid-cols-3 gap-2 md:gap-3", children: [jsx(Select, { ref: dayRef, options: DAY_OPTIONS, value: form.day || "", onValueChange: handleDayChange, placeholder: "DD", error: Boolean(errors.birthDate || errors.notMajor), allowCustomValue: true, inputMode: "numeric", pattern: "[0-9]*", maxLength: 2 }), jsx(Select, { ref: monthRef, options: monthOptionsWithTranslation, value: form.month || "", onValueChange: handleMonthChange, placeholder: "MM", error: Boolean(errors.birthDate || errors.notMajor), allowCustomValue: true, inputMode: "numeric", maxLength: 9 }), jsx(Select, { ref: yearRef, options: YEAR_OPTIONS, value: form.year || "", onValueChange: handleYearChange, placeholder: "AAAA", error: Boolean(errors.birthDate || errors.notMajor), allowCustomValue: true, inputMode: "numeric", pattern: "[0-9]*", maxLength: 4 })] }), errors.birthDate && (jsxs("p", { className: "text-red-600 text-sm flex items-center gap-1", children: [jsx("span", { className: "text-red-500", children: "\u26A0" }), t("user_input_form.errors.birth_date_required")] })), errors.notMajor && (jsxs("p", { className: "text-red-600 text-sm flex items-center gap-1", children: [jsx("span", { className: "text-red-500", children: "\u26A0" }), t("user_input_form.errors.not_major")] }))] }))] }));
44
+ : "border-gray-300 hover-border-gray-400"), autoComplete: "off" }), errors.lastName && (jsxs("p", { className: "text-red-600 text-sm flex items-center gap-1", children: [jsx("span", { className: "text-red-500", children: "\u26A0" }), t("user_input_form.errors.last_name_required")] }))] })), requestedFields.has("date_naissance") && (jsxs("div", { className: "space-y-2", children: [jsx(Label.Root, { className: "block text-sm md:text-base font-semibold text-gray-900", children: t(FIELD_LABELS.date_naissance) }), jsxs("div", { className: "grid grid-cols-3 gap-2 md:gap-3", children: [jsx(Select, { ref: dayRef, options: DAY_OPTIONS, value: form.day || "", onValueChange: handleDayChange, placeholder: "JJ", error: Boolean(errors.birthDate || errors.notMajor), allowCustomValue: true, inputMode: "numeric", pattern: "[0-9]*", maxLength: 2 }), jsx(Select, { ref: monthRef, options: monthOptionsWithTranslation, value: form.month || "", onValueChange: handleMonthChange, placeholder: "MM", error: Boolean(errors.birthDate || errors.notMajor), allowCustomValue: true, inputMode: "numeric", maxLength: 9 }), jsx(Select, { ref: yearRef, options: YEAR_OPTIONS, value: form.year || "", onValueChange: handleYearChange, placeholder: "AAAA", error: Boolean(errors.birthDate || errors.notMajor), allowCustomValue: true, inputMode: "numeric", pattern: "[0-9]*", maxLength: 4 })] }), errors.birthDate && (jsxs("p", { className: "text-red-600 text-sm flex items-center gap-1", children: [jsx("span", { className: "text-red-500", children: "\u26A0" }), t("user_input_form.errors.birth_date_required")] })), errors.notMajor && (jsxs("p", { className: "text-red-600 text-sm flex items-center gap-1", children: [jsx("span", { className: "text-red-500", children: "\u26A0" }), t("user_input_form.errors.not_major")] }))] }))] }));
45
45
  };
46
46
 
47
47
  export { IdentityFields as default };