project-booster-vue 9.42.7 → 9.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/restitution/PbRestitutionList.vue +5 -5
- package/src/components/trezor/PbTrezor.vue +65 -43
- package/src/components/trezor/__snapshots__/storyshots-puppeteer-test-puppeteer-ts-image-storyshots-project-booster-components-trezor-pb-trezor-/360/237/246/240-101-sandbox-1-snap.png +0 -0
- package/src/components/trezor/default-payload.json +19 -1
package/package.json
CHANGED
|
@@ -268,12 +268,12 @@ export default defineComponent({
|
|
|
268
268
|
answers: [],
|
|
269
269
|
action: action,
|
|
270
270
|
});
|
|
271
|
-
} else {
|
|
272
|
-
this.$emit('step-completed', {
|
|
273
|
-
answers: [],
|
|
274
|
-
nextStep: action,
|
|
275
|
-
});
|
|
276
271
|
}
|
|
272
|
+
} else {
|
|
273
|
+
this.$emit('step-completed', {
|
|
274
|
+
answers: [],
|
|
275
|
+
nextStep: action,
|
|
276
|
+
});
|
|
277
277
|
}
|
|
278
278
|
},
|
|
279
279
|
areConditionsValid(conditions: string[]) {
|
|
@@ -17,8 +17,6 @@
|
|
|
17
17
|
<m-text-input
|
|
18
18
|
v-model="formData.values.lastname"
|
|
19
19
|
:error="formData.errors.lastname"
|
|
20
|
-
@focus="validate('lastname')"
|
|
21
|
-
@keypress="validate('lastname')"
|
|
22
20
|
type="text"
|
|
23
21
|
label="Nom"
|
|
24
22
|
:required="true"
|
|
@@ -30,8 +28,6 @@
|
|
|
30
28
|
<m-text-input
|
|
31
29
|
v-model="formData.values.firstname"
|
|
32
30
|
:error="formData.errors.firstname"
|
|
33
|
-
@focus="validate('firstname')"
|
|
34
|
-
@keypress="validate('firstname')"
|
|
35
31
|
type="text"
|
|
36
32
|
label="Prénom"
|
|
37
33
|
:required="true"
|
|
@@ -39,12 +35,21 @@
|
|
|
39
35
|
></m-text-input>
|
|
40
36
|
</m-flex>
|
|
41
37
|
|
|
38
|
+
<m-flex class="pb-trezor__form__row">
|
|
39
|
+
<m-text-input
|
|
40
|
+
v-model="formData.values.surface"
|
|
41
|
+
:error="formData.errors.surface"
|
|
42
|
+
type="text"
|
|
43
|
+
label="Surface"
|
|
44
|
+
:required="true"
|
|
45
|
+
class="pb-trezor__input"
|
|
46
|
+
></m-text-input>
|
|
47
|
+
</m-flex>
|
|
48
|
+
|
|
42
49
|
<m-flex class="pb-trezor__form__row">
|
|
43
50
|
<m-text-input
|
|
44
51
|
v-model="formData.values.zipcode"
|
|
45
52
|
:error="formData.errors.zipcode"
|
|
46
|
-
@focus="validate('zipcode')"
|
|
47
|
-
@keypress="validate('zipcode')"
|
|
48
53
|
type="text"
|
|
49
54
|
label="Code postal"
|
|
50
55
|
:required="true"
|
|
@@ -56,8 +61,6 @@
|
|
|
56
61
|
<m-text-input
|
|
57
62
|
v-model="formData.values.email"
|
|
58
63
|
:error="formData.errors.email"
|
|
59
|
-
@focus="validate('email')"
|
|
60
|
-
@keypress="validate('email')"
|
|
61
64
|
type="email"
|
|
62
65
|
label="E-mail"
|
|
63
66
|
:required="true"
|
|
@@ -69,8 +72,6 @@
|
|
|
69
72
|
<m-text-input
|
|
70
73
|
v-model="formData.values.phone"
|
|
71
74
|
:error="formData.errors.phone"
|
|
72
|
-
@focus="validate('phone')"
|
|
73
|
-
@keypress="validate('phone')"
|
|
74
75
|
type="phone"
|
|
75
76
|
label="Numéro de téléphone"
|
|
76
77
|
:required="true"
|
|
@@ -126,6 +127,7 @@ import MLink from '../mozaic/link/MLink.vue';
|
|
|
126
127
|
import MTextInput from '../mozaic/text-input/MTextInput.vue';
|
|
127
128
|
import { ScenarioStepAnswer } from '@/types/pb/Scenario';
|
|
128
129
|
import { object, string, boolean } from 'yup';
|
|
130
|
+
import objectPath from 'object-path';
|
|
129
131
|
const BACK_ICON =
|
|
130
132
|
'https://storage.googleapis.com/project-booster-media/mozaic-icons/svg/Navigation_Arrow_Arrow--Left_16px.svg';
|
|
131
133
|
|
|
@@ -179,12 +181,35 @@ export default defineComponent({
|
|
|
179
181
|
},
|
|
180
182
|
setup(props, { emit }) {
|
|
181
183
|
const store = useStore();
|
|
184
|
+
|
|
185
|
+
const getAnswerValue = (answerCode: string, path: string) => {
|
|
186
|
+
if (!props.answers.get(answerCode) || props.answers.get(answerCode)?.length === 0) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return objectPath.get(props.answers.get(answerCode)?.at(0) as any, path);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const translationErrors = props.payload.viewModel.translationErrors;
|
|
194
|
+
|
|
195
|
+
const zipcode =
|
|
196
|
+
getAnswerValue(
|
|
197
|
+
props.payload.viewModel.defaultValue?.zipcode?.answerCode,
|
|
198
|
+
props.payload.viewModel.defaultValue?.zipcode?.path,
|
|
199
|
+
) || null;
|
|
200
|
+
const surface =
|
|
201
|
+
getAnswerValue(
|
|
202
|
+
props.payload.viewModel.defaultValue?.surface?.answerCode,
|
|
203
|
+
props.payload.viewModel.defaultValue?.surface?.path,
|
|
204
|
+
) || null;
|
|
205
|
+
|
|
182
206
|
let formData = ref<any>({
|
|
183
207
|
values: {
|
|
184
208
|
lastname: '',
|
|
185
209
|
firstname: '',
|
|
186
|
-
zipcode:
|
|
210
|
+
zipcode: zipcode,
|
|
187
211
|
email: '',
|
|
212
|
+
surface: surface,
|
|
188
213
|
phone: '',
|
|
189
214
|
optin: false,
|
|
190
215
|
optinPartners: false,
|
|
@@ -195,6 +220,7 @@ export default defineComponent({
|
|
|
195
220
|
zipcode: '',
|
|
196
221
|
email: '',
|
|
197
222
|
phone: '',
|
|
223
|
+
surface: '',
|
|
198
224
|
},
|
|
199
225
|
});
|
|
200
226
|
|
|
@@ -204,45 +230,42 @@ export default defineComponent({
|
|
|
204
230
|
zipcode: string().required(),
|
|
205
231
|
email: string().email().required(),
|
|
206
232
|
phone: string().required(),
|
|
233
|
+
surface: string().required(),
|
|
207
234
|
optin: boolean(),
|
|
208
235
|
optinPartners: boolean(),
|
|
209
236
|
});
|
|
210
237
|
|
|
211
|
-
const validate = async (field: string) => {
|
|
212
|
-
await validationSchema
|
|
213
|
-
.validateAt(field, formData.value.values)
|
|
214
|
-
.then(() => {
|
|
215
|
-
formData.value.errors[field] = '';
|
|
216
|
-
})
|
|
217
|
-
.catch((err) => {
|
|
218
|
-
formData.value.errors[err.path] = err.message;
|
|
219
|
-
});
|
|
220
|
-
};
|
|
221
|
-
|
|
222
238
|
const validateAllFields = async (action: any) => {
|
|
223
|
-
await validationSchema
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
239
|
+
await validationSchema
|
|
240
|
+
.validate(formData.value.values, { abortEarly: false })
|
|
241
|
+
.then(async () => {
|
|
242
|
+
const sending = await store.dispatch('trezor/sendFormData', {
|
|
243
|
+
payload: {
|
|
244
|
+
customer: {
|
|
245
|
+
lastname: formData.value.values.lastname,
|
|
246
|
+
firstname: formData.value.values.firstname,
|
|
247
|
+
zip: formData.value.values.zipcode,
|
|
248
|
+
email: formData.value.values.email,
|
|
249
|
+
phone: formData.value.values.phone,
|
|
250
|
+
},
|
|
251
|
+
optin: formData.value.values.optin,
|
|
252
|
+
optinPartners: formData.value.values.optinPartners,
|
|
232
253
|
},
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
},
|
|
236
|
-
typeLead: props.payload.viewModel.typeLead,
|
|
237
|
-
});
|
|
254
|
+
typeLead: props.payload.viewModel.typeLead,
|
|
255
|
+
});
|
|
238
256
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
257
|
+
if (sending) {
|
|
258
|
+
emit('step-completed', {
|
|
259
|
+
answers: null,
|
|
260
|
+
nextStep: action.action,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
})
|
|
264
|
+
.catch((err) => {
|
|
265
|
+
err.inner.forEach((e: any) => {
|
|
266
|
+
formData.value.errors[e.path] = translationErrors[e.path];
|
|
243
267
|
});
|
|
244
|
-
}
|
|
245
|
-
});
|
|
268
|
+
});
|
|
246
269
|
};
|
|
247
270
|
|
|
248
271
|
const callAction = async (item: any) => {
|
|
@@ -254,7 +277,6 @@ export default defineComponent({
|
|
|
254
277
|
return {
|
|
255
278
|
formData,
|
|
256
279
|
callAction,
|
|
257
|
-
validate,
|
|
258
280
|
BACK_ICON,
|
|
259
281
|
};
|
|
260
282
|
},
|
|
@@ -2,7 +2,25 @@
|
|
|
2
2
|
"viewModel": {
|
|
3
3
|
"backLabel": "Question précédente",
|
|
4
4
|
"label": "Renseignez notre formulaire pour être recontacté",
|
|
5
|
-
"typeLead": "HEAT_PUMP"
|
|
5
|
+
"typeLead": "HEAT_PUMP",
|
|
6
|
+
"defaultValue": {
|
|
7
|
+
"zipcode": {
|
|
8
|
+
"answerCode": "LMFR_PREVIOUS_QUESTION",
|
|
9
|
+
"path": "value"
|
|
10
|
+
},
|
|
11
|
+
"surface": {
|
|
12
|
+
"answerCode": "LMFR_PREVIOUS_QUESTION",
|
|
13
|
+
"path": "space"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"translationErrors": {
|
|
17
|
+
"lastname": "Le nom est requis",
|
|
18
|
+
"firstname": "Le prénom est requis",
|
|
19
|
+
"zipcode": "Le code postal est requis",
|
|
20
|
+
"email": "Votre adresse mail est requise",
|
|
21
|
+
"phone": "Votre numéro de téléphone est requis",
|
|
22
|
+
"surface": "Veuillez indiquer la surface de votre logement"
|
|
23
|
+
}
|
|
6
24
|
},
|
|
7
25
|
"callToActions": [
|
|
8
26
|
{
|