@wayke-se/ecom-web 1.5.0-beta.6 → 1.5.1-beta.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.js +35 -42
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +33 -40
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(()=>{var Yc=Object.create;var Jo=Object.defineProperty;var Kc=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";(()=>{var Yc=Object.create;var Jo=Object.defineProperty;var Kc=Object.getOwnPropertyDescriptor;var Qc=Object.getOwnPropertyNames;var zc=Object.getPrototypeOf,jc=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 Qc(i))!jc.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(zc(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-beta.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-beta.5",marked:"^4.3.0","object-path":"^0.11.8",redux:"^4.1.2","sanitize-html":"^2.7.0"},files:["dist"]};var fi=f("redux");var Ae=f("@wayke-se/ecom");var ot=(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",$=(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
|
|
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 Q=()=>{O();let s=document.getElementById("wayke-ecom-modal-body");s&&s.firstElementChild.setAttribute("hidden","");let i=document.createElement("div");return i.className="waykeecom-portal",s?.appendChild(i),i},O=()=>{let s=document.getElementById("wayke-ecom-modal-body");s&&s.firstElementChild.removeAttribute("hidden"),s?.childNodes.forEach((i,e)=>{e>0&&i.remove()})};var Ft=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{title:e,id:t,onClick:o}=this.props;this.node.innerHTML=`
|
|
219
219
|
<button type="button" id="${t}" title="${e}" class="waykeecom-button waykeecom-button--full-width waykeecom-button--action-clear">
|
|
220
220
|
${e}
|
|
221
221
|
</button>
|
|
@@ -295,7 +295,7 @@
|
|
|
295
295
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Mi}"></div>
|
|
296
296
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Oi}"></div>
|
|
297
297
|
</div>
|
|
298
|
-
`,new bi(this.node.querySelector(`#${xi}`),{id:`gallery-${e.id}`,media:l.map((y,g)=>({url:y.url,alt:`Bild ${g+1}`})),onGalleryImagePaging:()=>this.onGalleryImagePaging()}),new ce(this.node.querySelector(`#${Li}`),{title:"Tillbaka",onClick:()=>a()}),new te(this.node.querySelector(`#${Oi}`),{title:"Tillbaka",onClick:()=>a()}),new ee(this.node.querySelector(`#${Mi}`),{selected:t,fullSize:!0,onClick:()=>o()}),G()}},Pi=Wt;var Yt=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.exposureTracked=!1;this.props=t,_(this.props.store,"accessories",(o,a)=>{o.some(n=>n.id===this.props.accessory.id)!==a.some(n=>n.id===this.props.accessory.id)&&this.render()}),this.render()}onInfoOpen(){let{accessory:e}=this.props;d("MAIN","ACCESSORY_INFORMATION_OPEN","ACCESSORY",{id:e.id,label:e.name}),this.displayInfo=!0,this.render()}onInfoClose(){let{accessory:e}=this.props;d("MAIN","ACCESSORY_INFORMATION_CLOSE","ACCESSORY",{id:e.id,label:e.name}),this.displayInfo=!1,O(),this.render(),this.node.parentElement?.scrollIntoView()}onClick(){let{store:e,accessory:t}=this.props,a=e.getState().accessories.findIndex(n=>n.id===t.id)>-1;d("MAIN",a?"ACCESSORY_UNSELECTED":"ACCESSORY_SELECTED","ACCESSORY",{id:t.id,label:t.name}),ui(this.props.accessory)(this.props.store.dispatch)}trackExposure(){let{accessory:e}=this.props;this.exposureTracked=!0,d("MAIN","ACCESSORY_EXPOSURE","ACCESSORY",{id:e.id,label:e.name})}render(){let{store:e,accessory:t,key:o}=this.props,n=e.getState().accessories.findIndex(l=>l.id===t.id)>-1;this.displayInfo&&new Pi(
|
|
298
|
+
`,new bi(this.node.querySelector(`#${xi}`),{id:`gallery-${e.id}`,media:l.map((y,g)=>({url:y.url,alt:`Bild ${g+1}`})),onGalleryImagePaging:()=>this.onGalleryImagePaging()}),new ce(this.node.querySelector(`#${Li}`),{title:"Tillbaka",onClick:()=>a()}),new te(this.node.querySelector(`#${Oi}`),{title:"Tillbaka",onClick:()=>a()}),new ee(this.node.querySelector(`#${Mi}`),{selected:t,fullSize:!0,onClick:()=>o()}),G()}},Pi=Wt;var Yt=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.exposureTracked=!1;this.props=t,_(this.props.store,"accessories",(o,a)=>{o.some(n=>n.id===this.props.accessory.id)!==a.some(n=>n.id===this.props.accessory.id)&&this.render()}),this.render()}onInfoOpen(){let{accessory:e}=this.props;d("MAIN","ACCESSORY_INFORMATION_OPEN","ACCESSORY",{id:e.id,label:e.name}),this.displayInfo=!0,this.render()}onInfoClose(){let{accessory:e}=this.props;d("MAIN","ACCESSORY_INFORMATION_CLOSE","ACCESSORY",{id:e.id,label:e.name}),this.displayInfo=!1,O(),this.render(),this.node.parentElement?.scrollIntoView()}onClick(){let{store:e,accessory:t}=this.props,a=e.getState().accessories.findIndex(n=>n.id===t.id)>-1;d("MAIN",a?"ACCESSORY_UNSELECTED":"ACCESSORY_SELECTED","ACCESSORY",{id:t.id,label:t.name}),ui(this.props.accessory)(this.props.store.dispatch)}trackExposure(){let{accessory:e}=this.props;this.exposureTracked=!0,d("MAIN","ACCESSORY_EXPOSURE","ACCESSORY",{id:e.id,label:e.name})}render(){let{store:e,accessory:t,key:o}=this.props,n=e.getState().accessories.findIndex(l=>l.id===t.id)>-1;this.displayInfo&&new Pi(Q(),{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",Qt=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"),$("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=H(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 j(l,{keyValueList:o.accessories.length?o.accessories.map(m=>({key:m.name,image:m.media[0]?{src:`${m.media[0].url}?w=32&h=32`,srcSet:`${m.media[0].url}?w=64&h=64 2x`,alt:m.name}:void 0,value:k(m.price,{postfix:"kr"})})):[{key:"Tillbeh\xF6r",value:"Inga valda"}],changeButtonTitle:"\xC4ndra tillbeh\xF6r",onEdit:o.createdOrderId?void 0:()=>this.onEdit()});else if(o.navigation.stage===t){let m=o.order?.accessories||[];c.innerHTML=`
|
|
299
299
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
300
300
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
301
301
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vill du k\xF6pa till ett tillbeh\xF6r till din nya bil?</h4>
|
|
@@ -311,7 +311,7 @@
|
|
|
311
311
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Bi}"></div>
|
|
312
312
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Fi}"></div>
|
|
313
313
|
</div>
|
|
314
|
-
`,new Hi(c.querySelector(`#${Ui}`),{store:e,accessories:m}),new N(c.querySelector(`#${Bi}`),{id:Vi,title:"G\xE5 vidare",onClick:()=>this.onProceed()}),new K(c.querySelector(`#${Fi}`),{title:"Hoppa \xF6ver detta steg",onClick:()=>this.onProceed()})}l.appendChild(c),o.navigation.stage===t&&l.parentElement?.scrollIntoView()}},Gi=
|
|
314
|
+
`,new Hi(c.querySelector(`#${Ui}`),{store:e,accessories:m}),new N(c.querySelector(`#${Bi}`),{id:Vi,title:"G\xE5 vidare",onClick:()=>this.onProceed()}),new K(c.querySelector(`#${Fi}`),{title:"Hoppa \xF6ver detta steg",onClick:()=>this.onProceed()})}l.appendChild(c),o.navigation.stage===t&&l.parentElement?.scrollIntoView()}},Gi=Qt;var qi="waykeecom-input-error",zt=class extends r{constructor(e,t){super(e);this.props=t,this.render()}setError(e){this.props.error=e,this.render()}render(){let{error:e,errorMessage:t}=this.props,o=this.node.querySelector(`.${qi}`);if(o)e||o.remove();else if(e){let a=document.createElement("div");a.className=qi,a.setAttribute("role","alert"),a.innerHTML=t,this.node.appendChild(a)}}},se=zt;var jt=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{id:e,title:t,value:o,name:a,checked:n,meta:l,description:c,disabled:m,onClick:u}=this.props;this.node.innerHTML=`
|
|
315
315
|
<div class="waykeecom-input-selection" role="radio">
|
|
316
316
|
<input
|
|
317
317
|
type="radio"
|
|
@@ -363,7 +363,7 @@
|
|
|
363
363
|
${e?`<legend class="waykeecom-input-label"><div class="waykeecom-input-label__label">${e}</div></legend>`:""}
|
|
364
364
|
${t.map(h=>`<div class="waykeecom-input-group__item" id="${h.id}-node"></div>`).join("")}
|
|
365
365
|
</fieldset>
|
|
366
|
-
`,this.updateBorder(),l&&(this.contexts.error=new se(this.node,{error:n,errorMessage:l})),t.forEach(h=>new be(this.node.querySelector(`#${h.id}-node`),{id:h.id,name:o,title:h.title||h.value,value:h.value,checked:a===h.value,description:h.description,meta:h.meta,onClick:p=>m(p)})),c&&new oe(this.node.querySelector(".waykeecom-input-label"),{information:c,onClickInformation:u})}},
|
|
366
|
+
`,this.updateBorder(),l&&(this.contexts.error=new se(this.node,{error:n,errorMessage:l})),t.forEach(h=>new be(this.node.querySelector(`#${h.id}-node`),{id:h.id,name:o,title:h.title||h.value,value:h.value,checked:a===h.value,description:h.description,meta:h.meta,onClick:p=>m(p)})),c&&new oe(this.node.querySelector(".waykeecom-input-label"),{information:c,onClickInformation:u})}},z=Xt;var wl=({tone:s,children:i})=>`
|
|
367
367
|
<div class="waykeecom-alert ${s?`waykeecom-alert--${s}`:""}" role="alert">
|
|
368
368
|
<div class="waykeecom-alert__icon">
|
|
369
369
|
<div class="waykeecom-alert__icon-badge">
|
|
@@ -381,7 +381,7 @@
|
|
|
381
381
|
${i}
|
|
382
382
|
</div>
|
|
383
383
|
</div>
|
|
384
|
-
`,I=wl;var
|
|
384
|
+
`,I=wl;var zi="button-central-storage-proceed",Ki=`${zi}-node`,Nl="central-storage-branch",Qi=`${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"),$("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=H(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 j(u,{keyValueList:[{key:"Val av anl\xE4ggning",value:h?.name||""}],changeButtonTitle:"\xC4ndra",onEdit:a?void 0:()=>this.onEdit()})}else if(t.stage===n){u.innerHTML=`
|
|
385
385
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
386
386
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vilken anl\xE4ggning vill du k\xF6pa ifr\xE5n?</h4>
|
|
387
387
|
<div class="waykeecom-content">
|
|
@@ -389,7 +389,7 @@
|
|
|
389
389
|
</div>
|
|
390
390
|
</div>
|
|
391
391
|
|
|
392
|
-
<div class="waykeecom-stack waykeecom-stack--3" id="${
|
|
392
|
+
<div class="waykeecom-stack waykeecom-stack--3" id="${Qi}"></div>
|
|
393
393
|
|
|
394
394
|
${this.requestError?`<div class="waykeecom-stack waykeecom-stack--3">${I({tone:"error",children:"Ett fel uppstod och det gick inte att v\xE4lja ovanst\xE5ende anl\xE4ggning. F\xF6rs\xF6k igen."})}</div>`:""}
|
|
395
395
|
|
|
@@ -413,7 +413,7 @@
|
|
|
413
413
|
</div>
|
|
414
414
|
</div>
|
|
415
415
|
</div>
|
|
416
|
-
</div>`}});new
|
|
416
|
+
</div>`}});new z(u.querySelector(`#${Qi}`),{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:zi,disabled:!this.selectedDealer,onClick:()=>this.onProceed()})}t.stage===n&&u.parentElement?.scrollIntoView()}},ji=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:P,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>
|
|
@@ -586,7 +586,7 @@
|
|
|
586
586
|
</div>
|
|
587
587
|
`:""}
|
|
588
588
|
</div>
|
|
589
|
-
`,n&&new oe(this.node.querySelector(".waykeecom-input-label"),{information:n,onClickInformation:m}),u){this.contexts.rangeSlider=this.node.querySelector(`#${a}`)||void 0,this.contexts.rangeSlider&&(c&&this.contexts.rangeSlider.addEventListener("change",c),this.contexts.rangeSlider.addEventListener("input",p=>this.onInput(p)),this.updateRangeSliderColor(this.contexts.rangeSlider));let h=this.node.querySelector(`#${a}-input`);h&&(h.addEventListener("change",p=>this.onChange(p)),h.addEventListener("blur",p=>this.onBlur(p)))}}},
|
|
589
|
+
`,n&&new oe(this.node.querySelector(".waykeecom-input-label"),{information:n,onClickInformation:m}),u){this.contexts.rangeSlider=this.node.querySelector(`#${a}`)||void 0,this.contexts.rangeSlider&&(c&&this.contexts.rangeSlider.addEventListener("change",c),this.contexts.rangeSlider.addEventListener("input",p=>this.onInput(p)),this.updateRangeSliderColor(this.contexts.rangeSlider));let h=this.node.querySelector(`#${a}-input`);h&&(h.addEventListener("change",p=>this.onChange(p)),h.addEventListener("blur",p=>this.onBlur(p)))}}},Qe=ms;var ps=f("@wayke-se/ecom"),ga=({vehicleId:s,dealerId:i,downPayment:e,duration:t,residual:o})=>{let a=ps.payments.newLookupRequest().forVehicle(s).withDownPayment(e).withDuration(t);return o!==void 0&&a.withResidualValue(o),i!==void 0&&a.forDealer(i),ps.payments.lookupPayment(a.build())};var S=f("@wayke-se/ecom");var us=class extends r{constructor(e,t){super(e,t.append?{htmlTag:"div",className:"waykeecom-accordion"}:void 0);this.props=t,this.render()}render(){let{title:e,description:t,onClick:o}=this.props,a=`
|
|
590
590
|
<input
|
|
591
591
|
type="checkbox"
|
|
592
592
|
id="${this.props.id}"
|
|
@@ -609,7 +609,7 @@
|
|
|
609
609
|
<div class="waykeecom-accordion__body">${t}</div>
|
|
610
610
|
`;this.props.append&&(this.node.innerHTML=a),this.node.innerHTML=`
|
|
611
611
|
${a}
|
|
612
|
-
`,o&&this.node.querySelector("input")?.addEventListener("click",()=>o())}},
|
|
612
|
+
`,o&&this.node.querySelector("input")?.addEventListener("click",()=>o())}},ze=us;var q=f("@wayke-se/ecom");var Ie=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);var hs=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{qrCode:e,errorMessage:t}=this.props;if(t){this.node.innerHTML=I({tone:"error",children:t});return}this.node.innerHTML=`
|
|
613
613
|
${e?`
|
|
614
614
|
<div class="waykeecom-stack waykeecom-stack--4">
|
|
615
615
|
<div class="waykeecom-align waykeecom-align--center">
|
|
@@ -719,10 +719,10 @@
|
|
|
719
719
|
${b({type:"inline"})}
|
|
720
720
|
</span>`:""}
|
|
721
721
|
</button>
|
|
722
|
-
`,n&&this.node.querySelector("button")?.addEventListener("click",n)}},Je=Ss;var Bl="assessment-rejected-result",
|
|
723
|
-
<div class="waykeecom-stack waykeecom-stack--4" id="${za}"></div>
|
|
722
|
+
`,n&&this.node.querySelector("button")?.addEventListener("click",n)}},Je=Ss;var Bl="assessment-rejected-result",Qa=`${Bl}-node`,Ja="assessment-rejected-abort",za=`${Ja}-node`,ws=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,onGoBack:t}=this.props;this.node.innerHTML=`
|
|
724
723
|
<div class="waykeecom-stack waykeecom-stack--4" id="${Qa}"></div>
|
|
725
|
-
|
|
724
|
+
<div class="waykeecom-stack waykeecom-stack--4" id="${za}"></div>
|
|
725
|
+
`,new ae(this.node.querySelector(`#${Qa}`),{store:e,decision:ja.CreditAssessmentRecommendation.Reject}),new Je(this.node.querySelector(`#${za}`),{title:"G\xE5 tillbaka",id:Ja,onClick:()=>t()})}},Xa=ws;var As=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,creditAssessmentResponse:t,onProceed:o,onGoBack:a}=this.props,n=t.recommendation;n===Ns.CreditAssessmentRecommendation.Approve?new Fa(this.node,{store:e,onProceed:()=>o(),onGoBack:()=>a()}):n===Ns.CreditAssessmentRecommendation.AssessManually?new Ka(this.node,{store:e,onProceed:()=>o(),onGoBack:()=>a()}):new Xa(this.node,{store:e,onGoBack:()=>a()})}},Za=As;var Fl=s=>{let i=s>0,e=s%12===0;if(!i||!e)throw new TypeError("Invalid months for creating creidt assessment term");return`${s}months`},en=Fl;var Xe={},Oe=(s,i)=>{Xe[s]=i},Ts=()=>{Object.keys(Xe).forEach(s=>{clearInterval(Xe[s]),delete Xe[s]})};var tn=f("@wayke-se/ecom"),Cs=s=>tn.creditAssessment.decline(s);var Ds=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t,this.render()}updateBorder(){let e=this.node.querySelector(".waykeecom-input-text");e&&(this.props.error?e?.classList.add("waykeecom-input-text--has-error"):e?.classList.remove("waykeecom-input-text--has-error"))}setError(e,t){this.props.error=e,t&&(this.props.errorMessage=t),this.updateBorder(),this.contexts.error?.setError(e)}render(){let{id:e,options:t,value:o,name:a,title:n,error:l,errorMessage:c,onChange:m}=this.props;this.node.innerHTML=`
|
|
726
726
|
<div class="waykeecom-input-label">
|
|
727
727
|
<label for="wayke-estimated-mileage" class="waykeecom-input-label__label">${n}</label>
|
|
728
728
|
</div>
|
|
@@ -734,7 +734,7 @@
|
|
|
734
734
|
>
|
|
735
735
|
${t.map(u=>`<option value="${u.value}" ${u.value===o?'selected="selected"':""}>${u.title||u.value}</option>`).join("")}
|
|
736
736
|
</select>
|
|
737
|
-
`,this.updateBorder(),c&&(this.contexts.error=new se(this.node,{error:l,errorMessage:c})),this.node.querySelector("select")?.addEventListener("change",u=>m(u))}},Ze=Ds;var Ul="credit-assessment-martial-status",sn=`${Ul}-node`,Ls="credit-assessment-income",bs=`${Ls}-node`,Vl="credit-assessment-employment",on=`${Vl}-node`,Gl="credit-assessment-household-children",an=`${Gl}-node`,yn="credit-assessment-housing-cost",nn=`${yn}-node`,vn="credit-assessment-debt-specification-card-credit",rn=`${vn}-node`,En="credit-assessment-debt-specification-car-loan",cn=`${En}-node`,In="credit-assessment-debt-specification-collateral",ln=`${In}-node`,fn="credit-assessment-debt-specification-leasing-fees",dn=`${fn}-node`,gn="credit-assessment-debt-specification-private-loan",mn=`${gn}-node`,ql="credit-assessment-housing-type",pn=`${ql}-node`,_n="credit-assessment-perform-application",Rs=`${_n}-node`,un="disclaimer-node",hn="disclaimer-safe-node",kn="why-description-node",B={maritalStatus:C.requiredAssessmentMaritalStatus,income:C.requiredNumberGreaterOrEqualThanZero,employment:C.requiredAssessmentEmplyment,householdChildren:C.requiredNumberGreaterOrEqualThanZero,housingCost:C.requiredNumberGreaterOrEqualThanZero,"debtSpecification.cardCredits":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.carLoan":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.collateral":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.leasingFees":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.privateLoan":C.optionalNumberGreaterOrEqualThanZero,housingType:C.requiredHousingType},Wl={maritalStatus:S.MaritalStatus.Married,income:5e4,employment:S.Employment.FullTimeEmployed,householdChildren:0,housingCost:2e3,debtSpecification:{cardCredits:0,carLoan:0,collateral:0,leasingFees:0,privateLoan:0},housingType:S.HousingType.Apartment},Yl=()=>location.hostname==="localhost"?{...Wl}:void 0,Kl=s=>{let i={maritalStatus:s?.maritalStatus||"",income:s?.income.toString()||"",employment:s?.employment.toString()||"",householdChildren:s?.householdChildren.toString()||"",housingCost:s?.housingCost.toString()||"","debtSpecification.cardCredits":s?.debtSpecification.cardCredits.toString()||"","debtSpecification.carLoan":s?.debtSpecification.carLoan.toString()||"","debtSpecification.collateral":s?.debtSpecification.collateral.toString()||"","debtSpecification.leasingFees":s?.debtSpecification.leasingFees.toString()||"","debtSpecification.privateLoan":s?.debtSpecification.privateLoan.toString()||"",housingType:s?.housingType.toString()||""};return{value:i,validation:{maritalStatus:B.maritalStatus(i.maritalStatus),income:B.income(i.income),employment:B.employment(i.employment),householdChildren:B.householdChildren(i.householdChildren),housingCost:B.housingCost(i.housingCost),"debtSpecification.cardCredits":B["debtSpecification.cardCredits"](i["debtSpecification.cardCredits"]),"debtSpecification.carLoan":B["debtSpecification.carLoan"](i["debtSpecification.carLoan"]),"debtSpecification.collateral":B["debtSpecification.collateral"](i["debtSpecification.collateral"]),"debtSpecification.leasingFees":B["debtSpecification.leasingFees"](i["debtSpecification.leasingFees"]),"debtSpecification.privateLoan":B["debtSpecification.privateLoan"](i["debtSpecification.privateLoan"]),housingType:B.housingType(i.housingType)},interact:{maritalStatus:!1,income:!1,employment:!1,householdChildren:!1,housingCost:!1,"debtSpecification.cardCredits":!1,"debtSpecification.carLoan":!1,"debtSpecification.collateral":!1,"debtSpecification.leasingFees":!1,"debtSpecification.privateLoan":!1,housingType:!1}}},Os=class extends r{constructor(e,t){super(e);this.view=1;this.contexts={};this.bankidError=!1;this.signed=!1;this.props=t,this.state=Kl(Yl()),this.render()}onChange(e){let t=e.currentTarget,o=t.name,a=t.value;this.state.value[o]=a,this.state.validation[o]=B[o](a),this.updateUiError(o),this.updateProceedButton()}onBlur(e){let o=e.currentTarget.name;this.state.interact[o]=!0,this.state.validation[o]=B[o](this.state.value[o]),this.updateUiError(o),this.updateProceedButton()}onChangeSelect(e){let t=e.currentTarget,o=t.name,a=t.value;this.state.value[o]=a,this.state.validation[o]=B[o](a),this.updateProceedButton()}onChangeRadio(e){let t=e.currentTarget,o=t.name,a=t.value;this.state.value[o]=a,this.state.validation[o]=B[o](a),o==="housingType"&&(t.value===S.HousingType.SingleFamily&&(this.state.value.housingCost="0",this.state.validation.housingCost=B.housingCost(this.state.value.housingCost)),this.render()),this.updateProceedButton()}updateUiError(e){this.contexts[e]?.setError(this.state.interact[e]&&!this.state.validation[e])}updateProceedButton(){this.contexts.performApplicationButton?.disabled(!this.state.validation.maritalStatus||!this.state.validation.income||!this.state.validation.employment||!this.state.validation.householdChildren||!this.state.validation.housingCost||!this.state.validation["debtSpecification.cardCredits"]||!this.state.validation["debtSpecification.carLoan"]||!this.state.validation["debtSpecification.collateral"]||!this.state.validation["debtSpecification.leasingFees"]||!this.state.validation["debtSpecification.privateLoan"]||!this.state.validation.housingType)}async onAbort(){d("MAIN","FINANCIAL_CREDIT_SCORING_ABORTED","FINANCIAL_CREDIT_SCORING");let{store:e}=this.props;this.view=1,this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval);let t=e.getState().caseId;t&&(await Re(t),await Cs(t),me()(e.dispatch)),O(),this.creditAssessmentResponse=void 0,this.render(!0)}bankIdStatus(e,t,o=!1){o||d("MAIN",t===S.AuthMethod.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_REQUESTED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_REQUESTED","FINANCIAL_CREDIT_SCORING");let a=this.props.store.getState().order?.paymentOptions.find(n=>n.type===S.PaymentType.Loan);this.bankidStatusInterval=setInterval(async()=>{try{let n=await Da(e),l=n.getStatus();if(!this.signed&&l==="signed"&&(d("MAIN",t===S.AuthMethod.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_SUCCEEDED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.signed=!0,this.contexts.bankId?.setTitle(`V\xE4ntar p\xE5 ${a?.name}...`),this.contexts.bankId?.setDescription(`H\xE4mtar uppgifter fr\xE5n ${a?.name}. V\xE4nta kvar det kan ta n\xE5gra sekunder.`),this.contexts.bankId?.setFinalizing(!0),d("MAIN","FINANCIAL_CREDIT_SCORING_SIGNING_SIGNED","FINANCIAL_CREDIT_SCORING")),l==="signingFailed"){clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Ett fel uppstod");return}if(n.isScored()?(d("MAIN","FINANCIAL_CREDIT_SCORING_SIGNING_SCORED","FINANCIAL_CREDIT_SCORING"),this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.view=3,this.creditAssessmentResponse=Zo(n),me(e,this.creditAssessmentResponse)(this.props.store.dispatch),O(),this.render()):n.hasScoringError()&&(clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Ett fel uppstod")),!this.signed&&t===S.AuthMethod.QrCode){let c=n.getQrCode();this.contexts.bankId?.update(t,c)}}catch{clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering")}},1e3),Oe("bankidStatusInterval-credit",this.bankidStatusInterval)}async onStartBankIdAuth(e,t=!1){let o=this.props.store.getState().caseId;if(!o)throw"Missing caseID";this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval);try{t||d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_REQUESTED","FINANCIAL_CREDIT_SCORING"),this.contexts.bankId?.update(e);let a=await Oa({caseId:o,method:e});if(t||d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.bankIdStatus(o,e,t),e===S.AuthMethod.SameDevice){let n=a.getAutoLaunchUrl();this.contexts.bankId?.update(e,n)}else{let n=a.getQrCode();this.contexts.bankId?.update(e,n)}}catch{d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_FAILED","FINANCIAL_CREDIT_SCORING"),this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.bankidError=!0,this.view=1,O(),this.render(!0)}}async startBankId(e){let{store:t}=this.props;this.caseError=void 0,this.bankidError=!1,this.signed=!1;let o=t.getState().caseId;if(this.bankidStatusInterval&&(clearInterval(this.bankidStatusInterval),o&&(await Re(o),await Cs(o),me()(t.dispatch))),o){let a=await this.newCreditAssessmentCase();me(a)(t.dispatch),this.onStartBankIdAuth(e)}else try{d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_REQUESTED","FINANCIAL_CREDIT_SCORING");let a=await this.newCreditAssessmentCase();d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),a&&(me(a)(t.dispatch),this.onStartBankIdAuth(e))}catch{d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_FAILED","FINANCIAL_CREDIT_SCORING")}}async newCreditAssessmentCase(){try{let{store:e,loan:t,paymentLookupResponse:o}=this.props;this.contexts.performApplicationButton?.disabled(!0);let{customer:a}=e.getState(),{monthlyCost:n}=o.costs,{interest:l}=o.interests,c=o.downPaymentSpec.current,m=o.durationSpec.current,u=o.creditAmount,h=o.price,p=o.financialProductCode,y={employment:this.state.value.employment,householdChildren:parseInt(this.state.value.householdChildren,10),housingCost:parseInt(this.state.value.housingCost||"0",10),housingType:this.state.value.housingType,income:parseInt(this.state.value.income||"0",10),maritalStatus:this.state.value.maritalStatus,debtSpecification:{cardCredits:parseInt(this.state.value["debtSpecification.cardCredits"]||"0",10),carLoan:parseInt(this.state.value["debtSpecification.carLoan"]||"0",10),collateral:parseInt(this.state.value["debtSpecification.collateral"]||"0",10),leasingFees:parseInt(this.state.value["debtSpecification.leasingFees"]||"0",10),privateLoan:parseInt(this.state.value["debtSpecification.privateLoan"]||"0",10)}},g={customer:{...a},householdEconomy:y,externalId:t.externalId,loan:{downPayment:c,interestRate:l,credit:u,financialProductId:p,monthlyCost:n,price:h,term:en(m)}};return(await Ra(g)).caseId}catch(e){this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.caseError=e?.message||"",this.view=1,this.render(!0);return}finally{this.contexts.performApplicationButton?.disabled(!1)}}render(e){let{store:t,paymentLookupResponse:o,onProceed:a}=this.props,n=Ie(),{order:l}=t.getState(),c=l?.paymentOptions.find(h=>h.type===S.PaymentType.Loan),m=o.creditAmount,u=l?.contactInformation?.name;if(this.view===3&&this.creditAssessmentResponse)new Za(z(),{store:t,creditAssessmentResponse:this.creditAssessmentResponse,onProceed:()=>{O(),a()},onGoBack:()=>this.onAbort()});else if(this.view===2)this.contexts.bankId=new je(z(),{method:n?S.AuthMethod.SameDevice:S.AuthMethod.QrCode,descriptionQrCode:"F\xF6r att h\xE4mta dina uppgifter, starta din BankID applikation p\xE5 din andra enhet.",descriptionSameDevice:"F\xF6r att h\xE4mta dina uppgifter, starta din BankID-applikation.",onAbort:()=>this.onAbort(),onStart:h=>this.startBankId(h)}),G();else{this.node.innerHTML=`
|
|
737
|
+
`,this.updateBorder(),c&&(this.contexts.error=new se(this.node,{error:l,errorMessage:c})),this.node.querySelector("select")?.addEventListener("change",u=>m(u))}},Ze=Ds;var Ul="credit-assessment-martial-status",sn=`${Ul}-node`,Ls="credit-assessment-income",bs=`${Ls}-node`,Vl="credit-assessment-employment",on=`${Vl}-node`,Gl="credit-assessment-household-children",an=`${Gl}-node`,yn="credit-assessment-housing-cost",nn=`${yn}-node`,vn="credit-assessment-debt-specification-card-credit",rn=`${vn}-node`,En="credit-assessment-debt-specification-car-loan",cn=`${En}-node`,In="credit-assessment-debt-specification-collateral",ln=`${In}-node`,fn="credit-assessment-debt-specification-leasing-fees",dn=`${fn}-node`,gn="credit-assessment-debt-specification-private-loan",mn=`${gn}-node`,ql="credit-assessment-housing-type",pn=`${ql}-node`,_n="credit-assessment-perform-application",Rs=`${_n}-node`,un="disclaimer-node",hn="disclaimer-safe-node",kn="why-description-node",B={maritalStatus:C.requiredAssessmentMaritalStatus,income:C.requiredNumberGreaterOrEqualThanZero,employment:C.requiredAssessmentEmplyment,householdChildren:C.requiredNumberGreaterOrEqualThanZero,housingCost:C.requiredNumberGreaterOrEqualThanZero,"debtSpecification.cardCredits":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.carLoan":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.collateral":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.leasingFees":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.privateLoan":C.optionalNumberGreaterOrEqualThanZero,housingType:C.requiredHousingType},Wl={maritalStatus:S.MaritalStatus.Married,income:5e4,employment:S.Employment.FullTimeEmployed,householdChildren:0,housingCost:2e3,debtSpecification:{cardCredits:0,carLoan:0,collateral:0,leasingFees:0,privateLoan:0},housingType:S.HousingType.Apartment},Yl=()=>location.hostname==="localhost"?{...Wl}:void 0,Kl=s=>{let i={maritalStatus:s?.maritalStatus||"",income:s?.income.toString()||"",employment:s?.employment.toString()||"",householdChildren:s?.householdChildren.toString()||"",housingCost:s?.housingCost.toString()||"","debtSpecification.cardCredits":s?.debtSpecification.cardCredits.toString()||"","debtSpecification.carLoan":s?.debtSpecification.carLoan.toString()||"","debtSpecification.collateral":s?.debtSpecification.collateral.toString()||"","debtSpecification.leasingFees":s?.debtSpecification.leasingFees.toString()||"","debtSpecification.privateLoan":s?.debtSpecification.privateLoan.toString()||"",housingType:s?.housingType.toString()||""};return{value:i,validation:{maritalStatus:B.maritalStatus(i.maritalStatus),income:B.income(i.income),employment:B.employment(i.employment),householdChildren:B.householdChildren(i.householdChildren),housingCost:B.housingCost(i.housingCost),"debtSpecification.cardCredits":B["debtSpecification.cardCredits"](i["debtSpecification.cardCredits"]),"debtSpecification.carLoan":B["debtSpecification.carLoan"](i["debtSpecification.carLoan"]),"debtSpecification.collateral":B["debtSpecification.collateral"](i["debtSpecification.collateral"]),"debtSpecification.leasingFees":B["debtSpecification.leasingFees"](i["debtSpecification.leasingFees"]),"debtSpecification.privateLoan":B["debtSpecification.privateLoan"](i["debtSpecification.privateLoan"]),housingType:B.housingType(i.housingType)},interact:{maritalStatus:!1,income:!1,employment:!1,householdChildren:!1,housingCost:!1,"debtSpecification.cardCredits":!1,"debtSpecification.carLoan":!1,"debtSpecification.collateral":!1,"debtSpecification.leasingFees":!1,"debtSpecification.privateLoan":!1,housingType:!1}}},Os=class extends r{constructor(e,t){super(e);this.view=1;this.contexts={};this.bankidError=!1;this.signed=!1;this.props=t,this.state=Kl(Yl()),this.render()}onChange(e){let t=e.currentTarget,o=t.name,a=t.value;this.state.value[o]=a,this.state.validation[o]=B[o](a),this.updateUiError(o),this.updateProceedButton()}onBlur(e){let o=e.currentTarget.name;this.state.interact[o]=!0,this.state.validation[o]=B[o](this.state.value[o]),this.updateUiError(o),this.updateProceedButton()}onChangeSelect(e){let t=e.currentTarget,o=t.name,a=t.value;this.state.value[o]=a,this.state.validation[o]=B[o](a),this.updateProceedButton()}onChangeRadio(e){let t=e.currentTarget,o=t.name,a=t.value;this.state.value[o]=a,this.state.validation[o]=B[o](a),o==="housingType"&&(t.value===S.HousingType.SingleFamily&&(this.state.value.housingCost="0",this.state.validation.housingCost=B.housingCost(this.state.value.housingCost)),this.render()),this.updateProceedButton()}updateUiError(e){this.contexts[e]?.setError(this.state.interact[e]&&!this.state.validation[e])}updateProceedButton(){this.contexts.performApplicationButton?.disabled(!this.state.validation.maritalStatus||!this.state.validation.income||!this.state.validation.employment||!this.state.validation.householdChildren||!this.state.validation.housingCost||!this.state.validation["debtSpecification.cardCredits"]||!this.state.validation["debtSpecification.carLoan"]||!this.state.validation["debtSpecification.collateral"]||!this.state.validation["debtSpecification.leasingFees"]||!this.state.validation["debtSpecification.privateLoan"]||!this.state.validation.housingType)}async onAbort(){d("MAIN","FINANCIAL_CREDIT_SCORING_ABORTED","FINANCIAL_CREDIT_SCORING");let{store:e}=this.props;this.view=1,this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval);let t=e.getState().caseId;t&&(await Re(t),await Cs(t),me()(e.dispatch)),O(),this.creditAssessmentResponse=void 0,this.render(!0)}bankIdStatus(e,t,o=!1){o||d("MAIN",t===S.AuthMethod.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_REQUESTED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_REQUESTED","FINANCIAL_CREDIT_SCORING");let a=this.props.store.getState().order?.paymentOptions.find(n=>n.type===S.PaymentType.Loan);this.bankidStatusInterval=setInterval(async()=>{try{let n=await Da(e),l=n.getStatus();if(!this.signed&&l==="signed"&&(d("MAIN",t===S.AuthMethod.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_SUCCEEDED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.signed=!0,this.contexts.bankId?.setTitle(`V\xE4ntar p\xE5 ${a?.name}...`),this.contexts.bankId?.setDescription(`H\xE4mtar uppgifter fr\xE5n ${a?.name}. V\xE4nta kvar det kan ta n\xE5gra sekunder.`),this.contexts.bankId?.setFinalizing(!0),d("MAIN","FINANCIAL_CREDIT_SCORING_SIGNING_SIGNED","FINANCIAL_CREDIT_SCORING")),l==="signingFailed"){clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Ett fel uppstod");return}if(n.isScored()?(d("MAIN","FINANCIAL_CREDIT_SCORING_SIGNING_SCORED","FINANCIAL_CREDIT_SCORING"),this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.view=3,this.creditAssessmentResponse=Zo(n),me(e,this.creditAssessmentResponse)(this.props.store.dispatch),O(),this.render()):n.hasScoringError()&&(clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Ett fel uppstod")),!this.signed&&t===S.AuthMethod.QrCode){let c=n.getQrCode();this.contexts.bankId?.update(t,c)}}catch{clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering")}},1e3),Oe("bankidStatusInterval-credit",this.bankidStatusInterval)}async onStartBankIdAuth(e,t=!1){let o=this.props.store.getState().caseId;if(!o)throw"Missing caseID";this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval);try{t||d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_REQUESTED","FINANCIAL_CREDIT_SCORING"),this.contexts.bankId?.update(e);let a=await Oa({caseId:o,method:e});if(t||d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.bankIdStatus(o,e,t),e===S.AuthMethod.SameDevice){let n=a.getAutoLaunchUrl();this.contexts.bankId?.update(e,n)}else{let n=a.getQrCode();this.contexts.bankId?.update(e,n)}}catch{d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_FAILED","FINANCIAL_CREDIT_SCORING"),this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.bankidError=!0,this.view=1,O(),this.render(!0)}}async startBankId(e){let{store:t}=this.props;this.caseError=void 0,this.bankidError=!1,this.signed=!1;let o=t.getState().caseId;if(this.bankidStatusInterval&&(clearInterval(this.bankidStatusInterval),o&&(await Re(o),await Cs(o),me()(t.dispatch))),o){let a=await this.newCreditAssessmentCase();me(a)(t.dispatch),this.onStartBankIdAuth(e)}else try{d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_REQUESTED","FINANCIAL_CREDIT_SCORING");let a=await this.newCreditAssessmentCase();d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),a&&(me(a)(t.dispatch),this.onStartBankIdAuth(e))}catch{d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_FAILED","FINANCIAL_CREDIT_SCORING")}}async newCreditAssessmentCase(){try{let{store:e,loan:t,paymentLookupResponse:o}=this.props;this.contexts.performApplicationButton?.disabled(!0);let{customer:a}=e.getState(),{monthlyCost:n}=o.costs,{interest:l}=o.interests,c=o.downPaymentSpec.current,m=o.durationSpec.current,u=o.creditAmount,h=o.price,p=o.financialProductCode,y={employment:this.state.value.employment,householdChildren:parseInt(this.state.value.householdChildren,10),housingCost:parseInt(this.state.value.housingCost||"0",10),housingType:this.state.value.housingType,income:parseInt(this.state.value.income||"0",10),maritalStatus:this.state.value.maritalStatus,debtSpecification:{cardCredits:parseInt(this.state.value["debtSpecification.cardCredits"]||"0",10),carLoan:parseInt(this.state.value["debtSpecification.carLoan"]||"0",10),collateral:parseInt(this.state.value["debtSpecification.collateral"]||"0",10),leasingFees:parseInt(this.state.value["debtSpecification.leasingFees"]||"0",10),privateLoan:parseInt(this.state.value["debtSpecification.privateLoan"]||"0",10)}},g={customer:{...a},householdEconomy:y,externalId:t.externalId,loan:{downPayment:c,interestRate:l,credit:u,financialProductId:p,monthlyCost:n,price:h,term:en(m)}};return(await Ra(g)).caseId}catch(e){this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.caseError=e?.message||"",this.view=1,this.render(!0);return}finally{this.contexts.performApplicationButton?.disabled(!1)}}render(e){let{store:t,paymentLookupResponse:o,onProceed:a}=this.props,n=Ie(),{order:l}=t.getState(),c=l?.paymentOptions.find(h=>h.type===S.PaymentType.Loan),m=o.creditAmount,u=l?.contactInformation?.name;if(this.view===3&&this.creditAssessmentResponse)new Za(Q(),{store:t,creditAssessmentResponse:this.creditAssessmentResponse,onProceed:()=>{O(),a()},onGoBack:()=>this.onAbort()});else if(this.view===2)this.contexts.bankId=new je(Q(),{method:n?S.AuthMethod.SameDevice:S.AuthMethod.QrCode,descriptionQrCode:"F\xF6r att h\xE4mta dina uppgifter, starta din BankID applikation p\xE5 din andra enhet.",descriptionSameDevice:"F\xF6r att h\xE4mta dina uppgifter, starta din BankID-applikation.",onAbort:()=>this.onAbort(),onStart:h=>this.startBankId(h)}),G();else{this.node.innerHTML=`
|
|
738
738
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
739
739
|
<h5 class="waykeecom-heading waykeecom-heading--4">L\xE5neans\xF6kan</h5>
|
|
740
740
|
<div class="waykeecom-content">
|
|
@@ -843,7 +843,7 @@
|
|
|
843
843
|
<div class="waykeecom-stack waykeecom-stack--1" id="${hn}"></div>
|
|
844
844
|
</div>
|
|
845
845
|
</div>
|
|
846
|
-
`,this.contexts.maritalStatus=new
|
|
846
|
+
`,this.contexts.maritalStatus=new z(this.node.querySelector(`#${sn}`),{title:"Civilst\xE5nd",checked:this.state.value.maritalStatus,name:"maritalStatus",options:[{id:`maritalStatus-${1}`,value:S.MaritalStatus.Married,title:"Gift/partnerskap"},{id:`maritalStatus-${2}`,value:S.MaritalStatus.CommonLaw,title:"Sambo"},{id:`maritalStatus-${3}`,value:S.MaritalStatus.Single,title:"Ensamst\xE5ende"}],onClick:p=>this.onChangeRadio(p)}),this.contexts.income=new M(this.node.querySelector(`#${bs}`),{title:"Inkomst per m\xE5nad f\xF6re skatt",value:this.state.value.income,id:Ls,error:this.state.interact.income&&!this.state.validation.income,errorMessage:"Ange din inkomst per \xE5r f\xF6re skatt",name:"income",autocomplete:"off",unit:"kr",placeholder:"",type:"number",onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p)}),this.contexts.employment=new z(this.node.querySelector(`#${on}`),{title:"Syssels\xE4ttning",checked:this.state.value.employment,name:"employment",options:[{id:`employment-${1}`,value:S.Employment.FullTimeEmployed,title:"Fast eller tillsvidareanst\xE4lld"},{id:`employment-${2}`,value:S.Employment.TemporarilyEmployed,title:"Visstidsanst\xE4lld"},{id:`employment-${3}`,value:S.Employment.SelfEmployed,title:"Egen f\xF6retagare"},{id:`employment-${4}`,value:S.Employment.Retired,title:"Pension\xE4r"},{id:`employment-${5}`,value:S.Employment.Student,title:"Student"},{id:`employment-${6}`,value:S.Employment.Other,title:"Annan"}],onClick:p=>this.onChangeRadio(p)}),this.contexts.housingType=new z(this.node.querySelector(`#${pn}`),{title:"Boendeform",checked:this.state.value.housingType,name:"housingType",options:[{id:`housingType-${1}`,value:S.HousingType.SingleFamily,title:"Villa"},{id:`housingType-${2}`,value:S.HousingType.Condominium,title:"Bostadsr\xE4tt"},{id:`housingType-${3}`,value:S.HousingType.Apartment,title:"Hyresr\xE4tt"}],onClick:p=>this.onChangeRadio(p)}),this.contexts.income=new M(this.node.querySelector(`#${bs}`),{title:"Inkomst per m\xE5nad f\xF6re skatt",value:this.state.value.income,id:Ls,error:this.state.interact.income&&!this.state.validation.income,errorMessage:"Ange din inkomst per \xE5r f\xF6re skatt",name:"income",autocomplete:"off",placeholder:"",unit:"kr",type:"number",information:`
|
|
847
847
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
848
848
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Inkomst per m\xE5nad f\xF6re skatt</span></p>
|
|
849
849
|
<p class="waykeecom-content__p">L\xF6n och/eller pension, inte bidrag eller studiel\xE5n.</p>
|
|
@@ -878,7 +878,7 @@
|
|
|
878
878
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Privatl\xE5n (ej bol\xE5n och CSN)</span></p>
|
|
879
879
|
<p class="waykeecom-content__p">Total skuld, t.ex. blancol\xE5n och sms-l\xE5n</p>
|
|
880
880
|
</div>
|
|
881
|
-
`,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p),onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DEBT_SPECIFICATION_PRIVATE_LOAN_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts.performApplicationButton=new fe(this.node.querySelector(`#${Rs}`),{title:"Genomf\xF6r l\xE5neans\xF6kan",id:_n,disabled:!(this.state.validation.maritalStatus&&this.state.validation.income&&this.state.validation.employment&&this.state.validation.householdChildren&&this.state.validation.housingCost),onClick:()=>{this.view=2,this.render()}}),new ge(this.node.querySelector(`#${un}`),{text:`Genom att klicka p\xE5 \u201DGenomf\xF6r l\xE5neans\xF6kan\u201D godk\xE4nner jag att ${c?.name} g\xF6r en kreditupplysning p\xE5 mig baserat p\xE5 informationen ovan och jag bekr\xE4ftar att jag l\xE4st <a href="#" title="" target="_blank" rel="noopener noreferrer" class="waykeecom-link">${c?.name} dataskyddspolicy</a>.`}),new ke(this.node.querySelector(`#${hn}`),{text:"Dina uppgifter lagras och sparas s\xE4kert."}),new
|
|
881
|
+
`,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p),onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DEBT_SPECIFICATION_PRIVATE_LOAN_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts.performApplicationButton=new fe(this.node.querySelector(`#${Rs}`),{title:"Genomf\xF6r l\xE5neans\xF6kan",id:_n,disabled:!(this.state.validation.maritalStatus&&this.state.validation.income&&this.state.validation.employment&&this.state.validation.householdChildren&&this.state.validation.housingCost),onClick:()=>{this.view=2,this.render()}}),new ge(this.node.querySelector(`#${un}`),{text:`Genom att klicka p\xE5 \u201DGenomf\xF6r l\xE5neans\xF6kan\u201D godk\xE4nner jag att ${c?.name} g\xF6r en kreditupplysning p\xE5 mig baserat p\xE5 informationen ovan och jag bekr\xE4ftar att jag l\xE4st <a href="#" title="" target="_blank" rel="noopener noreferrer" class="waykeecom-link">${c?.name} dataskyddspolicy</a>.`}),new ke(this.node.querySelector(`#${hn}`),{text:"Dina uppgifter lagras och sparas s\xE4kert."}),new ze(this.node.querySelector(`#${kn}`),{id:"accordion-why-description",title:`
|
|
882
882
|
<div class="waykeecom-hstack waykeecom-hstack--align-center waykeecom-hstack--spacing-1">
|
|
883
883
|
<div class="waykeecom-hstack__item waykeecom-hstack__item--no-shrink" aria-hidden="true">
|
|
884
884
|
<div class="waykeecom-icon-backdrop waykeecom-icon-backdrop--info-alt">
|
|
@@ -1027,7 +1027,7 @@
|
|
|
1027
1027
|
</div>
|
|
1028
1028
|
</div>
|
|
1029
1029
|
</div>
|
|
1030
|
-
`,this.contexts.loanDetailsMontlyCost=new Cn(this.node.querySelector(`#${Dn}`),{monthlyCost:y}),this.contexts.pieChart=new wn(this.node.querySelector(`#${bn}`),{percentage:w}),this.contexts.loanDetailsBasic=new Nn(this.node.querySelector(`#${Rn}`),{downPayment:t,creditAmount:m,downPaymentPercentage:g,creditAmountPercentage:w}),this.contexts.loanDetailsDetailed=new Tn(this.node.querySelector(`#${Ln}`),{duration:e,administrationFee:o,setupFee:a,totalCreditCost:n,interest:l,effectiveInterest:c,publicUrl:u,loanOrgName:h})}},On=Hs;var Bs=class extends r{constructor(e,t){super(e);this.props=t,this.error=t.error,this.render()}update(e){this.error=e,this.render()}render(){if(!this.error){this.node.innerHTML="";return}this.node.innerHTML=I({tone:"error",children:this.error})}},Mn=Bs;var xn="downpayment-range-node",
|
|
1030
|
+
`,this.contexts.loanDetailsMontlyCost=new Cn(this.node.querySelector(`#${Dn}`),{monthlyCost:y}),this.contexts.pieChart=new wn(this.node.querySelector(`#${bn}`),{percentage:w}),this.contexts.loanDetailsBasic=new Nn(this.node.querySelector(`#${Rn}`),{downPayment:t,creditAmount:m,downPaymentPercentage:g,creditAmountPercentage:w}),this.contexts.loanDetailsDetailed=new Tn(this.node.querySelector(`#${Ln}`),{duration:e,administrationFee:o,setupFee:a,totalCreditCost:n,interest:l,effectiveInterest:c,publicUrl:u,loanOrgName:h})}},On=Hs;var Bs=class extends r{constructor(e,t){super(e);this.props=t,this.error=t.error,this.render()}update(e){this.error=e,this.render()}render(){if(!this.error){this.node.innerHTML="";return}this.node.innerHTML=I({tone:"error",children:this.error})}},Mn=Bs;var xn="downpayment-range-node",Ql="downpayment-range",Pn="duration-range-node",zl="duration-range",$n="residual-range-node",jl="residual-range",Jl="loan-details",Hn=`${Jl}-node`,Bn="credit-assessment-node",Vn="credit-assessment-proceed",Fn=`${Vn}-node`,Un="loan-error-node",Fs=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t;let o=this.props.loan.loanDetails;if(!o)throw"err";this.paymentLookupResponse=this.props.paymentLookupResponse||o,this.paymentState={vehicleId:this.props.vehicleId,dealerId:"",downPayment:this.paymentLookupResponse.downPaymentSpec,duration:this.paymentLookupResponse.durationSpec,residual:this.paymentLookupResponse.residualValueSpec},this.previousState=JSON.parse(JSON.stringify(this.paymentState)),this.render()}async payment(){this.contexts.downPayment?.disabled(!0),this.contexts.duration?.disabled(!0),this.contexts.residual?.disabled(!0),this.contexts.proceedButton?.disabled(!0);try{let e=await ga({vehicleId:this.paymentState.vehicleId,downPayment:this.paymentState.downPayment.current,duration:this.paymentState.duration.current,residual:this.paymentState.residual?.current});this.previousState=JSON.parse(JSON.stringify(this.paymentState)),this.paymentLookupResponse=we(e),this.paymentState={...this.paymentState,downPayment:this.paymentLookupResponse.downPaymentSpec,duration:this.paymentLookupResponse.durationSpec,residual:this.paymentLookupResponse.residualValueSpec},li(e)(this.props.store.dispatch),this.update(),this.contexts.errorAlert?.update(void 0),this.contexts.downPayment?.update(this.paymentState.downPayment.current,this.paymentState.downPayment.min,this.paymentState.downPayment.max),this.contexts.residual?.update(parseInt(`${this.paymentState.residual.current*100}`,10),parseInt(`${this.paymentState.residual.min*100}`,10),parseInt(`${this.paymentState.residual.max*100}`,10)),this.contexts.duration?.update(this.paymentState.duration.current,this.paymentState.duration.min,this.paymentState.duration.max)}catch{this.contexts.errorAlert?.update("Ett fel uppstod, f\xF6rs\xF6k igen."),this.contexts.downPayment?.disabled(!1),this.contexts.duration?.disabled(!1),this.contexts.residual?.disabled(!1),this.contexts.downPayment?.update(this.previousState.downPayment.current,this.previousState.downPayment.min,this.previousState.downPayment.max),this.contexts.residual?.update(parseInt(`${this.previousState.residual.current*100}`,10),parseInt(`${this.previousState.residual.min*100}`,10),parseInt(`${this.previousState.residual.max*100}`,10)),this.contexts.duration?.update(this.previousState.duration.current,this.previousState.duration.min,this.previousState.duration.max)}finally{this.contexts.downPayment?.disabled(!1),this.contexts.duration?.disabled(!1),this.contexts.residual?.disabled(!1),this.contexts.proceedButton?.disabled(!1)}}onChange(e){let t=e.currentTarget,o=t.name,a=t.value;t.value=a,this.paymentState[o].current=o==="residual"?parseInt(a,10)/100:parseInt(a,10),this.payment()}update(){this.contexts.loanDetails?.update({loan:this.props.loan,paymentLookupResponse:this.paymentLookupResponse})}render(){let{store:e,loan:t,onProceed:o}=this.props,{order:a}=e.getState(),n=a?.contactInformation?.name,l=t.loanDetails?.shouldUseCreditScoring;this.node.innerHTML=`
|
|
1031
1031
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1032
1032
|
<hr class="waykeecom-separator" />
|
|
1033
1033
|
</div>
|
|
@@ -1049,13 +1049,13 @@
|
|
|
1049
1049
|
${l?`
|
|
1050
1050
|
<div class="waykeecom-stack waykeecom-stack--3" id="${Bn}"></div>
|
|
1051
1051
|
`:`<div class="waykeecom-stack waykeecom-stack--3" id="${Fn}"></div>`}
|
|
1052
|
-
`,this.contexts.downPayment=new
|
|
1052
|
+
`,this.contexts.downPayment=new Qe(this.node.querySelector(`#${xn}`),{title:"Kontantinsats",value:this.paymentState.downPayment.current,id:Ql,name:"downPayment",onChange:c=>this.onChange(c),min:this.paymentState.downPayment.min,max:this.paymentState.downPayment.max,unit:"kr",information:`
|
|
1053
1053
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1054
1054
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Hur mycket av dina egna pengar vill du l\xE4gga?</span></p>
|
|
1055
1055
|
<p class="waykeecom-content__p">Kontantinsatsen \xE4r en del av bilens pris som du betalar med egna pengar. Den beh\xF6ver vara minst 20% av priset p\xE5 bilen. Kontantinsatsen betalar du senare i samband med avtalsskrivning hos ${n}.</p>
|
|
1056
1056
|
<p class="waykeecom-content__p">Ifall du har en inbytesbil kan du betala kontantinsatsen med den. Detta kommer du \xF6verens om tillsammans med ${n} vid avtalsskrivning. </p>
|
|
1057
1057
|
</div>
|
|
1058
|
-
`,onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DOWNPAYMENT_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts.duration=new
|
|
1058
|
+
`,onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DOWNPAYMENT_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts.duration=new Qe(this.node.querySelector(`#${Pn}`),{title:"Avbetalning",value:this.paymentState.duration.current,id:zl,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 Qe(this.node.querySelector(`#${$n}`),{title:"Restv\xE4rde",value:parseInt(`${this.paymentState.residual.current*100}`,10),id:jl,name:"residual",onChange:c=>this.onChange(c),min:parseInt(`${this.paymentState.residual.min*100}`,10),max:parseInt(`${this.paymentState.residual.max*100}`,10),step:parseInt(`${this.paymentState.residual.step*100}`,10),unit:"%"})),this.contexts.errorAlert=new Mn(this.node.querySelector(`#${Un}`),{}),this.contexts.loanDetails=new On(this.node.querySelector(`#${Hn}`),{loan:t,paymentLookupResponse:this.paymentLookupResponse}),l?new Sn(this.node.querySelector(`#${Bn}`),{store:e,loan:t,paymentLookupResponse:this.paymentLookupResponse,onProceed:()=>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*"})}],P=c.creditAssessmentResponse?.recommendation,X=`*Ber\xE4knat p\xE5 ${k(y*100,{decimals:2})} % r\xE4nta (effektivt ${k(g*100,{decimals:2})} %). Den r\xE4nta du f\xE5r s\xE4tts vid avtalskrivning.`;this.node.innerHTML=`
|
|
1059
1059
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
1060
1060
|
<h4 class="waykeecom-heading waykeecom-heading--4">Bill\xE5n</h4>
|
|
1061
1061
|
<div class="waykeecom-content">
|
|
@@ -1091,15 +1091,15 @@
|
|
|
1091
1091
|
</div>
|
|
1092
1092
|
</div>
|
|
1093
1093
|
`:""}
|
|
1094
|
-
`;n&&this.node.querySelector("button")?.addEventListener("click",()=>n())}},Wn=Vs;var jn="button-financial-proceed",Yn=`${jn}-node`,Zl="financial-option",Kn=`${Zl}-node`,ed="financial-option-second",
|
|
1094
|
+
`;n&&this.node.querySelector("button")?.addEventListener("click",()=>n())}},Wn=Vs;var jn="button-financial-proceed",Yn=`${jn}-node`,Zl="financial-option",Kn=`${Zl}-node`,ed="financial-option-second",Qn=`${ed}-node`,td="radio-financial-cash",sd="radio-financial-loan",od="radio-financial-lease",zn="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"),$("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=H(this.node,{completed:c,title:"\xC4gandeform",active:t.navigation.stage===this.props.index,id:"financial"}),u=document.createElement("div");if((t.navigation.stage>this.props.index||c&&t.navigation.stage!==this.props.index)&&this.paymentType){let h=l.find(p=>p.type===F.PaymentType.Loan);new Wn(m,{store:this.props.store,loan:h,paymentType:this.paymentType,paymentLookupResponse:n||h?.loanDetails,onEdit:t.createdOrderId?void 0:()=>this.onEdit()})}else if(t.navigation.stage===this.props.index){let h=t.order?.orderVehicle,p=l.find(L=>L.type===F.PaymentType.Cash),y=l.find(L=>L.type===F.PaymentType.Loan),g=l.find(L=>L.type===F.PaymentType.Lease);u.innerHTML=`
|
|
1095
1095
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1096
1096
|
<h4 class="waykeecom-heading waykeecom-heading--4 waykeecom-no-margin">Hur vill du finansiera din ${h?.title} ${pe(h)}?</h4>
|
|
1097
1097
|
</div>
|
|
1098
1098
|
|
|
1099
1099
|
${p||y?`<div class="waykeecom-stack waykeecom-stack--3" id="${Kn}"></div>`:""}
|
|
1100
|
-
${g?`<div class="waykeecom-stack waykeecom-stack--3" id="${
|
|
1100
|
+
${g?`<div class="waykeecom-stack waykeecom-stack--3" id="${Qn}"></div>`:""}
|
|
1101
1101
|
|
|
1102
|
-
<div class="waykeecom-stack waykeecom-stack--3" id="${
|
|
1102
|
+
<div class="waykeecom-stack waykeecom-stack--3" id="${zn}"></div>
|
|
1103
1103
|
${this.paymentType!==F.PaymentType.Loan?`<div class="waykeecom-stack waykeecom-stack--3" id="${Yn}"></div>`:""}
|
|
1104
1104
|
|
|
1105
1105
|
`,m.appendChild(u);let w=a.contactInformation,R=[];if(p&&R.push({id:td,value:F.PaymentType.Cash,title:"Kontant",description:`
|
|
@@ -1136,22 +1136,15 @@
|
|
|
1136
1136
|
<img src="${y.logo}" alt="${y.name} logotyp" class="waykeecom-image waykeecom-image--loan-logo" />
|
|
1137
1137
|
</div>
|
|
1138
1138
|
</div>`:""}
|
|
1139
|
-
</div>`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${k(L,{postfix:y.unit})}</div>`})}(p||y)&&new
|
|
1139
|
+
</div>`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${k(L,{postfix:y.unit})}</div>`})}(p||y)&&new z(u.querySelector(`#${Kn}`),{title:"K\xF6p bilen",checked:this.paymentType,name:"paymentType",information:`
|
|
1140
1140
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1141
1141
|
<p class="waykeecom-content__p">Du k\xF6per bilen och \xE4ger den sj\xE4lv, antingen genom att betala hela bilen med egna medel eller genom ett bill\xE5n. Du ansvarar sj\xE4lv f\xF6r f\xF6rs\xE4ljningen av bilen och v\xE4ljer s\xE5klart helt fritt n\xE4r den ska \xE4ga rum.</p>
|
|
1142
1142
|
</div>
|
|
1143
|
-
`,options:R,onClick:L=>this.onChange(L),onClickInformation:()=>{d("MAIN","FINANCIAL_INFORMATION_TOGGLE","FINANCIAL")}});let P=[];g&&(P.push({id:od,title:"Privatleasing",value:F.PaymentType.Lease,
|
|
1144
|
-
<div class="waykeecom-box">
|
|
1145
|
-
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1146
|
-
<ul class="waykeecom-content__ul">
|
|
1147
|
-
<li class="waykeecom-content__li">Inkl. 1 500 mil/\xE5r, 36 m\xE5n.</li>
|
|
1148
|
-
</ul>
|
|
1149
|
-
</div>
|
|
1150
|
-
</div>`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${k(g?.price,{postfix:g.unit})}</div>`}),new Q(u.querySelector(`#${zn}`),{title:"Leasa bilen",checked:this.paymentType,name:"paymentType",information:`
|
|
1143
|
+
`,options:R,onClick:L=>this.onChange(L),onClickInformation:()=>{d("MAIN","FINANCIAL_INFORMATION_TOGGLE","FINANCIAL")}});let P=[];g&&(P.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 z(u.querySelector(`#${Qn}`),{title:"Leasa bilen",checked:this.paymentType,name:"paymentType",information:`
|
|
1151
1144
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1152
1145
|
<p class="waykeecom-content__p">Du st\xE5r inte som \xE4gare p\xE5 bilen utan betalar en avtalad m\xE5nadsavgift d\xE4r det mesta ing\xE5r. N\xE4r avtalstiden g\xE5r ut \xE4r det bara att l\xE4mna tillbaka bilen till bilhandlaren.</p>
|
|
1153
1146
|
</div>
|
|
1154
|
-
`,options:P,onClick:L=>this.onChange(L)}));let X=u.querySelector(`#${
|
|
1147
|
+
`,options:P,onClick:L=>this.onChange(L)}));let X=u.querySelector(`#${zn}`);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:jn,disabled:!this.paymentType,onClick:()=>this.onProceed()}))}!e&&t.navigation.stage===this.props.index&&m.parentElement?.scrollIntoView()}},Jn=Gs;var U=f("@wayke-se/ecom");var qs=f("@wayke-se/ecom"),Xn=(s,i)=>{let e=s.getState();if(!e.id)throw"No id";let t=qs.insurances.newInsuranceOptionsRequest().forCustomer(e.customer.socialId).forVehicle(e.id).withDrivingDistance(i);return qs.insurances.getOptions(t.build())};var Ws=class extends r{constructor(e,t){super(e,t.append?{htmlTag:"div",className:"waykeecom-input-selection",attributes:[{key:"role",value:"checkbox"}]}:void 0);this.props=t,this.render()}checked(e){this.props.checked!==e&&(this.props.checked=e,this.render())}disabled(e){this.props.disabled!==e&&(this.props.disabled=e,this.render())}render(){let{id:e,title:t,value:o,name:a,checked:n,meta:l,description:c,append:m,disabled:u,onClick:h}=this.props,p=`
|
|
1155
1148
|
<input
|
|
1156
1149
|
type="checkbox"
|
|
1157
1150
|
id="${e}"
|
|
@@ -1188,8 +1181,8 @@
|
|
|
1188
1181
|
${b({type:"inline"})}
|
|
1189
1182
|
</span>`:""}
|
|
1190
1183
|
</button>
|
|
1191
|
-
`,n&&this.node.querySelector("button")?.addEventListener("click",n)}},Zn=Ys;var Ks=class extends r{constructor(i){super(i,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--1"}),this.render()}render(){return this.node.innerHTML='<div class="waykeecom-box"></div>',this.node.querySelector(".waykeecom-box")}},er=Ks;var
|
|
1192
|
-
<div class="waykeecom-nav-banner" id="${
|
|
1184
|
+
`,n&&this.node.querySelector("button")?.addEventListener("click",n)}},Zn=Ys;var Ks=class extends r{constructor(i){super(i,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--1"}),this.render()}render(){return this.node.innerHTML='<div class="waykeecom-box"></div>',this.node.querySelector(".waykeecom-box")}},er=Ks;var Qs="insurance-button-top-left-node",tr="insurance-button-bottom-left-node",zs="insurance-add-remove-node",sr="insurance-addons-node",or="insurance-accordion-node",_e=class extends r{constructor(e,t){super(e);this.initialAddons=[];this.addons=[];this.contexts={checkboxes:{}};this.props=t;let{insuranceAddOns:o}=this.props.store.getState();!!o?.insurance&&o.insurance===this.props.insurance.name&&(this.addons=[...o.addOns]),this.initialAddons=[...this.addons],this.render()}static containChanges(e,t){let o=[...e].sort(),a=[...t].sort();return o.join().localeCompare(a.join())!==0}onClick(e){let t=e.currentTarget,{name:o,checked:a}=t,n=this.props.insurance.addOns.find(c=>c.name===o);if(n){if(Object.keys(this.contexts.checkboxes).forEach(c=>{this.contexts.checkboxes[c]?.disabled(!1)}),this.contexts.checkboxes[o]?.checked(a),a)d("MAIN","INSURANCE_ADDON_SELECTED","INSURANCE_IF"),this.addons.push(n);else{d("MAIN","INSURANCE_ADDON_UNSELECTED","INSURANCE_IF");let c=this.addons.findIndex(m=>m.name===n.name);c>-1&&this.addons.splice(c,1)}[...new Set(this.addons.map(c=>c.exclude).flat())].forEach(c=>this.contexts.checkboxes[c]?.disabled(!0))}let l=_e.containChanges(this.initialAddons,this.addons);this.contexts.updateButton?.disabled(this.props.selected?!l:!1)}onUpdate(){let{insurance:e}=this.props.store.getState();!e||e&&this.props.insurance.name!==e.name?d("MAIN","INSURANCE_SELECTED","INSURANCE_IF"):d("MAIN","INSURANCE_UNSELECTED","INSURANCE_IF"),mi(this.props.insurance,this.addons)(this.props.store.dispatch),this.props.onClose()}render(){let{insurance:e,selected:t,onClose:o}=this.props,{name:a,description:n,legalDescription:l,legalUrl:c,insuranceItems:m}=e,u=e.addOns,h=_e.containChanges(this.initialAddons,this.addons);if(this.node.innerHTML=`
|
|
1185
|
+
<div class="waykeecom-nav-banner" id="${Qs}"></div>
|
|
1193
1186
|
|
|
1194
1187
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1195
1188
|
<div class="waykeecom-hstack waykeecom-hstack--align-center waykeecom-hstack--spacing-3">
|
|
@@ -1228,10 +1221,10 @@
|
|
|
1228
1221
|
<div class="waykeecom-stack waykeecom-stack--3" id="${or}"></div>
|
|
1229
1222
|
`:""}
|
|
1230
1223
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1231
|
-
<div class="waykeecom-stack waykeecom-stack--1" id="${
|
|
1224
|
+
<div class="waykeecom-stack waykeecom-stack--1" id="${zs}"></div>
|
|
1232
1225
|
<div class="waykeecom-stack waykeecom-stack--1" id="${tr}"></div>
|
|
1233
1226
|
</div>
|
|
1234
|
-
`,new ce(this.node.querySelector(`#${
|
|
1227
|
+
`,new ce(this.node.querySelector(`#${Qs}`),{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 ze(p,{id:y.name,title:y.name,description:y.description,append:!0}))}new ce(this.node.querySelector(`#${Qs}`),{title:"Tillbaka",onClick:()=>o()}),new te(this.node.querySelector(`#${tr}`),{title:"Tillbaka",onClick:()=>o()}),t?this.contexts.updateButton=new Zn(this.node.querySelector(`#${zs}`),{title:t?"Uppdatera":"V\xE4lj",disabled:t?!h:void 0,onClick:()=>this.onUpdate()}):this.contexts.updateButton=new ee(this.node.querySelector(`#${zs}`),{selected:!1,fullSize:!0,disabled:t?!h:void 0,onClick:()=>this.onUpdate()}),G()}},ir=_e;var js=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.props=t,_(this.props.store,"insurance",()=>{this.render()}),this.render()}onInfoOpen(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE_IF"),this.displayInfo=!0,this.render()}onInfoClose(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE_IF"),this.displayInfo=!1,O(),this.render(),this.node.parentElement?.scrollIntoView()}onClick(){let{insurance:e}=this.props.store.getState();!e||e&&this.props.insurance.name!==e.name?d("MAIN","INSURANCE_SELECTED","INSURANCE_IF"):d("MAIN","INSURANCE_UNSELECTED","INSURANCE_IF"),de(this.props.insurance)(this.props.store.dispatch)}render(){let{store:e,insurance:t,key:o}=this.props,a=e.getState(),n=a.order?.insuranceOption?.logo,l=a.insuranceAddOns?.insurance===t.name?a.insuranceAddOns.addOns.map(m=>({key:m?.title,value:k(m?.monthlyPrice,{postfix:"kr/m\xE5n"})})):void 0,c=a.insurance?JSON.stringify(a.insurance).localeCompare(JSON.stringify(t))===0:!1;this.displayInfo&&new ir(Q(),{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=js;var Js=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,insurances:t}=this.props,o=new ue(this.node,{id:"insurance-list",onClick:()=>d("MAIN","INSURANCE_ARROW","INSURANCE_IF")}),{overflowElement:a}=o;a&&(a.innerHTML="",t.forEach((n,l)=>new ar(a,{store:e,insurance:n,key:`insurance-${l}`})))}},nr=Js;var Xs="insurance-grid-list-node",id="button-insurances-proceed",rr=`${Xs}-node`,mr="button-insurances-skip",cr=`${mr}-node`,pr="button-insurance-edit-driving-distance",lr=`${pr}-node`,dr={},Zs=class extends r{constructor(e,t){super(e);this.requestError=!1;this.contexts={listners:[]};this.props=t;let o=_(this.props.store,"drivingDistance",()=>{this.fetchInsurance()});this.contexts.listners.push(o);let a=_(this.props.store,"customer.socialId",()=>{this.fetchInsurance()});this.contexts.listners.push(a);let n=_(this.props.store,"insurance",()=>{this.contexts.buttonProceed?.disabled(!this.props.store.getState().insurance)});this.contexts.listners.push(n),this.fetchInsurance(),this.render()}fetchInsurance(){this.props.store.getState().customer.socialId&&this.getInsurances()}async getInsurances(){let e=this.props.store.getState();this.requestError=!1,this.render();let t=`${e.customer.socialId}-${e.id}-${e.drivingDistance}`,o=dr[t];if(d("MAIN","INSURANCE_GET_INSURANCES_REQUESTED","INSURANCE_IF"),o){this.insurances=o,d("MAIN","INSURANCE_GET_INSURANCES_SUCCEEDED","INSURANCE_IF"),this.render();return}try{let a=await Xn(this.props.store,e.drivingDistance);d("MAIN","INSURANCE_GET_INSURANCES_SUCCEEDED","INSURANCE_IF"),this.insurances=a.getInsuranceOptions(),dr[t]=this.insurances}catch{d("MAIN","INSURANCE_GET_INSURANCES_FAILED","INSURANCE_IF"),this.requestError=!0}finally{this.render()}}onEditDrivingDistance(){this.contexts.listners.forEach(e=>e?.()),this.props.onEdit()}onProceed(){Z(this.props.lastStage)(this.props.store.dispatch)}onSkipInsurances(){d("MAIN","INSURANCE_SKIPPED","INSURANCE_IF"),de()(this.props.store.dispatch),Z(this.props.lastStage)(this.props.store.dispatch)}render(){let{store:e}=this.props,t=e.getState(),{insurance:o,drivingDistance:a}=t;this.node.innerHTML=`
|
|
1235
1228
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1236
1229
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vill du teckna en f\xF6rs\xE4kring p\xE5 din nya bil?</h4>
|
|
1237
1230
|
<div class="waykeecom-content">
|
|
@@ -1305,7 +1298,7 @@
|
|
|
1305
1298
|
<div class="waykeecom-stack waykeecom-stack--1" id="${wr}"></div>
|
|
1306
1299
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Sr}"></div>
|
|
1307
1300
|
</div>
|
|
1308
|
-
`,new ce(this.node.querySelector(`#${_r}`),{title:"Tillbaka",onClick:()=>o()}),new te(this.node.querySelector(`#${Sr}`),{title:"Tillbaka",onClick:()=>o()}),new ee(this.node.querySelector(`#${wr}`),{selected:t,fullSize:!0,onClick:()=>a()}),G()}},Nr=so;var oo=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.props=t,_(this.props.store,"freeInsurance",()=>{this.render()}),this.render()}onInfoOpen(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE"),this.displayInfo=!0,this.render()}onInfoClose(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE"),this.displayInfo=!1,O(),this.render(),this.node.parentElement?.scrollIntoView()}onClick(){let{freeInsurance:e}=this.props.store.getState();e&&this.props.freeInsurance!==e?d("MAIN","INSURANCE_SELECTED","INSURANCE"):d("MAIN","INSURANCE_UNSELECTED","INSURANCE"),pi(this.props.freeInsurance)(this.props.store.dispatch)}render(){let{store:e,freeInsurance:t,key:o}=this.props,a=e.getState(),n=a.order?.insuranceOption?.logo,l=a.freeInsurance?JSON.stringify(a.freeInsurance).localeCompare(JSON.stringify(this.props.freeInsurance))===0:!1;this.displayInfo&&new Nr(
|
|
1301
|
+
`,new ce(this.node.querySelector(`#${_r}`),{title:"Tillbaka",onClick:()=>o()}),new te(this.node.querySelector(`#${Sr}`),{title:"Tillbaka",onClick:()=>o()}),new ee(this.node.querySelector(`#${wr}`),{selected:t,fullSize:!0,onClick:()=>a()}),G()}},Nr=so;var oo=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.props=t,_(this.props.store,"freeInsurance",()=>{this.render()}),this.render()}onInfoOpen(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE"),this.displayInfo=!0,this.render()}onInfoClose(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE"),this.displayInfo=!1,O(),this.render(),this.node.parentElement?.scrollIntoView()}onClick(){let{freeInsurance:e}=this.props.store.getState();e&&this.props.freeInsurance!==e?d("MAIN","INSURANCE_SELECTED","INSURANCE"):d("MAIN","INSURANCE_UNSELECTED","INSURANCE"),pi(this.props.freeInsurance)(this.props.store.dispatch)}render(){let{store:e,freeInsurance:t,key:o}=this.props,a=e.getState(),n=a.order?.insuranceOption?.logo,l=a.freeInsurance?JSON.stringify(a.freeInsurance).localeCompare(JSON.stringify(this.props.freeInsurance))===0:!1;this.displayInfo&&new Nr(Q(),{freeInsurance:t,selected:l,onClick:()=>{this.onInfoClose(),this.onClick()},onClose:()=>this.onInfoClose()}),new he(this.node,{logo:n,id:o,title:t.title,description:t.description,price:"Gratis",selected:l,onClick:()=>this.onClick(),onInfo:()=>this.onInfoOpen()},o)}},Ar=oo;var io=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,insurances:t}=this.props,o=new ue(this.node,{id:"insurance-list",onClick:()=>d("MAIN","INSURANCE_ARROW","INSURANCE")}),{overflowElement:a}=o;a&&(a.innerHTML="",t.forEach((n,l)=>new Ar(a,{store:e,freeInsurance:n,key:`insurance-${l}`})))}},Tr=io;var ao="insurance-grid-list-node",ad="button-insurances-proceed",Cr=`${ao}-node`,nd="button-insurances-skip",rd=`${nd}-node`,no=class extends r{constructor(e,t){super(e);this.props=t,this.render()}onProceed(){let{freeInsurance:e}=this.props.store.getState();Z(this.props.lastStage)(this.props.store.dispatch),d("MAIN",e?"INSURANCE_SET":"INSURANCE_SKIPPED","INSURANCE")}render(){let{store:e,insurance:t}=this.props;this.node.innerHTML=`
|
|
1309
1302
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1310
1303
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vill du teckna en f\xF6rs\xE4kring p\xE5 din nya bil?</h4>
|
|
1311
1304
|
<div class="waykeecom-content">
|
|
@@ -1418,7 +1411,7 @@
|
|
|
1418
1411
|
<circle cx="11" cy="10" r="5.5" stroke="#FFF500" stroke-linejoin="round" stroke-dasharray="1 2"/>
|
|
1419
1412
|
<path d="M10.6707 21.692c1.392 0 2.04.564 2.28.996h1.644c-.264-1.08-1.248-2.364-3.924-2.364-2.028 0-3.408.912-3.408 2.436 0 1.536 1.2 2.34 2.904 2.508l1.512.156c.876.108 1.476.372 1.476 1.188 0 .684-.684 1.176-1.98 1.176-1.56 0-2.244-.72-2.472-1.26h-1.716c.336 1.224 1.404 2.628 4.188 2.628 2.412 0 3.624-1.116 3.624-2.652 0-1.8-1.308-2.448-3.012-2.616-.576-.06-.972-.108-1.5-.156-.888-.108-1.392-.444-1.392-1.02 0-.624.612-1.02 1.776-1.02Z" fill="#fff"/>
|
|
1420
1413
|
</svg>
|
|
1421
|
-
`,onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.mileage=new M(this.node.querySelector(`#${Mr}`),{title:"Miltal",value:this.state.value.mileage,id:Ur,error:this.state.interact.mileage&&!this.state.validation.mileage,errorMessage:"Ett miltal mellan 0 till 80 000 mil m\xE5ste anges",name:"mileage",autocomplete:"off",placeholder:"Ange bilens miltal",unit:"mil",pattern:"[0-9]*",inputmode:"numeric",onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.description=new Lr(this.node.querySelector(`#${xr}`),{title:"Beskrivning (valfritt)",value:this.state.value.description,id:Vr,error:this.state.interact.description&&!this.state.validation.description,errorMessage:"????",name:"description",autocomplete:"off",placeholder:"Beskriv bilen",onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),new
|
|
1414
|
+
`,onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.mileage=new M(this.node.querySelector(`#${Mr}`),{title:"Miltal",value:this.state.value.mileage,id:Ur,error:this.state.interact.mileage&&!this.state.validation.mileage,errorMessage:"Ett miltal mellan 0 till 80 000 mil m\xE5ste anges",name:"mileage",autocomplete:"off",placeholder:"Ange bilens miltal",unit:"mil",pattern:"[0-9]*",inputmode:"numeric",onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.description=new Lr(this.node.querySelector(`#${xr}`),{title:"Beskrivning (valfritt)",value:this.state.value.description,id:Vr,error:this.state.interact.description&&!this.state.validation.description,errorMessage:"????",name:"description",autocomplete:"off",placeholder:"Beskriv bilen",onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),new z(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 Qr="button-trade-in-yes",Yr=`${Qr}-node`,zr="button-trade-in-no",Kr=`${zr}-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"),$("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=H(this.node,{title:"Inbytesbil",active:l,completed:n,id:"trade-in"});c.innerHTML="";let m=document.createElement("div");if(a.navigation.stage>t||n&&a.navigation.stage!==t){let u=[];a.tradeIn&&a.tradeInVehicle?(u.push({key:"Miltal",value:`${a.tradeIn.mileage} mil`}),a.tradeIn.description&&u.push({key:"Beskrivning",value:`${a.tradeIn.description}`}),a.tradeIn.condition&&u.push({key:"Bilens skick",value:Ee[a.tradeIn.condition]}),m.innerHTML=`
|
|
1422
1415
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1423
1416
|
<div class="waykeecom-balloon">
|
|
1424
1417
|
<div class="waykeecom-stack waykeecom-stack--05">
|
|
@@ -1477,7 +1470,7 @@
|
|
|
1477
1470
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Yr}"></div>
|
|
1478
1471
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Kr}"></div>
|
|
1479
1472
|
</div>
|
|
1480
|
-
`,new N(m.querySelector(`#${Yr}`),{id:
|
|
1473
|
+
`,new N(m.querySelector(`#${Yr}`),{id:Qr,title:"Jag har inbytesbil",onClick:()=>this.onYesTradeIn()}),new K(m.querySelector(`#${Kr}`),{id:zr,title:"Hoppa \xF6ver detta steg",onClick:()=>this.onNoTradeIn()})));c.appendChild(m),a.navigation.stage===t&&c.parentElement?.scrollIntoView()}},jr=ko;var st={customer:{component:pa,name:"customer"},centralStorage:{component:ji,name:"centralStorage"},delivery:{component:fa,name:"delivery"},tradeIn:{component:jr,name:"tradeIn"},financial:{component:Jn,name:"financial"},insurance:{component:br,name:"insurance"},accessories:{component:Gi,name:"accessories"}};var yo=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){this.node.innerHTML=`
|
|
1481
1474
|
<h3 class="waykeecom-heading waykeecom-heading--4">K\xF6p online hos oss</h3>
|
|
1482
1475
|
<ul class="waykeecom-checklist" aria-label="F\xF6rdelar med att k\xF6pa bilen online hos oss">
|
|
1483
1476
|
${this.props.checklistItems.map(e=>` <li class="waykeecom-checklist__item">${e}</li>`).join("")}
|
|
@@ -1528,7 +1521,7 @@
|
|
|
1528
1521
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1529
1522
|
<div id="payment-menu" style="padding: 24px;border: 1px solid #ececeb;"></div>
|
|
1530
1523
|
</div>
|
|
1531
|
-
`}},ic=Eo;var W=f("@wayke-se/ecom");var Io=f("@wayke-se/ecom"),ac=s=>{let i=Io.bankid.newAuthRequest().withMethod(s).build();return Io.bankid.auth(i)};var fo=f("@wayke-se/ecom"),go=s=>{let i=fo.bankid.newCollectRequest().withOrderRef(s).build();return fo.bankid.collect(i)};var x=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=x.customers.newCustomer().withAddress(i.address).withPersonalNumber(i.customer.socialId).withEmail(i.customer.email).withPhoneNumber(i.customer.phone).build(),t=x.orders.newPayment().withType(i.paymentType);if(i.paymentType===x.PaymentType.Loan){let m=i.order?.paymentOptions.find(w=>w.type===x.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===x.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,P=i.creditAssessmentResponse.decision,X=u?.financialProductCode;if(!w||!R||!P||!X)throw"Missing credit assessment data";let L=x.orders.newCreditAssessment().withScoreId(w).withFinancialProductCode(X).withRecommendation(R).withDecision(P).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=x.orders.newCreateRequest().forVehicle(i.id).withCustomer(e).withPayment(o).withUrls(n,l).withDeliveryType(i.homeDelivery?x.DeliveryType.Delivery:x.DeliveryType.Pickup);if(i.insurance){let m=x.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=x.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 x.orders.create(c.build())};var rc=f("@wayke-se/ecom"),cc=s=>rc.creditAssessment.accept(s);var _o=f("@wayke-se/ecom"),lc=s=>{let i=_o.bankid.newQrCodeRequest().withOrderRef(s).build();return _o.bankid.qrcode(i)};var hc="confirm-conditions",dc=`${hc}-node`,mc="bankid-start-node",hd="bankid-start",pc="address-disclaimer-policy-node",uc="address-disclaimer-reservation-node",So=class extends r{constructor(e,t){super(e,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--2"});this.view=1;this.contexts={};this.ageError=!1;this.requestError=!1;this.socialIdNotMatchingError=!1;this.notAvailable=!1;this.confirmConditions=!1;this.bankidRequestRef=void 0;this.bankidStatus=async e=>{try{let t=await go(e);this.handleBankidStatusResponse(t,W.AuthMethod.QrCode)}catch{this.clearIntervals(),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering.")}};this.qrCode=async e=>{try{let o=(await lc(e)).getQrCode();this.contexts.bankId?.update(W.AuthMethod.QrCode,o)}catch{this.clearIntervals(),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta ny QR-kod f\xF6r BankId signering.")}};this.props=t,this.ageError=!1,this.render()}addWindowEvents(){this.removeWindowEvents(),window.addEventListener("focus",()=>this.onFocus())}removeWindowEvents(){window.removeEventListener("focus",()=>this.onFocus())}clearIntervals(){clearInterval(this.bankidQrCodeInterval),clearInterval(this.bankidStatusInterval)}async onFocus(){clearTimeout(this.focusTimeout),this.focusTimeout=setTimeout(async()=>{if(this.bankidRequestRef?.method===W.AuthMethod.SameDevice)try{let e=await go(this.bankidRequestRef.reference);this.handleBankidStatusResponse(e,this.bankidRequestRef.method)}catch{this.clearIntervals(),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering.")}},500)}onSameDeviceClick(){this.addWindowEvents()}setBankidRequestRef(e,t){this.bankidRequestRef={reference:e,method:t}}clearBankidRequestRef(){this.bankidRequestRef=void 0}async acceptCreditAssessment(){let{caseId:e}=this.props.store.getState();if(e)try{d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_REQUEST","CONFIRMATION"),await cc(e),d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_SUCCEEDED","CONFIRMATION")}catch{d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_FAILED","CONFIRMATION")}}async onCreateOrder(){let{store:e}=this.props;this.notAvailable=!1,this.requestError=!1;try{d("MAIN","CONFIRMATION_CREATE_ORDER_REQUESTED","CONFIRMATION");let{order:t}=e.getState(),o=await nc(e);d("MAIN","CONFIRMATION_CREATE_ORDER_SUCCEEDED","CONFIRMATION"),t?.isPaymentRequired&&O();let n=o.getPayment();ki(o.getOrderNumber(),n)(e.dispatch),this.acceptCreditAssessment()}catch(t){let o=t;this.view=1,d("MAIN","CONFIRMATION_CREATE_ORDER_FAILED","CONFIRMATION"),o.message==="The vehicle is not available for purchase"?(this.requestError=!1,this.notAvailable=!0):(this.notAvailable=!1,this.requestError=!0),O(),this.render()}}async handleBankidStatusResponse(e,t){if(e.isCompleted()){this.removeWindowEvents(),this.clearBankidRequestRef(),this.clearIntervals();let o=e.getAddress(),a=e.getPersonalNumber();if(o&&a){let n=this.props.store.getState();if(C.requiredSsnOver18(a)){if(n.customer.socialId!==a){d("MAIN",t===W.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED_SSN_MISSMATCH":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED_SSN_MISSMATCH","CONFIRMATION"),this.view=1,this.socialIdNotMatchingError=!0,O(),this.render();return}}else{d("MAIN",t===W.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED_NOT_OVER_18":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED_NOT_OVER_18","CONFIRMATION"),this.view=1,this.ageError=!0,O(),this.render();return}d("MAIN",t===W.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED","CONFIRMATION"),this.contexts.bankId?.setDescription("Verifiering klar, ordern skapas nu..."),await this.onCreateOrder()}}}async startBankidSameDevice(e,t,o=!1){o||d("MAIN","CONFIRMATION_BANKID_STATUS_SAME_DEVICE_REQUESTED","CONFIRMATION");try{this.setBankidRequestRef(t,W.AuthMethod.SameDevice);let a=e.getAutoLaunchUrl();this.contexts.bankId?.update(W.AuthMethod.SameDevice,a)}catch(a){this.removeWindowEvents(),this.clearBankidRequestRef();let n=a;this.contexts.bankId?.setErrorMessage(`Error: ${n.message}`)}}async startBankidWithQr(e,t=!1){t||d("MAIN","CONFIRMATION_BANKID_STATUS_QR_REQUESTED","CONFIRMATION"),this.bankidStatusInterval=setInterval(()=>{this.bankidStatus(e)},2e3),Oe("bankidStatusInterval",this.bankidStatusInterval),this.qrCode(e),this.bankidQrCodeInterval=setInterval(async()=>{this.qrCode(e)},1e3),Oe("bankidQrCodeInterval",this.bankidQrCodeInterval)}async onStartBankIdAuth(e,t=!1){this.clearIntervals();try{t||d("MAIN","CONFIRMATION_BANKID_INIT_REQUESTED","CONFIRMATION"),this.contexts.bankId?.update(e),this.contexts.buttonLinkToggle?.disabled(!0);let o=await ac(e);t||d("MAIN","CONFIRMATION_BANKID_INIT_SUCCEEDED","CONFIRMATION");let a=o.getOrderRef();e===W.AuthMethod.QrCode?this.startBankidWithQr(a,t):this.startBankidSameDevice(o,a,t)}catch{d("MAIN","CONFIRMATION_BANKID_INIT_FAILED","CONFIRMATION"),this.contexts.bankId?.setErrorMessage("Det gick tyv\xE4rr inte att initiera BankId. V\xE4nligen f\xF6rs\xF6k igen.")}finally{this.contexts.buttonLinkToggle?.disabled(!1)}}onAbort(){this.clearBankidRequestRef(),this.removeWindowEvents(),this.clearIntervals(),d("MAIN","CONFIRMATION_BANKID_ABORTED","CONFIRMATION"),this.view=1,O(),this.render()}onCheckbox(e){let t=e.currentTarget;this.confirmConditions=t.checked,this.contexts.confirmConditions?.checked(this.confirmConditions),this.contexts.startBankid?.disabled(!this.confirmConditions)}render(){let e=Ie(),{navigation:t,order:o,insurance:a}=this.props.store.getState();if(this.view===2)this.contexts.bankId=new je(
|
|
1524
|
+
`}},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 x=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=x.customers.newCustomer().withAddress(i.address).withPersonalNumber(i.customer.socialId).withEmail(i.customer.email).withPhoneNumber(i.customer.phone).build(),t=x.orders.newPayment().withType(i.paymentType);if(i.paymentType===x.PaymentType.Loan){let m=i.order?.paymentOptions.find(w=>w.type===x.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===x.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,P=i.creditAssessmentResponse.decision,X=u?.financialProductCode;if(!w||!R||!P||!X)throw"Missing credit assessment data";let L=x.orders.newCreditAssessment().withScoreId(w).withFinancialProductCode(X).withRecommendation(R).withDecision(P).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=x.orders.newCreateRequest().forVehicle(i.id).withCustomer(e).withPayment(o).withUrls(n,l).withDeliveryType(i.homeDelivery?x.DeliveryType.Delivery:x.DeliveryType.Pickup);if(i.insurance){let m=x.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=x.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 x.orders.create(c.build())};var rc=f("@wayke-se/ecom"),cc=s=>rc.creditAssessment.accept(s);var _o=f("@wayke-se/ecom"),lc=s=>{let i=_o.bankid.newQrCodeRequest().withOrderRef(s).build();return _o.bankid.qrcode(i)};var hc="confirm-conditions",dc=`${hc}-node`,mc="bankid-start-node",hd="bankid-start",pc="address-disclaimer-policy-node",uc="address-disclaimer-reservation-node",So=class extends r{constructor(e,t){super(e,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--2"});this.view=1;this.contexts={};this.ageError=!1;this.requestError=!1;this.socialIdNotMatchingError=!1;this.notAvailable=!1;this.confirmConditions=!1;this.bankidRequestRef=void 0;this.bankidStatus=async e=>{try{let t=await go(e);this.handleBankidStatusResponse(t,W.AuthMethod.QrCode)}catch{this.clearIntervals(),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering.")}};this.qrCode=async e=>{try{let o=(await lc(e)).getQrCode();this.contexts.bankId?.update(W.AuthMethod.QrCode,o)}catch{this.clearIntervals(),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta ny QR-kod f\xF6r BankId signering.")}};this.props=t,this.ageError=!1,this.render()}addWindowEvents(){this.removeWindowEvents(),window.addEventListener("focus",()=>this.onFocus())}removeWindowEvents(){window.removeEventListener("focus",()=>this.onFocus())}clearIntervals(){clearInterval(this.bankidQrCodeInterval),clearInterval(this.bankidStatusInterval)}async onFocus(){clearTimeout(this.focusTimeout),this.focusTimeout=setTimeout(async()=>{if(this.bankidRequestRef?.method===W.AuthMethod.SameDevice)try{let e=await go(this.bankidRequestRef.reference);this.handleBankidStatusResponse(e,this.bankidRequestRef.method)}catch{this.clearIntervals(),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering.")}},500)}onSameDeviceClick(){this.addWindowEvents()}setBankidRequestRef(e,t){this.bankidRequestRef={reference:e,method:t}}clearBankidRequestRef(){this.bankidRequestRef=void 0}async acceptCreditAssessment(){let{caseId:e}=this.props.store.getState();if(e)try{d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_REQUEST","CONFIRMATION"),await cc(e),d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_SUCCEEDED","CONFIRMATION")}catch{d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_FAILED","CONFIRMATION")}}async onCreateOrder(){let{store:e}=this.props;this.notAvailable=!1,this.requestError=!1;try{d("MAIN","CONFIRMATION_CREATE_ORDER_REQUESTED","CONFIRMATION");let{order:t}=e.getState(),o=await nc(e);d("MAIN","CONFIRMATION_CREATE_ORDER_SUCCEEDED","CONFIRMATION"),t?.isPaymentRequired&&O();let n=o.getPayment();ki(o.getOrderNumber(),n)(e.dispatch),this.acceptCreditAssessment()}catch(t){let o=t;this.view=1,d("MAIN","CONFIRMATION_CREATE_ORDER_FAILED","CONFIRMATION"),o.message==="The vehicle is not available for purchase"?(this.requestError=!1,this.notAvailable=!0):(this.notAvailable=!1,this.requestError=!0),O(),this.render()}}async handleBankidStatusResponse(e,t){if(e.isCompleted()){this.removeWindowEvents(),this.clearBankidRequestRef(),this.clearIntervals();let o=e.getAddress(),a=e.getPersonalNumber();if(o&&a){let n=this.props.store.getState();if(C.requiredSsnOver18(a)){if(n.customer.socialId!==a){d("MAIN",t===W.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED_SSN_MISSMATCH":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED_SSN_MISSMATCH","CONFIRMATION"),this.view=1,this.socialIdNotMatchingError=!0,O(),this.render();return}}else{d("MAIN",t===W.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED_NOT_OVER_18":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED_NOT_OVER_18","CONFIRMATION"),this.view=1,this.ageError=!0,O(),this.render();return}d("MAIN",t===W.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED","CONFIRMATION"),this.contexts.bankId?.setDescription("Verifiering klar, ordern skapas nu..."),await this.onCreateOrder()}}}async startBankidSameDevice(e,t,o=!1){o||d("MAIN","CONFIRMATION_BANKID_STATUS_SAME_DEVICE_REQUESTED","CONFIRMATION");try{this.setBankidRequestRef(t,W.AuthMethod.SameDevice);let a=e.getAutoLaunchUrl();this.contexts.bankId?.update(W.AuthMethod.SameDevice,a)}catch(a){this.removeWindowEvents(),this.clearBankidRequestRef();let n=a;this.contexts.bankId?.setErrorMessage(`Error: ${n.message}`)}}async startBankidWithQr(e,t=!1){t||d("MAIN","CONFIRMATION_BANKID_STATUS_QR_REQUESTED","CONFIRMATION"),this.bankidStatusInterval=setInterval(()=>{this.bankidStatus(e)},2e3),Oe("bankidStatusInterval",this.bankidStatusInterval),this.qrCode(e),this.bankidQrCodeInterval=setInterval(async()=>{this.qrCode(e)},1e3),Oe("bankidQrCodeInterval",this.bankidQrCodeInterval)}async onStartBankIdAuth(e,t=!1){this.clearIntervals();try{t||d("MAIN","CONFIRMATION_BANKID_INIT_REQUESTED","CONFIRMATION"),this.contexts.bankId?.update(e),this.contexts.buttonLinkToggle?.disabled(!0);let o=await ac(e);t||d("MAIN","CONFIRMATION_BANKID_INIT_SUCCEEDED","CONFIRMATION");let a=o.getOrderRef();e===W.AuthMethod.QrCode?this.startBankidWithQr(a,t):this.startBankidSameDevice(o,a,t)}catch{d("MAIN","CONFIRMATION_BANKID_INIT_FAILED","CONFIRMATION"),this.contexts.bankId?.setErrorMessage("Det gick tyv\xE4rr inte att initiera BankId. V\xE4nligen f\xF6rs\xF6k igen.")}finally{this.contexts.buttonLinkToggle?.disabled(!1)}}onAbort(){this.clearBankidRequestRef(),this.removeWindowEvents(),this.clearIntervals(),d("MAIN","CONFIRMATION_BANKID_ABORTED","CONFIRMATION"),this.view=1,O(),this.render()}onCheckbox(e){let t=e.currentTarget;this.confirmConditions=t.checked,this.contexts.confirmConditions?.checked(this.confirmConditions),this.contexts.startBankid?.disabled(!this.confirmConditions)}render(){let e=Ie(),{navigation:t,order:o,insurance:a}=this.props.store.getState();if(this.view===2)this.contexts.bankId=new je(Q(),{method:e?W.AuthMethod.SameDevice:W.AuthMethod.QrCode,descriptionQrCode:"F\xF6r att verifiera din identitet, starta din BankID applikation p\xE5 din andra enhet.",descriptionSameDevice:"F\xF6r att verifiera din identitet, starta din BankID-applikation.",onAbort:()=>this.onAbort(),onStart:n=>this.onStartBankIdAuth(n),onSameDeviceClick:()=>this.onSameDeviceClick()});else{let n=o?.contactInformation?.name,l=o?.conditionsPdfUri,c="https://www.wayke.se/trygghet-naer-det-kommer-till-dina-personuppgifter";this.node.innerHTML=`
|
|
1532
1525
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1533
1526
|
<h4 class="waykeecom-heading waykeecom-heading--4">Strax klart!</h4>
|
|
1534
1527
|
<div class="waykeecom-content">
|
|
@@ -1645,7 +1638,7 @@
|
|
|
1645
1638
|
</div>
|
|
1646
1639
|
<div class="waykeecom-stack waykeecom-stack--05">
|
|
1647
1640
|
<ul class="waykeecom-key-value-list">
|
|
1648
|
-
${E({key:"Privatleasing",value
|
|
1641
|
+
${E({key:"Privatleasing",value:`Fr\xE5n ${k(l?.price,{postfix:l?.unit})}`})}
|
|
1649
1642
|
</ul>
|
|
1650
1643
|
</div>
|
|
1651
1644
|
`:""}
|
|
@@ -1882,5 +1875,5 @@
|
|
|
1882
1875
|
<div class="waykeecom-stack waykeecom-stack--1" id="${$c}"></div>
|
|
1883
1876
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Pc}"></div>
|
|
1884
1877
|
</div>
|
|
1885
|
-
`,new Je(this.node.querySelector(`#${$c}`),{title:"Forts\xE4tt min order",onClick:()=>t()}),new xc(this.node.querySelector(`#${Pc}`),{title:"Avbryt min order",onClick:()=>e()})}},Hc=Yo;var Ko=()=>{let s=document.documentElement.clientWidth/100;document.documentElement.style.setProperty("--waykeecom-vw",`${s}px`)},Bc=()=>(Ko(),window.addEventListener("resize",Ko),()=>window.removeEventListener("resize",Ko));var
|
|
1878
|
+
`,new Je(this.node.querySelector(`#${$c}`),{title:"Forts\xE4tt min order",onClick:()=>t()}),new xc(this.node.querySelector(`#${Pc}`),{title:"Avbryt min order",onClick:()=>e()})}},Hc=Yo;var Ko=()=>{let s=document.documentElement.clientWidth/100;document.documentElement.style.setProperty("--waykeecom-vw",`${s}px`)},Bc=()=>(Ko(),window.addEventListener("resize",Ko),()=>window.removeEventListener("resize",Ko));var Qo="order",kd="wayke-ecom-web-payment",zo="wayke-ecom-web-id",Ce="wayke-ecom-modal",yd="ecom.wayketech.se",vd="ecom.wayke.se",Ed=s=>{switch(new URL(s).host){case vd:return"https://cdn.wayke.se";case yd:return"https://test-cdn.wayketech.se";default:return}},jo=class{constructor(i){this.contexts={store:gi()};if(!i.id)throw"Missing id";this.props=i,window.process||(window.process={...window.process||{},env:{}}),Fc.config.bind(i.ecomSdkConfig),this.cdnMedia=Ed(i.ecomSdkConfig.api.address);let e=document.createElement("div");if(e.className="waykeecom-root",this.root=e,this.props.rootId){let l=document.getElementById(this.props.rootId);if(!l)throw"Missing element with id wayke-ecom";l.appendChild(e)}else document.body.appendChild(this.root);this.root.dataset.version=Xo.version,this.stageOrderList=["centralStorage","customer","financial","tradeIn","accessories","insurance","delivery"],si(i.id)(this.contexts.store.dispatch),this.view=this.contexts.store.getState().navigation.view,_(this.contexts.store,"navigation.view",l=>{this.view=l,l!=="preview"&&this.render()},!0);let t=new URLSearchParams(location.search),o=t.get(Qo)||void 0,a=!!t.get(kd),n=t.get(zo);if(n&&n===this.props.id&&(o||a))if(a){let l=sessionStorage.getItem("wayke-ecom-state");sessionStorage.removeItem("wayke-ecom-state");let c=l?JSON.parse(l):void 0;c&&(this.view=c.navigation.view,yi({...c,stateLoadedFromSession:!0})(this.contexts.store.dispatch))}else o&&this.render({orderUrl:o,id:n})}close(){let i=Te();i&&d(i.view,"CLOSE",i.currentStep);let{caseId:e}=this.contexts.store.getState(),t=new URLSearchParams(location.search),o=t.get(Qo),a=t.get(zo),n=!1;o&&(t.delete(Qo),n=!0,location.search=t.toString()),a&&(t.delete(zo),n=!0),n&&(location.search=t.toString()),this.root.innerHTML="",this.contexts?.unsubribeVwListner?.(),Ts(),Ni(),e&&Re(e),sessionStorage.removeItem("wayke-ecom-state"),ti(this.props.id)(this.contexts.store.dispatch),this.props.onEvent&&Ti(this.props.onEvent)}destroy(){this.close(),this.root.remove()}closeWithConfirm(){let{navigation:i,createdOrderId:e}=this.contexts.store.getState(),t=i.view==="preview";if(Ts(),t||e){this.close();return}this.contexts.modal=new qo(this.root,{title:"Wayke Ecom",id:Ce,logo:this.props.logo,logoX2:this.props.logoX2});let o=Te();o&&d(o.view,"CONFIRM_CLOSE_ACTIVE"),new Hc(this.contexts.modal.content,{onConfirmClose:()=>{let a=Te();d(a.view,"CONFIRM_CLOSE_CONFIRMED",a.currentStep),this.close()},onAbortClose:()=>{let a=Te();d(a.view,"CONFIRM_CLOSE_ABORTED",a.currentStep),this.render()}})}start(){this.props.onEvent&&Ai(this.props.onEvent),d("PREVIEW","START"),this.render()}render(i){if(this.contexts.unsubribeVwListner||(this.contexts.unsubribeVwListner=Bc()),this.contexts.modal=new qo(this.root,{title:"Wayke Ecom",id:Ce,logo:this.props.logo,logoX2:this.props.logoX2,onClose:()=>this.closeWithConfirm()}),this.contexts.modal.content){if(this.contexts.modal.content.innerHTML="",i){new Ac(this.contexts.modal.content,{store:this.contexts.store,callbackOrder:i,onClose:()=>this.close()});return}switch(this.view){case"preview":new tc(this.contexts.modal.content,{store:this.contexts.store,stageOrderList:this.stageOrderList,vehicle:this.props.vehicle,cdnMedia:this.cdnMedia});break;case"main":new vc(this.contexts.modal.content,{store:this.contexts.store,cdnMedia:this.cdnMedia});break;case"summary":new Nc(this.contexts.modal.content,{store:this.contexts.store,cdnMedia:this.cdnMedia,onClose:()=>this.close()});break;default:throw"Unknown view..."}}}},Uc=jo;var y_=Uc;})();
|
|
1886
1879
|
//# sourceMappingURL=index.js.map
|