@wayke-se/ecom-web 1.5.0-beta.6 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -1
- package/dist/index.js +52 -55
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +51 -54
- package/dist/index.mjs.map +2 -2
- package/package.json +2 -2
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
|
|
1
|
+
"use strict";(()=>{var Yc=Object.create;var Jo=Object.defineProperty;var Kc=Object.getOwnPropertyDescriptor;var jc=Object.getOwnPropertyNames;var Qc=Object.getPrototypeOf,zc=Object.prototype.hasOwnProperty;var f=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(i,e)=>(typeof require<"u"?require:i)[e]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+s+'" is not supported')});var Jc=(s,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of jc(i))!zc.call(s,o)&&o!==e&&Jo(s,o,{get:()=>i[o],enumerable:!(t=Kc(i,o))||t.enumerable});return s};var Xc=(s,i,e)=>(e=s!=null?Yc(Qc(s)):{},Jc(i||!s||!s.__esModule?Jo(e,"default",{value:s,enumerable:!0}):e,s));var Fc=f("@wayke-se/ecom");var Xo={name:"@wayke-se/ecom-web",version:"1.5.0",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",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=(s,i)=>s!==void 0&&i!==void 0?JSON.stringify(s).localeCompare(JSON.stringify(i))===0:s===i;var we=s=>({costs:s.getCosts(),fees:s.getFees(),interests:s.getInterests(),durationSpec:s.getDurationSpec(),downPaymentSpec:s.getDownPaymentSpec(),residualValueSpec:s.getResidualValueSpec(),totalResidualValue:s.getTotalResidualValue(),publicURL:s.getPublicURL(),shouldUseCreditScoring:s.shouldUseCreditScoring(),financialProductCode:s.getFinancialProductCode(),price:s.getPrice(),creditAmount:s.getCreditAmount(),hasPrivacyPolicy:s.hasPrivacyPolicy(),privacyPolicyUrl:s.getPrivacyPolicyUrl()}),Zo=s=>({status:s.getStatus(),hasPendingSigning:s.hasPendingSigning(),hintCode:s.getHintCode(),signingMessage:s.getSigningMessage(),shouldRenewSigning:s.shouldRenewSigning(),isSigned:s.isSigned(),address:void 0,pendingScoring:s.hasPendingScoring(),isScored:s.isScored(),hasScoringError:s.hasScoringError(),scoringId:s.getScoringId(),recommendation:s.getRecommendation(),decision:s.getDecision(),isAccepted:s.isAccepted()}),Me=s=>({orderVehicle:s.getOrderVehicle(),accessories:s.getAccessories(),requiresDealerSelection:s.requiresDealerSelection(),dealerSites:s.getDealerSites(),paymentOptions:s.getPaymentOptions().map(e=>({...e,loanDetails:e.loanDetails?we(e.loanDetails):void 0})),deliveryOptions:s.getDeliveryOptions(),insuranceOption:s.getInsuranceOption(),orderConditions:s.getOrderConditions(),orderReturnConditions:s.getOrderReturnConditions(),conditionsPdfUri:s.getConditionsPdfUri(),contactInformation:s.getContactInformation(),allowsTradeIn:s.allowsTradeIn(),isUnavailable:s.isUnavailable(),isPaymentRequired:s.isPaymentRequired()}),ei=s=>({vehicle:s.getVehicle()});var it="RESET",ti=s=>i=>i({type:it,id:s}),at="SET_ORDER",xe=(s,i)=>e=>e({type:at,order:s,vehicle:i}),nt="SET_ID",si=s=>i=>i({type:nt,id:s}),rt="SET_CONTACT_EMAIL_AND_PHONE",oi=s=>i=>i({type:rt,value:s}),ct="SET_SOCIAL_ID_AND_ADDRESS",ii=(s,i,e)=>t=>t({type:ct,socialId:s,address:i,lastStage:e}),lt="SET_HOME_DELIVERY",ai=(s,i)=>e=>e({type:lt,homeDelivery:s,lastStage:i}),dt="SET_DEALER",ni=(s,i)=>e=>e({type:dt,dealer:s,lastStage:i}),mt="INIT_TRADE_IN",ri=s=>i=>i({type:mt,lastStage:s}),pt="SET_TRADE_IN",Ne=(s,i,e)=>t=>t({type:pt,lastStage:s,tradeIn:i,tradeInVehicle:e}),ut="SET_FINANCIAL",ci=(s,i)=>e=>e({type:ut,paymentType:s,lastStage:i}),ht="SET_PAYMENT_LOOKUP_RESPONSE",li=s=>i=>i({type:ht,paymentLookupResponse:we(s)}),kt="SET_DRIVING_DISTANCE",di=s=>i=>i({type:kt,drivingDistance:s}),yt="COMPLETE_STAGE",Z=s=>i=>i({type:yt,lastStage:s}),vt="SET_OR_REMOVE_INSURANCE",de=s=>i=>i({type:vt,insurance:s}),Et="SET_OR_REMOVE_INSURANCE_ADDONS",mi=(s,i)=>e=>e({type:Et,insurance:s,insuranceAddons:i}),It="SET_OR_REMOVE_FREE_INSURANCE",pi=s=>i=>i({type:It,freeInsurance:s}),ft="SET_OR_REMOVE_ACCESSORY",ui=s=>i=>i({type:ft,accessory:s}),gt="GO_TO",H=(s,i,e)=>t=>t({type:gt,view:s,index:i,subStage:e}),_t="SET_STAGES",hi=s=>i=>i({type:_t,stages:s}),St="SET_CREATED_ORDER_ID",ki=(s,i)=>e=>e({type:St,id:s,payment:i}),wt="SET_CREDIT_ASSESSMENT_RESPONSE",me=(s,i)=>e=>e({type:wt,caseId:s,creditAssessmentResponse:i}),Nt="SET_STATE",yi=s=>i=>i({type:Nt,state:s});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=(s,i)=>i?{view:"summary",stage:1,subStage:1}:{view:"main",stage:s+1,subStage:1},re=(s,i)=>i.view==="main"?s.stage<i.stage?i:v.topNavigation:{...s,stage:s.stage+1},At=s=>s&&s?.length===1&&s?.[0].type===Ae.PaymentType.Cash?Ae.PaymentType.Cash:void 0,v,Tt,tl=(s=Ei,i)=>{let e,t;switch(v={...s},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{...s,order:i.order,paymentType:At(i.order?.paymentOptions),vehicle:{...i.order.orderVehicle,...i.vehicle||{}}};case rt:let o={...v,customer:{...s.customer,email:i.value.email,phone:i.value.phone},navigation:{view:"main",stage:s.navigation.stage,subStage:2}};return delete o.wantTradeIn,delete o.tradeIn,delete o.tradeInVehicle,o.paymentType=At(s.order?.paymentOptions),delete o.paymentLookupResponse,delete o.insurance,delete o.insuranceAddOns,delete o.freeInsurance,delete o.dealer,o.accessories=[],o;case ct:return e=ne(v.navigation.stage,i.lastStage),t=re(v.topNavigation,e),v={...s,navigation:e,topNavigation:t,address:i.address,customer:{...s.customer,socialId:i.socialId}},v;case dt:return e=ne(s.navigation.stage,i.lastStage),t={...e},v={...s,navigation:e,topNavigation:t,dealer:i.dealer},delete v.wantTradeIn,delete v.tradeIn,delete v.tradeInVehicle,v.paymentType=At(s.order?.paymentOptions),delete v.paymentLookupResponse,delete v.insurance,delete v.insuranceAddOns,delete v.freeInsurance,v.accessories=[],v;case lt:return e=ne(s.navigation.stage,i.lastStage),t=re(v.topNavigation,e),v={...s,navigation:e,topNavigation:t,homeDelivery:i.homeDelivery},v;case mt:return e={view:"main",stage:s.navigation.stage,subStage:1},t=re(v.topNavigation,e),v={...s,navigation:e,wantTradeIn:!0,topNavigation:t,tradeIn:s.tradeIn||{registrationNumber:"",mileage:"",description:""}},v;case pt:return e=ne(s.navigation.stage,i.lastStage),t=re(v.topNavigation,e),v={...s,navigation:e,topNavigation:t,wantTradeIn:!!i.tradeIn,tradeIn:i.tradeIn,tradeInVehicle:i.tradeInVehicle},v;case ut:return e=ne(s.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(s.navigation.stage,i.lastStage),t=re(v.topNavigation,e),v={...s,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{...s,navigation:{view:i.view,stage:i.index||1,subStage:i.subStage||1}};case St:return i.payment?e={view:"main",stage:s.navigation.stage,subStage:2}:e=ne(s.navigation.stage,!0),t=re(v.topNavigation,e),v={...s,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 s}},Ii=tl;var gi=()=>(0,fi.createStore)(Ii);var Pe=(s,i)=>{if(!i)return s;let e=new URL(s);return`${i}${e.pathname}`};var sl=s=>s.toString().replace(/\s/g,""),ol=(s,i)=>{if(!i)return s;let e=Math.pow(10,i);return(Math.round(s*e)/e).toFixed(i)},k=(s,i)=>{if(s===void 0)return"???";let e=ol(s,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=(s,i)=>{let e=s.split(" "),t=i.split(" ").map(o=>o.toLowerCase());return e.filter(o=>!t.includes(o.toLowerCase())).join(" ")},pe=s=>{if(!!s)return il(s.shortDescription||"",s.title||"")};var al=({vehicle:s,order:i,meta:e,cdnMedia:t})=>{let o=s?.imageUrls,a=s?.title,n=k(s?.price||NaN),l=i?.contactInformation?.name;return`
|
|
2
2
|
<div class="waykeecom-product-card">
|
|
3
3
|
${o?.length?`
|
|
4
4
|
<div class="waykeecom-product-card__media">
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
</div>
|
|
125
125
|
</div>
|
|
126
126
|
`:""}
|
|
127
|
-
`,o&&this.node.querySelector("button")?.addEventListener("click",()=>o())}},
|
|
127
|
+
`,o&&this.node.querySelector("button")?.addEventListener("click",()=>o())}},z=Rt;var Lt=f("object-path"),ul=(s,i)=>s===i,hl=(s,i,e)=>{let t=e||ul,o=(0,Lt.get)(s(),i);return a=>()=>{let n=(0,Lt.get)(s(),i);if(!t(o,n)){let l=o;o=n,a(n,l,i)}}},wi=[],kl=s=>(wi.push(s),s),Ni=()=>wi.forEach(s=>s()),yl=(s,i,e,t)=>{let o=hl(s.getState,i);if(t)s.subscribe(o(e));else return kl(s.subscribe(o(e)))},_=yl;var vl=(s,i)=>{let{title:e,active:t,completed:o,id:a}=i,n=document.getElementById(a),l=n||document.createElement("section");l.setAttribute("aria-label",e),n||l.setAttribute("id",a);let c=["waykeecom-stepper__item"];t?c.push("waykeecom-stepper__item--is-active"):o?c.push("waykeecom-stepper__item--is-complete"):c.push("waykeecom-stepper__item--is-disabled"),l.className=c.join(" "),l.innerHTML=`
|
|
128
128
|
<header class="waykeecom-stepper__header">
|
|
129
129
|
<div class="waykeecom-stepper__icon" aria-hidden="true">
|
|
130
130
|
<div class="waykeecom-icon-backdrop waykeecom-icon-backdrop--success">
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
</h3>
|
|
147
147
|
</header>
|
|
148
148
|
<div class="waykeecom-stepper__body"></div>
|
|
149
|
-
`,n||s.appendChild(l);let m=l.querySelector(".waykeecom-stepper__body");if(!m)throw"Err no element";return m},
|
|
149
|
+
`,n||s.appendChild(l);let m=l.querySelector(".waykeecom-stepper__body");if(!m)throw"Err no element";return m},B=vl;var Ve=[],Ai=s=>{Ve.push(s)},Ti=s=>{let i=Ve.findIndex(e=>e===s);i>-1&&Ve.splice(i,1)},Ot=[],Te=()=>Ot[Ot.length-1],El=(s,i,e,t)=>{Ot.push({view:s,ecomEvent:i,currentStep:e}),Ve.forEach(o=>o(s,i,e,t))},d=El;var Mt=class extends r{constructor(e,t){super(e);this.props=t,this.render()}hide(e){this.props.hide!==e&&(this.props.hide=e,this.render())}render(){if(this.props.hide){this.node.innerHTML="";return}let{title:e,dataIcon:t,path:o}=this.props.direction==="left"?{title:"Visa f\xF6reg\xE5ende",dataIcon:"Chevron left",path:'<path d="m5.4 7 5.2-5 1 1-5.2 5 5.2 5-1.1 1-5.2-5-1-1 1.1-1z" />'}:{title:"Visa n\xE4sta",dataIcon:"Chevron right",path:'<path d="m10.5 9-5.2 5-1-1 5.2-5-5.2-5 1.1-1 5.2 5 1 1-1.1 1z" />'};this.node.innerHTML=`
|
|
150
150
|
<button type="button" title="${e}" class="waykeecom-icon-button">
|
|
151
151
|
<svg
|
|
152
152
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
</div>
|
|
216
216
|
<div class="waykeecom-tile__footer" id="${y}"></div>
|
|
217
217
|
</div>
|
|
218
|
-
`,h&&new V(this.node.querySelector(`#${p}`),{title:"L\xE4s mer",onClick:()=>h()}),new ee(this.node.querySelector(`#${y}`),{selected:m,onClick:()=>u()})}},he=Bt;var
|
|
218
|
+
`,h&&new V(this.node.querySelector(`#${p}`),{title:"L\xE4s mer",onClick:()=>h()}),new ee(this.node.querySelector(`#${y}`),{selected:m,onClick:()=>u()})}},he=Bt;var j=()=>{O();let s=document.getElementById("wayke-ecom-modal-body");s&&s.firstElementChild.setAttribute("hidden","");let i=document.createElement("div");return i.className="waykeecom-portal",s?.appendChild(i),i},O=()=>{let s=document.getElementById("wayke-ecom-modal-body");s&&s.firstElementChild.removeAttribute("hidden"),s?.childNodes.forEach((i,e)=>{e>0&&i.remove()})};var Ft=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{title:e,id:t,onClick:o}=this.props;this.node.innerHTML=`
|
|
219
219
|
<button type="button" id="${t}" title="${e}" class="waykeecom-button waykeecom-button--full-width waykeecom-button--action-clear">
|
|
220
220
|
${e}
|
|
221
221
|
</button>
|
|
@@ -295,7 +295,7 @@
|
|
|
295
295
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Mi}"></div>
|
|
296
296
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Oi}"></div>
|
|
297
297
|
</div>
|
|
298
|
-
`,new bi(this.node.querySelector(`#${xi}`),{id:`gallery-${e.id}`,media:l.map((y,g)=>({url:y.url,alt:`Bild ${g+1}`})),onGalleryImagePaging:()=>this.onGalleryImagePaging()}),new ce(this.node.querySelector(`#${Li}`),{title:"Tillbaka",onClick:()=>a()}),new te(this.node.querySelector(`#${Oi}`),{title:"Tillbaka",onClick:()=>a()}),new ee(this.node.querySelector(`#${Mi}`),{selected:t,fullSize:!0,onClick:()=>o()}),G()}},Pi=Wt;var Yt=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.exposureTracked=!1;this.props=t,_(this.props.store,"accessories",(o,a)=>{o.some(n=>n.id===this.props.accessory.id)!==a.some(n=>n.id===this.props.accessory.id)&&this.render()}),this.render()}onInfoOpen(){let{accessory:e}=this.props;d("MAIN","ACCESSORY_INFORMATION_OPEN","ACCESSORY",{id:e.id,label:e.name}),this.displayInfo=!0,this.render()}onInfoClose(){let{accessory:e}=this.props;d("MAIN","ACCESSORY_INFORMATION_CLOSE","ACCESSORY",{id:e.id,label:e.name}),this.displayInfo=!1,O(),this.render(),this.node.parentElement?.scrollIntoView()}onClick(){let{store:e,accessory:t}=this.props,a=e.getState().accessories.findIndex(n=>n.id===t.id)>-1;d("MAIN",a?"ACCESSORY_UNSELECTED":"ACCESSORY_SELECTED","ACCESSORY",{id:t.id,label:t.name}),ui(this.props.accessory)(this.props.store.dispatch)}trackExposure(){let{accessory:e}=this.props;this.exposureTracked=!0,d("MAIN","ACCESSORY_EXPOSURE","ACCESSORY",{id:e.id,label:e.name})}render(){let{store:e,accessory:t,key:o}=this.props,n=e.getState().accessories.findIndex(l=>l.id===t.id)>-1;this.displayInfo&&new Pi(
|
|
298
|
+
`,new bi(this.node.querySelector(`#${xi}`),{id:`gallery-${e.id}`,media:l.map((y,g)=>({url:y.url,alt:`Bild ${g+1}`})),onGalleryImagePaging:()=>this.onGalleryImagePaging()}),new ce(this.node.querySelector(`#${Li}`),{title:"Tillbaka",onClick:()=>a()}),new te(this.node.querySelector(`#${Oi}`),{title:"Tillbaka",onClick:()=>a()}),new ee(this.node.querySelector(`#${Mi}`),{selected:t,fullSize:!0,onClick:()=>o()}),G()}},Pi=Wt;var Yt=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.exposureTracked=!1;this.props=t,_(this.props.store,"accessories",(o,a)=>{o.some(n=>n.id===this.props.accessory.id)!==a.some(n=>n.id===this.props.accessory.id)&&this.render()}),this.render()}onInfoOpen(){let{accessory:e}=this.props;d("MAIN","ACCESSORY_INFORMATION_OPEN","ACCESSORY",{id:e.id,label:e.name}),this.displayInfo=!0,this.render()}onInfoClose(){let{accessory:e}=this.props;d("MAIN","ACCESSORY_INFORMATION_CLOSE","ACCESSORY",{id:e.id,label:e.name}),this.displayInfo=!1,O(),this.render(),this.node.parentElement?.scrollIntoView()}onClick(){let{store:e,accessory:t}=this.props,a=e.getState().accessories.findIndex(n=>n.id===t.id)>-1;d("MAIN",a?"ACCESSORY_UNSELECTED":"ACCESSORY_SELECTED","ACCESSORY",{id:t.id,label:t.name}),ui(this.props.accessory)(this.props.store.dispatch)}trackExposure(){let{accessory:e}=this.props;this.exposureTracked=!0,d("MAIN","ACCESSORY_EXPOSURE","ACCESSORY",{id:e.id,label:e.name})}render(){let{store:e,accessory:t,key:o}=this.props,n=e.getState().accessories.findIndex(l=>l.id===t.id)>-1;this.displayInfo&&new Pi(j(),{accessory:t,selected:n,onClick:()=>{this.onInfoClose(),this.onClick()},onClose:()=>this.onInfoClose()}),new he(this.node,{id:t.id,title:t.name,description:t.shortDescription,logo:t.logoUrl,image:t.media?.[0]?.url,price:k(t.price,{postfix:"kr"}),selected:n,onClick:()=>this.onClick(),onInfo:()=>this.onInfoOpen(),inViewPort:this.exposureTracked?void 0:()=>this.trackExposure()},o)}},$i=Yt;var Kt=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{accessories:e,store:t}=this.props,o=new ue(this.node,{id:"accessories-list",onClick:()=>d("MAIN","ACCESSORY_ARROWS","ACCESSORY")}),{overflowElement:a}=o;a&&(a.innerHTML="",e.forEach((n,l)=>new $i(a,{store:t,accessory:n,key:`accessory-${n.id}-${l}`})))}},Hi=Kt;var Vi="button-accessories-proceed",Bi=`${Vi}-node`,Sl="button-accessories-skip",Fi=`${Sl}-node`,Ui="accessory-grid-list-node",jt=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation",()=>{this.render()}),this.render()}onProceed(){Z(this.props.lastStage)(this.props.store.dispatch)}onEdit(){d("MAIN","ACCESSORY_EDIT","ACCESSORY"),H("main",this.props.index)(this.props.store.dispatch)}render(){let{store:e,index:t}=this.props,o=e.getState(),a=o.topNavigation.stage>t,n=o.navigation.stage===t;n&&d("MAIN","ACCESSORY_ACTIVE","ACCESSORY");let l=B(this.node,{completed:a,title:"Tillbeh\xF6r",active:n,id:"accessories"}),c=document.createElement("div");if(o.navigation.stage>t||a&&o.navigation.stage!==t)new z(l,{keyValueList:o.accessories.length?o.accessories.map(m=>({key:m.name,image:m.media[0]?{src:`${m.media[0].url}?w=32&h=32`,srcSet:`${m.media[0].url}?w=64&h=64 2x`,alt:m.name}:void 0,value:k(m.price,{postfix:"kr"})})):[{key:"Tillbeh\xF6r",value:"Inga valda"}],changeButtonTitle:"\xC4ndra tillbeh\xF6r",onEdit:o.createdOrderId?void 0:()=>this.onEdit()});else if(o.navigation.stage===t){let m=o.order?.accessories||[];c.innerHTML=`
|
|
299
299
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
300
300
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
301
301
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vill du k\xF6pa till ett tillbeh\xF6r till din nya bil?</h4>
|
|
@@ -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 N(c.querySelector(`#${Bi}`),{id:Vi,title:"G\xE5 vidare",onClick:()=>this.onProceed()}),new K(c.querySelector(`#${Fi}`),{title:"Hoppa \xF6ver detta steg",onClick:()=>this.onProceed()})}l.appendChild(c),o.navigation.stage===t&&l.parentElement?.scrollIntoView()}},Gi=
|
|
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 K(c.querySelector(`#${Fi}`),{title:"Hoppa \xF6ver detta steg",onClick:()=>this.onProceed()})}l.appendChild(c),o.navigation.stage===t&&l.parentElement?.scrollIntoView()}},Gi=jt;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,o=this.node.querySelector(`.${qi}`);if(o)e||o.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 zt=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{id:e,title:t,value:o,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"
|
|
@@ -332,7 +332,7 @@
|
|
|
332
332
|
</label>
|
|
333
333
|
`:""}
|
|
334
334
|
</div>
|
|
335
|
-
`;let h=this.node.querySelector(`#${e}`);h&&u&&h.addEventListener("click",u)}},be=
|
|
335
|
+
`;let h=this.node.querySelector(`#${e}`);h&&u&&h.addEventListener("click",u)}},be=zt;var Wi="waykeecom-input-label__help",Yi="waykeecom-input-label__foldout",Jt=class extends r{constructor(e,t){super(e);this.open=!1;this.props=t,this.render()}onClick(){this.open=!this.open,this.props.onClickInformation&&this.props.onClickInformation(this.open),this.render()}render(){let{information:e}=this.props;if(e){let t=this.node.querySelector(`.${Wi}`),o=this.node.querySelector(`.${Yi}`),a=t||document.createElement("div");if(t||(a.className=Wi),this.open){a.innerHTML=`
|
|
336
336
|
<button class="waykeecom-input-label__help-btn" title="Vad betyder detta?">
|
|
337
337
|
<span class="waykeecom-sr-only">St\xE4ng hj\xE4lp</span>
|
|
338
338
|
<svg
|
|
@@ -381,7 +381,7 @@
|
|
|
381
381
|
${i}
|
|
382
382
|
</div>
|
|
383
383
|
</div>
|
|
384
|
-
`,I=wl;var Qi="button-central-storage-proceed",Ki=`${Qi}-node`,Nl="central-storage-branch",
|
|
384
|
+
`,I=wl;var Qi="button-central-storage-proceed",Ki=`${Qi}-node`,Nl="central-storage-branch",ji=`${Nl}-node`,Zt=class extends r{constructor(e,t){super(e);this.requestError=!1;this.contexts={};this.props=t,_(this.props.store,"navigation",()=>{this.render()}),this.selectedDealer=this.props.store.getState().dealer,this.render()}async updateOrder(e){this.requestError&&(this.requestError=!1,this.render());let{id:t,vehicle:o}=this.props.store.getState();try{this.contexts.proceedButton?.loading(!0);let a=await Be(t,e);d("MAIN","CENTRAL_STORAGE_SET","CENTRAL_STORAGE"),xe(Me(a),o),ni(e,this.props.lastStage)(this.props.store.dispatch),this.contexts.proceedButton?.loading(!1)}catch{this.contexts.proceedButton?.loading(!1),this.requestError=!0,this.render()}}onChange(e){let o=e.currentTarget.value;this.selectedDealer=o,this.contexts.proceedButton?.disabled(!1),d("MAIN","CENTRAL_STORAGE_SELECTED","CENTRAL_STORAGE")}onEdit(){d("MAIN","CENTRAL_STORAGE_EDIT","CENTRAL_STORAGE"),H("main",this.props.index)(this.props.store.dispatch)}onProceed(){this.selectedDealer&&this.updateOrder(this.selectedDealer)}render(){let{order:e,navigation:t,topNavigation:o,createdOrderId:a}=this.props.store.getState(),{index:n}=this.props,l=e?.dealerSites||[],c=o.stage>n,m=t.stage===n;m&&d("MAIN","CENTRAL_STORAGE_ACTIVE","CENTRAL_STORAGE");let u=B(this.node,{completed:c,active:m,title:"Centrallager",id:"central-storage"});if((t.stage>n||c&&t.stage!==n)&&this.selectedDealer){let h=l.find(p=>p.id===this.selectedDealer);new z(u,{keyValueList:[{key:"Val av anl\xE4ggning",value:h?.name||""}],changeButtonTitle:"\xC4ndra",onEdit:a?void 0:()=>this.onEdit()})}else if(t.stage===n){u.innerHTML=`
|
|
385
385
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
386
386
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vilken anl\xE4ggning vill du k\xF6pa ifr\xE5n?</h4>
|
|
387
387
|
<div class="waykeecom-content">
|
|
@@ -389,7 +389,7 @@
|
|
|
389
389
|
</div>
|
|
390
390
|
</div>
|
|
391
391
|
|
|
392
|
-
<div class="waykeecom-stack waykeecom-stack--3" id="${
|
|
392
|
+
<div class="waykeecom-stack waykeecom-stack--3" id="${ji}"></div>
|
|
393
393
|
|
|
394
394
|
${this.requestError?`<div class="waykeecom-stack waykeecom-stack--3">${I({tone:"error",children:"Ett fel uppstod och det gick inte att v\xE4lja ovanst\xE5ende anl\xE4ggning. F\xF6rs\xF6k igen."})}</div>`:""}
|
|
395
395
|
|
|
@@ -413,7 +413,7 @@
|
|
|
413
413
|
</div>
|
|
414
414
|
</div>
|
|
415
415
|
</div>
|
|
416
|
-
</div>`}});new Q(u.querySelector(`#${
|
|
416
|
+
</div>`}});new Q(u.querySelector(`#${ji}`),{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()}},zi=Zt;var ie=s=>s.length<2?s:s.length===2?`${s.substring(0,1)}***`:s.length===3?`${s.substring(0,2)}***`:`${s.substring(0,3)}***`,qe=s=>`${s.substring(0,s.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:o,name:a,min:n,value:l,autocomplete:c,placeholder:m,unit:u,error:h,errorMessage:p,information:y,pattern:g,inputmode:w,onChange:R,onBlur:$,onClickInformation:X}=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>
|
|
@@ -433,7 +433,7 @@
|
|
|
433
433
|
/>
|
|
434
434
|
${u?`<div class="waykeecom-input-text__unit">${u}</div>`:""}
|
|
435
435
|
</div>
|
|
436
|
-
`,this.updateBorder(),p&&(this.contexts.error=new se(this.node,{error:h,errorMessage:p})),y&&new oe(this.node.querySelector(".waykeecom-input-label"),{information:y,onClickInformation:X});let L=this.node.querySelector("input");L&&(R&&L.addEventListener("input",R)
|
|
436
|
+
`,this.updateBorder(),p&&(this.contexts.error=new se(this.node,{error:h,errorMessage:p})),y&&new oe(this.node.querySelector(".waykeecom-input-label"),{information:y,onClickInformation:X});let L=this.node.querySelector("input");L&&(R&&L.addEventListener("input",R),$&&L.addEventListener("blur",$))}},M=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:s=>Ji.test(s),requiredTelephone:s=>Xi.test(s),requiredSsn:s=>ea.test(s),requiredSsnOver18:s=>{if(C.requiredSsn(s)){let e=s.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:s=>Zi.test(s),requiredNumberOrStringNumberInRange:(s,i,e)=>{let t=parseInt(s.toString(),10);return isNaN(t)?!1:t>=i&&t<=e},requiredNumber:s=>s!=null&&!Number.isNaN(+s),requiredNumberGreaterOrEqualThanZero:s=>{if(s==null)return!1;let i=parseInt(s.toString(),10);return!Number.isNaN(i)&&i>=0},optionalNumberGreaterOrEqualThanZero:s=>{if(s==null||typeof s=="string"&&!s)return!0;let i=parseInt(s.toString(),10);return!Number.isNaN(i)&&i>=0},optionalNumber:s=>s==null||!Number.isNaN(+s),requiredRegistrationNumber:s=>{if(!s)return!1;let i=s.replace(" ",""),e=i.length===6,t=ta.test(i);return e&&t},requiredMileage:s=>C.requiredNumberOrStringNumberInRange(s||"",0,8e4),optionalString:s=>!!s||!s,requiredCondition:s=>["VeryGood","Good","Ok"].includes(s||""),requiredAssessmentMaritalStatus:s=>["married","single","commonLaw"].includes(s||""),requiredAssessmentEmplyment:s=>["other","retired","fullTimeEmployed","student","temporarilyEmployed","selfEmployed"].includes(s||""),requiredHousingType:s=>["singleFamily","condominium","apartment"].includes(s||"")};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=s=>{let i={email:s?.email||"",phone:s?.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 o=this.props.store.getState();this.state=Dl(o.customer),this.render()}onChange(e){let t=e.currentTarget,o=t.name,a=t.value;this.state.value[o]=a,this.state.validation[o]=Ye[o](a),this.updateUiError(o),this.updateProceedButton()}onBlur(e){let o=e.currentTarget.name;this.state.interact[o]=!0,this.state.validation[o]=Ye[o](this.state.value[o]),this.updateUiError(o),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=`
|
|
437
437
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
438
438
|
<ul class="waykeecom-key-value-list">
|
|
439
439
|
${t.map(o=>E(o)).join("")}
|
|
@@ -505,7 +505,7 @@
|
|
|
505
505
|
${a.map(n=>E(n)).join("")}
|
|
506
506
|
</ul>
|
|
507
507
|
</div>
|
|
508
|
-
`}else this.node.innerHTML="",new da(this.node,{store:e,lastStage:t})}},ma=rs;var cs=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation",()=>{this.render()}),this.render()}onChange(){d("MAIN","CUSTOMER_EDIT","CUSTOMER_EMAIL_AND_PHONE")
|
|
508
|
+
`}else this.node.innerHTML="",new da(this.node,{store:e,lastStage:t})}},ma=rs;var cs=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation",()=>{this.render()}),this.render()}onChange(){d("MAIN","CUSTOMER_EDIT","CUSTOMER_EMAIL_AND_PHONE"),H("main",this.props.index)(this.props.store.dispatch)}render(){let{store:e,index:t,lastStage:o}=this.props,a=this.props.store.getState(),n=a.topNavigation.stage>t,l=a.navigation.stage===t&&!a.createdOrderId;l&&d("MAIN","CUSTOMER_ACTIVE",a.navigation.subStage===1?"CUSTOMER_EMAIL_AND_PHONE":"CUSTOMER_ADDRESS");let c=B(this.node,{completed:n,title:"Dina uppgifter",active:l,id:"customer"});c.innerHTML="";let m=document.createElement("div");m.className="waykeecom-stack waykeecom-stack--2";let u=document.createElement("div");if(u.className="waykeecom-stack waykeecom-stack--2",a.navigation.stage>t||n&&a.navigation.stage!==t){let h=[{key:"E-post",value:a.customer.email},{key:"Telefonnummer",value:a.customer.phone},{key:"Personnummer",value:qe(a.customer.socialId)},...a.address?[{key:"Namn",value:`${ie(a.address.givenName)} ${ie(a.address.surname)}`},{key:"Adress",value:a.address.street},{key:"Postnummer",value:a.address.postalCode},{key:"Stad",value:a.address.city}]:[]];new z(c,{keyValueList:h,changeButtonTitle:"\xC4ndra dina uppgifter",onEdit:a.createdOrderId?void 0:()=>this.onChange()})}else a.navigation.stage===t&&(new aa(c,{store:e}),a.navigation.subStage>1&&new ma(c,{store:e,lastStage:o}));a.navigation.stage===t&&c.parentElement?.scrollIntoView()}},pa=cs;var ls=f("@wayke-se/ecom");var Ol=(s,i)=>{if(!!s)return s.unit==="m"&&i.unit==="km"?Math.round(s.value/1e3):s.unit==="km"&&i.unit==="m"?s.value*1e3:s.value},ua=(s,i)=>{let e=Ol(s,i);if(!!e&&!!i.unitPrice)return i.startupCost+i.unitPrice*e};var va="radio-home-delivery-true",ha=`${va}-node`,Ea="radio-home-delivery-false",ka=`${Ea}-node`,Ia="button-home-delivery-proceed",ya=`${Ia}-node`,ds=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation",()=>{this.render()});let o=this.props.store.getState();this.homeDelivery=o.homeDelivery,this.render()}onChange(e){let o=e.currentTarget.value==="true";this.homeDelivery=o,d("MAIN",this.homeDelivery?"DELIVERY_HOME_SELECTED":"DELIVERY_DEALER_SELECTED","DELIVERY")}onProceed(){ai(this.homeDelivery,this.props.lastStage)(this.props.store.dispatch),d("MAIN",this.homeDelivery?"DELIVERY_HOME_SET":"DELIVERY_DEALER_SET","DELIVERY")}onEdit(){d("MAIN","DELIVERY_EDIT","DELIVERY"),H("main",this.props.index)(this.props.store.dispatch)}render(){let{store:e,index:t}=this.props,o=e.getState();if(!o.order)throw"Missing order...";let a=o.order.contactInformation;if(!a)throw"Missing dealer contact information";let n=o.topNavigation.stage>t,l=o.navigation.stage===t;l&&d("MAIN","DELIVERY_ACTIVE","DELIVERY");let c=B(this.node,{completed:n,title:"Leverans",active:l,id:"delivery"});if(o.navigation.stage>t||n&&o.navigation.stage!==t)new z(c,{keyValueList:[{key:"Leveranss\xE4tt",value:o.homeDelivery?"Hemleverans":"H\xE4mta hos handlaren"}],changeButtonTitle:"\xC4ndra leveranss\xE4tt",onEdit:o.createdOrderId?void 0:()=>this.onEdit()});else if(o.navigation.stage===t){let m=document.createElement("div");m.innerHTML=`
|
|
509
509
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
510
510
|
<h4 class="waykeecom-heading waykeecom-heading--4">Hur vill du ha din bil levererad?</h4>
|
|
511
511
|
<div class="waykeecom-content">
|
|
@@ -543,9 +543,9 @@
|
|
|
543
543
|
</div>
|
|
544
544
|
</div>
|
|
545
545
|
</div>
|
|
546
|
-
`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${y===0?"Gratis":k(y,{postfix:"kr"})}</div>`,checked:!this.homeDelivery,onClick
|
|
546
|
+
`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${y===0?"Gratis":k(y,{postfix:"kr"})}</div>`,checked:!this.homeDelivery,onClick:$=>this.onChange($)});break;case ls.DeliveryType.Delivery:let g=o.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">
|
|
547
547
|
<div class="waykeecom-stack waykeecom-stack--2">Till din folkbokf\xF6ringsadress</div>
|
|
548
|
-
${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
|
|
548
|
+
${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:$=>this.onChange($)});break;default:break}}),new N(m.querySelector(`#${ya}`),{title:"G\xE5 vidare",id:Ia,onClick:()=>this.onProceed()}),c.appendChild(m),o.navigation.stage===t&&c.parentElement?.scrollIntoView()}}},fa=ds;var F=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"},J={[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=(s,i)=>i?Math.round(s/i)*i:s,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,o){this.value=e,this.inputFieldValue=e,this.min=t,this.max=o,this.rangeSpan=o-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 o=xl(t,this.props.step);this.value=o,this.props.onChange&&e.currentTarget&&(e.currentTarget.value=o.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:o,id:a,information:n,unit:l,onChange:c,onClickInformation:m}=this.props,u=this.min!==this.max;if(this.node.innerHTML=`
|
|
549
549
|
<div class="waykeecom-input-label">
|
|
550
550
|
<label for="${a}" class="waykeecom-input-label__label">${e}</label>
|
|
551
551
|
</div>
|
|
@@ -586,7 +586,7 @@
|
|
|
586
586
|
</div>
|
|
587
587
|
`:""}
|
|
588
588
|
</div>
|
|
589
|
-
`,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)))}}},
|
|
589
|
+
`,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)))}}},je=ms;var ps=f("@wayke-se/ecom"),ga=({vehicleId:s,dealerId:i,downPayment:e,duration:t,residual:o})=>{let a=ps.payments.newLookupRequest().forVehicle(s).withDownPayment(e).withDuration(t);return o!==void 0&&a.withResidualValue(o),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:o}=this.props,a=`
|
|
590
590
|
<input
|
|
591
591
|
type="checkbox"
|
|
592
592
|
id="${this.props.id}"
|
|
@@ -664,7 +664,7 @@
|
|
|
664
664
|
<div class="waykeecom-stack waykeecom-stack--2" id="${Na}"></div>
|
|
665
665
|
</div>
|
|
666
666
|
</div>
|
|
667
|
-
`,!h){o===q.AuthMethod.SameDevice?new Sa(this.node.querySelector(`#${vs}`),{autoLaunchUrl:t,errorMessage:a,onClick:()=>this.props?.onSameDeviceClick?.()}):o===q.AuthMethod.QrCode&&new _a(this.node.querySelector(`#${vs}`),{qrCode:e,errorMessage:a});let R=o===q.AuthMethod.SameDevice?"Mitt BankID \xE4r p\xE5 en annan enhet":"\xD6ppna BankID p\xE5 den h\xE4r enheten";new V(this.node.querySelector(`#${wa}`),{title:R,id:Pl,onClick:()=>p(o===q.AuthMethod.SameDevice?q.AuthMethod.QrCode:q.AuthMethod.SameDevice)})}new V(this.node.querySelector(`#${Na}`),{title:"Avbryt",id:Aa,onClick:()=>y()})}},
|
|
667
|
+
`,!h){o===q.AuthMethod.SameDevice?new Sa(this.node.querySelector(`#${vs}`),{autoLaunchUrl:t,errorMessage:a,onClick:()=>this.props?.onSameDeviceClick?.()}):o===q.AuthMethod.QrCode&&new _a(this.node.querySelector(`#${vs}`),{qrCode:e,errorMessage:a});let R=o===q.AuthMethod.SameDevice?"Mitt BankID \xE4r p\xE5 en annan enhet":"\xD6ppna BankID p\xE5 den h\xE4r enheten";new V(this.node.querySelector(`#${wa}`),{title:R,id:Pl,onClick:()=>p(o===q.AuthMethod.SameDevice?q.AuthMethod.QrCode:q.AuthMethod.SameDevice)})}new V(this.node.querySelector(`#${Na}`),{title:"Avbryt",id:Aa,onClick:()=>y()})}},ze=Es;var Is=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){this.node.innerHTML=`
|
|
668
668
|
<div class="waykeecom-disclaimer">
|
|
669
669
|
<div class="waykeecom-disclaimer__text">
|
|
670
670
|
${this.props.text}
|
|
@@ -705,7 +705,7 @@
|
|
|
705
705
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Va}"></div>
|
|
706
706
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Ga}"></div>
|
|
707
707
|
</div>
|
|
708
|
-
`,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:()=>o()})}},Ka=_s;var
|
|
708
|
+
`,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:()=>o()})}},Ka=_s;var za=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:o,loading:a,onClick:n}=this.props;this.node.innerHTML=`
|
|
709
709
|
<button
|
|
710
710
|
type="button"
|
|
711
711
|
${t?`id="${t}"`:""}
|
|
@@ -719,10 +719,10 @@
|
|
|
719
719
|
${b({type:"inline"})}
|
|
720
720
|
</span>`:""}
|
|
721
721
|
</button>
|
|
722
|
-
`,n&&this.node.querySelector("button")?.addEventListener("click",n)}},Je=Ss;var Bl="assessment-rejected-result",
|
|
723
|
-
<div class="waykeecom-stack waykeecom-stack--4" id="${
|
|
722
|
+
`,n&&this.node.querySelector("button")?.addEventListener("click",n)}},Je=Ss;var Bl="assessment-rejected-result",ja=`${Bl}-node`,Ja="assessment-rejected-abort",Qa=`${Ja}-node`,ws=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,onGoBack:t}=this.props;this.node.innerHTML=`
|
|
723
|
+
<div class="waykeecom-stack waykeecom-stack--4" id="${ja}"></div>
|
|
724
724
|
<div class="waykeecom-stack waykeecom-stack--4" id="${Qa}"></div>
|
|
725
|
-
`,new ae(this.node.querySelector(`#${
|
|
725
|
+
`,new ae(this.node.querySelector(`#${ja}`),{store:e,decision:za.CreditAssessmentRecommendation.Reject}),new Je(this.node.querySelector(`#${Qa}`),{title:"G\xE5 tillbaka",id:Ja,onClick:()=>t()})}},Xa=ws;var As=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,creditAssessmentResponse:t,onProceed:o,onGoBack:a}=this.props,n=t.recommendation;n===Ns.CreditAssessmentRecommendation.Approve?new Fa(this.node,{store:e,onProceed:()=>o(),onGoBack:()=>a()}):n===Ns.CreditAssessmentRecommendation.AssessManually?new Ka(this.node,{store:e,onProceed:()=>o(),onGoBack:()=>a()}):new Xa(this.node,{store:e,onGoBack:()=>a()})}},Za=As;var Fl=s=>{let i=s>0,e=s%12===0;if(!i||!e)throw new TypeError("Invalid months for creating creidt assessment term");return`${s}months`},en=Fl;var Xe={},Oe=(s,i)=>{Xe[s]=i},Ts=()=>{Object.keys(Xe).forEach(s=>{clearInterval(Xe[s]),delete Xe[s]})};var tn=f("@wayke-se/ecom"),Cs=s=>tn.creditAssessment.decline(s);var Ds=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,options:t,value:o,name:a,title:n,error:l,errorMessage:c,onChange:m}=this.props;this.node.innerHTML=`
|
|
726
726
|
<div class="waykeecom-input-label">
|
|
727
727
|
<label for="wayke-estimated-mileage" class="waykeecom-input-label__label">${n}</label>
|
|
728
728
|
</div>
|
|
@@ -732,9 +732,13 @@
|
|
|
732
732
|
${a?`name="${a}"`:""}
|
|
733
733
|
${e?`id="${e}"`:""}
|
|
734
734
|
>
|
|
735
|
-
${t.map(u=>`<option
|
|
735
|
+
${t.map(u=>`<option
|
|
736
|
+
value="${u.value}"
|
|
737
|
+
${u.disabled?"disabled":""}
|
|
738
|
+
${u.value===o?'selected="selected"':""}
|
|
739
|
+
>${u.title||u.value}</option>`).join("")}
|
|
736
740
|
</select>
|
|
737
|
-
`,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",B={maritalStatus:C.requiredAssessmentMaritalStatus,income:C.requiredNumberGreaterOrEqualThanZero,employment:C.requiredAssessmentEmplyment,householdChildren:C.requiredNumberGreaterOrEqualThanZero,housingCost:C.requiredNumberGreaterOrEqualThanZero,"debtSpecification.cardCredits":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.carLoan":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.collateral":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.leasingFees":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.privateLoan":C.optionalNumberGreaterOrEqualThanZero,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=s=>{let i={maritalStatus:s?.maritalStatus||"",income:s?.income.toString()||"",employment:s?.employment.toString()||"",householdChildren:s?.householdChildren.toString()||"",housingCost:s?.housingCost.toString()||"","debtSpecification.cardCredits":s?.debtSpecification.cardCredits.toString()||"","debtSpecification.carLoan":s?.debtSpecification.carLoan.toString()||"","debtSpecification.collateral":s?.debtSpecification.collateral.toString()||"","debtSpecification.leasingFees":s?.debtSpecification.leasingFees.toString()||"","debtSpecification.privateLoan":s?.debtSpecification.privateLoan.toString()||"",housingType:s?.housingType.toString()||""};return{value:i,validation:{maritalStatus:B.maritalStatus(i.maritalStatus),income:B.income(i.income),employment:B.employment(i.employment),householdChildren:B.householdChildren(i.householdChildren),housingCost:B.housingCost(i.housingCost),"debtSpecification.cardCredits":B["debtSpecification.cardCredits"](i["debtSpecification.cardCredits"]),"debtSpecification.carLoan":B["debtSpecification.carLoan"](i["debtSpecification.carLoan"]),"debtSpecification.collateral":B["debtSpecification.collateral"](i["debtSpecification.collateral"]),"debtSpecification.leasingFees":B["debtSpecification.leasingFees"](i["debtSpecification.leasingFees"]),"debtSpecification.privateLoan":B["debtSpecification.privateLoan"](i["debtSpecification.privateLoan"]),housingType:B.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,o=t.name,a=t.value;this.state.value[o]=a,this.state.validation[o]=B[o](a),this.updateUiError(o),this.updateProceedButton()}onBlur(e){let o=e.currentTarget.name;this.state.interact[o]=!0,this.state.validation[o]=B[o](this.state.value[o]),this.updateUiError(o),this.updateProceedButton()}onChangeSelect(e){let t=e.currentTarget,o=t.name,a=t.value;this.state.value[o]=a,this.state.validation[o]=B[o](a),this.updateProceedButton()}onChangeRadio(e){let t=e.currentTarget,o=t.name,a=t.value;this.state.value[o]=a,this.state.validation[o]=B[o](a),o==="housingType"&&(t.value===S.HousingType.SingleFamily&&(this.state.value.housingCost="0",this.state.validation.housingCost=B.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)),O(),this.creditAssessmentResponse=void 0,this.render(!0)}bankIdStatus(e,t,o=!1){o||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),O(),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 o=this.props.store.getState().caseId;if(!o)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:o,method:e});if(t||d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.bankIdStatus(o,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,O(),this.render(!0)}}async startBankId(e){let{store:t}=this.props;this.caseError=void 0,this.bankidError=!1,this.signed=!1;let o=t.getState().caseId;if(this.bankidStatusInterval&&(clearInterval(this.bankidStatusInterval),o&&(await Re(o),await Cs(o),me()(t.dispatch))),o){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:o}=this.props;this.contexts.performApplicationButton?.disabled(!0);let{customer:a}=e.getState(),{monthlyCost:n}=o.costs,{interest:l}=o.interests,c=o.downPaymentSpec.current,m=o.durationSpec.current,u=o.creditAmount,h=o.price,p=o.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:o,onProceed:a}=this.props,n=Ie(),{order:l}=t.getState(),c=l?.paymentOptions.find(h=>h.type===S.PaymentType.Loan),m=o.creditAmount,u=l?.contactInformation?.name;if(this.view===3&&this.creditAssessmentResponse)new Za(z(),{store:t,creditAssessmentResponse:this.creditAssessmentResponse,onProceed:()=>{O(),a()},onGoBack:()=>this.onAbort()});else if(this.view===2)this.contexts.bankId=new je(z(),{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=`
|
|
741
|
+
`,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",x={maritalStatus:C.requiredAssessmentMaritalStatus,income:C.requiredNumberGreaterOrEqualThanZero,employment:C.requiredAssessmentEmplyment,householdChildren:C.requiredNumberGreaterOrEqualThanZero,housingCost:C.requiredNumberGreaterOrEqualThanZero,"debtSpecification.cardCredits":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.vehicleLoan":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.collateral":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.leasingFees":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.privateLoan":C.optionalNumberGreaterOrEqualThanZero,housingType:C.requiredHousingType},Wl={maritalStatus:S.MaritalStatus.Married,income:5e4,employment:S.Employment.FullTimeEmployed,householdChildren:-1,housingCost:2e3,debtSpecification:{cardCredits:0,vehicleLoan:0,collateral:0,leasingFees:0,privateLoan:0},housingType:S.HousingType.Apartment},Yl=()=>location.hostname==="localhost"?{...Wl}:void 0,Kl=s=>{let i={maritalStatus:s?.maritalStatus||"",income:s?.income.toString()||"",employment:s?.employment.toString()||"",householdChildren:s?.householdChildren.toString()||"-1",housingCost:s?.housingCost.toString()||"","debtSpecification.cardCredits":s?.debtSpecification.cardCredits.toString()||"","debtSpecification.vehicleLoan":s?.debtSpecification.vehicleLoan.toString()||"","debtSpecification.collateral":s?.debtSpecification.collateral.toString()||"","debtSpecification.leasingFees":s?.debtSpecification.leasingFees.toString()||"","debtSpecification.privateLoan":s?.debtSpecification.privateLoan.toString()||"",housingType:s?.housingType.toString()||""};return{value:i,validation:{maritalStatus:x.maritalStatus(i.maritalStatus),income:x.income(i.income),employment:x.employment(i.employment),householdChildren:x.householdChildren(i.householdChildren),housingCost:x.housingCost(i.housingCost),"debtSpecification.cardCredits":x["debtSpecification.cardCredits"](i["debtSpecification.cardCredits"]),"debtSpecification.vehicleLoan":x["debtSpecification.vehicleLoan"](i["debtSpecification.vehicleLoan"]),"debtSpecification.collateral":x["debtSpecification.collateral"](i["debtSpecification.collateral"]),"debtSpecification.leasingFees":x["debtSpecification.leasingFees"](i["debtSpecification.leasingFees"]),"debtSpecification.privateLoan":x["debtSpecification.privateLoan"](i["debtSpecification.privateLoan"]),housingType:x.housingType(i.housingType)},interact:{maritalStatus:!1,income:!1,employment:!1,householdChildren:!1,housingCost:!1,"debtSpecification.cardCredits":!1,"debtSpecification.vehicleLoan":!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,o=t.name,a=t.value;this.state.value[o]=a,this.state.validation[o]=x[o](a),this.updateUiError(o),this.updateProceedButton()}onBlur(e){let o=e.currentTarget.name;this.state.interact[o]=!0,this.state.validation[o]=x[o](this.state.value[o]),this.updateUiError(o),this.updateProceedButton()}onChangeSelect(e){let t=e.currentTarget,o=t.name,a=t.value;this.state.value[o]=a,this.state.validation[o]=x[o](a),this.updateProceedButton()}onChangeRadio(e){let t=e.currentTarget,o=t.name,a=t.value;this.state.value[o]=a,this.state.validation[o]=x[o](a),o==="housingType"&&(t.value===S.HousingType.SingleFamily?(this.state.value.housingCost="0",this.state.validation.housingCost=x.housingCost(this.state.value.housingCost)):(this.state.value.housingCost="",this.state.validation.housingCost=x.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.vehicleLoan"]||!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)),O(),this.creditAssessmentResponse=void 0,this.render(!0)}bankIdStatus(e,t,o=!1){o||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),O(),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 o=this.props.store.getState().caseId;if(!o)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:o,method:e});if(t||d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.bankIdStatus(o,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,O(),this.render(!0)}}async startBankId(e){let{store:t}=this.props;this.caseError=void 0,this.bankidError=!1,this.signed=!1;let o=t.getState().caseId;if(this.bankidStatusInterval&&(clearInterval(this.bankidStatusInterval),o&&(await Re(o),await Cs(o),me()(t.dispatch))),o){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:o}=this.props;this.contexts.performApplicationButton?.disabled(!0);let{customer:a}=e.getState(),{monthlyCost:n}=o.costs,{interest:l}=o.interests,c=o.downPaymentSpec.current,m=o.durationSpec.current,u=o.creditAmount,h=o.price,p=o.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),vehicleLoan:parseInt(this.state.value["debtSpecification.vehicleLoan"]||"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:o,onProceed:a}=this.props,n=Ie(),{order:l}=t.getState(),c=l?.paymentOptions.find(h=>h.type===S.PaymentType.Loan),m=o.creditAmount,u=l?.contactInformation?.name;if(this.view===3&&this.creditAssessmentResponse)new Za(j(),{store:t,creditAssessmentResponse:this.creditAssessmentResponse,onProceed:()=>{O(),a()},onGoBack:()=>this.onAbort()});else if(this.view===2)this.contexts.bankId=new ze(j(),{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=`
|
|
738
742
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
739
743
|
<h5 class="waykeecom-heading waykeecom-heading--4">L\xE5neans\xF6kan</h5>
|
|
740
744
|
<div class="waykeecom-content">
|
|
@@ -826,7 +830,7 @@
|
|
|
826
830
|
|
|
827
831
|
${this.caseError?`
|
|
828
832
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
829
|
-
${I({tone:"error",children:`Det gick inte att starta en l\xE5neans\xF6kan, f\xF6rs\xF6k igen.${this.caseError!==void 0
|
|
833
|
+
${I({tone:"error",children:`Det gick inte att starta en l\xE5neans\xF6kan, f\xF6rs\xF6k igen.${this.caseError!==void 0?` ${this.caseError}`:""}`})}
|
|
830
834
|
</div>
|
|
831
835
|
`:""}
|
|
832
836
|
|
|
@@ -843,12 +847,12 @@
|
|
|
843
847
|
<div class="waykeecom-stack waykeecom-stack--1" id="${hn}"></div>
|
|
844
848
|
</div>
|
|
845
849
|
</div>
|
|
846
|
-
`,this.contexts.maritalStatus=new Q(this.node.querySelector(`#${sn}`),{
|
|
850
|
+
`,this.contexts.maritalStatus=new Q(this.node.querySelector(`#${sn}`),{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 M(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 Q(this.node.querySelector(`#${on}`),{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 Q(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 M(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:`
|
|
847
851
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
848
852
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Inkomst per m\xE5nad f\xF6re skatt</span></p>
|
|
849
853
|
<p class="waykeecom-content__p">L\xF6n och/eller pension, inte bidrag eller studiel\xE5n.</p>
|
|
850
854
|
</div>
|
|
851
|
-
`,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 M(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",min:0,information:this.state.value.housingType===S.HousingType.Condominium?`
|
|
855
|
+
`,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",error:this.state.interact.householdChildren&&!this.state.validation.householdChildren,errorMessage:"V\xE4lj antal barn",options:[{value:"-1",title:"V\xE4lj antal barn",disabled:!0},{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 M(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",min:0,information:this.state.value.housingType===S.HousingType.Condominium?`
|
|
852
856
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
853
857
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Min del av m\xE5nadsavgiften</span></p>
|
|
854
858
|
<p class="waykeecom-content__p">Exklusive r\xE4nta och amortering</p>
|
|
@@ -858,7 +862,7 @@
|
|
|
858
862
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Kortkrediter</span></p>
|
|
859
863
|
<p class="waykeecom-content__p">Total skuld</p>
|
|
860
864
|
</div>
|
|
861
|
-
`,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p),onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DEBT_SPECIFICATION_CARD_CREDIT_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts["debtSpecification.
|
|
865
|
+
`,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p),onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DEBT_SPECIFICATION_CARD_CREDIT_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts["debtSpecification.vehicleLoan"]=new M(this.node.querySelector(`#${cn}`),{title:"Bill\xE5n",value:this.state.value["debtSpecification.vehicleLoan"],id:En,error:this.state.interact["debtSpecification.vehicleLoan"]&&!this.state.validation["debtSpecification.vehicleLoan"],errorMessage:"Ange bill\xE5n eller l\xE4mna tomt",name:"debtSpecification.vehicleLoan",autocomplete:"off",placeholder:"",unit:"kr",type:"number",min:0,information:`
|
|
862
866
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
863
867
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Bill\xE5n</span></p>
|
|
864
868
|
<p class="waykeecom-content__p">Total skuld. Ange inte skuld f\xF6r bil som ska ers\xE4ttas.</p>
|
|
@@ -1027,7 +1031,7 @@
|
|
|
1027
1031
|
</div>
|
|
1028
1032
|
</div>
|
|
1029
1033
|
</div>
|
|
1030
|
-
`,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:o,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",
|
|
1034
|
+
`,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:o,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",jl="downpayment-range",Pn="duration-range-node",Ql="duration-range",$n="residual-range-node",zl="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 o=this.props.loan.loanDetails;if(!o)throw"err";this.paymentLookupResponse=this.props.paymentLookupResponse||o,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,o=t.name,a=t.value;t.value=a,this.paymentState[o].current=o==="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:o}=this.props,{order:a}=e.getState(),n=a?.contactInformation?.name,l=t.loanDetails?.shouldUseCreditScoring;this.node.innerHTML=`
|
|
1031
1035
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1032
1036
|
<hr class="waykeecom-separator" />
|
|
1033
1037
|
</div>
|
|
@@ -1049,20 +1053,20 @@
|
|
|
1049
1053
|
${l?`
|
|
1050
1054
|
<div class="waykeecom-stack waykeecom-stack--3" id="${Bn}"></div>
|
|
1051
1055
|
`:`<div class="waykeecom-stack waykeecom-stack--3" id="${Fn}"></div>`}
|
|
1052
|
-
`,this.contexts.downPayment=new
|
|
1056
|
+
`,this.contexts.downPayment=new je(this.node.querySelector(`#${xn}`),{title:"Kontantinsats",value:this.paymentState.downPayment.current,id:jl,name:"downPayment",onChange:c=>this.onChange(c),min:this.paymentState.downPayment.min,max:this.paymentState.downPayment.max,unit:"kr",information:`
|
|
1053
1057
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1054
1058
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Hur mycket av dina egna pengar vill du l\xE4gga?</span></p>
|
|
1055
1059
|
<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>
|
|
1056
1060
|
<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>
|
|
1057
1061
|
</div>
|
|
1058
|
-
`,onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DOWNPAYMENT_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts.duration=new
|
|
1062
|
+
`,onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DOWNPAYMENT_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts.duration=new je(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 je(this.node.querySelector(`#${$n}`),{title:"Restv\xE4rde",value:parseInt(`${this.paymentState.residual.current*100}`,10),id:zl,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:()=>o()}):this.contexts.proceedButton=new N(this.node.querySelector(`#${Fn}`),{title:"G\xE5 vidare",id:Vn,onClick:()=>o()})}},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:o,paymentLookupResponse:a,onEdit:n}=this.props,l=o?.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*"})}],$=c.creditAssessmentResponse?.recommendation,X=`*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=`
|
|
1059
1063
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
1060
1064
|
<h4 class="waykeecom-heading waykeecom-heading--4">Bill\xE5n</h4>
|
|
1061
1065
|
<div class="waykeecom-content">
|
|
1062
1066
|
<p class="waykeecom-content__p">Ordern \xE4r snart klar, h\xE4r ser du ditt l\xE5nebesked:</p>
|
|
1063
1067
|
</div>
|
|
1064
1068
|
</div>
|
|
1065
|
-
${
|
|
1069
|
+
${$?`<div class="waykeecom-stack waykeecom-stack--2" id="${qn}"></div>`:""}
|
|
1066
1070
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
1067
1071
|
<div class="waykeecom-stack waykeecom-stack--1">
|
|
1068
1072
|
<ul class="waykeecom-key-value-list">
|
|
@@ -1078,7 +1082,7 @@
|
|
|
1078
1082
|
<button type="button" title="\xC4ndra finansiering" class="waykeecom-link">\xC4ndra</button>
|
|
1079
1083
|
</div>
|
|
1080
1084
|
</div>
|
|
1081
|
-
|
|
1085
|
+
`,$&&new ae(this.node.querySelector(`#${qn}`),{store:e,decision:$})}else this.node.innerHTML=`
|
|
1082
1086
|
<div class="waykeecom-stack waykeecom-stack--1">
|
|
1083
1087
|
<ul class="waykeecom-key-value-list">
|
|
1084
1088
|
${E({key:"Finansiering",value:t===Us.PaymentType.Cash?"Kontant":"Privatleasing"})}
|
|
@@ -1091,13 +1095,13 @@
|
|
|
1091
1095
|
</div>
|
|
1092
1096
|
</div>
|
|
1093
1097
|
`:""}
|
|
1094
|
-
`;n&&this.node.querySelector("button")?.addEventListener("click",()=>n())}},Wn=Vs;var
|
|
1098
|
+
`;n&&this.node.querySelector("button")?.addEventListener("click",()=>n())}},Wn=Vs;var zn="button-financial-proceed",Yn=`${zn}-node`,Zl="financial-option",Kn=`${Zl}-node`,ed="financial-option-second",jn=`${ed}-node`,td="radio-financial-cash",sd="radio-financial-loan",od="radio-financial-lease",Qn="payment-node",Gs=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation",()=>{let n=this.props.store.getState();this.paymentType=n.paymentType,this.render()});let o=this.props.store.getState(),{paymentType:a}=o;this.paymentType=a,this.render()}onChange(e){let o=e.currentTarget.value;switch(this.paymentType=o,this.render(!0),this.paymentType){case F.PaymentType.Cash:d("MAIN","FINANCIAL_CASH_SELECTED","FINANCIAL");break;case F.PaymentType.Lease:d("MAIN","FINANCIAL_LEASE_SELECTED","FINANCIAL");case F.PaymentType.Loan:d("MAIN","FINANCIAL_LOAN_SELECTED","FINANCIAL");default:break}}onProceed(){if(this.paymentType){switch(this.paymentType){case F.PaymentType.Cash:d("MAIN","FINANCIAL_CASH_SET","FINANCIAL");break;case F.PaymentType.Lease:d("MAIN","FINANCIAL_LEASE_SET","FINANCIAL");case F.PaymentType.Loan:d("MAIN","FINANCIAL_LOAN_SET","FINANCIAL");default:break}ci(this.paymentType,this.props.lastStage)(this.props.store.dispatch)}}onEdit(){d("MAIN","FINANCIAL_EDIT","FINANCIAL"),H("main",this.props.index)(this.props.store.dispatch)}render(e){let t=this.props.store.getState(),{id:o,order:a,paymentLookupResponse:n}=t;if(!a)throw"No order available";let l=a.paymentOptions,c=t.topNavigation.stage>this.props.index,m=B(this.node,{completed:c,title:"\xC4gandeform",active:t.navigation.stage===this.props.index,id:"financial"}),u=document.createElement("div");if((t.navigation.stage>this.props.index||c&&t.navigation.stage!==this.props.index)&&this.paymentType){let h=l.find(p=>p.type===F.PaymentType.Loan);new Wn(m,{store:this.props.store,loan:h,paymentType:this.paymentType,paymentLookupResponse:n||h?.loanDetails,onEdit:t.createdOrderId?void 0:()=>this.onEdit()})}else if(t.navigation.stage===this.props.index){let h=t.order?.orderVehicle,p=l.find(L=>L.type===F.PaymentType.Cash),y=l.find(L=>L.type===F.PaymentType.Loan),g=l.find(L=>L.type===F.PaymentType.Lease);u.innerHTML=`
|
|
1095
1099
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1096
1100
|
<h4 class="waykeecom-heading waykeecom-heading--4 waykeecom-no-margin">Hur vill du finansiera din ${h?.title} ${pe(h)}?</h4>
|
|
1097
1101
|
</div>
|
|
1098
1102
|
|
|
1099
1103
|
${p||y?`<div class="waykeecom-stack waykeecom-stack--3" id="${Kn}"></div>`:""}
|
|
1100
|
-
${g?`<div class="waykeecom-stack waykeecom-stack--3" id="${
|
|
1104
|
+
${g?`<div class="waykeecom-stack waykeecom-stack--3" id="${jn}"></div>`:""}
|
|
1101
1105
|
|
|
1102
1106
|
<div class="waykeecom-stack waykeecom-stack--3" id="${Qn}"></div>
|
|
1103
1107
|
${this.paymentType!==F.PaymentType.Loan?`<div class="waykeecom-stack waykeecom-stack--3" id="${Yn}"></div>`:""}
|
|
@@ -1140,18 +1144,11 @@
|
|
|
1140
1144
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1141
1145
|
<p class="waykeecom-content__p">Du k\xF6per bilen och \xE4ger den sj\xE4lv, antingen genom att betala hela bilen med egna medel eller genom ett bill\xE5n. Du ansvarar sj\xE4lv f\xF6r f\xF6rs\xE4ljningen av bilen och v\xE4ljer s\xE5klart helt fritt n\xE4r den ska \xE4ga rum.</p>
|
|
1142
1146
|
</div>
|
|
1143
|
-
`,options:R,onClick:L=>this.onChange(L),onClickInformation:()=>{d("MAIN","FINANCIAL_INFORMATION_TOGGLE","FINANCIAL")}});let
|
|
1144
|
-
<div class="waykeecom-box">
|
|
1145
|
-
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1146
|
-
<ul class="waykeecom-content__ul">
|
|
1147
|
-
<li class="waykeecom-content__li">Inkl. 1 500 mil/\xE5r, 36 m\xE5n.</li>
|
|
1148
|
-
</ul>
|
|
1149
|
-
</div>
|
|
1150
|
-
</div>`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${k(g?.price,{postfix:g.unit})}</div>`}),new Q(u.querySelector(`#${zn}`),{title:"Leasa bilen",checked:this.paymentType,name:"paymentType",information:`
|
|
1147
|
+
`,options:R,onClick:L=>this.onChange(L),onClickInformation:()=>{d("MAIN","FINANCIAL_INFORMATION_TOGGLE","FINANCIAL")}});let $=[];g&&($.push({id:od,title:"Privatleasing",value:F.PaymentType.Lease,meta:`<div class="waykeecom-text waykeecom-text--font-bold">Fr\xE5n ${k(g?.price,{postfix:g.unit})}</div>`}),new Q(u.querySelector(`#${jn}`),{title:"Leasa bilen",checked:this.paymentType,name:"paymentType",information:`
|
|
1151
1148
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1152
|
-
<p class="waykeecom-content__p">
|
|
1149
|
+
<p class="waykeecom-content__p">N\xE4r du privatleasar en bil \xE4ger du den inte sj\xE4lv utan betalar en m\xE5nadsavgift under en avtalad tid och som t\xE4cker en viss k\xF6rstr\xE4cka och andra avtalade tj\xE4nster.</p>
|
|
1153
1150
|
</div>
|
|
1154
|
-
`,options
|
|
1151
|
+
`,options:$,onClick:L=>this.onChange(L)}));let X=u.querySelector(`#${Qn}`);X&&(y&&this.paymentType===F.PaymentType.Loan?new Gn(X,{store:this.props.store,loan:y,vehicleId:o,paymentLookupResponse:n,onProceed:()=>this.onProceed()}):new N(u.querySelector(`#${Yn}`),{title:"G\xE5 vidare",id:zn,disabled:!this.paymentType,onClick:()=>this.onProceed()}))}!e&&t.navigation.stage===this.props.index&&m.parentElement?.scrollIntoView()}},Jn=Gs;var U=f("@wayke-se/ecom");var qs=f("@wayke-se/ecom"),Xn=(s,i)=>{let e=s.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:o,name:a,checked:n,meta:l,description:c,append:m,disabled:u,onClick:h}=this.props,p=`
|
|
1155
1152
|
<input
|
|
1156
1153
|
type="checkbox"
|
|
1157
1154
|
id="${e}"
|
|
@@ -1188,8 +1185,8 @@
|
|
|
1188
1185
|
${b({type:"inline"})}
|
|
1189
1186
|
</span>`:""}
|
|
1190
1187
|
</button>
|
|
1191
|
-
`,n&&this.node.querySelector("button")?.addEventListener("click",n)}},Zn=Ys;var Ks=class extends r{constructor(i){super(i,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--1"}),this.render()}render(){return this.node.innerHTML='<div class="waykeecom-box"></div>',this.node.querySelector(".waykeecom-box")}},er=Ks;var
|
|
1192
|
-
<div class="waykeecom-nav-banner" id="${
|
|
1188
|
+
`,n&&this.node.querySelector("button")?.addEventListener("click",n)}},Zn=Ys;var Ks=class extends r{constructor(i){super(i,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--1"}),this.render()}render(){return this.node.innerHTML='<div class="waykeecom-box"></div>',this.node.querySelector(".waykeecom-box")}},er=Ks;var js="insurance-button-top-left-node",tr="insurance-button-bottom-left-node",Qs="insurance-add-remove-node",sr="insurance-addons-node",or="insurance-accordion-node",_e=class extends r{constructor(e,t){super(e);this.initialAddons=[];this.addons=[];this.contexts={checkboxes:{}};this.props=t;let{insuranceAddOns:o}=this.props.store.getState();!!o?.insurance&&o.insurance===this.props.insurance.name&&(this.addons=[...o.addOns]),this.initialAddons=[...this.addons],this.render()}static containChanges(e,t){let o=[...e].sort(),a=[...t].sort();return o.join().localeCompare(a.join())!==0}onClick(e){let t=e.currentTarget,{name:o,checked:a}=t,n=this.props.insurance.addOns.find(c=>c.name===o);if(n){if(Object.keys(this.contexts.checkboxes).forEach(c=>{this.contexts.checkboxes[c]?.disabled(!1)}),this.contexts.checkboxes[o]?.checked(a),a)d("MAIN","INSURANCE_ADDON_SELECTED","INSURANCE_IF"),this.addons.push(n);else{d("MAIN","INSURANCE_ADDON_UNSELECTED","INSURANCE_IF");let c=this.addons.findIndex(m=>m.name===n.name);c>-1&&this.addons.splice(c,1)}[...new Set(this.addons.map(c=>c.exclude).flat())].forEach(c=>this.contexts.checkboxes[c]?.disabled(!0))}let l=_e.containChanges(this.initialAddons,this.addons);this.contexts.updateButton?.disabled(this.props.selected?!l:!1)}onUpdate(){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"),mi(this.props.insurance,this.addons)(this.props.store.dispatch),this.props.onClose()}render(){let{insurance:e,selected:t,onClose:o}=this.props,{name:a,description:n,legalDescription:l,legalUrl:c,insuranceItems:m}=e,u=e.addOns,h=_e.containChanges(this.initialAddons,this.addons);if(this.node.innerHTML=`
|
|
1189
|
+
<div class="waykeecom-nav-banner" id="${js}"></div>
|
|
1193
1190
|
|
|
1194
1191
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1195
1192
|
<div class="waykeecom-hstack waykeecom-hstack--align-center waykeecom-hstack--spacing-3">
|
|
@@ -1231,7 +1228,7 @@
|
|
|
1231
1228
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Qs}"></div>
|
|
1232
1229
|
<div class="waykeecom-stack waykeecom-stack--1" id="${tr}"></div>
|
|
1233
1230
|
</div>
|
|
1234
|
-
`,new ce(this.node.querySelector(`#${
|
|
1231
|
+
`,new ce(this.node.querySelector(`#${js}`),{title:"Tillbaka",onClick:()=>o()}),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(`#${js}`),{title:"Tillbaka",onClick:()=>o()}),new te(this.node.querySelector(`#${tr}`),{title:"Tillbaka",onClick:()=>o()}),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 zs=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,O(),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:o}=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(j(),{store:this.props.store,insurance:t,selected:c,onClose:()=>this.onInfoClose()}),new he(this.node,{logo:n,selected:c,id:o,title:t.name,description:t.description,price:k(t.price,{postfix:"kr/m\xE5n"}),priceDetails:l,onClick:()=>this.onClick(),onInfo:()=>this.onInfoOpen()},o)}},ar=zs;var Js=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,insurances:t}=this.props,o=new ue(this.node,{id:"insurance-list",onClick:()=>d("MAIN","INSURANCE_ARROW","INSURANCE_IF")}),{overflowElement:a}=o;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 o=_(this.props.store,"drivingDistance",()=>{this.fetchInsurance()});this.contexts.listners.push(o);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}`,o=dr[t];if(d("MAIN","INSURANCE_GET_INSURANCES_REQUESTED","INSURANCE_IF"),o){this.insurances=o,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:o,drivingDistance:a}=t;this.node.innerHTML=`
|
|
1235
1232
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1236
1233
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vill du teckna en f\xF6rs\xE4kring p\xE5 din nya bil?</h4>
|
|
1237
1234
|
<div class="waykeecom-content">
|
|
@@ -1305,7 +1302,7 @@
|
|
|
1305
1302
|
<div class="waykeecom-stack waykeecom-stack--1" id="${wr}"></div>
|
|
1306
1303
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Sr}"></div>
|
|
1307
1304
|
</div>
|
|
1308
|
-
`,new ce(this.node.querySelector(`#${_r}`),{title:"Tillbaka",onClick:()=>o()}),new te(this.node.querySelector(`#${Sr}`),{title:"Tillbaka",onClick:()=>o()}),new ee(this.node.querySelector(`#${wr}`),{selected:t,fullSize:!0,onClick:()=>a()}),G()}},Nr=so;var oo=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.props=t,_(this.props.store,"freeInsurance",()=>{this.render()}),this.render()}onInfoOpen(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE"),this.displayInfo=!0,this.render()}onInfoClose(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE"),this.displayInfo=!1,O(),this.render(),this.node.parentElement?.scrollIntoView()}onClick(){let{freeInsurance:e}=this.props.store.getState();e&&this.props.freeInsurance!==e?d("MAIN","INSURANCE_SELECTED","INSURANCE"):d("MAIN","INSURANCE_UNSELECTED","INSURANCE"),pi(this.props.freeInsurance)(this.props.store.dispatch)}render(){let{store:e,freeInsurance:t,key:o}=this.props,a=e.getState(),n=a.order?.insuranceOption?.logo,l=a.freeInsurance?JSON.stringify(a.freeInsurance).localeCompare(JSON.stringify(this.props.freeInsurance))===0:!1;this.displayInfo&&new Nr(
|
|
1305
|
+
`,new ce(this.node.querySelector(`#${_r}`),{title:"Tillbaka",onClick:()=>o()}),new te(this.node.querySelector(`#${Sr}`),{title:"Tillbaka",onClick:()=>o()}),new ee(this.node.querySelector(`#${wr}`),{selected:t,fullSize:!0,onClick:()=>a()}),G()}},Nr=so;var oo=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.props=t,_(this.props.store,"freeInsurance",()=>{this.render()}),this.render()}onInfoOpen(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE"),this.displayInfo=!0,this.render()}onInfoClose(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE"),this.displayInfo=!1,O(),this.render(),this.node.parentElement?.scrollIntoView()}onClick(){let{freeInsurance:e}=this.props.store.getState();e&&this.props.freeInsurance!==e?d("MAIN","INSURANCE_SELECTED","INSURANCE"):d("MAIN","INSURANCE_UNSELECTED","INSURANCE"),pi(this.props.freeInsurance)(this.props.store.dispatch)}render(){let{store:e,freeInsurance:t,key:o}=this.props,a=e.getState(),n=a.order?.insuranceOption?.logo,l=a.freeInsurance?JSON.stringify(a.freeInsurance).localeCompare(JSON.stringify(this.props.freeInsurance))===0:!1;this.displayInfo&&new Nr(j(),{freeInsurance:t,selected:l,onClick:()=>{this.onInfoClose(),this.onClick()},onClose:()=>this.onInfoClose()}),new he(this.node,{logo:n,id:o,title:t.title,description:t.description,price:"Gratis",selected:l,onClick:()=>this.onClick(),onInfo:()=>this.onInfoOpen()},o)}},Ar=oo;var io=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,insurances:t}=this.props,o=new ue(this.node,{id:"insurance-list",onClick:()=>d("MAIN","INSURANCE_ARROW","INSURANCE")}),{overflowElement:a}=o;a&&(a.innerHTML="",t.forEach((n,l)=>new Ar(a,{store:e,freeInsurance:n,key:`insurance-${l}`})))}},Tr=io;var ao="insurance-grid-list-node",ad="button-insurances-proceed",Cr=`${ao}-node`,nd="button-insurances-skip",rd=`${nd}-node`,no=class extends r{constructor(e,t){super(e);this.props=t,this.render()}onProceed(){let{freeInsurance:e}=this.props.store.getState();Z(this.props.lastStage)(this.props.store.dispatch),d("MAIN",e?"INSURANCE_SET":"INSURANCE_SKIPPED","INSURANCE")}render(){let{store:e,insurance:t}=this.props;this.node.innerHTML=`
|
|
1309
1306
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1310
1307
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vill du teckna en f\xF6rs\xE4kring p\xE5 din nya bil?</h4>
|
|
1311
1308
|
<div class="waykeecom-content">
|
|
@@ -1317,7 +1314,7 @@
|
|
|
1317
1314
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Cr}"></div>
|
|
1318
1315
|
<div class="waykeecom-stack waykeecom-stack--1" id="${rd}"></div>
|
|
1319
1316
|
</div>
|
|
1320
|
-
`,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())
|
|
1317
|
+
`,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()),H("main",this.props.index)(this.props.store.dispatch)}render(){let{store:e,index:t,lastStage:o}=this.props,a=e.getState(),n=a.topNavigation.stage>t,l=a.navigation.stage===t;l&&d("MAIN","INSURANCE_ACTIVE",this.getStep());let c=B(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:J[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 z(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:o,onSkip:()=>this.onSkipInsurances()});break;default:new Dr(c,{store:e,lastStage:o,insurance:m});break}}a.navigation.stage===t&&c.parentElement?.scrollIntoView()}},br=ro;var co=f("@wayke-se/ecom"),Rr=s=>{let i=co.vehicles.newLookupRequest().withRegistrationNumber(s.registrationNumber).withMileage(parseInt(s.mileage,10)).withCondition(s.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:o,id:a,error:n,errorMessage:l,placeholder:c,information:m,autocomplete:u,onChange:h,onBlur:p}=this.props;this.node.innerHTML=`
|
|
1321
1318
|
<div class="waykeecom-input-label">
|
|
1322
1319
|
<label for="${a}" class="waykeecom-input-label__label">${e}</label>
|
|
1323
1320
|
</div>
|
|
@@ -1418,7 +1415,7 @@
|
|
|
1418
1415
|
<circle cx="11" cy="10" r="5.5" stroke="#FFF500" stroke-linejoin="round" stroke-dasharray="1 2"/>
|
|
1419
1416
|
<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"/>
|
|
1420
1417
|
</svg>
|
|
1421
|
-
`,onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.mileage=new M(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 Q(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 K(this.node.querySelector(`#${tt}`),{id:mo,title:"Hoppa \xF6ver detta steg",onClick:()=>this.onNoTradeIn()})}},Wr=po;var
|
|
1418
|
+
`,onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.mileage=new M(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 Q(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 K(this.node.querySelector(`#${tt}`),{id:mo,title:"Hoppa \xF6ver detta steg",onClick:()=>this.onNoTradeIn()})}},Wr=po;var jr="button-trade-in-yes",Yr=`${jr}-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"),H("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:o}=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=B(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=`
|
|
1422
1419
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1423
1420
|
<div class="waykeecom-balloon">
|
|
1424
1421
|
<div class="waykeecom-stack waykeecom-stack--05">
|
|
@@ -1477,12 +1474,12 @@
|
|
|
1477
1474
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Yr}"></div>
|
|
1478
1475
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Kr}"></div>
|
|
1479
1476
|
</div>
|
|
1480
|
-
`,new N(m.querySelector(`#${Yr}`),{id:
|
|
1477
|
+
`,new N(m.querySelector(`#${Yr}`),{id:jr,title:"Jag har inbytesbil",onClick:()=>this.onYesTradeIn()}),new K(m.querySelector(`#${Kr}`),{id:Qr,title:"Hoppa \xF6ver detta steg",onClick:()=>this.onNoTradeIn()})));c.appendChild(m),a.navigation.stage===t&&c.parentElement?.scrollIntoView()}},zr=ko;var st={customer:{component:pa,name:"customer"},centralStorage:{component:zi,name:"centralStorage"},delivery:{component:fa,name:"delivery"},tradeIn:{component:zr,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=`
|
|
1481
1478
|
<h3 class="waykeecom-heading waykeecom-heading--4">K\xF6p online hos oss</h3>
|
|
1482
1479
|
<ul class="waykeecom-checklist" aria-label="F\xF6rdelar med att k\xF6pa bilen online hos oss">
|
|
1483
1480
|
${this.props.checklistItems.map(e=>` <li class="waykeecom-checklist__item">${e}</li>`).join("")}
|
|
1484
1481
|
</ul>
|
|
1485
|
-
`}},Jr=yo;var ec="preview-proceed",Xr=`${ec}-node`,pd="preview-checklist",Zr=`${pd}-node`,vo=class extends r{constructor(e,t){super(e);this.contexts={};this.requestError=!1;this.props=t,this.init(),this.render()}async init(){this.requestError=!1,this.render();let e=this.props.store.getState();try{this.contexts.buttonProceed?.disabled(!0);let t=await Be(e.id),o=Me(t),a=[];this.props.stageOrderList.forEach(n=>{n==="centralStorage"&&!o.requiresDealerSelection||n==="tradeIn"&&!o.allowsTradeIn||n==="insurance"&&!o.insuranceOption||n==="accessories"&&!o.accessories.length||a.push(st[n])}),hi(a)(this.props.store.dispatch),xe(o,this.props.vehicle)(this.props.store.dispatch),this.render()}catch(t){throw this.requestError=!0,this.render(),t}}onProceed(){d("PREVIEW","PREVIEW_PROCEED")
|
|
1482
|
+
`}},Jr=yo;var ec="preview-proceed",Xr=`${ec}-node`,pd="preview-checklist",Zr=`${pd}-node`,vo=class extends r{constructor(e,t){super(e);this.contexts={};this.requestError=!1;this.props=t,this.init(),this.render()}async init(){this.requestError=!1,this.render();let e=this.props.store.getState();try{this.contexts.buttonProceed?.disabled(!0);let t=await Be(e.id),o=Me(t),a=[];this.props.stageOrderList.forEach(n=>{n==="centralStorage"&&!o.requiresDealerSelection||n==="tradeIn"&&!o.allowsTradeIn||n==="insurance"&&!o.insuranceOption||n==="accessories"&&!o.accessories.length||a.push(st[n])}),hi(a)(this.props.store.dispatch),xe(o,this.props.vehicle)(this.props.store.dispatch),this.render()}catch(t){throw this.requestError=!0,this.render(),t}}onProceed(){d("PREVIEW","PREVIEW_PROCEED"),H("main")(this.props.store.dispatch)}render(){let{store:e,cdnMedia:t}=this.props,o=e.getState();if(!o.order){this.node.innerHTML=`
|
|
1486
1483
|
${this.requestError?I({tone:"error",children:"Ett fel uppstod och det gick inte att initiera modulen. F\xF6rs\xF6k igen."}):b()}
|
|
1487
1484
|
`;return}this.node.innerHTML=`
|
|
1488
1485
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
@@ -1528,7 +1525,7 @@
|
|
|
1528
1525
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1529
1526
|
<div id="payment-menu" style="padding: 24px;border: 1px solid #ececeb;"></div>
|
|
1530
1527
|
</div>
|
|
1531
|
-
`}},ic=Eo;var W=f("@wayke-se/ecom");var Io=f("@wayke-se/ecom"),ac=s=>{let i=Io.bankid.newAuthRequest().withMethod(s).build();return Io.bankid.auth(i)};var fo=f("@wayke-se/ecom"),go=s=>{let i=fo.bankid.newCollectRequest().withOrderRef(s).build();return fo.bankid.collect(i)};var
|
|
1528
|
+
`}},ic=Eo;var W=f("@wayke-se/ecom");var Io=f("@wayke-se/ecom"),ac=s=>{let i=Io.bankid.newAuthRequest().withMethod(s).build();return Io.bankid.auth(i)};var fo=f("@wayke-se/ecom"),go=s=>{let i=fo.bankid.newCollectRequest().withOrderRef(s).build();return fo.bankid.collect(i)};var P=f("@wayke-se/ecom"),nc=s=>{let i=s.getState();if(!i.address)throw"Missing address";if(!i.paymentType)throw"Missing paymentType";if(!i.vehicle)throw"Missing vehicle";let e=P.customers.newCustomer().withAddress(i.address).withPersonalNumber(i.customer.socialId).withEmail(i.customer.email).withPhoneNumber(i.customer.phone).build(),t=P.orders.newPayment().withType(i.paymentType);if(i.paymentType===P.PaymentType.Loan){let m=i.order?.paymentOptions.find(w=>w.type===P.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===P.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,$=i.creditAssessmentResponse.decision,X=u?.financialProductCode;if(!w||!R||!$||!X)throw"Missing credit assessment data";let L=P.orders.newCreditAssessment().withScoreId(w).withFinancialProductCode(X).withRecommendation(R).withDecision($).build();t.withCreditAssessment(L)}}let o=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=P.orders.newCreateRequest().forVehicle(i.id).withCustomer(e).withPayment(o).withUrls(n,l).withDeliveryType(i.homeDelivery?P.DeliveryType.Delivery:P.DeliveryType.Pickup);if(i.insurance){let m=P.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=P.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 P.orders.create(c.build())};var rc=f("@wayke-se/ecom"),cc=s=>rc.creditAssessment.accept(s);var _o=f("@wayke-se/ecom"),lc=s=>{let i=_o.bankid.newQrCodeRequest().withOrderRef(s).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 o=(await lc(e)).getQrCode();this.contexts.bankId?.update(W.AuthMethod.QrCode,o)}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(),o=await nc(e);d("MAIN","CONFIRMATION_CREATE_ORDER_SUCCEEDED","CONFIRMATION"),t?.isPaymentRequired&&O();let n=o.getPayment();ki(o.getOrderNumber(),n)(e.dispatch),this.acceptCreditAssessment()}catch(t){let o=t;this.view=1,d("MAIN","CONFIRMATION_CREATE_ORDER_FAILED","CONFIRMATION"),o.message==="The vehicle is not available for purchase"?(this.requestError=!1,this.notAvailable=!0):(this.notAvailable=!1,this.requestError=!0),O(),this.render()}}async handleBankidStatusResponse(e,t){if(e.isCompleted()){this.removeWindowEvents(),this.clearBankidRequestRef(),this.clearIntervals();let o=e.getAddress(),a=e.getPersonalNumber();if(o&&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,O(),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,O(),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,o=!1){o||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 o=await ac(e);t||d("MAIN","CONFIRMATION_BANKID_INIT_SUCCEEDED","CONFIRMATION");let a=o.getOrderRef();e===W.AuthMethod.QrCode?this.startBankidWithQr(a,t):this.startBankidSameDevice(o,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,O(),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:o,insurance:a}=this.props.store.getState();if(this.view===2)this.contexts.bankId=new ze(j(),{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=o?.contactInformation?.name,l=o?.conditionsPdfUri,c="https://www.wayke.se/trygghet-naer-det-kommer-till-dina-personuppgifter";this.node.innerHTML=`
|
|
1532
1529
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1533
1530
|
<h4 class="waykeecom-heading waykeecom-heading--4">Strax klart!</h4>
|
|
1534
1531
|
<div class="waykeecom-content">
|
|
@@ -1559,7 +1556,7 @@
|
|
|
1559
1556
|
<div class="waykeecom-stack waykeecom-stack--1" id="${uc}"></div>
|
|
1560
1557
|
</div>
|
|
1561
1558
|
</div>
|
|
1562
|
-
`,this.contexts.confirmConditions=new et(this.node.querySelector(`#${dc}`),{checked:this.confirmConditions,id:hc,disabled:this.notAvailable,name:"confirmConditions",title:`<div>Jag godk\xE4nner <a href="${l}" title="" target="_blank" rel="noopener noreferrer" class="waykeecom-link">k\xF6pvillkor och villkor f\xF6r \xE5ngerr\xE4tt</a>${a?' <span class="waykeecom-text waykeecom-text--margin-left">samt har tagit del av information kring f\xF6rs\xE4kringsf\xF6rmedling</span>':""}.</div>`,value:"confirmConditions",onClick:m=>this.onCheckbox(m)}),this.contexts.startBankid=new fe(this.node.querySelector(`#${mc}`),{title:"Reservera bilen",id:hd,disabled:!this.confirmConditions||this.notAvailable,onClick:()=>{this.view=2,this.render()}}),new ke(this.node.querySelector(`#${pc}`),{text:`Dina personuppgifter behandlas och sparas i enlighet med v\xE5r <a href="${c}" title="personuppgiftspolicy" target="_blank" rel="noopener noreferrer" class="waykeecom-link">personuppgiftspolicy</a>.`}),new ge(this.node.querySelector(`#${uc}`),{text:"Vi reserverar oss f\xF6r eventuell \xE4ndring i tillg\xE5ngen av utbjudna bilar."}),t.stage===this.props.index&&this.node.parentElement?.scrollIntoView()}}},kc=So;var wo=class extends r{constructor(e,t){super(e);this.view=1;this.props=t,_(this.props.store,"navigation",()=>{this.render()}),this.render()}render(){let{store:e,index:t}=this.props,{topNavigation:o,navigation:a,order:n}=e.getState(),l=o.stage>t,c=
|
|
1559
|
+
`,this.contexts.confirmConditions=new et(this.node.querySelector(`#${dc}`),{checked:this.confirmConditions,id:hc,disabled:this.notAvailable,name:"confirmConditions",title:`<div>Jag godk\xE4nner <a href="${l}" title="" target="_blank" rel="noopener noreferrer" class="waykeecom-link">k\xF6pvillkor och villkor f\xF6r \xE5ngerr\xE4tt</a>${a?' <span class="waykeecom-text waykeecom-text--margin-left">samt har tagit del av information kring f\xF6rs\xE4kringsf\xF6rmedling</span>':""}.</div>`,value:"confirmConditions",onClick:m=>this.onCheckbox(m)}),this.contexts.startBankid=new fe(this.node.querySelector(`#${mc}`),{title:"Reservera bilen",id:hd,disabled:!this.confirmConditions||this.notAvailable,onClick:()=>{this.view=2,this.render()}}),new ke(this.node.querySelector(`#${pc}`),{text:`Dina personuppgifter behandlas och sparas i enlighet med v\xE5r <a href="${c}" title="personuppgiftspolicy" target="_blank" rel="noopener noreferrer" class="waykeecom-link">personuppgiftspolicy</a>.`}),new ge(this.node.querySelector(`#${uc}`),{text:"Vi reserverar oss f\xF6r eventuell \xE4ndring i tillg\xE5ngen av utbjudna bilar."}),t.stage===this.props.index&&this.node.parentElement?.scrollIntoView()}}},kc=So;var wo=class extends r{constructor(e,t){super(e);this.view=1;this.props=t,_(this.props.store,"navigation",()=>{this.render()}),this.render()}render(){let{store:e,index:t}=this.props,{topNavigation:o,navigation:a,order:n}=e.getState(),l=o.stage>t,c=B(this.node,{completed:l,title:n?.isPaymentRequired?"Betalning":"Slutf\xF6r ordern",id:"confirmation",active:a.stage===t});a.stage===t&&(a.subStage===2?new ic(c,{store:e}):new kc(c,{lastStage:!0,index:t,store:this.props.store}),c.parentElement?.scrollIntoView())}},yc=wo;var No=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation.view",o=>{o===2&&this.render()}),this.render(),this.node.scrollTop=0}render(){let{store:e,cdnMedia:t}=this.props,o=e.getState(),{order:a,stages:n}=o;if(!a)throw"No order available";this.node.innerHTML="";let l=document.createElement("div");this.node.appendChild(l);let c=document.createElement("aside");c.className="waykeecom-cart",c.setAttribute("aria-label","Fordonsinformation"),c.innerHTML=sc({vehicle:o.vehicle,order:o.order,cdnMedia:t}),l.appendChild(c);let m=document.createElement("div");m.className="waykeecom-stepper",l.appendChild(m);let u=n?.length;n?.forEach((h,p)=>new st[h.name].component(m,{store:e,index:p+1,lastStage:!1})),new yc(m,{store:e,index:(u||0)+1,lastStage:!0})}},vc=No;var Ao=class extends r{constructor(i){super(i,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--4"})}},Y=Ao;var To=class extends Y{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e}=this.props,t=e.getState(),{order:o,tradeIn:a,tradeInVehicle:n}=t;!o?.allowsTradeIn||(this.node.innerHTML=`
|
|
1563
1560
|
<div class="waykeecom-stack waykeecom-stack--4">
|
|
1564
1561
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
1565
1562
|
<h4 class="waykeecom-heading waykeecom-heading--4 waykeecom-no-margin">Inbytesbil</h4>
|
|
@@ -1645,7 +1642,7 @@
|
|
|
1645
1642
|
</div>
|
|
1646
1643
|
<div class="waykeecom-stack waykeecom-stack--05">
|
|
1647
1644
|
<ul class="waykeecom-key-value-list">
|
|
1648
|
-
${E({key:"Privatleasing",value
|
|
1645
|
+
${E({key:"Privatleasing",value:`Fr\xE5n ${k(l?.price,{postfix:l?.unit})}`})}
|
|
1649
1646
|
</ul>
|
|
1650
1647
|
</div>
|
|
1651
1648
|
`:""}
|
|
@@ -1882,5 +1879,5 @@
|
|
|
1882
1879
|
<div class="waykeecom-stack waykeecom-stack--1" id="${$c}"></div>
|
|
1883
1880
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Pc}"></div>
|
|
1884
1881
|
</div>
|
|
1885
|
-
`,new Je(this.node.querySelector(`#${$c}`),{title:"Forts\xE4tt min order",onClick:()=>t()}),new xc(this.node.querySelector(`#${Pc}`),{title:"Avbryt min order",onClick:()=>e()})}},Hc=Yo;var Ko=()=>{let s=document.documentElement.clientWidth/100;document.documentElement.style.setProperty("--waykeecom-vw",`${s}px`)},Bc=()=>(Ko(),window.addEventListener("resize",Ko),()=>window.removeEventListener("resize",Ko));var
|
|
1882
|
+
`,new Je(this.node.querySelector(`#${$c}`),{title:"Forts\xE4tt min order",onClick:()=>t()}),new xc(this.node.querySelector(`#${Pc}`),{title:"Avbryt min order",onClick:()=>e()})}},Hc=Yo;var Ko=()=>{let s=document.documentElement.clientWidth/100;document.documentElement.style.setProperty("--waykeecom-vw",`${s}px`)},Bc=()=>(Ko(),window.addEventListener("resize",Ko),()=>window.removeEventListener("resize",Ko));var jo="order",kd="wayke-ecom-web-payment",Qo="wayke-ecom-web-id",Ce="wayke-ecom-modal",yd="ecom.wayketech.se",vd="ecom.wayke.se",Ed=s=>{switch(new URL(s).host){case vd:return"https://cdn.wayke.se";case yd:return"https://test-cdn.wayketech.se";default:return}},zo=class{constructor(i){this.contexts={store:gi()};if(!i.id)throw"Missing id";this.props=i,window.process||(window.process={...window.process||{},env:{}}),Fc.config.bind(i.ecomSdkConfig),this.cdnMedia=Ed(i.ecomSdkConfig.api.address);let e=document.createElement("div");if(e.className="waykeecom-root",this.root=e,this.props.rootId){let l=document.getElementById(this.props.rootId);if(!l)throw"Missing element with id wayke-ecom";l.appendChild(e)}else document.body.appendChild(this.root);this.root.dataset.version=Xo.version,this.stageOrderList=["centralStorage","customer","financial","tradeIn","accessories","insurance","delivery"],si(i.id)(this.contexts.store.dispatch),this.view=this.contexts.store.getState().navigation.view,_(this.contexts.store,"navigation.view",l=>{this.view=l,l!=="preview"&&this.render()},!0);let t=new URLSearchParams(location.search),o=t.get(jo)||void 0,a=!!t.get(kd),n=t.get(Qo);if(n&&n===this.props.id&&(o||a))if(a){let l=sessionStorage.getItem("wayke-ecom-state");sessionStorage.removeItem("wayke-ecom-state");let c=l?JSON.parse(l):void 0;c&&(this.view=c.navigation.view,yi({...c,stateLoadedFromSession:!0})(this.contexts.store.dispatch))}else o&&this.render({orderUrl:o,id:n})}close(){let i=Te();i&&d(i.view,"CLOSE",i.currentStep);let{caseId:e}=this.contexts.store.getState(),t=new URLSearchParams(location.search),o=t.get(jo),a=t.get(Qo),n=!1;o&&(t.delete(jo),n=!0,location.search=t.toString()),a&&(t.delete(Qo),n=!0),n&&(location.search=t.toString()),this.root.innerHTML="",this.contexts?.unsubribeVwListner?.(),Ts(),Ni(),e&&Re(e),sessionStorage.removeItem("wayke-ecom-state"),ti(this.props.id)(this.contexts.store.dispatch),this.props.onEvent&&Ti(this.props.onEvent)}destroy(){this.close(),this.root.remove()}closeWithConfirm(){let{navigation:i,createdOrderId:e}=this.contexts.store.getState(),t=i.view==="preview";if(Ts(),t||e){this.close();return}this.contexts.modal=new qo(this.root,{title:"Wayke Ecom",id:Ce,logo:this.props.logo,logoX2:this.props.logoX2});let o=Te();o&&d(o.view,"CONFIRM_CLOSE_ACTIVE"),new Hc(this.contexts.modal.content,{onConfirmClose:()=>{let a=Te();d(a.view,"CONFIRM_CLOSE_CONFIRMED",a.currentStep),this.close()},onAbortClose:()=>{let a=Te();d(a.view,"CONFIRM_CLOSE_ABORTED",a.currentStep),this.render()}})}start(){this.props.onEvent&&Ai(this.props.onEvent),d("PREVIEW","START"),this.render()}render(i){if(this.contexts.unsubribeVwListner||(this.contexts.unsubribeVwListner=Bc()),this.contexts.modal=new qo(this.root,{title:"Wayke Ecom",id:Ce,logo:this.props.logo,logoX2:this.props.logoX2,onClose:()=>this.closeWithConfirm()}),this.contexts.modal.content){if(this.contexts.modal.content.innerHTML="",i){new Ac(this.contexts.modal.content,{store:this.contexts.store,callbackOrder:i,onClose:()=>this.close()});return}switch(this.view){case"preview":new tc(this.contexts.modal.content,{store:this.contexts.store,stageOrderList:this.stageOrderList,vehicle:this.props.vehicle,cdnMedia:this.cdnMedia});break;case"main":new vc(this.contexts.modal.content,{store:this.contexts.store,cdnMedia:this.cdnMedia});break;case"summary":new Nc(this.contexts.modal.content,{store:this.contexts.store,cdnMedia:this.cdnMedia,onClose:()=>this.close()});break;default:throw"Unknown view..."}}}},Uc=zo;var y_=Uc;})();
|
|
1886
1883
|
//# sourceMappingURL=index.js.map
|