user-mydata
Example
<cr-component id="component" name="user-questionnaire" loading></cr-component>
<script>
const component = document.getElementById("#component");
let questionnaireProps = {
skip: true,
intro: {
enabled: true,
description:
"Para poder ofrecerte un producto adaptado a tu perfil, necesitamos que completes este test de idoneidad.",
title: "Test de idoneidad",
},
steps: [
{
id: 1,
name: "N 1",
question: "¿Cuáles son tus ingresos netos anuales?",
type: "text",
placeholder: "Especifique aquí",
},
{
id: 2,
name: "N 2",
question: "¿Cuáles son tus ingresos netos anuales?",
type: "currency",
value: 55555,
},
],
score: {
enabled: true,
from: 0,
to: 10,
title: "conservador",
description:
"Un perfil más elevado te permitiría acceder a productos con mayor riesgo y, por lo tanto, mayor rentabilidad esperada en el largo plazo.",
error: {
description:
"Dichas respuestas son incorrectas o no estan relacionadas. Por favor, revise las siguientes respuestas",
questions: [],
},
},
};
let newScore = {
value: 7,
title: "Arriesgado",
description:
"Un perfil más elevado te permitiría acceder a productos con mayor riesgo y, por lo tanto, mayor rentabilidad esperada en el largo plazo.",
};
let newError = {
questions: [1, 2, 5],
description: "Te faltaron estas preguntas por responder",
};
component.init(questionnaireProps);
component.addEventListener("change", (e) => {
if (
questionnaireProps.score.enabled &&
questionnaireProps.steps.length + questionnaireProps.intro.enabled === e.detail.current
) {
setTimeout(() => {
questionnaireProps.steps.length === e.detail.answers.length
? component.updateScore(newScore)
: component.updateErrors(newError);
}, 1000);
}
});
</script>
Schema
{
"type": "object",
"properties": {
"intro": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"default": false
},
"title": {
"type": "string",
"default": "Mis datos"
},
"description": {
"type": "string",
"default": ""
},
"image": {
"type": "string",
"default": "undefined/assets/img/data.svg"
}
},
"default": {
"enabled": false,
"image": "undefined/assets/img/data.svg"
}
},
"dni": {
"type": "object",
"properties": {
"cover": {
"type": "string",
"default": "undefined/assets/img/scan.png"
},
"front": {
"type": "string",
"default": ""
},
"back": {
"type": "string",
"default": ""
},
"verified": {
"type": "boolean",
"default": false
},
"error": {
"type": "boolean",
"default": false
}
},
"default": {
"cover": "undefined/assets/img/scan.png"
}
},
"fields": {
"type": "object",
"properties": {
"hidden": {
"type": "array",
"items": {
"type": "string"
},
"default": []
},
"require": {
"type": "array",
"items": {
"type": "string"
},
"default": []
},
"values": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"value": {
"type": [
"string",
"object"
]
}
}
},
"default": [
{
"id": "documentType",
"value": "DNI/NIE"
}
]
}
},
"default": {}
},
"current": {
"type": "number",
"default": 0
}
},
"additionalProperties": true
}
Complete Schema
{}
Public functions
-
goToStep(step)
Function to change the step
Params
- {number} step
Locales
{
"address": "Address",
"completeManually": "Complete manually",
"contact": "Contact",
"dataTreatment": "Your data will be treated with the utmost discretion and will only be used to complete your profile",
"estimation": "It won't take you more than {{estimatedTime}} minutes",
"genderOptions": {
"female": "Feminine",
"male": "Male"
},
"idErrors": {
"dni": "The DNI is not valid",
"nie": "The NIE is not valid"
},
"labels": {
"address": "Address",
"back": "Rear",
"birthdate": "Date of birth",
"block": "Block",
"dni": "DNI/NIF/NIE",
"dniError": "There was a problem with the images",
"documentType": "Type of document",
"door": "Door",
"firstSurname": "First surname",
"floor": "Floor",
"frontal": "Frontal",
"gate": "Gate",
"language": "Language",
"locality": "Municipality",
"name": "Name",
"number": "Number",
"postcode": "PC",
"province": "Province",
"secondSurname": "Second surname",
"sex": "Sex",
"validityDate": "Validity date",
"wayType": "Type of road"
},
"languageOptions": {
"catalan": "Catalan",
"english": "English",
"spanish": "Spanish"
},
"loading": "Loading data from your ID",
"personalData": "Personal data",
"roadOptions": {
"alley": "Alley",
"avenue": "Avenue",
"boulevard": "Boulevard",
"crossing": "Crossing",
"passage": "Passage",
"polygon": "Polygon",
"promenade": "Promenade",
"residence": "Residence",
"road": "Road",
"round": "Round",
"roundabout": "Roundabout",
"square": "square",
"street": "Street",
"urbanization": "Urbanization",
"via": "Via",
"way": "Way"
},
"scanDocument": "Scan document",
"telephone": "Telephone"
}