@wayke-se/ecom-web 1.5.1-beta.6 → 1.5.1
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 +1 -0
- package/dist/index.js +39 -33
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +39 -33
- package/dist/index.mjs.map +3 -3
- package/package.json +3 -3
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 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.1
|
|
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.1",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",O=(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">
|
|
@@ -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 j=()=>{
|
|
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=()=>{M();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},M=()=>{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,
|
|
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,M(),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"),O("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>
|
|
@@ -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",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"),
|
|
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"),O("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">
|
|
@@ -413,7 +413,7 @@
|
|
|
413
413
|
</div>
|
|
414
414
|
</div>
|
|
415
415
|
</div>
|
|
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
|
|
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:H,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,13 +433,19 @@
|
|
|
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),H&&L.addEventListener("blur",H))}},x=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)}onChangeContacts(){d("MAIN","CUSTOMER_EDIT","CUSTOMER_EMAIL_AND_PHONE"),O("main",1)(this.props.store.dispatch)}render(){let e=this.props.store.getState().navigation.subStage;if(e>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("")}
|
|
440
440
|
</ul>
|
|
441
441
|
</div>
|
|
442
|
-
|
|
442
|
+
`,e<=2&&(this.node.innerHTML+=`
|
|
443
|
+
<div class="waykeecom-stack waykeecom-stack--2">
|
|
444
|
+
<div class="waykeecom-align waykeecom-align--end">
|
|
445
|
+
<button type="button" title="\xC4ndra dina uppgifter" class="waykeecom-link" id="change-contacts">\xC4ndra</button>
|
|
446
|
+
</div>
|
|
447
|
+
</div>
|
|
448
|
+
`)}else this.node.innerHTML=`
|
|
443
449
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
444
450
|
<h4 class="waykeecom-heading waykeecom-heading--4">Kontaktuppgifter</h4>
|
|
445
451
|
<div class="waykeecom-content">
|
|
@@ -452,7 +458,7 @@
|
|
|
452
458
|
<div class="waykeecom-stack waykeecom-stack--2" id="${oa}"></div>
|
|
453
459
|
</div>
|
|
454
460
|
<div class="waykeecom-stack waykeecom-stack--3" id="${ia}"></div>
|
|
455
|
-
`,this.contexts.email=new
|
|
461
|
+
`,this.contexts.email=new x(this.node.querySelector(`#${sa}`),{title:"E-post",value:this.state.value.email,id:Al,error:this.state.interact.email&&!this.state.validation.email,errorMessage:"En giltig e-postadress m\xE5ste anges",name:"email",autocomplete:"email",placeholder:"Ange din e-postadress",onChange:t=>this.onChange(t),onBlur:t=>this.onBlur(t)}),this.contexts.phone=new x(this.node.querySelector(`#${oa}`),{title:"Telefonnummer",value:this.state.value.phone,id:Tl,error:this.state.interact.phone&&!this.state.validation.phone,errorMessage:"Ange ditt telefonnummer",name:"phone",autocomplete:"tel",placeholder:"Ange ditt telefonnummer",onChange:t=>this.onChange(t),onBlur:t=>this.onBlur(t)}),this.contexts.button=new N(this.node.querySelector(`#${ia}`),{title:"G\xE5 vidare",id:Cl,disabled:!(this.state.validation.email&&this.state.validation.phone),onClick:()=>this.onProceed()});this.node.querySelector("#change-contacts")?.addEventListener("click",()=>this.onChangeContacts())}},aa=ts;var ss=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){this.node.innerHTML=`
|
|
456
462
|
<div class="waykeecom-disclaimer">
|
|
457
463
|
<div class="waykeecom-disclaimer__icon" aria-hidden="true">
|
|
458
464
|
<svg
|
|
@@ -499,13 +505,13 @@
|
|
|
499
505
|
<div class="waykeecom-stack waykeecom-stack--2" id="${la}"></div>
|
|
500
506
|
</div>
|
|
501
507
|
</div>
|
|
502
|
-
`,this.contexts.socialId=new
|
|
508
|
+
`,this.contexts.socialId=new x(this.node.querySelector(`#${is}`),{title:"Personnummer",value:this.state.value.socialId,id:Ke,error:this.state.interact.socialId&&!this.state.validation.socialId,errorMessage:"Ange personnummer i formatet \xC5\xC5\xC5\xC5MMDD-XXXX. M\xE5ste vara \xF6ver 18 \xE5r.",name:"socialId",placeholder:"\xC5\xC5\xC5\xC5MMDD-XXXX",pattern:"[0-9]*",inputmode:"numeric",onChange:t=>this.onChange(t),onBlur:t=>this.onBlur(t)}),Object.keys(this.state.value).forEach(t=>this.updateUiError(t)),this.contexts.buttonFetch=new N(this.node.querySelector(`#${ca}`),{title:"H\xE4mta uppgifter",id:Rl,disabled:!this.state.validation.socialId,onClick:()=>this.onFetchAddress()}),new ke(this.node.querySelector(`#${la}`),{text:`Dina personuppgifter behandlas och sparas i enlighet med v\xE5r <a href="${e}" title="personuppgiftspolicy" target="_blank" rel="noopener noreferrer" class="waykeecom-link">personuppgiftspolicy</a>.`}),this.updateProceedButton()}},da=ns;var rs=class extends r{constructor(e,t){super(e,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--2"});this.props=t;let o=this.props.store.getState();this.state=o.customer,this.render()}render(){let{store:e,lastStage:t}=this.props;if(e.getState().navigation.subStage>2){let a=[{key:"Personnummer",value:this.state.socialId}];this.node.innerHTML=`
|
|
503
509
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
504
510
|
<ul class="waykeecom-key-value-list">
|
|
505
511
|
${a.map(n=>E(n)).join("")}
|
|
506
512
|
</ul>
|
|
507
513
|
</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"),
|
|
514
|
+
`}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"),O("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"),O("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
515
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
510
516
|
<h4 class="waykeecom-heading waykeecom-heading--4">Hur vill du ha din bil levererad?</h4>
|
|
511
517
|
<div class="waykeecom-content">
|
|
@@ -543,9 +549,9 @@
|
|
|
543
549
|
</div>
|
|
544
550
|
</div>
|
|
545
551
|
</div>
|
|
546
|
-
`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${y===0?"Gratis":k(y,{postfix:"kr"})}</div>`,checked:!this.homeDelivery,onClick
|
|
552
|
+
`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${y===0?"Gratis":k(y,{postfix:"kr"})}</div>`,checked:!this.homeDelivery,onClick:H=>this.onChange(H)});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
553
|
<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
|
|
554
|
+
${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:H=>this.onChange(H)});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
555
|
<div class="waykeecom-input-label">
|
|
550
556
|
<label for="${a}" class="waykeecom-input-label__label">${e}</label>
|
|
551
557
|
</div>
|
|
@@ -738,7 +744,7 @@
|
|
|
738
744
|
${u.value===o?'selected="selected"':""}
|
|
739
745
|
>${u.title||u.value}</option>`).join("")}
|
|
740
746
|
</select>
|
|
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=`
|
|
747
|
+
`,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",P={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:P.maritalStatus(i.maritalStatus),income:P.income(i.income),employment:P.employment(i.employment),householdChildren:P.householdChildren(i.householdChildren),housingCost:P.housingCost(i.housingCost),"debtSpecification.cardCredits":P["debtSpecification.cardCredits"](i["debtSpecification.cardCredits"]),"debtSpecification.vehicleLoan":P["debtSpecification.vehicleLoan"](i["debtSpecification.vehicleLoan"]),"debtSpecification.collateral":P["debtSpecification.collateral"](i["debtSpecification.collateral"]),"debtSpecification.leasingFees":P["debtSpecification.leasingFees"](i["debtSpecification.leasingFees"]),"debtSpecification.privateLoan":P["debtSpecification.privateLoan"](i["debtSpecification.privateLoan"]),housingType:P.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]=P[o](a),this.updateUiError(o),this.updateProceedButton()}onBlur(e){let o=e.currentTarget.name;this.state.interact[o]=!0,this.state.validation[o]=P[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]=P[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]=P[o](a),o==="housingType"&&(t.value===S.HousingType.SingleFamily?(this.state.value.housingCost="0",this.state.validation.housingCost=P.housingCost(this.state.value.housingCost)):(this.state.value.housingCost="",this.state.validation.housingCost=P.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)),M(),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),M(),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,M(),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:()=>{M(),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=`
|
|
742
748
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
743
749
|
<h5 class="waykeecom-heading waykeecom-heading--4">L\xE5neans\xF6kan</h5>
|
|
744
750
|
<div class="waykeecom-content">
|
|
@@ -847,37 +853,37 @@
|
|
|
847
853
|
<div class="waykeecom-stack waykeecom-stack--1" id="${hn}"></div>
|
|
848
854
|
</div>
|
|
849
855
|
</div>
|
|
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
|
|
856
|
+
`,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 x(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 x(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:`
|
|
851
857
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
852
858
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Inkomst per m\xE5nad f\xF6re skatt</span></p>
|
|
853
859
|
<p class="waykeecom-content__p">L\xF6n och/eller pension, inte bidrag eller studiel\xE5n.</p>
|
|
854
860
|
</div>
|
|
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
|
|
861
|
+
`,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 x(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?`
|
|
856
862
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
857
863
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Min del av m\xE5nadsavgiften</span></p>
|
|
858
864
|
<p class="waykeecom-content__p">Exklusive r\xE4nta och amortering</p>
|
|
859
865
|
</div>
|
|
860
|
-
`:void 0,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p),onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_HOUSEHOLD_DEBT_INFORMATION_TOGGLE","FINANCIAL")}})),this.contexts["debtSpecification.cardCredits"]=new
|
|
866
|
+
`:void 0,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p),onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_HOUSEHOLD_DEBT_INFORMATION_TOGGLE","FINANCIAL")}})),this.contexts["debtSpecification.cardCredits"]=new x(this.node.querySelector(`#${rn}`),{title:"Kortkrediter",value:this.state.value["debtSpecification.cardCredits"],id:vn,error:this.state.interact["debtSpecification.cardCredits"]&&!this.state.validation["debtSpecification.cardCredits"],errorMessage:"Ange kortkrediter eller l\xE4mna tomt",name:"debtSpecification.cardCredits",autocomplete:"off",placeholder:"",unit:"kr",type:"number",min:0,information:`
|
|
861
867
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
862
868
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Kortkrediter</span></p>
|
|
863
869
|
<p class="waykeecom-content__p">Total skuld</p>
|
|
864
870
|
</div>
|
|
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
|
|
871
|
+
`,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 x(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:`
|
|
866
872
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
867
873
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Bill\xE5n</span></p>
|
|
868
874
|
<p class="waykeecom-content__p">Total skuld. Ange inte skuld f\xF6r bil som ska ers\xE4ttas.</p>
|
|
869
875
|
</div>
|
|
870
|
-
`,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p),onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DEBT_SPECIFICATION_CAR_LOAN_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts["debtSpecification.collateral"]=new
|
|
876
|
+
`,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p),onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DEBT_SPECIFICATION_CAR_LOAN_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts["debtSpecification.collateral"]=new x(this.node.querySelector(`#${ln}`),{title:"Borgens\xE5tagande ",value:this.state.value["debtSpecification.collateral"],id:In,error:this.state.interact["debtSpecification.collateral"]&&!this.state.validation["debtSpecification.collateral"],errorMessage:"Ange borgens\xE5tagande eller l\xE4mna tomt",name:"debtSpecification.collateral",autocomplete:"off",placeholder:"",unit:"kr",type:"number",min:0,information:`
|
|
871
877
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
872
878
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Borgens\xE5tagande</span></p>
|
|
873
879
|
<p class="waykeecom-content__p">Totalt belopp.</p>
|
|
874
880
|
</div>
|
|
875
|
-
`,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p),onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DEBT_SPECIFICATION_COLLATERAL_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts["debtSpecification.leasingFees"]=new
|
|
881
|
+
`,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p),onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DEBT_SPECIFICATION_COLLATERAL_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts["debtSpecification.leasingFees"]=new x(this.node.querySelector(`#${dn}`),{title:"Billeasing ",value:this.state.value["debtSpecification.leasingFees"],id:fn,error:this.state.interact["debtSpecification.leasingFees"]&&!this.state.validation["debtSpecification.leasingFees"],errorMessage:"Ang billeasingkostnader eller l\xE4mna tomt",name:"debtSpecification.leasingFees",autocomplete:"off",placeholder:"",unit:"kr",type:"number",min:0,information:`
|
|
876
882
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
877
883
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Billeasing</span></p>
|
|
878
884
|
<p class="waykeecom-content__p">Ange inte m\xE5nadskostnad f\xF6r bil som skall ers\xE4ttas</p>
|
|
879
885
|
</div>
|
|
880
|
-
`,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p),onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DEBT_SPECIFICATION_LEASING_FEES_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts["debtSpecification.privateLoan"]=new
|
|
886
|
+
`,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p),onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DEBT_SPECIFICATION_LEASING_FEES_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts["debtSpecification.privateLoan"]=new x(this.node.querySelector(`#${mn}`),{title:"Privatl\xE5n (ej bol\xE5n och CSN)",value:this.state.value["debtSpecification.privateLoan"],id:gn,error:this.state.interact["debtSpecification.privateLoan"]&&!this.state.validation["debtSpecification.privateLoan"],errorMessage:"Ange privatl\xE5n eller l\xE4mna tomt",name:"debtSpecification.privateLoan",autocomplete:"off",placeholder:"",unit:"kr",type:"number",min:0,information:`
|
|
881
887
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
882
888
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Privatl\xE5n (ej bol\xE5n och CSN)</span></p>
|
|
883
889
|
<p class="waykeecom-content__p">Total skuld, t.ex. blancol\xE5n och sms-l\xE5n</p>
|
|
@@ -1059,14 +1065,14 @@
|
|
|
1059
1065
|
<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>
|
|
1060
1066
|
<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>
|
|
1061
1067
|
</div>
|
|
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*"})}]
|
|
1068
|
+
`,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*"})}],H=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=`
|
|
1063
1069
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
1064
1070
|
<h4 class="waykeecom-heading waykeecom-heading--4">Bill\xE5n</h4>
|
|
1065
1071
|
<div class="waykeecom-content">
|
|
1066
1072
|
<p class="waykeecom-content__p">Ordern \xE4r snart klar, h\xE4r ser du ditt l\xE5nebesked:</p>
|
|
1067
1073
|
</div>
|
|
1068
1074
|
</div>
|
|
1069
|
-
${
|
|
1075
|
+
${H?`<div class="waykeecom-stack waykeecom-stack--2" id="${qn}"></div>`:""}
|
|
1070
1076
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
1071
1077
|
<div class="waykeecom-stack waykeecom-stack--1">
|
|
1072
1078
|
<ul class="waykeecom-key-value-list">
|
|
@@ -1082,7 +1088,7 @@
|
|
|
1082
1088
|
<button type="button" title="\xC4ndra finansiering" class="waykeecom-link">\xC4ndra</button>
|
|
1083
1089
|
</div>
|
|
1084
1090
|
</div>
|
|
1085
|
-
|
|
1091
|
+
`,H&&new ae(this.node.querySelector(`#${qn}`),{store:e,decision:H})}else this.node.innerHTML=`
|
|
1086
1092
|
<div class="waykeecom-stack waykeecom-stack--1">
|
|
1087
1093
|
<ul class="waykeecom-key-value-list">
|
|
1088
1094
|
${E({key:"Finansiering",value:t===Us.PaymentType.Cash?"Kontant":"Privatleasing"})}
|
|
@@ -1095,7 +1101,7 @@
|
|
|
1095
1101
|
</div>
|
|
1096
1102
|
</div>
|
|
1097
1103
|
`:""}
|
|
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"),
|
|
1104
|
+
`;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"),O("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=`
|
|
1099
1105
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1100
1106
|
<h4 class="waykeecom-heading waykeecom-heading--4 waykeecom-no-margin">Hur vill du finansiera din ${h?.title} ${pe(h)}?</h4>
|
|
1101
1107
|
</div>
|
|
@@ -1144,11 +1150,11 @@
|
|
|
1144
1150
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1145
1151
|
<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>
|
|
1146
1152
|
</div>
|
|
1147
|
-
`,options:R,onClick:L=>this.onChange(L),onClickInformation:()=>{d("MAIN","FINANCIAL_INFORMATION_TOGGLE","FINANCIAL")}});let
|
|
1153
|
+
`,options:R,onClick:L=>this.onChange(L),onClickInformation:()=>{d("MAIN","FINANCIAL_INFORMATION_TOGGLE","FINANCIAL")}});let H=[];g&&(H.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:`
|
|
1148
1154
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1149
1155
|
<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>
|
|
1150
1156
|
</div>
|
|
1151
|
-
`,options
|
|
1157
|
+
`,options:H,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=`
|
|
1152
1158
|
<input
|
|
1153
1159
|
type="checkbox"
|
|
1154
1160
|
id="${e}"
|
|
@@ -1228,7 +1234,7 @@
|
|
|
1228
1234
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Qs}"></div>
|
|
1229
1235
|
<div class="waykeecom-stack waykeecom-stack--1" id="${tr}"></div>
|
|
1230
1236
|
</div>
|
|
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,
|
|
1237
|
+
`,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,M(),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=`
|
|
1232
1238
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1233
1239
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vill du teckna en f\xF6rs\xE4kring p\xE5 din nya bil?</h4>
|
|
1234
1240
|
<div class="waykeecom-content">
|
|
@@ -1302,7 +1308,7 @@
|
|
|
1302
1308
|
<div class="waykeecom-stack waykeecom-stack--1" id="${wr}"></div>
|
|
1303
1309
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Sr}"></div>
|
|
1304
1310
|
</div>
|
|
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,
|
|
1311
|
+
`,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,M(),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=`
|
|
1306
1312
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1307
1313
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vill du teckna en f\xF6rs\xE4kring p\xE5 din nya bil?</h4>
|
|
1308
1314
|
<div class="waykeecom-content">
|
|
@@ -1314,7 +1320,7 @@
|
|
|
1314
1320
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Cr}"></div>
|
|
1315
1321
|
<div class="waykeecom-stack waykeecom-stack--1" id="${rd}"></div>
|
|
1316
1322
|
</div>
|
|
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()),
|
|
1323
|
+
`,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()),O("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=`
|
|
1318
1324
|
<div class="waykeecom-input-label">
|
|
1319
1325
|
<label for="${a}" class="waykeecom-input-label__label">${e}</label>
|
|
1320
1326
|
</div>
|
|
@@ -1409,13 +1415,13 @@
|
|
|
1409
1415
|
<div class="waykeecom-stack waykeecom-stack--1" id="${$r}"></div>
|
|
1410
1416
|
<div class="waykeecom-stack waykeecom-stack--1" id="${tt}"></div>
|
|
1411
1417
|
</div>
|
|
1412
|
-
`,this.contexts.registrationNumber=new
|
|
1418
|
+
`,this.contexts.registrationNumber=new x(this.node.querySelector(`#${Or}`),{title:"Registreringsnummer",value:this.state.value.registrationNumber,id:Fr,error:this.state.interact.registrationNumber&&!this.state.validation.registrationNumber,errorMessage:"Ett giltig registreringsnummer i formatet ABC123 eller ABC12A m\xE5ste anges",name:"registrationNumber",autocomplete:"off",placeholder:"Ange registreringsnummer",unit:`
|
|
1413
1419
|
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 34" class="waykeecom-input-text__unit-regnr-icon" aria-hidden="true">
|
|
1414
1420
|
<rect width="22" height="34" rx="1" fill="#458BDD"/>
|
|
1415
1421
|
<circle cx="11" cy="10" r="5.5" stroke="#FFF500" stroke-linejoin="round" stroke-dasharray="1 2"/>
|
|
1416
1422
|
<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"/>
|
|
1417
1423
|
</svg>
|
|
1418
|
-
`,onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.mileage=new
|
|
1424
|
+
`,onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.mileage=new x(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"),O("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=`
|
|
1419
1425
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1420
1426
|
<div class="waykeecom-balloon">
|
|
1421
1427
|
<div class="waykeecom-stack waykeecom-stack--05">
|
|
@@ -1479,7 +1485,7 @@
|
|
|
1479
1485
|
<ul class="waykeecom-checklist" aria-label="F\xF6rdelar med att k\xF6pa bilen online hos oss">
|
|
1480
1486
|
${this.props.checklistItems.map(e=>` <li class="waykeecom-checklist__item">${e}</li>`).join("")}
|
|
1481
1487
|
</ul>
|
|
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"),
|
|
1488
|
+
`}},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"),O("main")(this.props.store.dispatch)}render(){let{store:e,cdnMedia:t}=this.props,o=e.getState();if(!o.order){this.node.innerHTML=`
|
|
1483
1489
|
${this.requestError?I({tone:"error",children:"Ett fel uppstod och det gick inte att initiera modulen. F\xF6rs\xF6k igen."}):b()}
|
|
1484
1490
|
`;return}this.node.innerHTML=`
|
|
1485
1491
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
@@ -1525,7 +1531,7 @@
|
|
|
1525
1531
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1526
1532
|
<div id="payment-menu" style="padding: 24px;border: 1px solid #ececeb;"></div>
|
|
1527
1533
|
</div>
|
|
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
|
|
1534
|
+
`}},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 $=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=$.customers.newCustomer().withAddress(i.address).withPersonalNumber(i.customer.socialId).withEmail(i.customer.email).withPhoneNumber(i.customer.phone).build(),t=$.orders.newPayment().withType(i.paymentType);if(i.paymentType===$.PaymentType.Loan){let m=i.order?.paymentOptions.find(w=>w.type===$.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===$.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,H=i.creditAssessmentResponse.decision,X=u?.financialProductCode;if(!w||!R||!H||!X)throw"Missing credit assessment data";let L=$.orders.newCreditAssessment().withScoreId(w).withFinancialProductCode(X).withRecommendation(R).withDecision(H).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=$.orders.newCreateRequest().forVehicle(i.id).withCustomer(e).withPayment(o).withUrls(n,l).withDeliveryType(i.homeDelivery?$.DeliveryType.Delivery:$.DeliveryType.Pickup);if(i.insurance){let m=$.orders.newInsurance().withDrivingDistance(i.drivingDistance);i.insuranceAddOns?.addOns.length&&i.insuranceAddOns.insurance===i.insurance.name&&m.withAddOns(i.insuranceAddOns.addOns.map(h=>h.name));let u=m.build();c.withInsurance(u)}else i.freeInsurance&&c.withInsurance({});if(i.accessories.length&&c.withAccessories(i.accessories),i.tradeIn&&i.tradeInVehicle&&i.tradeIn.condition){let m=$.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 $.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&&M();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),M(),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,M(),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,M(),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,M(),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=`
|
|
1529
1535
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1530
1536
|
<h4 class="waykeecom-heading waykeecom-heading--4">Strax klart!</h4>
|
|
1531
1537
|
<div class="waykeecom-content">
|