@wayke-se/ecom-web 1.5.0-beta.4 → 1.5.0-beta.5
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/dist/index.js +36 -36
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +51 -51
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(()=>{var Yc=Object.create;var Jo=Object.defineProperty;var Kc=Object.getOwnPropertyDescriptor;var zc=Object.getOwnPropertyNames;var Qc=Object.getPrototypeOf,jc=Object.prototype.hasOwnProperty;var f=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(i,e)=>(typeof require<"u"?require:i)[e]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+o+'" is not supported')});var Jc=(o,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of zc(i))!jc.call(o,s)&&s!==e&&Jo(o,s,{get:()=>i[s],enumerable:!(t=Kc(i,s))||t.enumerable});return o};var Xc=(o,i,e)=>(e=o!=null?Yc(Qc(o)):{},Jc(i||!o||!o.__esModule?Jo(e,"default",{value:o,enumerable:!0}):e,o));var Fc=f("@wayke-se/ecom");var Xo={name:"@wayke-se/ecom-web",version:"1.5.0-beta.
|
|
1
|
+
"use strict";(()=>{var Yc=Object.create;var Jo=Object.defineProperty;var Kc=Object.getOwnPropertyDescriptor;var zc=Object.getOwnPropertyNames;var Qc=Object.getPrototypeOf,jc=Object.prototype.hasOwnProperty;var f=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(i,e)=>(typeof require<"u"?require:i)[e]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+o+'" is not supported')});var Jc=(o,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of zc(i))!jc.call(o,s)&&s!==e&&Jo(o,s,{get:()=>i[s],enumerable:!(t=Kc(i,s))||t.enumerable});return o};var Xc=(o,i,e)=>(e=o!=null?Yc(Qc(o)):{},Jc(i||!o||!o.__esModule?Jo(e,"default",{value:o,enumerable:!0}):e,o));var Fc=f("@wayke-se/ecom");var Xo={name:"@wayke-se/ecom-web",version:"1.5.0-beta.5",description:"Wayke Ecom Web",module:"dist/index.mjs",main:"dist/index.js",types:"dist/index.d.ts",homepage:"https://github.com/wayke-se/wayke-ecom-web",scripts:{start:"node ./esbuild/start.js",clip:"node ./esbuild/clip-ui.js && node ./clip-ui/start.js",build:"npm run clean && node ./esbuild/lib.js && node ./esbuild/cdn.js",clean:"rimraf build && rimraf dist && rimraf dist-cdn",test:"npm run lint && npm run typecheck",typecheck:"tsc -noEmit","typecheck:watch":"tsc -noEmit -watch",lint:"eslint --ext .ts,.js 'src'","lint:fix":"eslint --ext .ts,.js 'src' --fix",stylelint:"stylelint '**/*.scss'",prepare:"husky install"},author:"Wayke",license:"ISC",devDependencies:{"@ourstudio/clip-ui":"^0.0.11","@types/marked":"^4.3.0","@types/node":"^17.0.18","@types/object-path":"^0.11.1","@types/sanitize-html":"^2.6.2","@typescript-eslint/eslint-plugin":"^5.12.0","@typescript-eslint/parser":"^5.12.0",esbuild:"^0.15.10","esbuild-sass-plugin":"2.3.3",eslint:"^8.9.0","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^4.0.0",husky:"^8.0.1","npm-dts":"^1.3.11",prettier:"^2.5.1",rimraf:"^5.0.1",stylelint:"^15.2.0","stylelint-config-prettier-scss":"^1.0.0","stylelint-config-standard-scss":"^9.0.0",typescript:"^5.1.3"},dependencies:{"@wayke-se/ecom":"^4.4.0-beta.5",marked:"^4.3.0","object-path":"^0.11.8",redux:"^4.1.2","sanitize-html":"^2.7.0"},files:["dist"]};var fi=f("redux");var Ae=f("@wayke-se/ecom");var ot=(o,i)=>o!==void 0&&i!==void 0?JSON.stringify(o).localeCompare(JSON.stringify(i))===0:o===i;var we=o=>({costs:o.getCosts(),fees:o.getFees(),interests:o.getInterests(),durationSpec:o.getDurationSpec(),downPaymentSpec:o.getDownPaymentSpec(),residualValueSpec:o.getResidualValueSpec(),totalResidualValue:o.getTotalResidualValue(),publicURL:o.getPublicURL(),shouldUseCreditScoring:o.shouldUseCreditScoring(),financialProductCode:o.getFinancialProductCode(),price:o.getPrice(),creditAmount:o.getCreditAmount(),hasPrivacyPolicy:o.hasPrivacyPolicy(),privacyPolicyUrl:o.getPrivacyPolicyUrl()}),Zo=o=>({status:o.getStatus(),hasPendingSigning:o.hasPendingSigning(),hintCode:o.getHintCode(),signingMessage:o.getSigningMessage(),shouldRenewSigning:o.shouldRenewSigning(),isSigned:o.isSigned(),address:void 0,pendingScoring:o.hasPendingScoring(),isScored:o.isScored(),hasScoringError:o.hasScoringError(),scoringId:o.getScoringId(),recommendation:o.getRecommendation(),decision:o.getDecision(),isAccepted:o.isAccepted()}),Me=o=>({orderVehicle:o.getOrderVehicle(),accessories:o.getAccessories(),requiresDealerSelection:o.requiresDealerSelection(),dealerSites:o.getDealerSites(),paymentOptions:o.getPaymentOptions().map(e=>({...e,loanDetails:e.loanDetails?we(e.loanDetails):void 0})),deliveryOptions:o.getDeliveryOptions(),insuranceOption:o.getInsuranceOption(),orderConditions:o.getOrderConditions(),orderReturnConditions:o.getOrderReturnConditions(),conditionsPdfUri:o.getConditionsPdfUri(),contactInformation:o.getContactInformation(),allowsTradeIn:o.allowsTradeIn(),isUnavailable:o.isUnavailable(),isPaymentRequired:o.isPaymentRequired()}),ei=o=>({vehicle:o.getVehicle()});var it="RESET",ti=o=>i=>i({type:it,id:o}),at="SET_ORDER",xe=(o,i)=>e=>e({type:at,order:o,vehicle:i}),nt="SET_ID",si=o=>i=>i({type:nt,id:o}),rt="SET_CONTACT_EMAIL_AND_PHONE",oi=o=>i=>i({type:rt,value:o}),ct="SET_SOCIAL_ID_AND_ADDRESS",ii=(o,i,e)=>t=>t({type:ct,socialId:o,address:i,lastStage:e}),lt="SET_HOME_DELIVERY",ai=(o,i)=>e=>e({type:lt,homeDelivery:o,lastStage:i}),dt="SET_DEALER",ni=(o,i)=>e=>e({type:dt,dealer:o,lastStage:i}),mt="INIT_TRADE_IN",ri=o=>i=>i({type:mt,lastStage:o}),pt="SET_TRADE_IN",Ne=(o,i,e)=>t=>t({type:pt,lastStage:o,tradeIn:i,tradeInVehicle:e}),ut="SET_FINANCIAL",ci=(o,i)=>e=>e({type:ut,paymentType:o,lastStage:i}),ht="SET_PAYMENT_LOOKUP_RESPONSE",li=o=>i=>i({type:ht,paymentLookupResponse:we(o)}),kt="SET_DRIVING_DISTANCE",di=o=>i=>i({type:kt,drivingDistance:o}),yt="COMPLETE_STAGE",Z=o=>i=>i({type:yt,lastStage:o}),vt="SET_OR_REMOVE_INSURANCE",de=o=>i=>i({type:vt,insurance:o}),Et="SET_OR_REMOVE_INSURANCE_ADDONS",mi=(o,i)=>e=>e({type:Et,insurance:o,insuranceAddons:i}),It="SET_OR_REMOVE_FREE_INSURANCE",pi=o=>i=>i({type:It,freeInsurance:o}),ft="SET_OR_REMOVE_ACCESSORY",ui=o=>i=>i({type:ft,accessory:o}),gt="GO_TO",x=(o,i,e)=>t=>t({type:gt,view:o,index:i,subStage:e}),_t="SET_STAGES",hi=o=>i=>i({type:_t,stages:o}),St="SET_CREATED_ORDER_ID",ki=(o,i)=>e=>e({type:St,id:o,payment:i}),wt="SET_CREDIT_ASSESSMENT_RESPONSE",me=(o,i)=>e=>e({type:wt,caseId:o,creditAssessmentResponse:i}),Nt="SET_STATE",yi=o=>i=>i({type:Nt,state:o});var el={};var vi={view:"preview",stage:1,subStage:1},Ei={id:"",topNavigation:{...vi},navigation:{...vi},customer:{email:"",phone:"",givenName:"",surname:"",socialId:""},homeDelivery:!1,accessories:[],drivingDistance:Ae.DrivingDistance.Between0And1000,...el},ne=(o,i)=>i?{view:"summary",stage:1,subStage:1}:{view:"main",stage:o+1,subStage:1},re=(o,i)=>i.view==="main"?o.stage<i.stage?i:v.topNavigation:{...o,stage:o.stage+1},At=o=>o&&o?.length===1&&o?.[0].type===Ae.PaymentType.Cash?Ae.PaymentType.Cash:void 0,v,Tt,tl=(o=Ei,i)=>{let e,t;switch(v={...o},i.type){case it:return{...Ei,id:i.id};case _t:return{...v,stages:i.stages};case nt:return{...v,id:i.id};case at:return{...o,order:i.order,paymentType:At(i.order?.paymentOptions),vehicle:{...i.order.orderVehicle,...i.vehicle||{}}};case rt:let s={...v,customer:{...o.customer,email:i.value.email,phone:i.value.phone},navigation:{view:"main",stage:o.navigation.stage,subStage:2}};return delete s.wantTradeIn,delete s.tradeIn,delete s.tradeInVehicle,s.paymentType=At(o.order?.paymentOptions),delete s.paymentLookupResponse,delete s.insurance,delete s.insuranceAddOns,delete s.freeInsurance,delete s.dealer,s.accessories=[],s;case ct:return e=ne(v.navigation.stage,i.lastStage),t=re(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,address:i.address,customer:{...o.customer,socialId:i.socialId}},v;case dt:return e=ne(o.navigation.stage,i.lastStage),t={...e},v={...o,navigation:e,topNavigation:t,dealer:i.dealer},delete v.wantTradeIn,delete v.tradeIn,delete v.tradeInVehicle,v.paymentType=At(o.order?.paymentOptions),delete v.paymentLookupResponse,delete v.insurance,delete v.insuranceAddOns,delete v.freeInsurance,v.accessories=[],v;case lt:return e=ne(o.navigation.stage,i.lastStage),t=re(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,homeDelivery:i.homeDelivery},v;case mt:return e={view:"main",stage:o.navigation.stage,subStage:1},t=re(v.topNavigation,e),v={...o,navigation:e,wantTradeIn:!0,topNavigation:t,tradeIn:o.tradeIn||{registrationNumber:"",mileage:"",description:""}},v;case pt:return e=ne(o.navigation.stage,i.lastStage),t=re(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,wantTradeIn:!!i.tradeIn,tradeIn:i.tradeIn,tradeInVehicle:i.tradeInVehicle},v;case ut:return e=ne(o.navigation.stage,i.lastStage),t=re(v.topNavigation,e),{...v,navigation:e,topNavigation:t,paymentType:i.paymentType};case ht:return{...v,paymentLookupResponse:i.paymentLookupResponse};case kt:return{...v,drivingDistance:i.drivingDistance};case yt:return e=ne(o.navigation.stage,i.lastStage),t=re(v.topNavigation,e),v={...o,navigation:e,topNavigation:t},v;case Et:return v.insurance=i.insurance,v.insuranceAddOns={insurance:i.insurance.name,addOns:i.insuranceAddons},v;case vt:return ot(v.insurance,i.insurance)?v.insurance=void 0:v.insurance=i.insurance,v.insuranceAddOns?.insurance&&(v.insuranceAddOns=void 0),v;case It:return ot(v.freeInsurance,i.freeInsurance)?v.freeInsurance=void 0:v.freeInsurance=i.freeInsurance,v;case ft:return Tt=v.accessories.findIndex(a=>a.id===i.accessory.id),v.accessories=[...v.accessories],Tt>-1?v.accessories.splice(Tt,1):v.accessories.push(i.accessory),{...v,accessories:[...v.accessories]};case gt:return{...o,navigation:{view:i.view,stage:i.index||1,subStage:i.subStage||1}};case St:return i.payment?e={view:"main",stage:o.navigation.stage,subStage:2}:e=ne(o.navigation.stage,!0),t=re(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,createdOrderId:i.id,payment:i.payment},v;case wt:return{...v,caseId:i.caseId,creditAssessmentResponse:i.creditAssessmentResponse};case Nt:return{...i.state};default:return o}},Ii=tl;var gi=()=>(0,fi.createStore)(Ii);var Pe=(o,i)=>{if(!i)return o;let e=new URL(o);return`${i}${e.pathname}`};var sl=o=>o.toString().replace(/\s/g,""),ol=(o,i)=>{if(!i)return o;let e=Math.pow(10,i);return(Math.round(o*e)/e).toFixed(i)},k=(o,i)=>{if(o===void 0)return"???";let e=ol(o,i?.decimals!==void 0?i.decimals:0);return`${i?.prefix?`${i.prefix}`:""}${sl(e).replace(/\B(?=(\d{3})+(?!\d))/g," ")}${i?.postfix?` ${i.postfix}`:""}`},il=(o,i)=>{let e=o.split(" "),t=i.split(" ").map(s=>s.toLowerCase());return e.filter(s=>!t.includes(s.toLowerCase())).join(" ")},pe=o=>{if(!!o)return il(o.shortDescription||"",o.title||"")};var al=({vehicle:o,order:i,meta:e,cdnMedia:t})=>{let s=o?.imageUrls,a=o?.title,n=k(o?.price||NaN),l=i?.contactInformation?.name;return`
|
|
2
2
|
<div class="waykeecom-product-card">
|
|
3
3
|
${s?.length?`
|
|
4
4
|
<div class="waykeecom-product-card__media">
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
</svg>`}
|
|
85
85
|
</span>
|
|
86
86
|
</button>
|
|
87
|
-
`,n&&this.node.querySelector("button")?.addEventListener("click",n)}},
|
|
87
|
+
`,n&&this.node.querySelector("button")?.addEventListener("click",n)}},N=Dt;var bt=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{title:e,id:t,onClick:s}=this.props;this.node.innerHTML=`
|
|
88
88
|
<button
|
|
89
89
|
type="button"
|
|
90
90
|
${t?`id="${t}"`:""}
|
|
@@ -311,7 +311,7 @@
|
|
|
311
311
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Bi}"></div>
|
|
312
312
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Fi}"></div>
|
|
313
313
|
</div>
|
|
314
|
-
`,new Hi(c.querySelector(`#${Ui}`),{store:e,accessories:m}),new
|
|
314
|
+
`,new Hi(c.querySelector(`#${Ui}`),{store:e,accessories:m}),new N(c.querySelector(`#${Bi}`),{id:Vi,title:"G\xE5 vidare",onClick:()=>this.onProceed()}),new z(c.querySelector(`#${Fi}`),{title:"Hoppa \xF6ver detta steg",onClick:()=>this.onProceed()})}l.appendChild(c),s.navigation.stage===t&&l.parentElement?.scrollIntoView()}},Gi=zt;var qi="waykeecom-input-error",Qt=class extends r{constructor(e,t){super(e);this.props=t,this.render()}setError(e){this.props.error=e,this.render()}render(){let{error:e,errorMessage:t}=this.props,s=this.node.querySelector(`.${qi}`);if(s)e||s.remove();else if(e){let a=document.createElement("div");a.className=qi,a.setAttribute("role","alert"),a.innerHTML=t,this.node.appendChild(a)}}},se=Qt;var jt=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{id:e,title:t,value:s,name:a,checked:n,meta:l,description:c,disabled:m,onClick:u}=this.props;this.node.innerHTML=`
|
|
315
315
|
<div class="waykeecom-input-selection" role="radio">
|
|
316
316
|
<input
|
|
317
317
|
type="radio"
|
|
@@ -413,7 +413,7 @@
|
|
|
413
413
|
</div>
|
|
414
414
|
</div>
|
|
415
415
|
</div>
|
|
416
|
-
</div>`}});new j(u.querySelector(`#${zi}`),{checked:this.selectedDealer,name:"dealer",options:h,onClick:p=>this.onChange(p)}),this.contexts.proceedButton=new
|
|
416
|
+
</div>`}});new j(u.querySelector(`#${zi}`),{checked:this.selectedDealer,name:"dealer",options:h,onClick:p=>this.onChange(p)}),this.contexts.proceedButton=new N(u.querySelector(`#${Ki}`),{title:"G\xE5 vidare",id:Qi,disabled:!this.selectedDealer,onClick:()=>this.onProceed()})}t.stage===n&&u.parentElement?.scrollIntoView()}},ji=Zt;var ie=o=>o.length<2?o:o.length===2?`${o.substring(0,1)}***`:o.length===3?`${o.substring(0,2)}***`:`${o.substring(0,3)}***`,qe=o=>`${o.substring(0,o.length-4)}****`;var es=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t,this.render()}updateBorder(){let e=this.node.querySelector(".waykeecom-input-text");e&&(this.props.error?e?.classList.add("waykeecom-input-text--has-error"):e?.classList.remove("waykeecom-input-text--has-error"))}setError(e,t){this.props.error=e,t&&(this.props.errorMessage=t),this.updateBorder(),this.contexts.error?.setError(e)}render(){let{id:e,title:t,type:s,name:a,value:n,autocomplete:l,placeholder:c,unit:m,error:u,errorMessage:h,information:p,pattern:y,inputmode:g,onChange:w,onBlur:R,onClickInformation:F}=this.props;this.node.innerHTML=`
|
|
417
417
|
<div class="waykeecom-input-label">
|
|
418
418
|
<label for="${e}" class="waykeecom-input-label__label">${t}</label>
|
|
419
419
|
</div>
|
|
@@ -432,7 +432,7 @@
|
|
|
432
432
|
/>
|
|
433
433
|
${m?`<div class="waykeecom-input-text__unit">${m}</div>`:""}
|
|
434
434
|
</div>
|
|
435
|
-
`,this.updateBorder(),h&&(this.contexts.error=new se(this.node,{error:u,errorMessage:h})),p&&new oe(this.node.querySelector(".waykeecom-input-label"),{information:p,onClickInformation:F});let K=this.node.querySelector("input");K&&(
|
|
435
|
+
`,this.updateBorder(),h&&(this.contexts.error=new se(this.node,{error:u,errorMessage:h})),p&&new oe(this.node.querySelector(".waykeecom-input-label"),{information:p,onClickInformation:F});let K=this.node.querySelector("input");K&&(w&&K.addEventListener("input",w),R&&K.addEventListener("blur",R))}},O=es;var Ji=/\S+@\S+\.\S+/,Xi=/^[0-9\-\+\(\)\ ]+$/,Zi=/^[0-9\ \-]+$/,ea=/^(19|20)(\d{6}(-|\s)\d{4}|(?!19|20)\d{10})$/,ta=/[a-zA-Z]{3}\d{2}(d||[a-zA-Z]){1}/,We=/\D/g;var C={requiredEmail:o=>Ji.test(o),requiredTelephone:o=>Xi.test(o),requiredSsn:o=>ea.test(o),requiredSsnOver18:o=>{if(C.requiredSsn(o)){let e=o.replace(We,"").slice(0,8),t=`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;return new Date(new Date().valueOf()-new Date(t).valueOf()).getFullYear()-1970>17}return!1},requiredZip:o=>Zi.test(o),requiredNumberOrStringNumberInRange:(o,i,e)=>{let t=parseInt(o.toString(),10);return isNaN(t)?!1:t>=i&&t<=e},requiredNumber:o=>o!=null&&!Number.isNaN(+o),optionalNumber:o=>o==null||!Number.isNaN(+o),requiredRegistrationNumber:o=>{if(!o)return!1;let i=o.replace(" ",""),e=i.length===6,t=ta.test(i);return e&&t},requiredMileage:o=>C.requiredNumberOrStringNumberInRange(o||"",0,8e4),optionalString:o=>!!o||!o,requiredCondition:o=>["VeryGood","Good","Ok"].includes(o||""),requiredAssessmentMaritalStatus:o=>["married","single"].includes(o||""),requiredAssessmentEmplyment:o=>["other","retired","fullTimeEmployed","student","temporarilyEmployed","selfEmployed"].includes(o||""),requiredHousingType:o=>["singleFamily","condominium","apartment"].includes(o||"")};var sa="contact-email-node",Al="contact-email",oa="contact-phone-node",Tl="contact-phone",ia="contact-proceed-node",Cl="contact-proceed",Ye={email:C.requiredEmail,phone:C.requiredTelephone},Dl=o=>{let i={email:o?.email||"",phone:o?.phone||""};return{value:i,validation:{email:Ye.email(i.email),phone:Ye.phone(i.phone)},interact:{email:!1,phone:!1}}},ts=class extends r{constructor(e,t){super(e,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--2"});this.contexts={};this.props=t;let s=this.props.store.getState();this.state=Dl(s.customer),this.render()}onChange(e){let t=e.currentTarget,s=t.name,a=t.value;this.state.value[s]=a,this.state.validation[s]=Ye[s](a),this.updateUiError(s),this.updateProceedButton()}onBlur(e){let s=e.currentTarget.name;this.state.interact[s]=!0,this.state.validation[s]=Ye[s](this.state.value[s]),this.updateUiError(s),this.updateProceedButton()}updateUiError(e){this.contexts[e]?.setError(this.state.interact[e]&&!this.state.validation[e])}updateProceedButton(){this.contexts.button?.disabled(!this.state.validation.email||!this.state.validation.phone)}onProceed(){d("MAIN","CUSTOMER_EMAIL_AND_PHONE_SET","CUSTOMER_EMAIL_AND_PHONE"),oi({email:this.state.value.email.trim(),phone:this.state.value.phone.trim()})(this.props.store.dispatch)}render(){if(this.props.store.getState().navigation.subStage>1){let t=[{key:"E-post",value:this.state.value.email},{key:"Telefonnummer",value:this.state.value.phone}];this.node.innerHTML=`
|
|
436
436
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
437
437
|
<ul class="waykeecom-key-value-list">
|
|
438
438
|
${t.map(s=>E(s)).join("")}
|
|
@@ -451,7 +451,7 @@
|
|
|
451
451
|
<div class="waykeecom-stack waykeecom-stack--2" id="${oa}"></div>
|
|
452
452
|
</div>
|
|
453
453
|
<div class="waykeecom-stack waykeecom-stack--3" id="${ia}"></div>
|
|
454
|
-
`,this.contexts.email=new O(this.node.querySelector(`#${sa}`),{title:"E-post",value:this.state.value.email,id:Al,error:this.state.interact.email&&!this.state.validation.email,errorMessage:"En giltig e-postadress m\xE5ste anges",name:"email",autocomplete:"email",placeholder:"Ange din e-postadress",onChange:t=>this.onChange(t),onBlur:t=>this.onBlur(t)}),this.contexts.phone=new O(this.node.querySelector(`#${oa}`),{title:"Telefonnummer",value:this.state.value.phone,id:Tl,error:this.state.interact.phone&&!this.state.validation.phone,errorMessage:"Ange ditt telefonnummer",name:"phone",autocomplete:"tel",placeholder:"Ange ditt telefonnummer",onChange:t=>this.onChange(t),onBlur:t=>this.onBlur(t)}),this.contexts.button=new
|
|
454
|
+
`,this.contexts.email=new O(this.node.querySelector(`#${sa}`),{title:"E-post",value:this.state.value.email,id:Al,error:this.state.interact.email&&!this.state.validation.email,errorMessage:"En giltig e-postadress m\xE5ste anges",name:"email",autocomplete:"email",placeholder:"Ange din e-postadress",onChange:t=>this.onChange(t),onBlur:t=>this.onBlur(t)}),this.contexts.phone=new O(this.node.querySelector(`#${oa}`),{title:"Telefonnummer",value:this.state.value.phone,id:Tl,error:this.state.interact.phone&&!this.state.validation.phone,errorMessage:"Ange ditt telefonnummer",name:"phone",autocomplete:"tel",placeholder:"Ange ditt telefonnummer",onChange:t=>this.onChange(t),onBlur:t=>this.onBlur(t)}),this.contexts.button=new N(this.node.querySelector(`#${ia}`),{title:"G\xE5 vidare",id:Cl,disabled:!(this.state.validation.email&&this.state.validation.phone),onClick:()=>this.onProceed()})}},aa=ts;var ss=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){this.node.innerHTML=`
|
|
455
455
|
<div class="waykeecom-disclaimer">
|
|
456
456
|
<div class="waykeecom-disclaimer__icon" aria-hidden="true">
|
|
457
457
|
<svg
|
|
@@ -498,7 +498,7 @@
|
|
|
498
498
|
<div class="waykeecom-stack waykeecom-stack--2" id="${la}"></div>
|
|
499
499
|
</div>
|
|
500
500
|
</div>
|
|
501
|
-
`,this.contexts.socialId=new O(this.node.querySelector(`#${is}`),{title:"Personnummer",value:this.state.value.socialId,id:Ke,error:this.state.interact.socialId&&!this.state.validation.socialId,errorMessage:"Ange personnummer i formatet \xC5\xC5\xC5\xC5MMDD-XXXX. M\xE5ste vara \xF6ver 18 \xE5r.",name:"socialId",placeholder:"\xC5\xC5\xC5\xC5MMDD-XXXX",pattern:"[0-9]*",inputmode:"numeric",onChange:t=>this.onChange(t),onBlur:t=>this.onBlur(t)}),Object.keys(this.state.value).forEach(t=>this.updateUiError(t)),this.contexts.buttonFetch=new
|
|
501
|
+
`,this.contexts.socialId=new O(this.node.querySelector(`#${is}`),{title:"Personnummer",value:this.state.value.socialId,id:Ke,error:this.state.interact.socialId&&!this.state.validation.socialId,errorMessage:"Ange personnummer i formatet \xC5\xC5\xC5\xC5MMDD-XXXX. M\xE5ste vara \xF6ver 18 \xE5r.",name:"socialId",placeholder:"\xC5\xC5\xC5\xC5MMDD-XXXX",pattern:"[0-9]*",inputmode:"numeric",onChange:t=>this.onChange(t),onBlur:t=>this.onBlur(t)}),Object.keys(this.state.value).forEach(t=>this.updateUiError(t)),this.contexts.buttonFetch=new N(this.node.querySelector(`#${ca}`),{title:"H\xE4mta uppgifter",id:Rl,disabled:!this.state.validation.socialId,onClick:()=>this.onFetchAddress()}),new ke(this.node.querySelector(`#${la}`),{text:`Dina personuppgifter behandlas och sparas i enlighet med v\xE5r <a href="${e}" title="personuppgiftspolicy" target="_blank" rel="noopener noreferrer" class="waykeecom-link">personuppgiftspolicy</a>.`}),this.updateProceedButton()}},da=ns;var rs=class extends r{constructor(e,t){super(e,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--2"});this.props=t;let s=this.props.store.getState();this.state=s.customer,this.render()}render(){let{store:e,lastStage:t}=this.props;if(e.getState().navigation.subStage>2){let a=[{key:"Personnummer",value:this.state.socialId}];this.node.innerHTML=`
|
|
502
502
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
503
503
|
<ul class="waykeecom-key-value-list">
|
|
504
504
|
${a.map(n=>E(n)).join("")}
|
|
@@ -542,9 +542,9 @@
|
|
|
542
542
|
</div>
|
|
543
543
|
</div>
|
|
544
544
|
</div>
|
|
545
|
-
`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${y===0?"Gratis":k(y,{postfix:"kr"})}</div>`,checked:!this.homeDelivery,onClick:F=>this.onChange(F)});break;case ls.DeliveryType.Delivery:let g=s.address?.distance?.value||0,
|
|
545
|
+
`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${y===0?"Gratis":k(y,{postfix:"kr"})}</div>`,checked:!this.homeDelivery,onClick:F=>this.onChange(F)});break;case ls.DeliveryType.Delivery:let g=s.address?.distance?.value||0,w=h.unitPrice||0,R=g>w;new be(m.querySelector(`#${ha}`),{id:Ea,name:"homeDelivery",title:"Hemleverans",value:"true",disabled:R,description:`<div class="waykeecom-box">
|
|
546
546
|
<div class="waykeecom-stack waykeecom-stack--2">Till din folkbokf\xF6ringsadress</div>
|
|
547
|
-
${R?`<div class="waykeecom-stack waykeecom-stack--2">${I({tone:"info",children:"Tyv\xE4rr kan vi inte erbjuda hemleverans till din adress."})}</div>`:""}</div>`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${R?"-":k(y,{postfix:"kr"})}</div>`,checked:this.homeDelivery,onClick:F=>this.onChange(F)});break;default:break}}),new
|
|
547
|
+
${R?`<div class="waykeecom-stack waykeecom-stack--2">${I({tone:"info",children:"Tyv\xE4rr kan vi inte erbjuda hemleverans till din adress."})}</div>`:""}</div>`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${R?"-":k(y,{postfix:"kr"})}</div>`,checked:this.homeDelivery,onClick:F=>this.onChange(F)});break;default:break}}),new N(m.querySelector(`#${ya}`),{title:"G\xE5 vidare",id:Ia,onClick:()=>this.onProceed()}),c.appendChild(m),s.navigation.stage===t&&c.parentElement?.scrollIntoView()}}},fa=ds;var H=f("@wayke-se/ecom");var ye=f("@wayke-se/ecom");var ve={bankid:"https://cdn.wayke.se/public-assets/bankid-logo.svg",illustrations:{payment:"https://cdn.wayke.se/public-assets/payment.svg"}},Ee={["VeryGood"]:"Mycket bra",["Good"]:"Bra",["Ok"]:"Ok"},X={[ye.DrivingDistance.Between0And1000]:"0\u20131000 mil",[ye.DrivingDistance.Between1000And1500]:"1000\u20131500 mil",[ye.DrivingDistance.Between1500And2000]:"1500\u20132000 mil",[ye.DrivingDistance.Between2000And2500]:"2000\u20132500 mil",[ye.DrivingDistance.Over2500]:"2500+ mil"};var xl=(o,i)=>i?Math.round(o/i)*i:o,ms=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t,this.value=t.value,this.min=t.min,this.max=t.max,this.isDisabled=t.disabled,this.inputFieldValue=this.value,this.rangeSpan=this.max-this.min,this.currentValueInPercentage=parseInt((100*((this.value-this.min)/this.rangeSpan)).toString(),10),this.render()}update(e,t,s){this.value=e,this.inputFieldValue=e,this.min=t,this.max=s,this.rangeSpan=s-t,this.isDisabled=!this.rangeSpan;let a=parseInt((100*((this.value-t)/this.rangeSpan)).toString(),10);this.currentValueInPercentage=isNaN(a)?0:a,this.render()}disabled(e){this.isDisabled!==e&&(this.isDisabled=e,this.render())}onOpenInformation(){let e=this.node.querySelector(".input-label__foldout");e&&(e.style.display="")}onChange(e){let t=e.currentTarget;this.inputFieldValue=t.valueAsNumber}onBlur(e){let t=this.inputFieldValue;if(!isNaN(t)&&t>=this.min&&t<=this.max){let s=xl(t,this.props.step);this.value=s,this.props.onChange&&e.currentTarget&&(e.currentTarget.value=s.toString(),this.props.onChange(e)),this.inputFieldValue=this.value,this.currentValueInPercentage=parseInt((100*((this.value-this.min)/this.rangeSpan)).toString(),10),this.render()}else this.inputFieldValue=this.value,this.updateInputField()}onFocus(e){let t=e.currentTarget;t.value=this.value.toString()}onInput(e){let t=e.currentTarget;this.value=parseInt(t.value,10),this.inputFieldValue=this.value,this.currentValueInPercentage=parseInt((100*((this.value-this.min)/this.rangeSpan)).toString(),10),this.updateInputField(),this.updateRangeSliderColor(t)}updateRangeSliderColor(e){let t=e||this.node.querySelector(`#${this.props.id}`);t&&t.style.setProperty("--percentage",`${this.currentValueInPercentage}%`)}updateInputField(){let e=this.node.querySelector(`#${this.props.id}-input`);e&&(e.value=this.inputFieldValue.toString())}render(){let{title:e,step:t,name:s,id:a,information:n,unit:l,onChange:c,onClickInformation:m}=this.props,u=this.min!==this.max;if(this.node.innerHTML=`
|
|
548
548
|
<div class="waykeecom-input-label">
|
|
549
549
|
<label for="${a}" class="waykeecom-input-label__label">${e}</label>
|
|
550
550
|
</div>
|
|
@@ -585,7 +585,7 @@
|
|
|
585
585
|
</div>
|
|
586
586
|
`:""}
|
|
587
587
|
</div>
|
|
588
|
-
`,n&&new oe(this.node.querySelector(".waykeecom-input-label"),{information:n,onClickInformation:m}),u){this.contexts.rangeSlider=this.node.querySelector(`#${a}`)||void 0,this.contexts.rangeSlider&&(c&&this.contexts.rangeSlider.addEventListener("change",c),this.contexts.rangeSlider.addEventListener("input",p=>this.onInput(p)),this.updateRangeSliderColor(this.contexts.rangeSlider));let h=this.node.querySelector(`#${a}-input`);h&&(h.addEventListener("change",p=>this.onChange(p)),h.addEventListener("blur",p=>this.onBlur(p)))}}},ze=ms;var ps=f("@wayke-se/ecom"),ga=({vehicleId:o,dealerId:i,downPayment:e,duration:t,residual:s})=>{let a=ps.payments.newLookupRequest().forVehicle(o).withDownPayment(e).withDuration(t);return s!==void 0&&a.withResidualValue(s),i!==void 0&&a.forDealer(i),ps.payments.lookupPayment(a.build())};var
|
|
588
|
+
`,n&&new oe(this.node.querySelector(".waykeecom-input-label"),{information:n,onClickInformation:m}),u){this.contexts.rangeSlider=this.node.querySelector(`#${a}`)||void 0,this.contexts.rangeSlider&&(c&&this.contexts.rangeSlider.addEventListener("change",c),this.contexts.rangeSlider.addEventListener("input",p=>this.onInput(p)),this.updateRangeSliderColor(this.contexts.rangeSlider));let h=this.node.querySelector(`#${a}-input`);h&&(h.addEventListener("change",p=>this.onChange(p)),h.addEventListener("blur",p=>this.onBlur(p)))}}},ze=ms;var ps=f("@wayke-se/ecom"),ga=({vehicleId:o,dealerId:i,downPayment:e,duration:t,residual:s})=>{let a=ps.payments.newLookupRequest().forVehicle(o).withDownPayment(e).withDuration(t);return s!==void 0&&a.withResidualValue(s),i!==void 0&&a.forDealer(i),ps.payments.lookupPayment(a.build())};var S=f("@wayke-se/ecom");var us=class extends r{constructor(e,t){super(e,t.append?{htmlTag:"div",className:"waykeecom-accordion"}:void 0);this.props=t,this.render()}render(){let{title:e,description:t,onClick:s}=this.props,a=`
|
|
589
589
|
<input
|
|
590
590
|
type="checkbox"
|
|
591
591
|
id="${this.props.id}"
|
|
@@ -643,12 +643,12 @@
|
|
|
643
643
|
</div>
|
|
644
644
|
</div>
|
|
645
645
|
<div class="waykeecom-stack waykeecom-stack--4">${b()}</div>
|
|
646
|
-
`,new fe(this.node,{title:"\xD6ppna BankID",disabled:!e,onClick:()=>{window.open(e,"_blank"),this.props.onClick&&this.props.onClick()},htmlNodesettings:{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--4"}})}},Sa=ys;var wa="bankid-start-node",Pl="bankid-start",Aa="bankid-abort",Na=`${Aa}-node`,vs="bankid-auth-method-node",Es=class extends r{constructor(e,t){super(e);this.props=t,setTimeout(()=>{Ie()?this.props.onStart(q.AuthMethod.SameDevice):this.props.onStart(q.AuthMethod.QrCode)},1),this.render(),G()}update(e,t){switch(this.props.errorMessage=void 0,this.props.method=e,e){case q.AuthMethod.QrCode:this.props.autoLaunchUrl=void 0,this.props.qrCode=t||this.props.qrCode;break;case q.AuthMethod.SameDevice:this.props.qrCode=void 0,this.props.autoLaunchUrl=t||this.props.autoLaunchUrl;break;default:break}this.render()}setErrorMessage(e){this.props.errorMessage=e,this.render()}setInfo(e){e!==this.props.info&&(this.props.info=e,this.render())}setTitle(e){e!==this.props.title&&(this.props.title=e,this.render())}setDescription(e){e!==this.props.description&&(this.props.description=e,this.render())}setFinalizing(e){e!==this.props.finalizing&&(this.props.finalizing=e,this.render())}render(){let{qrCode:e,autoLaunchUrl:t,method:s,errorMessage:a,descriptionQrCode:n,descriptionSameDevice:l,info:c,title:m,description:u,finalizing:h,onStart:p,onAbort:y}=this.props,g=m||(s===q.AuthMethod.QrCode?"\xD6ppna BankID och scanna QR-koden":"Skriv in din s\xE4kerhetskod i BankID-appen"),
|
|
646
|
+
`,new fe(this.node,{title:"\xD6ppna BankID",disabled:!e,onClick:()=>{window.open(e,"_blank"),this.props.onClick&&this.props.onClick()},htmlNodesettings:{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--4"}})}},Sa=ys;var wa="bankid-start-node",Pl="bankid-start",Aa="bankid-abort",Na=`${Aa}-node`,vs="bankid-auth-method-node",Es=class extends r{constructor(e,t){super(e);this.props=t,setTimeout(()=>{Ie()?this.props.onStart(q.AuthMethod.SameDevice):this.props.onStart(q.AuthMethod.QrCode)},1),this.render(),G()}update(e,t){switch(this.props.errorMessage=void 0,this.props.method=e,e){case q.AuthMethod.QrCode:this.props.autoLaunchUrl=void 0,this.props.qrCode=t||this.props.qrCode;break;case q.AuthMethod.SameDevice:this.props.qrCode=void 0,this.props.autoLaunchUrl=t||this.props.autoLaunchUrl;break;default:break}this.render()}setErrorMessage(e){this.props.errorMessage=e,this.render()}setInfo(e){e!==this.props.info&&(this.props.info=e,this.render())}setTitle(e){e!==this.props.title&&(this.props.title=e,this.render())}setDescription(e){e!==this.props.description&&(this.props.description=e,this.render())}setFinalizing(e){e!==this.props.finalizing&&(this.props.finalizing=e,this.render())}render(){let{qrCode:e,autoLaunchUrl:t,method:s,errorMessage:a,descriptionQrCode:n,descriptionSameDevice:l,info:c,title:m,description:u,finalizing:h,onStart:p,onAbort:y}=this.props,g=m||(s===q.AuthMethod.QrCode?"\xD6ppna BankID och scanna QR-koden":"Skriv in din s\xE4kerhetskod i BankID-appen"),w=u||(s===q.AuthMethod.QrCode?n:l);if(this.node.innerHTML=`
|
|
647
647
|
<div class="waykeecom-text waykeecom-text--align-center">
|
|
648
648
|
<div class="waykeecom-stack waykeecom-stack--4" id="">
|
|
649
649
|
<h4 class="waykeecom-heading waykeecom-heading--4">${g}</h4>
|
|
650
650
|
<div class="waykeecom-content">
|
|
651
|
-
<p class="waykeecom-content__p">${
|
|
651
|
+
<p class="waykeecom-content__p">${w}</p>
|
|
652
652
|
</div>
|
|
653
653
|
</div>
|
|
654
654
|
${c?` <div class="waykeecom-stack waykeecom-stack--4">${c}</div>`:""}
|
|
@@ -698,13 +698,13 @@
|
|
|
698
698
|
<div class="waykeecom-stack waykeecom-stack--2" id="${xa}"></div>
|
|
699
699
|
<div class="waykeecom-stack waykeecom-stack--2" id="${Pa}"></div>
|
|
700
700
|
</div>
|
|
701
|
-
`,new ae(this.node.querySelector(`#${Ma}`),{store:e,decision:$a.CreditAssessmentRecommendation.Approve}),new
|
|
701
|
+
`,new ae(this.node.querySelector(`#${Ma}`),{store:e,decision:$a.CreditAssessmentRecommendation.Approve}),new N(this.node.querySelector(`#${xa}`),{title:"G\xE5 vidare",id:Ha,onClick:()=>t()}),new V(this.node.querySelector(`#${Pa}`),{title:"Avbryt",id:Ba,onClick:()=>s()})}},Fa=gs;var qa=f("@wayke-se/ecom");var Hl="assessment-assess-manually-result",Ua=`${Hl}-node`,Wa="assessment-assess-manually-proceed",Va=`${Wa}-node`,Ya="assessment-assess-manually-abort",Ga=`${Ya}-node`,_s=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,onProceed:t,onGoBack:s}=this.props;this.node.innerHTML=`
|
|
702
702
|
<div class="waykeecom-stack waykeecom-stack--4" id="${Ua}"></div>
|
|
703
703
|
<div class="waykeecom-stack waykeecom-stack--4">
|
|
704
704
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Va}"></div>
|
|
705
705
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Ga}"></div>
|
|
706
706
|
</div>
|
|
707
|
-
`,new ae(this.node.querySelector(`#${Ua}`),{store:e,decision:qa.CreditAssessmentRecommendation.AssessManually}),new
|
|
707
|
+
`,new ae(this.node.querySelector(`#${Ua}`),{store:e,decision:qa.CreditAssessmentRecommendation.AssessManually}),new N(this.node.querySelector(`#${Va}`),{title:"G\xE5 vidare",id:Wa,onClick:()=>t()}),new te(this.node.querySelector(`#${Ga}`),{title:"Avbryt",id:Ya,onClick:()=>s()})}},Ka=_s;var ja=f("@wayke-se/ecom");var Ss=class extends r{constructor(e,t){super(e);this.props=t,this.render()}isDisabled(){return this.props.disabled}disabled(e){this.props.disabled!==e&&(this.props.disabled=e,this.render())}loading(e){this.props.loading!==e&&(this.props.loading=e,this.props.disabled=e,this.render())}render(){let{title:e,id:t,disabled:s,loading:a,onClick:n}=this.props;this.node.innerHTML=`
|
|
708
708
|
<button
|
|
709
709
|
type="button"
|
|
710
710
|
${t?`id="${t}"`:""}
|
|
@@ -733,7 +733,7 @@
|
|
|
733
733
|
>
|
|
734
734
|
${t.map(u=>`<option value="${u.value}" ${u.value===s?'selected="selected"':""}>${u.title||u.value}</option>`).join("")}
|
|
735
735
|
</select>
|
|
736
|
-
`,this.updateBorder(),c&&(this.contexts.error=new se(this.node,{error:l,errorMessage:c})),this.node.querySelector("select")?.addEventListener("change",u=>m(u))}},Ze=Ds;var Ul="credit-assessment-martial-status",sn=`${Ul}-node`,Ls="credit-assessment-income",bs=`${Ls}-node`,Vl="credit-assessment-employment",on=`${Vl}-node`,Gl="credit-assessment-household-children",an=`${Gl}-node`,yn="credit-assessment-housing-cost",nn=`${yn}-node`,vn="credit-assessment-debt-specification-card-credit",rn=`${vn}-node`,En="credit-assessment-debt-specification-car-loan",cn=`${En}-node`,In="credit-assessment-debt-specification-collateral",ln=`${In}-node`,fn="credit-assessment-debt-specification-leasing-fees",dn=`${fn}-node`,gn="credit-assessment-debt-specification-private-loan",mn=`${gn}-node`,ql="credit-assessment-housing-type",pn=`${ql}-node`,_n="credit-assessment-perform-application",Rs=`${_n}-node`,un="disclaimer-node",hn="disclaimer-safe-node",kn="why-description-node",$={maritalStatus:C.requiredAssessmentMaritalStatus,income:C.requiredNumber,employment:C.requiredAssessmentEmplyment,householdChildren:C.requiredNumber,housingCost:C.requiredNumber,"debtSpecification.cardCredits":C.optionalNumber,"debtSpecification.carLoan":C.optionalNumber,"debtSpecification.collateral":C.optionalNumber,"debtSpecification.leasingFees":C.optionalNumber,"debtSpecification.privateLoan":C.optionalNumber,housingType:C.requiredHousingType},Wl={maritalStatus:N.MaritalStatus.Married,income:5e4,employment:N.Employment.FullTimeEmployed,householdChildren:0,housingCost:2e3,debtSpecification:{cardCredits:0,carLoan:0,collateral:0,leasingFees:0,privateLoan:0},housingType:N.HousingType.Apartment},Yl=()=>location.hostname==="localhost"?{...Wl}:void 0,Kl=o=>{let i={maritalStatus:o?.maritalStatus||"",income:o?.income.toString()||"",employment:o?.employment.toString()||"",householdChildren:o?.householdChildren.toString()||"",housingCost:o?.housingCost.toString()||"","debtSpecification.cardCredits":o?.debtSpecification.cardCredits.toString()||"","debtSpecification.carLoan":o?.debtSpecification.carLoan.toString()||"","debtSpecification.collateral":o?.debtSpecification.collateral.toString()||"","debtSpecification.leasingFees":o?.debtSpecification.leasingFees.toString()||"","debtSpecification.privateLoan":o?.debtSpecification.privateLoan.toString()||"",housingType:o?.housingType.toString()||""};return{value:i,validation:{maritalStatus:$.maritalStatus(i.maritalStatus),income:$.income(i.income),employment:$.employment(i.employment),householdChildren:$.householdChildren(i.householdChildren),housingCost:$.housingCost(i.housingCost),"debtSpecification.cardCredits":$["debtSpecification.cardCredits"](i["debtSpecification.cardCredits"]),"debtSpecification.carLoan":$["debtSpecification.carLoan"](i["debtSpecification.carLoan"]),"debtSpecification.collateral":$["debtSpecification.collateral"](i["debtSpecification.collateral"]),"debtSpecification.leasingFees":$["debtSpecification.leasingFees"](i["debtSpecification.leasingFees"]),"debtSpecification.privateLoan":$["debtSpecification.privateLoan"](i["debtSpecification.privateLoan"]),housingType:$.housingType(i.housingType)},interact:{maritalStatus:!1,income:!1,employment:!1,householdChildren:!1,housingCost:!1,"debtSpecification.cardCredits":!1,"debtSpecification.carLoan":!1,"debtSpecification.collateral":!1,"debtSpecification.leasingFees":!1,"debtSpecification.privateLoan":!1,housingType:!1}}},Os=class extends r{constructor(e,t){super(e);this.view=1;this.contexts={};this.bankidError=!1;this.signed=!1;this.props=t,this.state=Kl(Yl()),this.render()}onChange(e){let t=e.currentTarget,s=t.name,a=t.value;this.state.value[s]=a,this.state.validation[s]=$[s](a),this.updateUiError(s),this.updateProceedButton()}onBlur(e){let s=e.currentTarget.name;this.state.interact[s]=!0,this.state.validation[s]=$[s](this.state.value[s]),this.updateUiError(s),this.updateProceedButton()}onChangeSelect(e){let t=e.currentTarget,s=t.name,a=t.value;this.state.value[s]=a,this.state.validation[s]=$[s](a),this.updateProceedButton()}onChangeRadio(e){let t=e.currentTarget,s=t.name,a=t.value;this.state.value[s]=a,this.state.validation[s]=$[s](a),s==="housingType"&&(t.value===N.HousingType.SingleFamily&&(this.state.value.housingCost="0",this.state.validation.housingCost=$.housingCost(this.state.value.housingCost),this.render()),this.render()),this.updateProceedButton()}updateUiError(e){this.contexts[e]?.setError(this.state.interact[e]&&!this.state.validation[e])}updateProceedButton(){this.contexts.performApplicationButton?.disabled(!this.state.validation.maritalStatus||!this.state.validation.income||!this.state.validation.employment||!this.state.validation.householdChildren||!this.state.validation.housingCost||!this.state.validation["debtSpecification.cardCredits"]||!this.state.validation["debtSpecification.carLoan"]||!this.state.validation["debtSpecification.collateral"]||!this.state.validation["debtSpecification.leasingFees"]||!this.state.validation["debtSpecification.privateLoan"]||!this.state.validation.housingType)}async onAbort(){d("MAIN","FINANCIAL_CREDIT_SCORING_ABORTED","FINANCIAL_CREDIT_SCORING");let{store:e}=this.props;this.view=1,this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval);let t=e.getState().caseId;t&&(await Re(t),await Cs(t),me()(e.dispatch)),L(),this.creditAssessmentResponse=void 0,this.render(!0)}bankIdStatus(e,t,s=!1){s||d("MAIN",t===N.AuthMethod.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_REQUESTED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_REQUESTED","FINANCIAL_CREDIT_SCORING");let a=this.props.store.getState().order?.paymentOptions.find(n=>n.type===N.PaymentType.Loan);this.bankidStatusInterval=setInterval(async()=>{try{let n=await Da(e),l=n.getStatus();if(!this.signed&&l==="signed"&&(d("MAIN",t===N.AuthMethod.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_SUCCEEDED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.signed=!0,this.contexts.bankId?.setTitle(`V\xE4ntar p\xE5 ${a?.name}...`),this.contexts.bankId?.setDescription(`H\xE4mtar uppgifter fr\xE5n ${a?.name}. V\xE4nta kvar det kan ta n\xE5gra sekunder.`),this.contexts.bankId?.setFinalizing(!0),d("MAIN","FINANCIAL_CREDIT_SCORING_SIGNING_SIGNED","FINANCIAL_CREDIT_SCORING")),l==="signingFailed"){clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Ett fel uppstod");return}if(n.isScored()?(d("MAIN","FINANCIAL_CREDIT_SCORING_SIGNING_SCORED","FINANCIAL_CREDIT_SCORING"),this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.view=3,this.creditAssessmentResponse=Zo(n),me(e,this.creditAssessmentResponse)(this.props.store.dispatch),L(),this.render()):n.hasScoringError()&&(clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Ett fel uppstod")),!this.signed&&t===N.AuthMethod.QrCode){let c=n.getQrCode();this.contexts.bankId?.update(t,c)}}catch{clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering")}},1e3),Oe("bankidStatusInterval-credit",this.bankidStatusInterval)}async onStartBankIdAuth(e,t=!1){let s=this.props.store.getState().caseId;if(!s)throw"Missing caseID";this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval);try{t||d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_REQUESTED","FINANCIAL_CREDIT_SCORING"),this.contexts.bankId?.update(e);let a=await Oa({caseId:s,method:e});if(t||d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.bankIdStatus(s,e,t),e===N.AuthMethod.SameDevice){let n=a.getAutoLaunchUrl();this.contexts.bankId?.update(e,n)}else{let n=a.getQrCode();this.contexts.bankId?.update(e,n)}}catch{d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_FAILED","FINANCIAL_CREDIT_SCORING"),this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.bankidError=!0,this.view=1,L(),this.render(!0)}}async startBankId(e){let{store:t}=this.props;this.caseError=void 0,this.bankidError=!1,this.signed=!1;let s=t.getState().caseId;if(this.bankidStatusInterval&&(clearInterval(this.bankidStatusInterval),s&&(await Re(s),await Cs(s),me()(t.dispatch))),s){let a=await this.newCreditAssessmentCase();me(a)(t.dispatch),this.onStartBankIdAuth(e)}else try{d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_REQUESTED","FINANCIAL_CREDIT_SCORING");let a=await this.newCreditAssessmentCase();d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),a&&(me(a)(t.dispatch),this.onStartBankIdAuth(e))}catch{d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_FAILED","FINANCIAL_CREDIT_SCORING")}}async newCreditAssessmentCase(){try{let{store:e,loan:t,paymentLookupResponse:s}=this.props;this.contexts.performApplicationButton?.disabled(!0);let{customer:a}=e.getState(),{monthlyCost:n}=s.costs,{interest:l}=s.interests,c=s.downPaymentSpec.current,m=s.durationSpec.current,u=s.creditAmount,h=s.price,p=s.financialProductCode,y={employment:this.state.value.employment,householdChildren:parseInt(this.state.value.householdChildren,10),housingCost:parseInt(this.state.value.housingCost||"0",10),housingType:this.state.value.housingType,income:parseInt(this.state.value.income||"0",10),maritalStatus:this.state.value.maritalStatus,debtSpecification:{cardCredits:parseInt(this.state.value["debtSpecification.cardCredits"]||"0",10),carLoan:parseInt(this.state.value["debtSpecification.carLoan"]||"0",10),collateral:parseInt(this.state.value["debtSpecification.collateral"]||"0",10),leasingFees:parseInt(this.state.value["debtSpecification.leasingFees"]||"0",10),privateLoan:parseInt(this.state.value["debtSpecification.privateLoan"]||"0",10)}},g={customer:{...a},householdEconomy:y,externalId:t.externalId,loan:{downPayment:c,interestRate:l,credit:u,financialProductId:p,monthlyCost:n,price:h,term:en(m)}};return(await Ra(g)).caseId}catch(e){this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.caseError=e?.message||"",this.view=1,this.render(!0);return}finally{this.contexts.performApplicationButton?.disabled(!1)}}render(e){let{store:t,paymentLookupResponse:s,onProceed:a}=this.props,n=Ie(),{order:l}=t.getState(),c=l?.paymentOptions.find(h=>h.type===N.PaymentType.Loan),m=s.creditAmount,u=l?.contactInformation?.name;if(this.view===3&&this.creditAssessmentResponse)new Za(Q(),{store:t,creditAssessmentResponse:this.creditAssessmentResponse,onProceed:()=>{L(),a()},onGoBack:()=>this.onAbort()});else if(this.view===2)this.contexts.bankId=new je(Q(),{method:n?N.AuthMethod.SameDevice:N.AuthMethod.QrCode,descriptionQrCode:"F\xF6r att h\xE4mta dina uppgifter, starta din BankID applikation p\xE5 din andra enhet.",descriptionSameDevice:"F\xF6r att h\xE4mta dina uppgifter, starta din BankID-applikation.",onAbort:()=>this.onAbort(),onStart:h=>this.startBankId(h)}),G();else{this.node.innerHTML=`
|
|
736
|
+
`,this.updateBorder(),c&&(this.contexts.error=new se(this.node,{error:l,errorMessage:c})),this.node.querySelector("select")?.addEventListener("change",u=>m(u))}},Ze=Ds;var Ul="credit-assessment-martial-status",sn=`${Ul}-node`,Ls="credit-assessment-income",bs=`${Ls}-node`,Vl="credit-assessment-employment",on=`${Vl}-node`,Gl="credit-assessment-household-children",an=`${Gl}-node`,yn="credit-assessment-housing-cost",nn=`${yn}-node`,vn="credit-assessment-debt-specification-card-credit",rn=`${vn}-node`,En="credit-assessment-debt-specification-car-loan",cn=`${En}-node`,In="credit-assessment-debt-specification-collateral",ln=`${In}-node`,fn="credit-assessment-debt-specification-leasing-fees",dn=`${fn}-node`,gn="credit-assessment-debt-specification-private-loan",mn=`${gn}-node`,ql="credit-assessment-housing-type",pn=`${ql}-node`,_n="credit-assessment-perform-application",Rs=`${_n}-node`,un="disclaimer-node",hn="disclaimer-safe-node",kn="why-description-node",$={maritalStatus:C.requiredAssessmentMaritalStatus,income:C.requiredNumber,employment:C.requiredAssessmentEmplyment,householdChildren:C.requiredNumber,housingCost:C.requiredNumber,"debtSpecification.cardCredits":C.optionalNumber,"debtSpecification.carLoan":C.optionalNumber,"debtSpecification.collateral":C.optionalNumber,"debtSpecification.leasingFees":C.optionalNumber,"debtSpecification.privateLoan":C.optionalNumber,housingType:C.requiredHousingType},Wl={maritalStatus:S.MaritalStatus.Married,income:5e4,employment:S.Employment.FullTimeEmployed,householdChildren:0,housingCost:2e3,debtSpecification:{cardCredits:0,carLoan:0,collateral:0,leasingFees:0,privateLoan:0},housingType:S.HousingType.Apartment},Yl=()=>location.hostname==="localhost"?{...Wl}:void 0,Kl=o=>{let i={maritalStatus:o?.maritalStatus||"",income:o?.income.toString()||"",employment:o?.employment.toString()||"",householdChildren:o?.householdChildren.toString()||"",housingCost:o?.housingCost.toString()||"","debtSpecification.cardCredits":o?.debtSpecification.cardCredits.toString()||"","debtSpecification.carLoan":o?.debtSpecification.carLoan.toString()||"","debtSpecification.collateral":o?.debtSpecification.collateral.toString()||"","debtSpecification.leasingFees":o?.debtSpecification.leasingFees.toString()||"","debtSpecification.privateLoan":o?.debtSpecification.privateLoan.toString()||"",housingType:o?.housingType.toString()||""};return{value:i,validation:{maritalStatus:$.maritalStatus(i.maritalStatus),income:$.income(i.income),employment:$.employment(i.employment),householdChildren:$.householdChildren(i.householdChildren),housingCost:$.housingCost(i.housingCost),"debtSpecification.cardCredits":$["debtSpecification.cardCredits"](i["debtSpecification.cardCredits"]),"debtSpecification.carLoan":$["debtSpecification.carLoan"](i["debtSpecification.carLoan"]),"debtSpecification.collateral":$["debtSpecification.collateral"](i["debtSpecification.collateral"]),"debtSpecification.leasingFees":$["debtSpecification.leasingFees"](i["debtSpecification.leasingFees"]),"debtSpecification.privateLoan":$["debtSpecification.privateLoan"](i["debtSpecification.privateLoan"]),housingType:$.housingType(i.housingType)},interact:{maritalStatus:!1,income:!1,employment:!1,householdChildren:!1,housingCost:!1,"debtSpecification.cardCredits":!1,"debtSpecification.carLoan":!1,"debtSpecification.collateral":!1,"debtSpecification.leasingFees":!1,"debtSpecification.privateLoan":!1,housingType:!1}}},Os=class extends r{constructor(e,t){super(e);this.view=1;this.contexts={};this.bankidError=!1;this.signed=!1;this.props=t,this.state=Kl(Yl()),this.render()}onChange(e){let t=e.currentTarget,s=t.name,a=t.value;this.state.value[s]=a,this.state.validation[s]=$[s](a),this.updateUiError(s),this.updateProceedButton()}onBlur(e){let s=e.currentTarget.name;this.state.interact[s]=!0,this.state.validation[s]=$[s](this.state.value[s]),this.updateUiError(s),this.updateProceedButton()}onChangeSelect(e){let t=e.currentTarget,s=t.name,a=t.value;this.state.value[s]=a,this.state.validation[s]=$[s](a),this.updateProceedButton()}onChangeRadio(e){let t=e.currentTarget,s=t.name,a=t.value;this.state.value[s]=a,this.state.validation[s]=$[s](a),s==="housingType"&&(t.value===S.HousingType.SingleFamily&&(this.state.value.housingCost="0",this.state.validation.housingCost=$.housingCost(this.state.value.housingCost)),this.render()),this.updateProceedButton()}updateUiError(e){this.contexts[e]?.setError(this.state.interact[e]&&!this.state.validation[e])}updateProceedButton(){this.contexts.performApplicationButton?.disabled(!this.state.validation.maritalStatus||!this.state.validation.income||!this.state.validation.employment||!this.state.validation.householdChildren||!this.state.validation.housingCost||!this.state.validation["debtSpecification.cardCredits"]||!this.state.validation["debtSpecification.carLoan"]||!this.state.validation["debtSpecification.collateral"]||!this.state.validation["debtSpecification.leasingFees"]||!this.state.validation["debtSpecification.privateLoan"]||!this.state.validation.housingType)}async onAbort(){d("MAIN","FINANCIAL_CREDIT_SCORING_ABORTED","FINANCIAL_CREDIT_SCORING");let{store:e}=this.props;this.view=1,this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval);let t=e.getState().caseId;t&&(await Re(t),await Cs(t),me()(e.dispatch)),L(),this.creditAssessmentResponse=void 0,this.render(!0)}bankIdStatus(e,t,s=!1){s||d("MAIN",t===S.AuthMethod.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_REQUESTED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_REQUESTED","FINANCIAL_CREDIT_SCORING");let a=this.props.store.getState().order?.paymentOptions.find(n=>n.type===S.PaymentType.Loan);this.bankidStatusInterval=setInterval(async()=>{try{let n=await Da(e),l=n.getStatus();if(!this.signed&&l==="signed"&&(d("MAIN",t===S.AuthMethod.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_SUCCEEDED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.signed=!0,this.contexts.bankId?.setTitle(`V\xE4ntar p\xE5 ${a?.name}...`),this.contexts.bankId?.setDescription(`H\xE4mtar uppgifter fr\xE5n ${a?.name}. V\xE4nta kvar det kan ta n\xE5gra sekunder.`),this.contexts.bankId?.setFinalizing(!0),d("MAIN","FINANCIAL_CREDIT_SCORING_SIGNING_SIGNED","FINANCIAL_CREDIT_SCORING")),l==="signingFailed"){clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Ett fel uppstod");return}if(n.isScored()?(d("MAIN","FINANCIAL_CREDIT_SCORING_SIGNING_SCORED","FINANCIAL_CREDIT_SCORING"),this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.view=3,this.creditAssessmentResponse=Zo(n),me(e,this.creditAssessmentResponse)(this.props.store.dispatch),L(),this.render()):n.hasScoringError()&&(clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Ett fel uppstod")),!this.signed&&t===S.AuthMethod.QrCode){let c=n.getQrCode();this.contexts.bankId?.update(t,c)}}catch{clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering")}},1e3),Oe("bankidStatusInterval-credit",this.bankidStatusInterval)}async onStartBankIdAuth(e,t=!1){let s=this.props.store.getState().caseId;if(!s)throw"Missing caseID";this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval);try{t||d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_REQUESTED","FINANCIAL_CREDIT_SCORING"),this.contexts.bankId?.update(e);let a=await Oa({caseId:s,method:e});if(t||d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.bankIdStatus(s,e,t),e===S.AuthMethod.SameDevice){let n=a.getAutoLaunchUrl();this.contexts.bankId?.update(e,n)}else{let n=a.getQrCode();this.contexts.bankId?.update(e,n)}}catch{d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_FAILED","FINANCIAL_CREDIT_SCORING"),this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.bankidError=!0,this.view=1,L(),this.render(!0)}}async startBankId(e){let{store:t}=this.props;this.caseError=void 0,this.bankidError=!1,this.signed=!1;let s=t.getState().caseId;if(this.bankidStatusInterval&&(clearInterval(this.bankidStatusInterval),s&&(await Re(s),await Cs(s),me()(t.dispatch))),s){let a=await this.newCreditAssessmentCase();me(a)(t.dispatch),this.onStartBankIdAuth(e)}else try{d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_REQUESTED","FINANCIAL_CREDIT_SCORING");let a=await this.newCreditAssessmentCase();d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),a&&(me(a)(t.dispatch),this.onStartBankIdAuth(e))}catch{d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_FAILED","FINANCIAL_CREDIT_SCORING")}}async newCreditAssessmentCase(){try{let{store:e,loan:t,paymentLookupResponse:s}=this.props;this.contexts.performApplicationButton?.disabled(!0);let{customer:a}=e.getState(),{monthlyCost:n}=s.costs,{interest:l}=s.interests,c=s.downPaymentSpec.current,m=s.durationSpec.current,u=s.creditAmount,h=s.price,p=s.financialProductCode,y={employment:this.state.value.employment,householdChildren:parseInt(this.state.value.householdChildren,10),housingCost:parseInt(this.state.value.housingCost||"0",10),housingType:this.state.value.housingType,income:parseInt(this.state.value.income||"0",10),maritalStatus:this.state.value.maritalStatus,debtSpecification:{cardCredits:parseInt(this.state.value["debtSpecification.cardCredits"]||"0",10),carLoan:parseInt(this.state.value["debtSpecification.carLoan"]||"0",10),collateral:parseInt(this.state.value["debtSpecification.collateral"]||"0",10),leasingFees:parseInt(this.state.value["debtSpecification.leasingFees"]||"0",10),privateLoan:parseInt(this.state.value["debtSpecification.privateLoan"]||"0",10)}},g={customer:{...a},householdEconomy:y,externalId:t.externalId,loan:{downPayment:c,interestRate:l,credit:u,financialProductId:p,monthlyCost:n,price:h,term:en(m)}};return(await Ra(g)).caseId}catch(e){this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.caseError=e?.message||"",this.view=1,this.render(!0);return}finally{this.contexts.performApplicationButton?.disabled(!1)}}render(e){let{store:t,paymentLookupResponse:s,onProceed:a}=this.props,n=Ie(),{order:l}=t.getState(),c=l?.paymentOptions.find(h=>h.type===S.PaymentType.Loan),m=s.creditAmount,u=l?.contactInformation?.name;if(this.view===3&&this.creditAssessmentResponse)new Za(Q(),{store:t,creditAssessmentResponse:this.creditAssessmentResponse,onProceed:()=>{L(),a()},onGoBack:()=>this.onAbort()});else if(this.view===2)this.contexts.bankId=new je(Q(),{method:n?S.AuthMethod.SameDevice:S.AuthMethod.QrCode,descriptionQrCode:"F\xF6r att h\xE4mta dina uppgifter, starta din BankID applikation p\xE5 din andra enhet.",descriptionSameDevice:"F\xF6r att h\xE4mta dina uppgifter, starta din BankID-applikation.",onAbort:()=>this.onAbort(),onStart:h=>this.startBankId(h)}),G();else{this.node.innerHTML=`
|
|
737
737
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
738
738
|
<h5 class="waykeecom-heading waykeecom-heading--4">L\xE5neans\xF6kan</h5>
|
|
739
739
|
<div class="waykeecom-content">
|
|
@@ -781,7 +781,7 @@
|
|
|
781
781
|
<div class="waykeecom-stack waykeecom-stack--2" id="${pn}"></div>
|
|
782
782
|
</div>
|
|
783
783
|
|
|
784
|
-
${this.state.value.housingType!==
|
|
784
|
+
${this.state.value.housingType!==S.HousingType.SingleFamily?`
|
|
785
785
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
786
786
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
787
787
|
<h5 class="waykeecom-heading waykeecom-heading--4 waykeecom-no-margin">Boendekostnad</h5>
|
|
@@ -842,17 +842,17 @@
|
|
|
842
842
|
<div class="waykeecom-stack waykeecom-stack--1" id="${hn}"></div>
|
|
843
843
|
</div>
|
|
844
844
|
</div>
|
|
845
|
-
`,this.contexts.maritalStatus=new j(this.node.querySelector(`#${sn}`),{title:"Civilst\xE5nd",checked:this.state.value.maritalStatus,name:"maritalStatus",options:[{id:`maritalStatus-${1}`,value:
|
|
845
|
+
`,this.contexts.maritalStatus=new j(this.node.querySelector(`#${sn}`),{title:"Civilst\xE5nd",checked:this.state.value.maritalStatus,name:"maritalStatus",options:[{id:`maritalStatus-${1}`,value:S.MaritalStatus.Married,title:"Gift/partnerskap"},{id:`maritalStatus-${2}`,value:S.MaritalStatus.CommonLaw,title:"Sambo"},{id:`maritalStatus-${3}`,value:S.MaritalStatus.Single,title:"Ensamst\xE5ende"}],onClick:p=>this.onChangeRadio(p)}),this.contexts.income=new O(this.node.querySelector(`#${bs}`),{title:"Inkomst per m\xE5nad f\xF6re skatt",value:this.state.value.income,id:Ls,error:this.state.interact.income&&!this.state.validation.income,errorMessage:"Ange din inkomst per \xE5r f\xF6re skatt",name:"income",autocomplete:"off",unit:"kr",placeholder:"",type:"number",onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p)}),this.contexts.employment=new j(this.node.querySelector(`#${on}`),{title:"Syssels\xE4ttning",checked:this.state.value.employment,name:"employment",options:[{id:`employment-${1}`,value:S.Employment.FullTimeEmployed,title:"Fast eller tillsvidareanst\xE4lld"},{id:`employment-${2}`,value:S.Employment.TemporarilyEmployed,title:"Visstidsanst\xE4lld"},{id:`employment-${3}`,value:S.Employment.SelfEmployed,title:"Egen f\xF6retagare"},{id:`employment-${4}`,value:S.Employment.Retired,title:"Pension\xE4r"},{id:`employment-${5}`,value:S.Employment.Student,title:"Student"},{id:`employment-${6}`,value:S.Employment.Other,title:"Annan"}],onClick:p=>this.onChangeRadio(p)}),this.contexts.housingType=new j(this.node.querySelector(`#${pn}`),{title:"Boendeform",checked:this.state.value.housingType,name:"housingType",options:[{id:`housingType-${1}`,value:S.HousingType.SingleFamily,title:"Villa"},{id:`housingType-${2}`,value:S.HousingType.Condominium,title:"Bostadsr\xE4tt"},{id:`housingType-${3}`,value:S.HousingType.Apartment,title:"Hyresr\xE4tt"}],onClick:p=>this.onChangeRadio(p)}),this.contexts.income=new O(this.node.querySelector(`#${bs}`),{title:"Inkomst per m\xE5nad f\xF6re skatt",value:this.state.value.income,id:Ls,error:this.state.interact.income&&!this.state.validation.income,errorMessage:"Ange din inkomst per \xE5r f\xF6re skatt",name:"income",autocomplete:"off",placeholder:"",unit:"kr",type:"number",information:`
|
|
846
846
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
847
847
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Inkomst per m\xE5nad f\xF6re skatt</span></p>
|
|
848
848
|
<p class="waykeecom-content__p">L\xF6n och/eller pension, inte bidrag eller studiel\xE5n.</p>
|
|
849
849
|
</div>
|
|
850
|
-
`,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p)}),this.contexts.householdChildren=new Ze(this.node.querySelector(`#${an}`),{title:"Antal barn under 18 \xE5r",value:this.state.value.householdChildren,name:"householdChildren",options:[{value:"0"},{value:"1"},{value:"2"},{value:"3"},{value:"4"},{value:"5"},{value:"6"},{value:"7"},{value:"8"},{value:"9"},{value:"10",title:"10 eller fler"}],onChange:p=>this.onChangeSelect(p)});let h=this.node.querySelector(`#${nn}`);h&&(this.contexts.housingCost=new O(h,{title:"Boendekostnad",value:this.state.value.housingCost,id:yn,error:this.state.interact.housingCost&&!this.state.validation.housingCost,errorMessage:"Ange boendekostnader per m\xE5nad",name:"housingCost",autocomplete:"off",placeholder:"",unit:"kr",type:"number",information
|
|
850
|
+
`,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p)}),this.contexts.householdChildren=new Ze(this.node.querySelector(`#${an}`),{title:"Antal barn under 18 \xE5r",value:this.state.value.householdChildren,name:"householdChildren",options:[{value:"0"},{value:"1"},{value:"2"},{value:"3"},{value:"4"},{value:"5"},{value:"6"},{value:"7"},{value:"8"},{value:"9"},{value:"10",title:"10 eller fler"}],onChange:p=>this.onChangeSelect(p)});let h=this.node.querySelector(`#${nn}`);h&&(this.contexts.housingCost=new O(h,{title:this.state.value.housingType===S.HousingType.Condominium?"Min del av m\xE5nadsavgiften":this.state.value.housingType===S.HousingType.Apartment?"Min del av m\xE5nadshyran":"Boendekostnad",value:this.state.value.housingCost,id:yn,error:this.state.interact.housingCost&&!this.state.validation.housingCost,errorMessage:"Ange boendekostnader per m\xE5nad",name:"housingCost",autocomplete:"off",placeholder:"",unit:"kr",type:"number",information:this.state.value.housingType===S.HousingType.Condominium?`
|
|
851
851
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
852
|
-
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">
|
|
852
|
+
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Min del av m\xE5nadsavgiften</span></p>
|
|
853
853
|
<p class="waykeecom-content__p">Exklusive r\xE4nta och amortering</p>
|
|
854
854
|
</div>
|
|
855
|
-
|
|
855
|
+
`:void 0,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p),onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_HOUSEHOLD_DEBT_INFORMATION_TOGGLE","FINANCIAL")}})),this.contexts["debtSpecification.cardCredits"]=new O(this.node.querySelector(`#${rn}`),{title:"Kortkrediter",value:this.state.value["debtSpecification.cardCredits"],id:vn,error:this.state.interact["debtSpecification.cardCredits"]&&!this.state.validation["debtSpecification.cardCredits"],errorMessage:"Ange kortkrediter eller l\xE4mna tomt",name:"debtSpecification.cardCredits",autocomplete:"off",placeholder:"",unit:"kr",type:"number",information:`
|
|
856
856
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
857
857
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Kortkrediter</span></p>
|
|
858
858
|
<p class="waykeecom-content__p">Total skuld</p>
|
|
@@ -999,7 +999,7 @@
|
|
|
999
999
|
<ul class="waykeecom-key-value-list waykeecom-key-value-list--large-value">
|
|
1000
1000
|
${E({key:"M\xE5nadskostnad f\xF6r l\xE5net",value:k(e,{postfix:"kr/m\xE5n*"})})}
|
|
1001
1001
|
</ul>
|
|
1002
|
-
`}},Cn=$s;var Dn="finance-details-monthly-cost",bn="finance-details-pie-chart-node",Rn="finance-details-basic",Ln="finance-details-detailed",Hs=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t,this.render()}extractProps(){let{loan:e,paymentLookupResponse:t}=this.props,{monthlyCost:s,totalCreditCost:a}=t.costs,{interest:n,effectiveInterest:l}=t.interests,c=t.downPaymentSpec.current,m=t.durationSpec.current,{administrationFee:u,setupFee:h}=t.fees,p=t.creditAmount,y=t.publicURL,g=c+p,
|
|
1002
|
+
`}},Cn=$s;var Dn="finance-details-monthly-cost",bn="finance-details-pie-chart-node",Rn="finance-details-basic",Ln="finance-details-detailed",Hs=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t,this.render()}extractProps(){let{loan:e,paymentLookupResponse:t}=this.props,{monthlyCost:s,totalCreditCost:a}=t.costs,{interest:n,effectiveInterest:l}=t.interests,c=t.downPaymentSpec.current,m=t.durationSpec.current,{administrationFee:u,setupFee:h}=t.fees,p=t.creditAmount,y=t.publicURL,g=c+p,w=Math.round(c/g*100),R=Math.round(p/g*100);return{duration:m,downPayment:c,administrationFee:u,setupFee:h,totalCreditCost:a,interest:n,effectiveInterest:l,creditAmount:p,total:g,publicUrl:y,monthlyCost:s,loanOrgName:e.name,loanOrgLogo:e.logo,downPaymentPercentage:w,creditAmountPercentage:R}}update(e){this.props=e;let{duration:t,downPayment:s,administrationFee:a,setupFee:n,monthlyCost:l,totalCreditCost:c,interest:m,effectiveInterest:u,creditAmount:h,publicUrl:p,loanOrgName:y,downPaymentPercentage:g,creditAmountPercentage:w}=this.extractProps();this.contexts.loanDetailsMontlyCost?.update({monthlyCost:l}),this.contexts.pieChart?.update({percentage:w}),this.contexts.loanDetailsBasic?.update({downPayment:s,creditAmount:h,downPaymentPercentage:g,creditAmountPercentage:w}),this.contexts.loanDetailsDetailed?.update({duration:t,administrationFee:a,setupFee:n,totalCreditCost:c,interest:m,effectiveInterest:u,publicUrl:p,loanOrgName:y})}render(){let{duration:e,downPayment:t,administrationFee:s,setupFee:a,totalCreditCost:n,interest:l,effectiveInterest:c,creditAmount:m,publicUrl:u,loanOrgName:h,loanOrgLogo:p,monthlyCost:y,downPaymentPercentage:g,creditAmountPercentage:w}=this.extractProps(),R=`*Ber\xE4knat p\xE5 ${k(l*100,{decimals:2})} % r\xE4nta (effektivt ${k(c*100,{decimals:2})} %). Den r\xE4nta du f\xE5r s\xE4tts vid avtalskrivning.`;this.node.innerHTML=`
|
|
1003
1003
|
<div class="waykeecom-stepper__break">
|
|
1004
1004
|
<div class="waykeecom-shadow-box">
|
|
1005
1005
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
@@ -1026,7 +1026,7 @@
|
|
|
1026
1026
|
</div>
|
|
1027
1027
|
</div>
|
|
1028
1028
|
</div>
|
|
1029
|
-
`,this.contexts.loanDetailsMontlyCost=new Cn(this.node.querySelector(`#${Dn}`),{monthlyCost:y}),this.contexts.pieChart=new wn(this.node.querySelector(`#${bn}`),{percentage:
|
|
1029
|
+
`,this.contexts.loanDetailsMontlyCost=new Cn(this.node.querySelector(`#${Dn}`),{monthlyCost:y}),this.contexts.pieChart=new wn(this.node.querySelector(`#${bn}`),{percentage:w}),this.contexts.loanDetailsBasic=new Nn(this.node.querySelector(`#${Rn}`),{downPayment:t,creditAmount:m,downPaymentPercentage:g,creditAmountPercentage:w}),this.contexts.loanDetailsDetailed=new Tn(this.node.querySelector(`#${Ln}`),{duration:e,administrationFee:s,setupFee:a,totalCreditCost:n,interest:l,effectiveInterest:c,publicUrl:u,loanOrgName:h})}},On=Hs;var Bs=class extends r{constructor(e,t){super(e);this.props=t,this.error=t.error,this.render()}update(e){this.error=e,this.render()}render(){if(!this.error){this.node.innerHTML="";return}this.node.innerHTML=I({tone:"error",children:this.error})}},Mn=Bs;var xn="downpayment-range-node",zl="downpayment-range",Pn="duration-range-node",Ql="duration-range",$n="residual-range-node",jl="residual-range",Jl="loan-details",Hn=`${Jl}-node`,Bn="credit-assessment-node",Vn="credit-assessment-proceed",Fn=`${Vn}-node`,Un="loan-error-node",Fs=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t;let s=this.props.loan.loanDetails;if(!s)throw"err";this.paymentLookupResponse=this.props.paymentLookupResponse||s,this.paymentState={vehicleId:this.props.vehicleId,dealerId:"",downPayment:this.paymentLookupResponse.downPaymentSpec,duration:this.paymentLookupResponse.durationSpec,residual:this.paymentLookupResponse.residualValueSpec},this.previousState=JSON.parse(JSON.stringify(this.paymentState)),this.render()}async payment(){this.contexts.downPayment?.disabled(!0),this.contexts.duration?.disabled(!0),this.contexts.residual?.disabled(!0),this.contexts.proceedButton?.disabled(!0);try{let e=await ga({vehicleId:this.paymentState.vehicleId,downPayment:this.paymentState.downPayment.current,duration:this.paymentState.duration.current,residual:this.paymentState.residual?.current});this.previousState=JSON.parse(JSON.stringify(this.paymentState)),this.paymentLookupResponse=we(e),this.paymentState={...this.paymentState,downPayment:this.paymentLookupResponse.downPaymentSpec,duration:this.paymentLookupResponse.durationSpec,residual:this.paymentLookupResponse.residualValueSpec},li(e)(this.props.store.dispatch),this.update(),this.contexts.errorAlert?.update(void 0),this.contexts.downPayment?.update(this.paymentState.downPayment.current,this.paymentState.downPayment.min,this.paymentState.downPayment.max),this.contexts.residual?.update(parseInt(`${this.paymentState.residual.current*100}`,10),parseInt(`${this.paymentState.residual.min*100}`,10),parseInt(`${this.paymentState.residual.max*100}`,10)),this.contexts.duration?.update(this.paymentState.duration.current,this.paymentState.duration.min,this.paymentState.duration.max)}catch{this.contexts.errorAlert?.update("Ett fel uppstod, f\xF6rs\xF6k igen."),this.contexts.downPayment?.disabled(!1),this.contexts.duration?.disabled(!1),this.contexts.residual?.disabled(!1),this.contexts.downPayment?.update(this.previousState.downPayment.current,this.previousState.downPayment.min,this.previousState.downPayment.max),this.contexts.residual?.update(parseInt(`${this.previousState.residual.current*100}`,10),parseInt(`${this.previousState.residual.min*100}`,10),parseInt(`${this.previousState.residual.max*100}`,10)),this.contexts.duration?.update(this.previousState.duration.current,this.previousState.duration.min,this.previousState.duration.max)}finally{this.contexts.downPayment?.disabled(!1),this.contexts.duration?.disabled(!1),this.contexts.residual?.disabled(!1),this.contexts.proceedButton?.disabled(!1)}}onChange(e){let t=e.currentTarget,s=t.name,a=t.value;t.value=a,this.paymentState[s].current=s==="residual"?parseInt(a,10)/100:parseInt(a,10),this.payment()}update(){this.contexts.loanDetails?.update({loan:this.props.loan,paymentLookupResponse:this.paymentLookupResponse})}render(){let{store:e,loan:t,onProceed:s}=this.props,{order:a}=e.getState(),n=a?.contactInformation?.name,l=t.loanDetails?.shouldUseCreditScoring;this.node.innerHTML=`
|
|
1030
1030
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1031
1031
|
<hr class="waykeecom-separator" />
|
|
1032
1032
|
</div>
|
|
@@ -1054,7 +1054,7 @@
|
|
|
1054
1054
|
<p class="waykeecom-content__p">Kontantinsatsen \xE4r en del av bilens pris som du betalar med egna pengar. Den beh\xF6ver vara minst 20% av priset p\xE5 bilen. Kontantinsatsen betalar du senare i samband med avtalsskrivning hos ${n}.</p>
|
|
1055
1055
|
<p class="waykeecom-content__p">Ifall du har en inbytesbil kan du betala kontantinsatsen med den. Detta kommer du \xF6verens om tillsammans med ${n} vid avtalsskrivning. </p>
|
|
1056
1056
|
</div>
|
|
1057
|
-
`,onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DOWNPAYMENT_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts.duration=new ze(this.node.querySelector(`#${Pn}`),{title:"Avbetalning",value:this.paymentState.duration.current,id:Ql,name:"duration",onChange:c=>this.onChange(c),min:this.paymentState.duration.min,max:this.paymentState.duration.max,step:this.paymentState.duration.step,unit:"m\xE5n"}),this.paymentState.residual&&(this.contexts.residual=new ze(this.node.querySelector(`#${$n}`),{title:"Restv\xE4rde",value:parseInt(`${this.paymentState.residual.current*100}`,10),id:jl,name:"residual",onChange:c=>this.onChange(c),min:parseInt(`${this.paymentState.residual.min*100}`,10),max:parseInt(`${this.paymentState.residual.max*100}`,10),step:parseInt(`${this.paymentState.residual.step*100}`,10),unit:"%"})),this.contexts.errorAlert=new Mn(this.node.querySelector(`#${Un}`),{}),this.contexts.loanDetails=new On(this.node.querySelector(`#${Hn}`),{loan:t,paymentLookupResponse:this.paymentLookupResponse}),l?new Sn(this.node.querySelector(`#${Bn}`),{store:e,loan:t,paymentLookupResponse:this.paymentLookupResponse,onProceed:()=>s()}):this.contexts.proceedButton=new
|
|
1057
|
+
`,onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DOWNPAYMENT_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts.duration=new ze(this.node.querySelector(`#${Pn}`),{title:"Avbetalning",value:this.paymentState.duration.current,id:Ql,name:"duration",onChange:c=>this.onChange(c),min:this.paymentState.duration.min,max:this.paymentState.duration.max,step:this.paymentState.duration.step,unit:"m\xE5n"}),this.paymentState.residual&&(this.contexts.residual=new ze(this.node.querySelector(`#${$n}`),{title:"Restv\xE4rde",value:parseInt(`${this.paymentState.residual.current*100}`,10),id:jl,name:"residual",onChange:c=>this.onChange(c),min:parseInt(`${this.paymentState.residual.min*100}`,10),max:parseInt(`${this.paymentState.residual.max*100}`,10),step:parseInt(`${this.paymentState.residual.step*100}`,10),unit:"%"})),this.contexts.errorAlert=new Mn(this.node.querySelector(`#${Un}`),{}),this.contexts.loanDetails=new On(this.node.querySelector(`#${Hn}`),{loan:t,paymentLookupResponse:this.paymentLookupResponse}),l?new Sn(this.node.querySelector(`#${Bn}`),{store:e,loan:t,paymentLookupResponse:this.paymentLookupResponse,onProceed:()=>s()}):this.contexts.proceedButton=new N(this.node.querySelector(`#${Fn}`),{title:"G\xE5 vidare",id:Vn,onClick:()=>s()})}},Gn=Fs;var Us=f("@wayke-se/ecom");var Xl="credit-assessment-result",qn=`${Xl}-node`,Vs=class extends r{constructor(e,t){super(e,{htmlTag:"div"});this.props=t,this.render()}render(){let{store:e,paymentType:t,loan:s,paymentLookupResponse:a,onEdit:n}=this.props,l=s?.loanDetails;if(t===Us.PaymentType.Loan){let c=this.props.store.getState(),m=a||l;if(!l||!m)throw"Missing loan";let u=m.downPaymentSpec.current,h=m.creditAmount,p=m.durationSpec.current,{interest:y,effectiveInterest:g}=m.interests,{monthlyCost:w}=m.costs,R=[{key:"Kontantinsats",value:k(u,{postfix:"kr"})},{key:"L\xE5nebelopp",value:k(h,{postfix:"kr"})},{key:"Avbetalningsperoid",value:`${p} m\xE5n`},{key:"M\xE5nadskostnad f\xF6r l\xE5net",value:k(w,{postfix:"kr*"})}],F=c.creditAssessmentResponse?.recommendation,K=`*Ber\xE4knat p\xE5 ${k(y*100,{decimals:2})} % r\xE4nta (effektivt ${k(g*100,{decimals:2})} %). Den r\xE4nta du f\xE5r s\xE4tts vid avtalskrivning.`;this.node.innerHTML=`
|
|
1058
1058
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
1059
1059
|
<h4 class="waykeecom-heading waykeecom-heading--4">Bill\xE5n</h4>
|
|
1060
1060
|
<div class="waykeecom-content">
|
|
@@ -1101,11 +1101,11 @@
|
|
|
1101
1101
|
<div class="waykeecom-stack waykeecom-stack--3" id="${Qn}"></div>
|
|
1102
1102
|
${this.paymentType!==H.PaymentType.Loan?`<div class="waykeecom-stack waykeecom-stack--3" id="${Yn}"></div>`:""}
|
|
1103
1103
|
|
|
1104
|
-
`,m.appendChild(u);let
|
|
1104
|
+
`,m.appendChild(u);let w=a.contactInformation,R=[];if(p&&R.push({id:td,value:H.PaymentType.Cash,title:"Kontant",description:`
|
|
1105
1105
|
<div class="waykeecom-box">
|
|
1106
1106
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1107
1107
|
<ul class="waykeecom-content__ul">
|
|
1108
|
-
<li class="waykeecom-content__li">Betalning sker hos ${
|
|
1108
|
+
<li class="waykeecom-content__li">Betalning sker hos ${w?.name} vid
|
|
1109
1109
|
kontraktskrivning.</li>
|
|
1110
1110
|
<li class="waykeecom-content__li">Inga kostnader tillkommer.</li>
|
|
1111
1111
|
</ul>
|
|
@@ -1124,7 +1124,7 @@
|
|
|
1124
1124
|
</div>
|
|
1125
1125
|
</li>
|
|
1126
1126
|
`:""}
|
|
1127
|
-
<li class="waykeecom-content__li">Betalning sker hos ${
|
|
1127
|
+
<li class="waykeecom-content__li">Betalning sker hos ${w?.name} vid
|
|
1128
1128
|
kontraktskrivning.</li>
|
|
1129
1129
|
<li class="waykeecom-content__li">Ber\xE4knat p\xE5 ${k(qc,{postfix:"kr"})}, ${Vc} m\xE5n, ${k(Gc*100,{decimals:2})}% r\xE4nta.</li>
|
|
1130
1130
|
</ul>
|
|
@@ -1150,7 +1150,7 @@
|
|
|
1150
1150
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1151
1151
|
<p class="waykeecom-content__p">Du st\xE5r inte som \xE4gare p\xE5 bilen utan betalar en avtalad m\xE5nadsavgift d\xE4r det mesta ing\xE5r. N\xE4r avtalstiden g\xE5r ut \xE4r det bara att l\xE4mna tillbaka bilen till bilhandlaren.</p>
|
|
1152
1152
|
</div>
|
|
1153
|
-
`,options:F,onClick:U=>this.onChange(U)}));let K=u.querySelector(`#${Qn}`);K&&(y&&this.paymentType===H.PaymentType.Loan?new Gn(K,{store:this.props.store,loan:y,vehicleId:s,paymentLookupResponse:n,onProceed:()=>this.onProceed()}):new
|
|
1153
|
+
`,options:F,onClick:U=>this.onChange(U)}));let K=u.querySelector(`#${Qn}`);K&&(y&&this.paymentType===H.PaymentType.Loan?new Gn(K,{store:this.props.store,loan:y,vehicleId:s,paymentLookupResponse:n,onProceed:()=>this.onProceed()}):new N(u.querySelector(`#${Yn}`),{title:"G\xE5 vidare",id:jn,disabled:!this.paymentType,onClick:()=>this.onProceed()}))}!e&&t.navigation.stage===this.props.index&&m.parentElement?.scrollIntoView()}},Jn=Gs;var B=f("@wayke-se/ecom");var qs=f("@wayke-se/ecom"),Xn=(o,i)=>{let e=o.getState();if(!e.id)throw"No id";let t=qs.insurances.newInsuranceOptionsRequest().forCustomer(e.customer.socialId).forVehicle(e.id).withDrivingDistance(i);return qs.insurances.getOptions(t.build())};var Ws=class extends r{constructor(e,t){super(e,t.append?{htmlTag:"div",className:"waykeecom-input-selection",attributes:[{key:"role",value:"checkbox"}]}:void 0);this.props=t,this.render()}checked(e){this.props.checked!==e&&(this.props.checked=e,this.render())}disabled(e){this.props.disabled!==e&&(this.props.disabled=e,this.render())}render(){let{id:e,title:t,value:s,name:a,checked:n,meta:l,description:c,append:m,disabled:u,onClick:h}=this.props,p=`
|
|
1154
1154
|
<input
|
|
1155
1155
|
type="checkbox"
|
|
1156
1156
|
id="${e}"
|
|
@@ -1230,7 +1230,7 @@
|
|
|
1230
1230
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Qs}"></div>
|
|
1231
1231
|
<div class="waykeecom-stack waykeecom-stack--1" id="${tr}"></div>
|
|
1232
1232
|
</div>
|
|
1233
|
-
`,new ce(this.node.querySelector(`#${zs}`),{title:"Tillbaka",onClick:()=>s()}),u?.length){let p=this.node.querySelector(`#${sr}`);u.forEach(y=>{let g=new er(p);this.contexts.checkboxes[y.name]=new et(g.render(),{id:y.name,name:y.name,title:y.title,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${k(y.monthlyPrice,{postfix:"kr/m\xE5n"})}</div>`,description:`<div class="waykeecom-text waykeecom-text--tone-alt">${y.description}</div>`,append:!0,value:y.name,checked:this.addons.findIndex(
|
|
1233
|
+
`,new ce(this.node.querySelector(`#${zs}`),{title:"Tillbaka",onClick:()=>s()}),u?.length){let p=this.node.querySelector(`#${sr}`);u.forEach(y=>{let g=new er(p);this.contexts.checkboxes[y.name]=new et(g.render(),{id:y.name,name:y.name,title:y.title,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${k(y.monthlyPrice,{postfix:"kr/m\xE5n"})}</div>`,description:`<div class="waykeecom-text waykeecom-text--tone-alt">${y.description}</div>`,append:!0,value:y.name,checked:this.addons.findIndex(w=>w.name===y.name)>-1,onClick:w=>this.onClick(w)})})}if(m?.length){let p=this.node.querySelector(`#${or}`);m.forEach(y=>new Qe(p,{id:y.name,title:y.name,description:y.description,append:!0}))}new ce(this.node.querySelector(`#${zs}`),{title:"Tillbaka",onClick:()=>s()}),new te(this.node.querySelector(`#${tr}`),{title:"Tillbaka",onClick:()=>s()}),t?this.contexts.updateButton=new Zn(this.node.querySelector(`#${Qs}`),{title:t?"Uppdatera":"V\xE4lj",disabled:t?!h:void 0,onClick:()=>this.onUpdate()}):this.contexts.updateButton=new ee(this.node.querySelector(`#${Qs}`),{selected:!1,fullSize:!0,disabled:t?!h:void 0,onClick:()=>this.onUpdate()}),G()}},ir=_e;var js=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.props=t,_(this.props.store,"insurance",()=>{this.render()}),this.render()}onInfoOpen(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE_IF"),this.displayInfo=!0,this.render()}onInfoClose(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE_IF"),this.displayInfo=!1,L(),this.render(),this.node.parentElement?.scrollIntoView()}onClick(){let{insurance:e}=this.props.store.getState();!e||e&&this.props.insurance.name!==e.name?d("MAIN","INSURANCE_SELECTED","INSURANCE_IF"):d("MAIN","INSURANCE_UNSELECTED","INSURANCE_IF"),de(this.props.insurance)(this.props.store.dispatch)}render(){let{store:e,insurance:t,key:s}=this.props,a=e.getState(),n=a.order?.insuranceOption?.logo,l=a.insuranceAddOns?.insurance===t.name?a.insuranceAddOns.addOns.map(m=>({key:m?.title,value:k(m?.monthlyPrice,{postfix:"kr/m\xE5n"})})):void 0,c=a.insurance?JSON.stringify(a.insurance).localeCompare(JSON.stringify(t))===0:!1;this.displayInfo&&new ir(Q(),{store:this.props.store,insurance:t,selected:c,onClose:()=>this.onInfoClose()}),new he(this.node,{logo:n,selected:c,id:s,title:t.name,description:t.description,price:k(t.price,{postfix:"kr/m\xE5n"}),priceDetails:l,onClick:()=>this.onClick(),onInfo:()=>this.onInfoOpen()},s)}},ar=js;var Js=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,insurances:t}=this.props,s=new ue(this.node,{id:"insurance-list",onClick:()=>d("MAIN","INSURANCE_ARROW","INSURANCE_IF")}),{overflowElement:a}=s;a&&(a.innerHTML="",t.forEach((n,l)=>new ar(a,{store:e,insurance:n,key:`insurance-${l}`})))}},nr=Js;var Xs="insurance-grid-list-node",id="button-insurances-proceed",rr=`${Xs}-node`,mr="button-insurances-skip",cr=`${mr}-node`,pr="button-insurance-edit-driving-distance",lr=`${pr}-node`,dr={},Zs=class extends r{constructor(e,t){super(e);this.requestError=!1;this.contexts={listners:[]};this.props=t;let s=_(this.props.store,"drivingDistance",()=>{this.fetchInsurance()});this.contexts.listners.push(s);let a=_(this.props.store,"customer.socialId",()=>{this.fetchInsurance()});this.contexts.listners.push(a);let n=_(this.props.store,"insurance",()=>{this.contexts.buttonProceed?.disabled(!this.props.store.getState().insurance)});this.contexts.listners.push(n),this.fetchInsurance(),this.render()}fetchInsurance(){this.props.store.getState().customer.socialId&&this.getInsurances()}async getInsurances(){let e=this.props.store.getState();this.requestError=!1,this.render();let t=`${e.customer.socialId}-${e.id}-${e.drivingDistance}`,s=dr[t];if(d("MAIN","INSURANCE_GET_INSURANCES_REQUESTED","INSURANCE_IF"),s){this.insurances=s,d("MAIN","INSURANCE_GET_INSURANCES_SUCCEEDED","INSURANCE_IF"),this.render();return}try{let a=await Xn(this.props.store,e.drivingDistance);d("MAIN","INSURANCE_GET_INSURANCES_SUCCEEDED","INSURANCE_IF"),this.insurances=a.getInsuranceOptions(),dr[t]=this.insurances}catch{d("MAIN","INSURANCE_GET_INSURANCES_FAILED","INSURANCE_IF"),this.requestError=!0}finally{this.render()}}onEditDrivingDistance(){this.contexts.listners.forEach(e=>e?.()),this.props.onEdit()}onProceed(){Z(this.props.lastStage)(this.props.store.dispatch)}onSkipInsurances(){d("MAIN","INSURANCE_SKIPPED","INSURANCE_IF"),de()(this.props.store.dispatch),Z(this.props.lastStage)(this.props.store.dispatch)}render(){let{store:e}=this.props,t=e.getState(),{insurance:s,drivingDistance:a}=t;this.node.innerHTML=`
|
|
1234
1234
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1235
1235
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vill du teckna en f\xF6rs\xE4kring p\xE5 din nya bil?</h4>
|
|
1236
1236
|
<div class="waykeecom-content">
|
|
@@ -1254,7 +1254,7 @@
|
|
|
1254
1254
|
<div class="waykeecom-stack waykeecom-stack--1" id="${rr}"></div>
|
|
1255
1255
|
<div class="waykeecom-stack waykeecom-stack--1" id="${cr}"></div>
|
|
1256
1256
|
</div>
|
|
1257
|
-
`;let n=this.node.querySelector(`#${Xs}`);if(n)if(this.requestError)n.innerHTML=I({tone:"error",children:'Det gick inte att h\xE4mta f\xF6rs\xE4kringar. <button type="button" titlte="F\xF6rs\xF6k igen" class="waykeecom-link waykeecom-link--align-baseline waykeecom-link--current-color">Klicka h\xE4r f\xF6r att f\xF6rs\xF6ka igen</button>.'}),n.querySelector("button")?.addEventListener("click",()=>this.getInsurances());else{let l=this.insurances;l?.length?new nr(n,{store:e,insurances:l}):n.innerHTML=b()}new V(this.node.querySelector(`#${lr}`),{id:pr,title:"\xC4ndra",onClick:()=>this.onEditDrivingDistance()}),this.contexts.buttonProceed=new
|
|
1257
|
+
`;let n=this.node.querySelector(`#${Xs}`);if(n)if(this.requestError)n.innerHTML=I({tone:"error",children:'Det gick inte att h\xE4mta f\xF6rs\xE4kringar. <button type="button" titlte="F\xF6rs\xF6k igen" class="waykeecom-link waykeecom-link--align-baseline waykeecom-link--current-color">Klicka h\xE4r f\xF6r att f\xF6rs\xF6ka igen</button>.'}),n.querySelector("button")?.addEventListener("click",()=>this.getInsurances());else{let l=this.insurances;l?.length?new nr(n,{store:e,insurances:l}):n.innerHTML=b()}new V(this.node.querySelector(`#${lr}`),{id:pr,title:"\xC4ndra",onClick:()=>this.onEditDrivingDistance()}),this.contexts.buttonProceed=new N(this.node.querySelector(`#${rr}`),{id,disabled:!s,title:"G\xE5 vidare",onClick:()=>this.onProceed()}),new z(this.node.querySelector(`#${cr}`),{id:mr,title:"Hoppa \xF6ver detta steg",onClick:()=>this.onSkipInsurances()})}},ur=Zs;var Ir="select-insurance-distance",hr=`${Ir}-node`,kr="insurance-info-node",to="button-insurances-show",yr=`${to}-node`,vr=`${to}-disclaimer-node`,fr="button-insurances-skip",Er=`${fr}-node`,eo=class extends r{constructor(e,t){super(e);this.showInsurances=!1;this.props=t,this.showInsurances=!!this.props.store.getState().insurance,this.render()}onChangeDistance(e){this.showInsurances=!1;let s=e.currentTarget.value;switch(di(s)(this.props.store.dispatch),s){case B.DrivingDistance.Between0And1000:d("MAIN","INSURANCE_MILEAGE_BETWEEN_0_AND_1000_SELECTED","INSURANCE_IF");break;case B.DrivingDistance.Between1000And1500:d("MAIN","INSURANCE_MILEAGE_BETWEEN_1000_AND_1500_SELECTED","INSURANCE_IF");break;case B.DrivingDistance.Between1500And2000:d("MAIN","INSURANCE_MILEAGE_BETWEEN_1500_AND_2000_SELECTED","INSURANCE_IF");break;case B.DrivingDistance.Between2000And2500:d("MAIN","INSURANCE_MILEAGE_BETWEEN_2000_AND_2500_SELECTED","INSURANCE_IF");break;case B.DrivingDistance.Over2500:d("MAIN","INSURANCE_MILEAGE_OVER_2500_SELECTED","INSURANCE_IF");break;default:break}}onShowInsurances(){this.showInsurances=!0,d("MAIN","INSURANCE_SHOW","INSURANCE_IF"),this.render()}onEdit(){this.showInsurances=!1,d("MAIN","INSURANCE_EDIT_MILEAGE","INSURANCE_IF"),this.render()}render(){let{store:e,lastStage:t,onSkip:s}=this.props,a=e.getState(),n=a.order?.insuranceOption?.title||"[Ok\xE4nt f\xF6rs\xE4kringsbolag]";if(this.showInsurances)new ur(this.node,{store:e,lastStage:t,onEdit:()=>this.onEdit()});else{this.node.innerHTML=`
|
|
1258
1258
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1259
1259
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vill du teckna en f\xF6rs\xE4kring p\xE5 din nya bil?</h4>
|
|
1260
1260
|
<div class="waykeecom-content">
|
|
@@ -1270,7 +1270,7 @@
|
|
|
1270
1270
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Er}"></div>
|
|
1271
1271
|
<div class="waykeecom-stack waykeecom-stack--1" id="${vr}"></div>
|
|
1272
1272
|
</div>
|
|
1273
|
-
`,new Ze(this.node.querySelector(`#${hr}`),{id:Ir,title:"Visa f\xF6rs\xE4kringar",name:"distance",value:a.drivingDistance,options:[{value:B.DrivingDistance.Between0And1000,title:X[B.DrivingDistance.Between0And1000]},{value:B.DrivingDistance.Between1000And1500,title:X[B.DrivingDistance.Between1000And1500]},{value:B.DrivingDistance.Between1500And2000,title:X[B.DrivingDistance.Between1500And2000]},{value:B.DrivingDistance.Between2000And2500,title:X[B.DrivingDistance.Between2000And2500]},{value:B.DrivingDistance.Over2500,title:X[B.DrivingDistance.Over2500]}],onChange:c=>this.onChangeDistance(c)}),new
|
|
1273
|
+
`,new Ze(this.node.querySelector(`#${hr}`),{id:Ir,title:"Visa f\xF6rs\xE4kringar",name:"distance",value:a.drivingDistance,options:[{value:B.DrivingDistance.Between0And1000,title:X[B.DrivingDistance.Between0And1000]},{value:B.DrivingDistance.Between1000And1500,title:X[B.DrivingDistance.Between1000And1500]},{value:B.DrivingDistance.Between1500And2000,title:X[B.DrivingDistance.Between1500And2000]},{value:B.DrivingDistance.Between2000And2500,title:X[B.DrivingDistance.Between2000And2500]},{value:B.DrivingDistance.Over2500,title:X[B.DrivingDistance.Over2500]}],onChange:c=>this.onChangeDistance(c)}),new N(this.node.querySelector(`#${yr}`),{id:to,title:"Visa f\xF6rs\xE4kringar",onClick:()=>this.onShowInsurances()});let l=this.node.querySelector(`#${kr}`);l&&(l.innerHTML=I({tone:"info",children:`Vi \xE4r anknutna f\xF6rs\xE4kringsf\xF6rmedlare till ${n}, If Skadef\xF6rs\xE4kring. F\xF6rs\xE4kringsgivare \xE4r If Skadef\xF6rs\xE4kring (publ). Vad detta inneb\xE4r kan du l\xE4sa mer om p\xE5 f\xF6rs\xE4kringsf\xF6rmedlarens hemsida.`})),new ge(this.node.querySelector(`#${vr}`),{text:`Genom att du klickar p\xE5 Visa f\xF6rs\xE4kringar s\xE5 godk\xE4nner du att vi skickar dina uppgifter vidare till ${n} f\xF6r att de ska kunna ge dig ett pris p\xE5 f\xF6rs\xE4kring. Hur de hanterar dina personuppgifter kan du l\xE4sa om p\xE5 deras hemsida.`}),new z(this.node.querySelector(`#${Er}`),{id:fr,title:"Hoppa \xF6ver detta steg",onClick:()=>s()})}}},gr=eo;var _r="insurance-button-top-left-node",Sr="insurance-button-bottom-left-node",wr="insurance-add-remove-node",so=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{freeInsurance:e,selected:t,onClose:s,onClick:a}=this.props,{title:n,description:l,logo:c,longDescription:m}=e;this.node.innerHTML=`
|
|
1274
1274
|
<div class="waykeecom-nav-banner" id="${_r}"></div>
|
|
1275
1275
|
|
|
1276
1276
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
@@ -1316,7 +1316,7 @@
|
|
|
1316
1316
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Cr}"></div>
|
|
1317
1317
|
<div class="waykeecom-stack waykeecom-stack--1" id="${rd}"></div>
|
|
1318
1318
|
</div>
|
|
1319
|
-
`,new Tr(this.node.querySelector(`#${ao}`),{store:e,insurances:[t]}),new
|
|
1319
|
+
`,new Tr(this.node.querySelector(`#${ao}`),{store:e,insurances:[t]}),new N(this.node.querySelector(`#${Cr}`),{id:ad,title:"G\xE5 vidare",onClick:()=>this.onProceed()})}},Dr=no;var ro=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation",()=>{this.render()}),this.render()}getStep(){let{order:e}=this.props.store.getState();return e?.insuranceOption?.institute==="IF"?"INSURANCE_IF":"INSURANCE"}onSkipInsurances(){de()(this.props.store.dispatch),Z(this.props.lastStage)(this.props.store.dispatch),d("MAIN","INSURANCE_SKIPPED",this.getStep())}onEdit(){d("MAIN","INSURANCE_EDIT",this.getStep()),x("main",this.props.index)(this.props.store.dispatch)}render(){let{store:e,index:t,lastStage:s}=this.props,a=e.getState(),n=a.topNavigation.stage>t,l=a.navigation.stage===t;l&&d("MAIN","INSURANCE_ACTIVE",this.getStep());let c=P(this.node,{completed:n,title:"F\xF6rs\xE4kring",active:l,id:"insurance"});if(a.navigation.stage>t||n&&a.navigation.stage!==t){let m=[];a.insurance?(m.push({key:"Uppskattad k\xF6rstr\xE4cka",value:X[a.drivingDistance]}),m.push({key:a.insurance.name,value:k(a.insurance.price,{postfix:"kr/m\xE5n"})}),a.insuranceAddOns?.insurance===a.insurance.name&&a.insuranceAddOns.addOns.forEach(u=>m.push({key:u.title,value:k(u.monthlyPrice,{postfix:"kr/m\xE5n"})}))):a.freeInsurance?m.push({key:"F\xF6rs\xE4kring",value:a.freeInsurance.title}):m.push({key:"F\xF6rs\xE4kring",value:"Ingen"}),new J(c,{keyValueList:m,changeButtonTitle:"\xC4ndra f\xF6rs\xE4kring",onEdit:a.createdOrderId?void 0:()=>this.onEdit()})}else if(a.navigation.stage===t){let m=a.order?.insuranceOption;if(!m)throw"Missing insurance";switch(m?.institute){case"IF":new gr(c,{store:e,lastStage:s,onSkip:()=>this.onSkipInsurances()});break;default:new Dr(c,{store:e,lastStage:s,insurance:m});break}}a.navigation.stage===t&&c.parentElement?.scrollIntoView()}},br=ro;var co=f("@wayke-se/ecom"),Rr=o=>{let i=co.vehicles.newLookupRequest().withRegistrationNumber(o.registrationNumber).withMileage(parseInt(o.mileage,10)).withCondition(o.condition);return co.vehicles.lookupVehicle(i.build())};var lo=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t,this.render()}setError(e){this.contexts.error?.setError(e)}render(){let{title:e,value:t,name:s,id:a,error:n,errorMessage:l,placeholder:c,information:m,autocomplete:u,onChange:h,onBlur:p}=this.props;this.node.innerHTML=`
|
|
1320
1320
|
<div class="waykeecom-input-label">
|
|
1321
1321
|
<label for="${a}" class="waykeecom-input-label__label">${e}</label>
|
|
1322
1322
|
</div>
|
|
@@ -1393,7 +1393,7 @@
|
|
|
1393
1393
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Hr}"></div>
|
|
1394
1394
|
<div class="waykeecom-stack waykeecom-stack--1" id="${tt}"></div>
|
|
1395
1395
|
</div>
|
|
1396
|
-
`,new V(this.node.querySelector(`#${Br}`),{id:qr,title:"\xC4ndra",onClick:()=>this.onEdit()}),new
|
|
1396
|
+
`,new V(this.node.querySelector(`#${Br}`),{id:qr,title:"\xC4ndra",onClick:()=>this.onEdit()}),new N(this.node.querySelector(`#${Hr}`),{title:"Anv\xE4nd och g\xE5 vidare",onClick:()=>this.onProceed()}),new z(this.node.querySelector(`#${tt}`),{id:mo,title:"Hoppa \xF6ver detta steg",onClick:()=>this.onNoTradeIn()}),this.node.parentElement?.parentElement?.scrollIntoView()}else this.node.innerHTML=`
|
|
1397
1397
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1398
1398
|
<h4 class="waykeecom-heading waykeecom-heading--4">Uppgifter om din inbytesbil</h4>
|
|
1399
1399
|
<div class="waykeecom-content">
|
|
@@ -1417,7 +1417,7 @@
|
|
|
1417
1417
|
<circle cx="11" cy="10" r="5.5" stroke="#FFF500" stroke-linejoin="round" stroke-dasharray="1 2"/>
|
|
1418
1418
|
<path d="M10.6707 21.692c1.392 0 2.04.564 2.28.996h1.644c-.264-1.08-1.248-2.364-3.924-2.364-2.028 0-3.408.912-3.408 2.436 0 1.536 1.2 2.34 2.904 2.508l1.512.156c.876.108 1.476.372 1.476 1.188 0 .684-.684 1.176-1.98 1.176-1.56 0-2.244-.72-2.472-1.26h-1.716c.336 1.224 1.404 2.628 4.188 2.628 2.412 0 3.624-1.116 3.624-2.652 0-1.8-1.308-2.448-3.012-2.616-.576-.06-.972-.108-1.5-.156-.888-.108-1.392-.444-1.392-1.02 0-.624.612-1.02 1.776-1.02Z" fill="#fff"/>
|
|
1419
1419
|
</svg>
|
|
1420
|
-
`,onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.mileage=new O(this.node.querySelector(`#${Mr}`),{title:"Miltal",value:this.state.value.mileage,id:Ur,error:this.state.interact.mileage&&!this.state.validation.mileage,errorMessage:"Ett miltal mellan 0 till 80 000 mil m\xE5ste anges",name:"mileage",autocomplete:"off",placeholder:"Ange bilens miltal",unit:"mil",pattern:"[0-9]*",inputmode:"numeric",onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.description=new Lr(this.node.querySelector(`#${xr}`),{title:"Beskrivning (valfritt)",value:this.state.value.description,id:Vr,error:this.state.interact.description&&!this.state.validation.description,errorMessage:"????",name:"description",autocomplete:"off",placeholder:"Beskriv bilen",onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),new j(this.node.querySelector(`#${Pr}`),{title:"Bilens skick",checked:this.state.value.condition,name:"condition",options:dd,onClick:e=>this.onChangeRadio(e)}),this.contexts.buttonFetch=new
|
|
1420
|
+
`,onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.mileage=new O(this.node.querySelector(`#${Mr}`),{title:"Miltal",value:this.state.value.mileage,id:Ur,error:this.state.interact.mileage&&!this.state.validation.mileage,errorMessage:"Ett miltal mellan 0 till 80 000 mil m\xE5ste anges",name:"mileage",autocomplete:"off",placeholder:"Ange bilens miltal",unit:"mil",pattern:"[0-9]*",inputmode:"numeric",onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.description=new Lr(this.node.querySelector(`#${xr}`),{title:"Beskrivning (valfritt)",value:this.state.value.description,id:Vr,error:this.state.interact.description&&!this.state.validation.description,errorMessage:"????",name:"description",autocomplete:"off",placeholder:"Beskriv bilen",onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),new j(this.node.querySelector(`#${Pr}`),{title:"Bilens skick",checked:this.state.value.condition,name:"condition",options:dd,onClick:e=>this.onChangeRadio(e)}),this.contexts.buttonFetch=new N(this.node.querySelector(`#${$r}`),{title:"H\xE4mta uppskattat v\xE4rde",id:Gr,disabled:!(this.state.validation.registrationNumber&&this.state.validation.mileage&&this.state.validation.condition),onClick:()=>this.onFetchVehicle()}),new z(this.node.querySelector(`#${tt}`),{id:mo,title:"Hoppa \xF6ver detta steg",onClick:()=>this.onNoTradeIn()})}},Wr=po;var zr="button-trade-in-yes",Yr=`${zr}-node`,Qr="button-trade-in-no",Kr=`${Qr}-node`,ho="button-trade-in-change",uo=`${ho}-node`,ko=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation",()=>{this.render()}),this.render()}onEdit(){d("MAIN","TRADE_IN_EDIT","TRADE_IN"),x("main",this.props.index)(this.props.store.dispatch)}onYesTradeIn(){d("MAIN","TRADE_IN_SELECTED","TRADE_IN"),ri(this.props.lastStage)(this.props.store.dispatch)}onNoTradeIn(){d("MAIN","TRADE_IN_SKIPPED","TRADE_IN"),Ne(this.props.lastStage)(this.props.store.dispatch)}render(){let{store:e,index:t,lastStage:s}=this.props,a=this.props.store.getState();if(!a.order?.allowsTradeIn)return;let n=a.topNavigation.stage>t,l=a.navigation.stage===t;l&&d("MAIN","TRADE_IN_ACTIVE",a.navigation.subStage===1?"TRADE_IN":"TRADE_IN_DETAILS");let c=P(this.node,{title:"Inbytesbil",active:l,completed:n,id:"trade-in"});c.innerHTML="";let m=document.createElement("div");if(a.navigation.stage>t||n&&a.navigation.stage!==t){let u=[];a.tradeIn&&a.tradeInVehicle?(u.push({key:"Miltal",value:`${a.tradeIn.mileage} mil`}),a.tradeIn.description&&u.push({key:"Beskrivning",value:`${a.tradeIn.description}`}),a.tradeIn.condition&&u.push({key:"Bilens skick",value:Ee[a.tradeIn.condition]}),m.innerHTML=`
|
|
1421
1421
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1422
1422
|
<div class="waykeecom-balloon">
|
|
1423
1423
|
<div class="waykeecom-stack waykeecom-stack--05">
|
|
@@ -1476,7 +1476,7 @@
|
|
|
1476
1476
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Yr}"></div>
|
|
1477
1477
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Kr}"></div>
|
|
1478
1478
|
</div>
|
|
1479
|
-
`,new
|
|
1479
|
+
`,new N(m.querySelector(`#${Yr}`),{id:zr,title:"Jag har inbytesbil",onClick:()=>this.onYesTradeIn()}),new z(m.querySelector(`#${Kr}`),{id:Qr,title:"Hoppa \xF6ver detta steg",onClick:()=>this.onNoTradeIn()})));c.appendChild(m),a.navigation.stage===t&&c.parentElement?.scrollIntoView()}},jr=ko;var st={customer:{component:pa,name:"customer"},centralStorage:{component:ji,name:"centralStorage"},delivery:{component:fa,name:"delivery"},tradeIn:{component:jr,name:"tradeIn"},financial:{component:Jn,name:"financial"},insurance:{component:br,name:"insurance"},accessories:{component:Gi,name:"accessories"}};var yo=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){this.node.innerHTML=`
|
|
1480
1480
|
<h3 class="waykeecom-heading waykeecom-heading--4">K\xF6p online hos oss</h3>
|
|
1481
1481
|
<ul class="waykeecom-checklist" aria-label="F\xF6rdelar med att k\xF6pa bilen online hos oss">
|
|
1482
1482
|
${this.props.checklistItems.map(e=>` <li class="waykeecom-checklist__item">${e}</li>`).join("")}
|
|
@@ -1493,7 +1493,7 @@
|
|
|
1493
1493
|
${Si({order:s.order,stageOrderList:s.stages})}
|
|
1494
1494
|
<div class="waykeecom-stack waykeecom-stack--3" id="${Xr}"></div>
|
|
1495
1495
|
<footer class="waykeecom-footer" id="${Zr}"></footer>
|
|
1496
|
-
`,this.contexts.buttonProceed=new
|
|
1496
|
+
`,this.contexts.buttonProceed=new N(document.querySelector(`#${Xr}`),{id:ec,title:"G\xE5 vidare",onClick:()=>this.onProceed()}),new Jr(document.querySelector(`#${Zr}`),{title:"K\xF6p online hos Wayke",ariaLabel:"F\xF6rdelar med att k\xF6pa bilen online hos Wayke",checklistItems:["Trygg hantering av personuppgifter","Reservera bilen nu \u2013 betalning och avtalsskrivning sker senare med handlaren","Inte bindande f\xF6rr\xE4n avtal skrivits ihop med handlaren","Bara kontrollerade bilar"]})}},tc=vo;var ud=({vehicle:o,order:i,cdnMedia:e})=>{let t=o?.imageUrls?.[0],s=o?.title,a=k(o?.price||NaN),n=i?.contactInformation?.name;return`
|
|
1497
1497
|
<div class="waykeecom-preview-card">
|
|
1498
1498
|
${t?`
|
|
1499
1499
|
<div class="waykeecom-preview-card__media">
|
|
@@ -1527,7 +1527,7 @@
|
|
|
1527
1527
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1528
1528
|
<div id="payment-menu" style="padding: 24px;border: 1px solid #ececeb;"></div>
|
|
1529
1529
|
</div>
|
|
1530
|
-
`}},ic=Eo;var W=f("@wayke-se/ecom");var Io=f("@wayke-se/ecom"),ac=o=>{let i=Io.bankid.newAuthRequest().withMethod(o).build();return Io.bankid.auth(i)};var fo=f("@wayke-se/ecom"),go=o=>{let i=fo.bankid.newCollectRequest().withOrderRef(o).build();return fo.bankid.collect(i)};var M=f("@wayke-se/ecom"),nc=o=>{let i=o.getState();if(!i.address)throw"Missing address";if(!i.paymentType)throw"Missing paymentType";if(!i.vehicle)throw"Missing vehicle";let e=M.customers.newCustomer().withAddress(i.address).withPersonalNumber(i.customer.socialId).withEmail(i.customer.email).withPhoneNumber(i.customer.phone).build(),t=M.orders.newPayment().withType(i.paymentType);if(i.paymentType===M.PaymentType.Loan){let m=i.order?.paymentOptions.find(
|
|
1530
|
+
`}},ic=Eo;var W=f("@wayke-se/ecom");var Io=f("@wayke-se/ecom"),ac=o=>{let i=Io.bankid.newAuthRequest().withMethod(o).build();return Io.bankid.auth(i)};var fo=f("@wayke-se/ecom"),go=o=>{let i=fo.bankid.newCollectRequest().withOrderRef(o).build();return fo.bankid.collect(i)};var M=f("@wayke-se/ecom"),nc=o=>{let i=o.getState();if(!i.address)throw"Missing address";if(!i.paymentType)throw"Missing paymentType";if(!i.vehicle)throw"Missing vehicle";let e=M.customers.newCustomer().withAddress(i.address).withPersonalNumber(i.customer.socialId).withEmail(i.customer.email).withPhoneNumber(i.customer.phone).build(),t=M.orders.newPayment().withType(i.paymentType);if(i.paymentType===M.PaymentType.Loan){let m=i.order?.paymentOptions.find(w=>w.type===M.PaymentType.Loan),u=i.paymentLookupResponse||m?.loanDetails,h=u?.durationSpec.current,p=u?.downPaymentSpec.current,y=u?.residualValueSpec?.current,g=i.order?.paymentOptions.find(w=>w.type===M.PaymentType.Loan)?.externalId;if(t.withDuration(h).withDownPayment(Math.round(p)),y&&t.withResidualValue(y),g&&t.withExternalId(g),i.creditAssessmentResponse){let w=i.creditAssessmentResponse.scoringId,R=i.creditAssessmentResponse.recommendation,F=i.creditAssessmentResponse.decision,K=u?.financialProductCode;if(!w||!R||!F||!K)throw"Missing credit assessment data";let U=M.orders.newCreditAssessment().withScoreId(w).withFinancialProductCode(K).withRecommendation(R).withDecision(F).build();t.withCreditAssessment(U)}}let s=t.build(),a=new URLSearchParams(window.location.search);a.set("wayke-ecom-web-id",i.id);let n=`${window.location.origin}${window.location.pathname}?${a.toString()}${window.location.hash}`;a.set("wayke-ecom-web-payment","true");let l=`${window.location.origin}${window.location.pathname}?${a.toString()}${window.location.hash}`,c=M.orders.newCreateRequest().forVehicle(i.id).withCustomer(e).withPayment(s).withUrls(n,l).withDeliveryType(i.homeDelivery?M.DeliveryType.Delivery:M.DeliveryType.Pickup);if(i.insurance){let m=M.orders.newInsurance().withDrivingDistance(i.drivingDistance);i.insuranceAddOns?.addOns.length&&i.insuranceAddOns.insurance===i.insurance.name&&m.withAddOns(i.insuranceAddOns.addOns.map(h=>h.name));let u=m.build();c.withInsurance(u)}else i.freeInsurance&&c.withInsurance({});if(i.accessories.length&&c.withAccessories(i.accessories),i.tradeIn&&i.tradeInVehicle&&i.tradeIn.condition){let m=M.vehicles.newVehicleTrade().forVehicle(i.tradeIn.registrationNumber).withMileage(parseInt(i.tradeIn.mileage,10)).withCondition(i.tradeIn.condition).withComment(i.tradeIn.description).build();c.withTradeIn(m)}return M.orders.create(c.build())};var rc=f("@wayke-se/ecom"),cc=o=>rc.creditAssessment.accept(o);var _o=f("@wayke-se/ecom"),lc=o=>{let i=_o.bankid.newQrCodeRequest().withOrderRef(o).build();return _o.bankid.qrcode(i)};var hc="confirm-conditions",dc=`${hc}-node`,mc="bankid-start-node",hd="bankid-start",pc="address-disclaimer-policy-node",uc="address-disclaimer-reservation-node",So=class extends r{constructor(e,t){super(e,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--2"});this.view=1;this.contexts={};this.ageError=!1;this.requestError=!1;this.socialIdNotMatchingError=!1;this.notAvailable=!1;this.confirmConditions=!1;this.bankidRequestRef=void 0;this.bankidStatus=async e=>{try{let t=await go(e);this.handleBankidStatusResponse(t,W.AuthMethod.QrCode)}catch{this.clearIntervals(),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering.")}};this.qrCode=async e=>{try{let s=(await lc(e)).getQrCode();this.contexts.bankId?.update(W.AuthMethod.QrCode,s)}catch{this.clearIntervals(),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta ny QR-kod f\xF6r BankId signering.")}};this.props=t,this.ageError=!1,this.render()}addWindowEvents(){this.removeWindowEvents(),window.addEventListener("focus",()=>this.onFocus())}removeWindowEvents(){window.removeEventListener("focus",()=>this.onFocus())}clearIntervals(){clearInterval(this.bankidQrCodeInterval),clearInterval(this.bankidStatusInterval)}async onFocus(){clearTimeout(this.focusTimeout),this.focusTimeout=setTimeout(async()=>{if(this.bankidRequestRef?.method===W.AuthMethod.SameDevice)try{let e=await go(this.bankidRequestRef.reference);this.handleBankidStatusResponse(e,this.bankidRequestRef.method)}catch{this.clearIntervals(),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering.")}},500)}onSameDeviceClick(){this.addWindowEvents()}setBankidRequestRef(e,t){this.bankidRequestRef={reference:e,method:t}}clearBankidRequestRef(){this.bankidRequestRef=void 0}async acceptCreditAssessment(){let{caseId:e}=this.props.store.getState();if(e)try{d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_REQUEST","CONFIRMATION"),await cc(e),d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_SUCCEEDED","CONFIRMATION")}catch{d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_FAILED","CONFIRMATION")}}async onCreateOrder(){let{store:e}=this.props;this.notAvailable=!1,this.requestError=!1;try{d("MAIN","CONFIRMATION_CREATE_ORDER_REQUESTED","CONFIRMATION");let{order:t}=e.getState(),s=await nc(e);d("MAIN","CONFIRMATION_CREATE_ORDER_SUCCEEDED","CONFIRMATION"),t?.isPaymentRequired&&L();let n=s.getPayment();ki(s.getOrderNumber(),n)(e.dispatch),this.acceptCreditAssessment()}catch(t){let s=t;this.view=1,d("MAIN","CONFIRMATION_CREATE_ORDER_FAILED","CONFIRMATION"),s.message==="The vehicle is not available for purchase"?(this.requestError=!1,this.notAvailable=!0):(this.notAvailable=!1,this.requestError=!0),L(),this.render()}}async handleBankidStatusResponse(e,t){if(e.isCompleted()){this.removeWindowEvents(),this.clearBankidRequestRef(),this.clearIntervals();let s=e.getAddress(),a=e.getPersonalNumber();if(s&&a){let n=this.props.store.getState();if(C.requiredSsnOver18(a)){if(n.customer.socialId!==a){d("MAIN",t===W.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED_SSN_MISSMATCH":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED_SSN_MISSMATCH","CONFIRMATION"),this.view=1,this.socialIdNotMatchingError=!0,L(),this.render();return}}else{d("MAIN",t===W.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED_NOT_OVER_18":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED_NOT_OVER_18","CONFIRMATION"),this.view=1,this.ageError=!0,L(),this.render();return}d("MAIN",t===W.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED","CONFIRMATION"),this.contexts.bankId?.setDescription("Verifiering klar, ordern skapas nu..."),await this.onCreateOrder()}}}async startBankidSameDevice(e,t,s=!1){s||d("MAIN","CONFIRMATION_BANKID_STATUS_SAME_DEVICE_REQUESTED","CONFIRMATION");try{this.setBankidRequestRef(t,W.AuthMethod.SameDevice);let a=e.getAutoLaunchUrl();this.contexts.bankId?.update(W.AuthMethod.SameDevice,a)}catch(a){this.removeWindowEvents(),this.clearBankidRequestRef();let n=a;this.contexts.bankId?.setErrorMessage(`Error: ${n.message}`)}}async startBankidWithQr(e,t=!1){t||d("MAIN","CONFIRMATION_BANKID_STATUS_QR_REQUESTED","CONFIRMATION"),this.bankidStatusInterval=setInterval(()=>{this.bankidStatus(e)},2e3),Oe("bankidStatusInterval",this.bankidStatusInterval),this.qrCode(e),this.bankidQrCodeInterval=setInterval(async()=>{this.qrCode(e)},1e3),Oe("bankidQrCodeInterval",this.bankidQrCodeInterval)}async onStartBankIdAuth(e,t=!1){this.clearIntervals();try{t||d("MAIN","CONFIRMATION_BANKID_INIT_REQUESTED","CONFIRMATION"),this.contexts.bankId?.update(e),this.contexts.buttonLinkToggle?.disabled(!0);let s=await ac(e);t||d("MAIN","CONFIRMATION_BANKID_INIT_SUCCEEDED","CONFIRMATION");let a=s.getOrderRef();e===W.AuthMethod.QrCode?this.startBankidWithQr(a,t):this.startBankidSameDevice(s,a,t)}catch{d("MAIN","CONFIRMATION_BANKID_INIT_FAILED","CONFIRMATION"),this.contexts.bankId?.setErrorMessage("Det gick tyv\xE4rr inte att initiera BankId. V\xE4nligen f\xF6rs\xF6k igen.")}finally{this.contexts.buttonLinkToggle?.disabled(!1)}}onAbort(){this.clearBankidRequestRef(),this.removeWindowEvents(),this.clearIntervals(),d("MAIN","CONFIRMATION_BANKID_ABORTED","CONFIRMATION"),this.view=1,L(),this.render()}onCheckbox(e){let t=e.currentTarget;this.confirmConditions=t.checked,this.contexts.confirmConditions?.checked(this.confirmConditions),this.contexts.startBankid?.disabled(!this.confirmConditions)}render(){let e=Ie(),{navigation:t,order:s,insurance:a}=this.props.store.getState();if(this.view===2)this.contexts.bankId=new je(Q(),{method:e?W.AuthMethod.SameDevice:W.AuthMethod.QrCode,descriptionQrCode:"F\xF6r att verifiera din identitet, starta din BankID applikation p\xE5 din andra enhet.",descriptionSameDevice:"F\xF6r att verifiera din identitet, starta din BankID-applikation.",onAbort:()=>this.onAbort(),onStart:n=>this.onStartBankIdAuth(n),onSameDeviceClick:()=>this.onSameDeviceClick()});else{let n=s?.contactInformation?.name,l=s?.conditionsPdfUri,c="https://www.wayke.se/trygghet-naer-det-kommer-till-dina-personuppgifter";this.node.innerHTML=`
|
|
1531
1531
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1532
1532
|
<h4 class="waykeecom-heading waykeecom-heading--4">Strax klart!</h4>
|
|
1533
1533
|
<div class="waykeecom-content">
|