|
|
@@ -271,12 +271,11 @@
|
|
|
</v-col>
|
|
|
|
|
|
<v-col cols="12" md="6">
|
|
|
- <v-text-field
|
|
|
+ <CommonPhoneInput
|
|
|
+ ref="phoneInput"
|
|
|
v-model="trialRequest.representativePhone"
|
|
|
- :rules="[validateRequired, validatePhone]"
|
|
|
label="Téléphone*"
|
|
|
required
|
|
|
- type="tel"
|
|
|
/>
|
|
|
</v-col>
|
|
|
</v-row>
|
|
|
@@ -368,13 +367,13 @@
|
|
|
</v-card-title>
|
|
|
<v-card-text class="text-center">
|
|
|
<p>
|
|
|
- Votre essai gratuit de 30 jours d'Opentalent Artist Premium
|
|
|
- a bien été activé.
|
|
|
+ Votre demande d'essai gratuit de 30 jours d'Opentalent
|
|
|
+ Artist Premium a bien été enregistrée, mais nécessite une
|
|
|
+ validation de votre part.
|
|
|
</p>
|
|
|
<p>
|
|
|
- Vous allez recevoir un email avec vos identifiants de
|
|
|
- connexion et toutes les informations nécessaires pour
|
|
|
- commencer à utiliser la plateforme.
|
|
|
+ Vous allez recevoir un email permettant de valider cette
|
|
|
+ demande, à la suite de quoi votre compte sera créé.
|
|
|
</p>
|
|
|
<p>
|
|
|
Notre équipe reste à votre disposition pour vous accompagner
|
|
|
@@ -400,12 +399,14 @@ import { useRouter } from 'vue-router'
|
|
|
import type { Ref } from 'vue'
|
|
|
import { reactive } from 'vue'
|
|
|
import _ from 'lodash'
|
|
|
-import { parsePhoneNumber, isValidPhoneNumber } from 'libphonenumber-js'
|
|
|
import { useRuntimeConfig, useAsyncData, useNuxtApp } from '#app'
|
|
|
import type { TrialRequest } from '~/types/interface'
|
|
|
import { STRUCTURE_TYPE, LEGAL_STATUS } from '~/types/types'
|
|
|
import { useAp2iRequestService } from '~/composables/data/useAp2iRequestService'
|
|
|
-import { slugify } from '~/services/utils/stringUtils'
|
|
|
+import {
|
|
|
+ convertPhoneNumberToInternationalFormat,
|
|
|
+ slugify,
|
|
|
+} from '~/services/utils/stringUtils'
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
@@ -457,7 +458,10 @@ const trialRequest = reactive<TrialRequest>({
|
|
|
|
|
|
// Function to fill the form with dummy data
|
|
|
const fillWithDummyData = () => {
|
|
|
- trialRequest.structureName = 'Compagnie Artistique Test'
|
|
|
+ // Generate a short timestamp (unix timestamp in seconds)
|
|
|
+ const shortTimestamp = Math.floor(Date.now() / 1000).toString()
|
|
|
+
|
|
|
+ trialRequest.structureName = `Compagnie Artistique Test ${shortTimestamp}`
|
|
|
trialRequest.address = '123 Rue des Arts'
|
|
|
trialRequest.addressComplement = 'Bâtiment B'
|
|
|
trialRequest.postalCode = '75001'
|
|
|
@@ -465,8 +469,7 @@ const fillWithDummyData = () => {
|
|
|
trialRequest.structureEmail = 'contact@compagnie-test.fr'
|
|
|
trialRequest.structureType = 'ARTISTIC_PRACTICE_ONLY'
|
|
|
trialRequest.legalStatus = 'ASSOCIATION_LAW_1901'
|
|
|
- trialRequest.structureIdentifier =
|
|
|
- 'compagnie-test-' + Math.floor(Math.random() * 1000)
|
|
|
+ trialRequest.structureIdentifier = `compagnie-test-${shortTimestamp}`
|
|
|
trialRequest.siren = '123456789'
|
|
|
trialRequest.representativeFirstName = 'Jean'
|
|
|
trialRequest.representativeLastName = 'Dupont'
|
|
|
@@ -534,15 +537,6 @@ const validateEmail = (email: string) =>
|
|
|
const validatePostalCode = (postalCode: string) =>
|
|
|
/^\d{5}$/.test(postalCode) || 'Code postal invalide (5 chiffres)'
|
|
|
|
|
|
-const validatePhone = (phone: string) => {
|
|
|
- try {
|
|
|
- // Assume French phone number if no country code is provided
|
|
|
- return isValidPhoneNumber(phone, 'FR') || 'Numéro de téléphone invalide'
|
|
|
- } catch (error) {
|
|
|
- return 'Numéro de téléphone invalide'
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
const validateSiren = (siren: string) =>
|
|
|
!siren || /^\d{9}$/.test(siren) || 'SIREN invalide (9 chiffres)'
|
|
|
|
|
|
@@ -571,21 +565,8 @@ const validateSubdomainAvailability = (value: string) => {
|
|
|
// Form state
|
|
|
const trialRequestSent: Ref<boolean> = ref(false)
|
|
|
const errorMsg: Ref<string | null> = ref(null)
|
|
|
-
|
|
|
-// Function to convert phone number to international format
|
|
|
-const convertToInternationalFormat = (phone: string): string => {
|
|
|
- try {
|
|
|
- // Assume French phone number if no country code is provided
|
|
|
- const phoneNumber = parsePhoneNumber(phone, 'FR')
|
|
|
- if (phoneNumber && phoneNumber.isValid()) {
|
|
|
- return phoneNumber.format('E.164') // E.164 format: +33123456789
|
|
|
- }
|
|
|
- return phone
|
|
|
- } catch (error) {
|
|
|
- console.error('Error converting phone number:', error)
|
|
|
- return phone
|
|
|
- }
|
|
|
-}
|
|
|
+// Reference to the phone input component
|
|
|
+const phoneInput = ref(null)
|
|
|
|
|
|
// Submit function
|
|
|
const submit = async (): Promise<void> => {
|
|
|
@@ -596,9 +577,11 @@ const submit = async (): Promise<void> => {
|
|
|
}
|
|
|
|
|
|
// Convert phone number to international format before submission
|
|
|
- trialRequest.representativePhone = convertToInternationalFormat(
|
|
|
- trialRequest.representativePhone
|
|
|
- )
|
|
|
+ if (phoneInput.value) {
|
|
|
+ trialRequest.representativePhone = convertPhoneNumberToInternationalFormat(
|
|
|
+ trialRequest.representativePhone
|
|
|
+ )
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
|
const { data, error } = await useAsyncData('submit-trial-request', () =>
|