|
| 1 | +/** |
| 2 | + * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors |
| 3 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | + */ |
| 5 | + |
| 6 | +import { ref } from '@vue/reactivity' |
| 7 | + |
| 8 | +interface ActionCodes { |
| 9 | + REDIRECT: number |
| 10 | + CREATE_ACCOUNT: number |
| 11 | + DO_NOTHING: number |
| 12 | + SIGN: number |
| 13 | + SIGN_INTERNAL: number |
| 14 | + SIGN_ID_DOC: number |
| 15 | + SHOW_ERROR: number |
| 16 | + SIGNED: number |
| 17 | + CREATE_SIGNATURE_PASSWORD: number |
| 18 | + RENEW_EMAIL: number |
| 19 | + INCOMPLETE_SETUP: number |
| 20 | +} |
| 21 | + |
| 22 | +interface ActionCodeToRoute { |
| 23 | + [key: number]: string |
| 24 | +} |
| 25 | + |
| 26 | +interface RequirementToModal { |
| 27 | + [key: string]: string |
| 28 | +} |
| 29 | + |
| 30 | +export const ACTION_CODES: Readonly<ActionCodes> = Object.freeze({ |
| 31 | + REDIRECT: 1000, |
| 32 | + CREATE_ACCOUNT: 1500, |
| 33 | + DO_NOTHING: 2000, |
| 34 | + SIGN: 2500, |
| 35 | + SIGN_INTERNAL: 2625, |
| 36 | + SIGN_ID_DOC: 2750, |
| 37 | + SHOW_ERROR: 3000, |
| 38 | + SIGNED: 3500, |
| 39 | + CREATE_SIGNATURE_PASSWORD: 4000, |
| 40 | + RENEW_EMAIL: 4500, |
| 41 | + INCOMPLETE_SETUP: 5000, |
| 42 | +}) |
| 43 | + |
| 44 | +export const ACTION_CODE_TO_ROUTE: Readonly<ActionCodeToRoute> = Object.freeze({ |
| 45 | + [ACTION_CODES.REDIRECT]: 'redirect', |
| 46 | + [ACTION_CODES.CREATE_ACCOUNT]: 'CreateAccount', |
| 47 | + [ACTION_CODES.DO_NOTHING]: 'current', |
| 48 | + [ACTION_CODES.SIGN]: 'SignPDF', |
| 49 | + [ACTION_CODES.SIGN_INTERNAL]: 'SignPDF', |
| 50 | + [ACTION_CODES.SIGN_ID_DOC]: 'IdDocsApprove', |
| 51 | + [ACTION_CODES.SHOW_ERROR]: 'DefaultPageError', |
| 52 | + [ACTION_CODES.SIGNED]: 'ValidationFile', |
| 53 | + [ACTION_CODES.CREATE_SIGNATURE_PASSWORD]: 'CreatePassword', |
| 54 | + [ACTION_CODES.RENEW_EMAIL]: 'RenewEmail', |
| 55 | + [ACTION_CODES.INCOMPLETE_SETUP]: 'Incomplete', |
| 56 | +}) |
| 57 | + |
| 58 | +/** |
| 59 | + * Shared reactive ref for the initial action code injected by the server |
| 60 | + * (#initial-state-libresign-action). Written once by router.ts beforeEach, |
| 61 | + * read by App.vue. Lives here (not in router.ts) to avoid App.vue triggering |
| 62 | + * the router module's side effects (createRouter, generateUrl) on import. |
| 63 | + */ |
| 64 | +export const initialActionCode = ref(0) |
| 65 | + |
| 66 | +export const REQUIREMENT_TO_MODAL: Readonly<RequirementToModal> = Object.freeze({ |
| 67 | + identificationDocuments: 'uploadDocuments', |
| 68 | + emailCode: 'emailToken', |
| 69 | + createSignature: 'createSignature', |
| 70 | + tokenCode: 'token', |
| 71 | + uploadCertificate: 'uploadCertificate', |
| 72 | + createPassword: 'createPassword', |
| 73 | + passwordSignature: 'password', |
| 74 | + clickToSign: 'clickToSign', |
| 75 | +}) |
0 commit comments