@wayke-se/ecom-web 1.5.1-beta.3 → 1.5.1-beta.4
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 +41 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -40
- package/dist/index.mjs.map +1 -1
- 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 jc=Object.getOwnPropertyNames;var Qc=Object.getPrototypeOf,zc=Object.prototype.hasOwnProperty;var f=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(i,e)=>(typeof require<"u"?require:i)[e]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+s+'" is not supported')});var Jc=(s,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of jc(i))!zc.call(s,o)&&o!==e&&Jo(s,o,{get:()=>i[o],enumerable:!(t=Kc(i,o))||t.enumerable});return s};var Xc=(s,i,e)=>(e=s!=null?Yc(Qc(s)):{},Jc(i||!s||!s.__esModule?Jo(e,"default",{value:s,enumerable:!0}):e,s));var Fc=f("@wayke-se/ecom");var Xo={name:"@wayke-se/ecom-web",version:"1.5.1-beta.4",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",H=(s,i,e)=>t=>t({type:gt,view:s,index:i,subStage:e}),_t="SET_STAGES",hi=s=>i=>i({type:_t,stages:s}),St="SET_CREATED_ORDER_ID",ki=(s,i)=>e=>e({type:St,id:s,payment:i}),wt="SET_CREDIT_ASSESSMENT_RESPONSE",me=(s,i)=>e=>e({type:wt,caseId:s,creditAssessmentResponse:i}),Nt="SET_STATE",yi=s=>i=>i({type:Nt,state:s});var el={};var vi={view:"preview",stage:1,subStage:1},Ei={id:"",topNavigation:{...vi},navigation:{...vi},customer:{email:"",phone:"",givenName:"",surname:"",socialId:""},homeDelivery:!1,accessories:[],drivingDistance:Ae.DrivingDistance.Between0And1000,...el},ne=(s,i)=>i?{view:"summary",stage:1,subStage:1}:{view:"main",stage:s+1,subStage:1},re=(s,i)=>i.view==="main"?s.stage<i.stage?i:v.topNavigation:{...s,stage:s.stage+1},At=s=>s&&s?.length===1&&s?.[0].type===Ae.PaymentType.Cash?Ae.PaymentType.Cash:void 0,v,Tt,tl=(s=Ei,i)=>{let e,t;switch(v={...s},i.type){case it:return{...Ei,id:i.id};case _t:return{...v,stages:i.stages};case nt:return{...v,id:i.id};case at:return{...s,order:i.order,paymentType:At(i.order?.paymentOptions),vehicle:{...i.order.orderVehicle,...i.vehicle||{}}};case rt:let o={...v,customer:{...s.customer,email:i.value.email,phone:i.value.phone},navigation:{view:"main",stage:s.navigation.stage,subStage:2}};return delete o.wantTradeIn,delete o.tradeIn,delete o.tradeInVehicle,o.paymentType=At(s.order?.paymentOptions),delete o.paymentLookupResponse,delete o.insurance,delete o.insuranceAddOns,delete o.freeInsurance,delete o.dealer,o.accessories=[],o;case ct:return e=ne(v.navigation.stage,i.lastStage),t=re(v.topNavigation,e),v={...s,navigation:e,topNavigation:t,address:i.address,customer:{...s.customer,socialId:i.socialId}},v;case dt:return e=ne(s.navigation.stage,i.lastStage),t={...e},v={...s,navigation:e,topNavigation:t,dealer:i.dealer},delete v.wantTradeIn,delete v.tradeIn,delete v.tradeInVehicle,v.paymentType=At(s.order?.paymentOptions),delete v.paymentLookupResponse,delete v.insurance,delete v.insuranceAddOns,delete v.freeInsurance,v.accessories=[],v;case lt:return e=ne(s.navigation.stage,i.lastStage),t=re(v.topNavigation,e),v={...s,navigation:e,topNavigation:t,homeDelivery:i.homeDelivery},v;case mt:return e={view:"main",stage:s.navigation.stage,subStage:1},t=re(v.topNavigation,e),v={...s,navigation:e,wantTradeIn:!0,topNavigation:t,tradeIn:s.tradeIn||{registrationNumber:"",mileage:"",description:""}},v;case pt:return e=ne(s.navigation.stage,i.lastStage),t=re(v.topNavigation,e),v={...s,navigation:e,topNavigation:t,wantTradeIn:!!i.tradeIn,tradeIn:i.tradeIn,tradeInVehicle:i.tradeInVehicle},v;case ut:return e=ne(s.navigation.stage,i.lastStage),t=re(v.topNavigation,e),{...v,navigation:e,topNavigation:t,paymentType:i.paymentType};case ht:return{...v,paymentLookupResponse:i.paymentLookupResponse};case kt:return{...v,drivingDistance:i.drivingDistance};case yt:return e=ne(s.navigation.stage,i.lastStage),t=re(v.topNavigation,e),v={...s,navigation:e,topNavigation:t},v;case Et:return v.insurance=i.insurance,v.insuranceAddOns={insurance:i.insurance.name,addOns:i.insuranceAddons},v;case vt:return ot(v.insurance,i.insurance)?v.insurance=void 0:v.insurance=i.insurance,v.insuranceAddOns?.insurance&&(v.insuranceAddOns=void 0),v;case It:return ot(v.freeInsurance,i.freeInsurance)?v.freeInsurance=void 0:v.freeInsurance=i.freeInsurance,v;case ft:return Tt=v.accessories.findIndex(a=>a.id===i.accessory.id),v.accessories=[...v.accessories],Tt>-1?v.accessories.splice(Tt,1):v.accessories.push(i.accessory),{...v,accessories:[...v.accessories]};case gt:return{...s,navigation:{view:i.view,stage:i.index||1,subStage:i.subStage||1}};case St:return i.payment?e={view:"main",stage:s.navigation.stage,subStage:2}:e=ne(s.navigation.stage,!0),t=re(v.topNavigation,e),v={...s,navigation:e,topNavigation:t,createdOrderId:i.id,payment:i.payment},v;case wt:return{...v,caseId:i.caseId,creditAssessmentResponse:i.creditAssessmentResponse};case Nt:return{...i.state};default:return s}},Ii=tl;var gi=()=>(0,fi.createStore)(Ii);var Pe=(s,i)=>{if(!i)return s;let e=new URL(s);return`${i}${e.pathname}`};var sl=s=>s.toString().replace(/\s/g,""),ol=(s,i)=>{if(!i)return s;let e=Math.pow(10,i);return(Math.round(s*e)/e).toFixed(i)},k=(s,i)=>{if(s===void 0)return"???";let e=ol(s,i?.decimals!==void 0?i.decimals:0);return`${i?.prefix?`${i.prefix}`:""}${sl(e).replace(/\B(?=(\d{3})+(?!\d))/g," ")}${i?.postfix?` ${i.postfix}`:""}`},il=(s,i)=>{let e=s.split(" "),t=i.split(" ").map(o=>o.toLowerCase());return e.filter(o=>!t.includes(o.toLowerCase())).join(" ")},pe=s=>{if(!!s)return il(s.shortDescription||"",s.title||"")};var al=({vehicle:s,order:i,meta:e,cdnMedia:t})=>{let o=s?.imageUrls,a=s?.title,n=k(s?.price||NaN),l=i?.contactInformation?.name;return`
|
|
2
2
|
<div class="waykeecom-product-card">
|
|
3
3
|
${o?.length?`
|
|
4
4
|
<div class="waykeecom-product-card__media">
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
</div>
|
|
125
125
|
</div>
|
|
126
126
|
`:""}
|
|
127
|
-
`,o&&this.node.querySelector("button")?.addEventListener("click",()=>o())}},
|
|
127
|
+
`,o&&this.node.querySelector("button")?.addEventListener("click",()=>o())}},z=Rt;var Lt=f("object-path"),ul=(s,i)=>s===i,hl=(s,i,e)=>{let t=e||ul,o=(0,Lt.get)(s(),i);return a=>()=>{let n=(0,Lt.get)(s(),i);if(!t(o,n)){let l=o;o=n,a(n,l,i)}}},wi=[],kl=s=>(wi.push(s),s),Ni=()=>wi.forEach(s=>s()),yl=(s,i,e,t)=>{let o=hl(s.getState,i);if(t)s.subscribe(o(e));else return kl(s.subscribe(o(e)))},_=yl;var vl=(s,i)=>{let{title:e,active:t,completed:o,id:a}=i,n=document.getElementById(a),l=n||document.createElement("section");l.setAttribute("aria-label",e),n||l.setAttribute("id",a);let c=["waykeecom-stepper__item"];t?c.push("waykeecom-stepper__item--is-active"):o?c.push("waykeecom-stepper__item--is-complete"):c.push("waykeecom-stepper__item--is-disabled"),l.className=c.join(" "),l.innerHTML=`
|
|
128
128
|
<header class="waykeecom-stepper__header">
|
|
129
129
|
<div class="waykeecom-stepper__icon" aria-hidden="true">
|
|
130
130
|
<div class="waykeecom-icon-backdrop waykeecom-icon-backdrop--success">
|
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
</div>
|
|
216
216
|
<div class="waykeecom-tile__footer" id="${y}"></div>
|
|
217
217
|
</div>
|
|
218
|
-
`,h&&new V(this.node.querySelector(`#${p}`),{title:"L\xE4s mer",onClick:()=>h()}),new ee(this.node.querySelector(`#${y}`),{selected:m,onClick:()=>u()})}},he=Bt;var
|
|
218
|
+
`,h&&new V(this.node.querySelector(`#${p}`),{title:"L\xE4s mer",onClick:()=>h()}),new ee(this.node.querySelector(`#${y}`),{selected:m,onClick:()=>u()})}},he=Bt;var j=()=>{O();let s=document.getElementById("wayke-ecom-modal-body");s&&s.firstElementChild.setAttribute("hidden","");let i=document.createElement("div");return i.className="waykeecom-portal",s?.appendChild(i),i},O=()=>{let s=document.getElementById("wayke-ecom-modal-body");s&&s.firstElementChild.removeAttribute("hidden"),s?.childNodes.forEach((i,e)=>{e>0&&i.remove()})};var Ft=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{title:e,id:t,onClick:o}=this.props;this.node.innerHTML=`
|
|
219
219
|
<button type="button" id="${t}" title="${e}" class="waykeecom-button waykeecom-button--full-width waykeecom-button--action-clear">
|
|
220
220
|
${e}
|
|
221
221
|
</button>
|
|
@@ -295,7 +295,7 @@
|
|
|
295
295
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Mi}"></div>
|
|
296
296
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Oi}"></div>
|
|
297
297
|
</div>
|
|
298
|
-
`,new bi(this.node.querySelector(`#${xi}`),{id:`gallery-${e.id}`,media:l.map((y,g)=>({url:y.url,alt:`Bild ${g+1}`})),onGalleryImagePaging:()=>this.onGalleryImagePaging()}),new ce(this.node.querySelector(`#${Li}`),{title:"Tillbaka",onClick:()=>a()}),new te(this.node.querySelector(`#${Oi}`),{title:"Tillbaka",onClick:()=>a()}),new ee(this.node.querySelector(`#${Mi}`),{selected:t,fullSize:!0,onClick:()=>o()}),G()}},Pi=Wt;var Yt=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.exposureTracked=!1;this.props=t,_(this.props.store,"accessories",(o,a)=>{o.some(n=>n.id===this.props.accessory.id)!==a.some(n=>n.id===this.props.accessory.id)&&this.render()}),this.render()}onInfoOpen(){let{accessory:e}=this.props;d("MAIN","ACCESSORY_INFORMATION_OPEN","ACCESSORY",{id:e.id,label:e.name}),this.displayInfo=!0,this.render()}onInfoClose(){let{accessory:e}=this.props;d("MAIN","ACCESSORY_INFORMATION_CLOSE","ACCESSORY",{id:e.id,label:e.name}),this.displayInfo=!1,O(),this.render(),this.node.parentElement?.scrollIntoView()}onClick(){let{store:e,accessory:t}=this.props,a=e.getState().accessories.findIndex(n=>n.id===t.id)>-1;d("MAIN",a?"ACCESSORY_UNSELECTED":"ACCESSORY_SELECTED","ACCESSORY",{id:t.id,label:t.name}),ui(this.props.accessory)(this.props.store.dispatch)}trackExposure(){let{accessory:e}=this.props;this.exposureTracked=!0,d("MAIN","ACCESSORY_EXPOSURE","ACCESSORY",{id:e.id,label:e.name})}render(){let{store:e,accessory:t,key:o}=this.props,n=e.getState().accessories.findIndex(l=>l.id===t.id)>-1;this.displayInfo&&new Pi(
|
|
298
|
+
`,new bi(this.node.querySelector(`#${xi}`),{id:`gallery-${e.id}`,media:l.map((y,g)=>({url:y.url,alt:`Bild ${g+1}`})),onGalleryImagePaging:()=>this.onGalleryImagePaging()}),new ce(this.node.querySelector(`#${Li}`),{title:"Tillbaka",onClick:()=>a()}),new te(this.node.querySelector(`#${Oi}`),{title:"Tillbaka",onClick:()=>a()}),new ee(this.node.querySelector(`#${Mi}`),{selected:t,fullSize:!0,onClick:()=>o()}),G()}},Pi=Wt;var Yt=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.exposureTracked=!1;this.props=t,_(this.props.store,"accessories",(o,a)=>{o.some(n=>n.id===this.props.accessory.id)!==a.some(n=>n.id===this.props.accessory.id)&&this.render()}),this.render()}onInfoOpen(){let{accessory:e}=this.props;d("MAIN","ACCESSORY_INFORMATION_OPEN","ACCESSORY",{id:e.id,label:e.name}),this.displayInfo=!0,this.render()}onInfoClose(){let{accessory:e}=this.props;d("MAIN","ACCESSORY_INFORMATION_CLOSE","ACCESSORY",{id:e.id,label:e.name}),this.displayInfo=!1,O(),this.render(),this.node.parentElement?.scrollIntoView()}onClick(){let{store:e,accessory:t}=this.props,a=e.getState().accessories.findIndex(n=>n.id===t.id)>-1;d("MAIN",a?"ACCESSORY_UNSELECTED":"ACCESSORY_SELECTED","ACCESSORY",{id:t.id,label:t.name}),ui(this.props.accessory)(this.props.store.dispatch)}trackExposure(){let{accessory:e}=this.props;this.exposureTracked=!0,d("MAIN","ACCESSORY_EXPOSURE","ACCESSORY",{id:e.id,label:e.name})}render(){let{store:e,accessory:t,key:o}=this.props,n=e.getState().accessories.findIndex(l=>l.id===t.id)>-1;this.displayInfo&&new Pi(j(),{accessory:t,selected:n,onClick:()=>{this.onInfoClose(),this.onClick()},onClose:()=>this.onInfoClose()}),new he(this.node,{id:t.id,title:t.name,description:t.shortDescription,logo:t.logoUrl,image:t.media?.[0]?.url,price:k(t.price,{postfix:"kr"}),selected:n,onClick:()=>this.onClick(),onInfo:()=>this.onInfoOpen(),inViewPort:this.exposureTracked?void 0:()=>this.trackExposure()},o)}},$i=Yt;var Kt=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{accessories:e,store:t}=this.props,o=new ue(this.node,{id:"accessories-list",onClick:()=>d("MAIN","ACCESSORY_ARROWS","ACCESSORY")}),{overflowElement:a}=o;a&&(a.innerHTML="",e.forEach((n,l)=>new $i(a,{store:t,accessory:n,key:`accessory-${n.id}-${l}`})))}},Hi=Kt;var Vi="button-accessories-proceed",Bi=`${Vi}-node`,Sl="button-accessories-skip",Fi=`${Sl}-node`,Ui="accessory-grid-list-node",jt=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation",()=>{this.render()}),this.render()}onProceed(){Z(this.props.lastStage)(this.props.store.dispatch)}onEdit(){d("MAIN","ACCESSORY_EDIT","ACCESSORY"),H("main",this.props.index)(this.props.store.dispatch)}render(){let{store:e,index:t}=this.props,o=e.getState(),a=o.topNavigation.stage>t,n=o.navigation.stage===t;n&&d("MAIN","ACCESSORY_ACTIVE","ACCESSORY");let l=B(this.node,{completed:a,title:"Tillbeh\xF6r",active:n,id:"accessories"}),c=document.createElement("div");if(o.navigation.stage>t||a&&o.navigation.stage!==t)new z(l,{keyValueList:o.accessories.length?o.accessories.map(m=>({key:m.name,image:m.media[0]?{src:`${m.media[0].url}?w=32&h=32`,srcSet:`${m.media[0].url}?w=64&h=64 2x`,alt:m.name}:void 0,value:k(m.price,{postfix:"kr"})})):[{key:"Tillbeh\xF6r",value:"Inga valda"}],changeButtonTitle:"\xC4ndra tillbeh\xF6r",onEdit:o.createdOrderId?void 0:()=>this.onEdit()});else if(o.navigation.stage===t){let m=o.order?.accessories||[];c.innerHTML=`
|
|
299
299
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
300
300
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
301
301
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vill du k\xF6pa till ett tillbeh\xF6r till din nya bil?</h4>
|
|
@@ -311,7 +311,7 @@
|
|
|
311
311
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Bi}"></div>
|
|
312
312
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Fi}"></div>
|
|
313
313
|
</div>
|
|
314
|
-
`,new Hi(c.querySelector(`#${Ui}`),{store:e,accessories:m}),new N(c.querySelector(`#${Bi}`),{id:Vi,title:"G\xE5 vidare",onClick:()=>this.onProceed()}),new K(c.querySelector(`#${Fi}`),{title:"Hoppa \xF6ver detta steg",onClick:()=>this.onProceed()})}l.appendChild(c),o.navigation.stage===t&&l.parentElement?.scrollIntoView()}},Gi=
|
|
314
|
+
`,new Hi(c.querySelector(`#${Ui}`),{store:e,accessories:m}),new N(c.querySelector(`#${Bi}`),{id:Vi,title:"G\xE5 vidare",onClick:()=>this.onProceed()}),new K(c.querySelector(`#${Fi}`),{title:"Hoppa \xF6ver detta steg",onClick:()=>this.onProceed()})}l.appendChild(c),o.navigation.stage===t&&l.parentElement?.scrollIntoView()}},Gi=jt;var qi="waykeecom-input-error",Qt=class extends r{constructor(e,t){super(e);this.props=t,this.render()}setError(e){this.props.error=e,this.render()}render(){let{error:e,errorMessage:t}=this.props,o=this.node.querySelector(`.${qi}`);if(o)e||o.remove();else if(e){let a=document.createElement("div");a.className=qi,a.setAttribute("role","alert"),a.innerHTML=t,this.node.appendChild(a)}}},se=Qt;var zt=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{id:e,title:t,value:o,name:a,checked:n,meta:l,description:c,disabled:m,onClick:u}=this.props;this.node.innerHTML=`
|
|
315
315
|
<div class="waykeecom-input-selection" role="radio">
|
|
316
316
|
<input
|
|
317
317
|
type="radio"
|
|
@@ -332,7 +332,7 @@
|
|
|
332
332
|
</label>
|
|
333
333
|
`:""}
|
|
334
334
|
</div>
|
|
335
|
-
`;let h=this.node.querySelector(`#${e}`);h&&u&&h.addEventListener("click",u)}},be=
|
|
335
|
+
`;let h=this.node.querySelector(`#${e}`);h&&u&&h.addEventListener("click",u)}},be=zt;var Wi="waykeecom-input-label__help",Yi="waykeecom-input-label__foldout",Jt=class extends r{constructor(e,t){super(e);this.open=!1;this.props=t,this.render()}onClick(){this.open=!this.open,this.props.onClickInformation&&this.props.onClickInformation(this.open),this.render()}render(){let{information:e}=this.props;if(e){let t=this.node.querySelector(`.${Wi}`),o=this.node.querySelector(`.${Yi}`),a=t||document.createElement("div");if(t||(a.className=Wi),this.open){a.innerHTML=`
|
|
336
336
|
<button class="waykeecom-input-label__help-btn" title="Vad betyder detta?">
|
|
337
337
|
<span class="waykeecom-sr-only">St\xE4ng hj\xE4lp</span>
|
|
338
338
|
<svg
|
|
@@ -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})}},Q=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 Qi="button-central-storage-proceed",Ki=`${Qi}-node`,Nl="central-storage-branch",ji=`${Nl}-node`,Zt=class extends r{constructor(e,t){super(e);this.requestError=!1;this.contexts={};this.props=t,_(this.props.store,"navigation",()=>{this.render()}),this.selectedDealer=this.props.store.getState().dealer,this.render()}async updateOrder(e){this.requestError&&(this.requestError=!1,this.render());let{id:t,vehicle:o}=this.props.store.getState();try{this.contexts.proceedButton?.loading(!0);let a=await Be(t,e);d("MAIN","CENTRAL_STORAGE_SET","CENTRAL_STORAGE"),xe(Me(a),o),ni(e,this.props.lastStage)(this.props.store.dispatch),this.contexts.proceedButton?.loading(!1)}catch{this.contexts.proceedButton?.loading(!1),this.requestError=!0,this.render()}}onChange(e){let o=e.currentTarget.value;this.selectedDealer=o,this.contexts.proceedButton?.disabled(!1),d("MAIN","CENTRAL_STORAGE_SELECTED","CENTRAL_STORAGE")}onEdit(){d("MAIN","CENTRAL_STORAGE_EDIT","CENTRAL_STORAGE"),H("main",this.props.index)(this.props.store.dispatch)}onProceed(){this.selectedDealer&&this.updateOrder(this.selectedDealer)}render(){let{order:e,navigation:t,topNavigation:o,createdOrderId:a}=this.props.store.getState(),{index:n}=this.props,l=e?.dealerSites||[],c=o.stage>n,m=t.stage===n;m&&d("MAIN","CENTRAL_STORAGE_ACTIVE","CENTRAL_STORAGE");let u=B(this.node,{completed:c,active:m,title:"Centrallager",id:"central-storage"});if((t.stage>n||c&&t.stage!==n)&&this.selectedDealer){let h=l.find(p=>p.id===this.selectedDealer);new z(u,{keyValueList:[{key:"Val av anl\xE4ggning",value:h?.name||""}],changeButtonTitle:"\xC4ndra",onEdit:a?void 0:()=>this.onEdit()})}else if(t.stage===n){u.innerHTML=`
|
|
385
385
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
386
386
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vilken anl\xE4ggning vill du k\xF6pa ifr\xE5n?</h4>
|
|
387
387
|
<div class="waykeecom-content">
|
|
@@ -389,7 +389,7 @@
|
|
|
389
389
|
</div>
|
|
390
390
|
</div>
|
|
391
391
|
|
|
392
|
-
<div class="waykeecom-stack waykeecom-stack--3" id="${
|
|
392
|
+
<div class="waykeecom-stack waykeecom-stack--3" id="${ji}"></div>
|
|
393
393
|
|
|
394
394
|
${this.requestError?`<div class="waykeecom-stack waykeecom-stack--3">${I({tone:"error",children:"Ett fel uppstod och det gick inte att v\xE4lja ovanst\xE5ende anl\xE4ggning. F\xF6rs\xF6k igen."})}</div>`:""}
|
|
395
395
|
|
|
@@ -413,7 +413,7 @@
|
|
|
413
413
|
</div>
|
|
414
414
|
</div>
|
|
415
415
|
</div>
|
|
416
|
-
</div>`}});new
|
|
416
|
+
</div>`}});new Q(u.querySelector(`#${ji}`),{checked:this.selectedDealer,name:"dealer",options:h,onClick:p=>this.onChange(p)}),this.contexts.proceedButton=new N(u.querySelector(`#${Ki}`),{title:"G\xE5 vidare",id:Qi,disabled:!this.selectedDealer,onClick:()=>this.onProceed()})}t.stage===n&&u.parentElement?.scrollIntoView()}},zi=Zt;var ie=s=>s.length<2?s:s.length===2?`${s.substring(0,1)}***`:s.length===3?`${s.substring(0,2)}***`:`${s.substring(0,3)}***`,qe=s=>`${s.substring(0,s.length-4)}****`;var es=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t,this.render()}updateBorder(){let e=this.node.querySelector(".waykeecom-input-text");e&&(this.props.error?e?.classList.add("waykeecom-input-text--has-error"):e?.classList.remove("waykeecom-input-text--has-error"))}setError(e,t){this.props.error=e,t&&(this.props.errorMessage=t),this.updateBorder(),this.contexts.error?.setError(e)}render(){let{id:e,title:t,type:o,name:a,min:n,value:l,autocomplete:c,placeholder:m,unit:u,error:h,errorMessage:p,information:y,pattern:g,inputmode:w,onChange:R,onBlur:$,onClickInformation:X}=this.props;this.node.innerHTML=`
|
|
417
417
|
<div class="waykeecom-input-label">
|
|
418
418
|
<label for="${e}" class="waykeecom-input-label__label">${t}</label>
|
|
419
419
|
</div>
|
|
@@ -505,7 +505,7 @@
|
|
|
505
505
|
${a.map(n=>E(n)).join("")}
|
|
506
506
|
</ul>
|
|
507
507
|
</div>
|
|
508
|
-
`}else this.node.innerHTML="",new da(this.node,{store:e,lastStage:t})}},ma=rs;var cs=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation",()=>{this.render()}),this.render()}onChange(){d("MAIN","CUSTOMER_EDIT","CUSTOMER_EMAIL_AND_PHONE"),H("main",this.props.index)(this.props.store.dispatch)}render(){let{store:e,index:t,lastStage:o}=this.props,a=this.props.store.getState(),n=a.topNavigation.stage>t,l=a.navigation.stage===t&&!a.createdOrderId;l&&d("MAIN","CUSTOMER_ACTIVE",a.navigation.subStage===1?"CUSTOMER_EMAIL_AND_PHONE":"CUSTOMER_ADDRESS");let c=B(this.node,{completed:n,title:"Dina uppgifter",active:l,id:"customer"});c.innerHTML="";let m=document.createElement("div");m.className="waykeecom-stack waykeecom-stack--2";let u=document.createElement("div");if(u.className="waykeecom-stack waykeecom-stack--2",a.navigation.stage>t||n&&a.navigation.stage!==t){let h=[{key:"E-post",value:a.customer.email},{key:"Telefonnummer",value:a.customer.phone},{key:"Personnummer",value:qe(a.customer.socialId)},...a.address?[{key:"Namn",value:`${ie(a.address.givenName)} ${ie(a.address.surname)}`},{key:"Adress",value:a.address.street},{key:"Postnummer",value:a.address.postalCode},{key:"Stad",value:a.address.city}]:[]];new
|
|
508
|
+
`}else this.node.innerHTML="",new da(this.node,{store:e,lastStage:t})}},ma=rs;var cs=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation",()=>{this.render()}),this.render()}onChange(){d("MAIN","CUSTOMER_EDIT","CUSTOMER_EMAIL_AND_PHONE"),H("main",this.props.index)(this.props.store.dispatch)}render(){let{store:e,index:t,lastStage:o}=this.props,a=this.props.store.getState(),n=a.topNavigation.stage>t,l=a.navigation.stage===t&&!a.createdOrderId;l&&d("MAIN","CUSTOMER_ACTIVE",a.navigation.subStage===1?"CUSTOMER_EMAIL_AND_PHONE":"CUSTOMER_ADDRESS");let c=B(this.node,{completed:n,title:"Dina uppgifter",active:l,id:"customer"});c.innerHTML="";let m=document.createElement("div");m.className="waykeecom-stack waykeecom-stack--2";let u=document.createElement("div");if(u.className="waykeecom-stack waykeecom-stack--2",a.navigation.stage>t||n&&a.navigation.stage!==t){let h=[{key:"E-post",value:a.customer.email},{key:"Telefonnummer",value:a.customer.phone},{key:"Personnummer",value:qe(a.customer.socialId)},...a.address?[{key:"Namn",value:`${ie(a.address.givenName)} ${ie(a.address.surname)}`},{key:"Adress",value:a.address.street},{key:"Postnummer",value:a.address.postalCode},{key:"Stad",value:a.address.city}]:[]];new z(c,{keyValueList:h,changeButtonTitle:"\xC4ndra dina uppgifter",onEdit:a.createdOrderId?void 0:()=>this.onChange()})}else a.navigation.stage===t&&(new aa(c,{store:e}),a.navigation.subStage>1&&new ma(c,{store:e,lastStage:o}));a.navigation.stage===t&&c.parentElement?.scrollIntoView()}},pa=cs;var ls=f("@wayke-se/ecom");var Ol=(s,i)=>{if(!!s)return s.unit==="m"&&i.unit==="km"?Math.round(s.value/1e3):s.unit==="km"&&i.unit==="m"?s.value*1e3:s.value},ua=(s,i)=>{let e=Ol(s,i);if(!!e&&!!i.unitPrice)return i.startupCost+i.unitPrice*e};var va="radio-home-delivery-true",ha=`${va}-node`,Ea="radio-home-delivery-false",ka=`${Ea}-node`,Ia="button-home-delivery-proceed",ya=`${Ia}-node`,ds=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation",()=>{this.render()});let o=this.props.store.getState();this.homeDelivery=o.homeDelivery,this.render()}onChange(e){let o=e.currentTarget.value==="true";this.homeDelivery=o,d("MAIN",this.homeDelivery?"DELIVERY_HOME_SELECTED":"DELIVERY_DEALER_SELECTED","DELIVERY")}onProceed(){ai(this.homeDelivery,this.props.lastStage)(this.props.store.dispatch),d("MAIN",this.homeDelivery?"DELIVERY_HOME_SET":"DELIVERY_DEALER_SET","DELIVERY")}onEdit(){d("MAIN","DELIVERY_EDIT","DELIVERY"),H("main",this.props.index)(this.props.store.dispatch)}render(){let{store:e,index:t}=this.props,o=e.getState();if(!o.order)throw"Missing order...";let a=o.order.contactInformation;if(!a)throw"Missing dealer contact information";let n=o.topNavigation.stage>t,l=o.navigation.stage===t;l&&d("MAIN","DELIVERY_ACTIVE","DELIVERY");let c=B(this.node,{completed:n,title:"Leverans",active:l,id:"delivery"});if(o.navigation.stage>t||n&&o.navigation.stage!==t)new z(c,{keyValueList:[{key:"Leveranss\xE4tt",value:o.homeDelivery?"Hemleverans":"H\xE4mta hos handlaren"}],changeButtonTitle:"\xC4ndra leveranss\xE4tt",onEdit:o.createdOrderId?void 0:()=>this.onEdit()});else if(o.navigation.stage===t){let m=document.createElement("div");m.innerHTML=`
|
|
509
509
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
510
510
|
<h4 class="waykeecom-heading waykeecom-heading--4">Hur vill du ha din bil levererad?</h4>
|
|
511
511
|
<div class="waykeecom-content">
|
|
@@ -586,7 +586,7 @@
|
|
|
586
586
|
</div>
|
|
587
587
|
`:""}
|
|
588
588
|
</div>
|
|
589
|
-
`,n&&new oe(this.node.querySelector(".waykeecom-input-label"),{information:n,onClickInformation:m}),u){this.contexts.rangeSlider=this.node.querySelector(`#${a}`)||void 0,this.contexts.rangeSlider&&(c&&this.contexts.rangeSlider.addEventListener("change",c),this.contexts.rangeSlider.addEventListener("input",p=>this.onInput(p)),this.updateRangeSliderColor(this.contexts.rangeSlider));let h=this.node.querySelector(`#${a}-input`);h&&(h.addEventListener("change",p=>this.onChange(p)),h.addEventListener("blur",p=>this.onBlur(p)))}}},
|
|
589
|
+
`,n&&new oe(this.node.querySelector(".waykeecom-input-label"),{information:n,onClickInformation:m}),u){this.contexts.rangeSlider=this.node.querySelector(`#${a}`)||void 0,this.contexts.rangeSlider&&(c&&this.contexts.rangeSlider.addEventListener("change",c),this.contexts.rangeSlider.addEventListener("input",p=>this.onInput(p)),this.updateRangeSliderColor(this.contexts.rangeSlider));let h=this.node.querySelector(`#${a}-input`);h&&(h.addEventListener("change",p=>this.onChange(p)),h.addEventListener("blur",p=>this.onBlur(p)))}}},je=ms;var ps=f("@wayke-se/ecom"),ga=({vehicleId:s,dealerId:i,downPayment:e,duration:t,residual:o})=>{let a=ps.payments.newLookupRequest().forVehicle(s).withDownPayment(e).withDuration(t);return o!==void 0&&a.withResidualValue(o),i!==void 0&&a.forDealer(i),ps.payments.lookupPayment(a.build())};var S=f("@wayke-se/ecom");var us=class extends r{constructor(e,t){super(e,t.append?{htmlTag:"div",className:"waykeecom-accordion"}:void 0);this.props=t,this.render()}render(){let{title:e,description:t,onClick:o}=this.props,a=`
|
|
590
590
|
<input
|
|
591
591
|
type="checkbox"
|
|
592
592
|
id="${this.props.id}"
|
|
@@ -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())}},Qe=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">
|
|
@@ -664,7 +664,7 @@
|
|
|
664
664
|
<div class="waykeecom-stack waykeecom-stack--2" id="${Na}"></div>
|
|
665
665
|
</div>
|
|
666
666
|
</div>
|
|
667
|
-
`,!h){o===q.AuthMethod.SameDevice?new Sa(this.node.querySelector(`#${vs}`),{autoLaunchUrl:t,errorMessage:a,onClick:()=>this.props?.onSameDeviceClick?.()}):o===q.AuthMethod.QrCode&&new _a(this.node.querySelector(`#${vs}`),{qrCode:e,errorMessage:a});let R=o===q.AuthMethod.SameDevice?"Mitt BankID \xE4r p\xE5 en annan enhet":"\xD6ppna BankID p\xE5 den h\xE4r enheten";new V(this.node.querySelector(`#${wa}`),{title:R,id:Pl,onClick:()=>p(o===q.AuthMethod.SameDevice?q.AuthMethod.QrCode:q.AuthMethod.SameDevice)})}new V(this.node.querySelector(`#${Na}`),{title:"Avbryt",id:Aa,onClick:()=>y()})}},
|
|
667
|
+
`,!h){o===q.AuthMethod.SameDevice?new Sa(this.node.querySelector(`#${vs}`),{autoLaunchUrl:t,errorMessage:a,onClick:()=>this.props?.onSameDeviceClick?.()}):o===q.AuthMethod.QrCode&&new _a(this.node.querySelector(`#${vs}`),{qrCode:e,errorMessage:a});let R=o===q.AuthMethod.SameDevice?"Mitt BankID \xE4r p\xE5 en annan enhet":"\xD6ppna BankID p\xE5 den h\xE4r enheten";new V(this.node.querySelector(`#${wa}`),{title:R,id:Pl,onClick:()=>p(o===q.AuthMethod.SameDevice?q.AuthMethod.QrCode:q.AuthMethod.SameDevice)})}new V(this.node.querySelector(`#${Na}`),{title:"Avbryt",id:Aa,onClick:()=>y()})}},ze=Es;var Is=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){this.node.innerHTML=`
|
|
668
668
|
<div class="waykeecom-disclaimer">
|
|
669
669
|
<div class="waykeecom-disclaimer__text">
|
|
670
670
|
${this.props.text}
|
|
@@ -705,7 +705,7 @@
|
|
|
705
705
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Va}"></div>
|
|
706
706
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Ga}"></div>
|
|
707
707
|
</div>
|
|
708
|
-
`,new ae(this.node.querySelector(`#${Ua}`),{store:e,decision:qa.CreditAssessmentRecommendation.AssessManually}),new N(this.node.querySelector(`#${Va}`),{title:"G\xE5 vidare",id:Wa,onClick:()=>t()}),new te(this.node.querySelector(`#${Ga}`),{title:"Avbryt",id:Ya,onClick:()=>o()})}},Ka=_s;var
|
|
708
|
+
`,new ae(this.node.querySelector(`#${Ua}`),{store:e,decision:qa.CreditAssessmentRecommendation.AssessManually}),new N(this.node.querySelector(`#${Va}`),{title:"G\xE5 vidare",id:Wa,onClick:()=>t()}),new te(this.node.querySelector(`#${Ga}`),{title:"Avbryt",id:Ya,onClick:()=>o()})}},Ka=_s;var za=f("@wayke-se/ecom");var Ss=class extends r{constructor(e,t){super(e);this.props=t,this.render()}isDisabled(){return this.props.disabled}disabled(e){this.props.disabled!==e&&(this.props.disabled=e,this.render())}loading(e){this.props.loading!==e&&(this.props.loading=e,this.props.disabled=e,this.render())}render(){let{title:e,id:t,disabled:o,loading:a,onClick:n}=this.props;this.node.innerHTML=`
|
|
709
709
|
<button
|
|
710
710
|
type="button"
|
|
711
711
|
${t?`id="${t}"`:""}
|
|
@@ -719,10 +719,10 @@
|
|
|
719
719
|
${b({type:"inline"})}
|
|
720
720
|
</span>`:""}
|
|
721
721
|
</button>
|
|
722
|
-
`,n&&this.node.querySelector("button")?.addEventListener("click",n)}},Je=Ss;var Bl="assessment-rejected-result",
|
|
722
|
+
`,n&&this.node.querySelector("button")?.addEventListener("click",n)}},Je=Ss;var Bl="assessment-rejected-result",ja=`${Bl}-node`,Ja="assessment-rejected-abort",Qa=`${Ja}-node`,ws=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,onGoBack:t}=this.props;this.node.innerHTML=`
|
|
723
|
+
<div class="waykeecom-stack waykeecom-stack--4" id="${ja}"></div>
|
|
723
724
|
<div class="waykeecom-stack waykeecom-stack--4" id="${Qa}"></div>
|
|
724
|
-
|
|
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=`
|
|
725
|
+
`,new ae(this.node.querySelector(`#${ja}`),{store:e,decision:za.CreditAssessmentRecommendation.Reject}),new Je(this.node.querySelector(`#${Qa}`),{title:"G\xE5 tillbaka",id:Ja,onClick:()=>t()})}},Xa=ws;var As=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,creditAssessmentResponse:t,onProceed:o,onGoBack:a}=this.props,n=t.recommendation;n===Ns.CreditAssessmentRecommendation.Approve?new Fa(this.node,{store:e,onProceed:()=>o(),onGoBack:()=>a()}):n===Ns.CreditAssessmentRecommendation.AssessManually?new Ka(this.node,{store:e,onProceed:()=>o(),onGoBack:()=>a()}):new Xa(this.node,{store:e,onGoBack:()=>a()})}},Za=As;var Fl=s=>{let i=s>0,e=s%12===0;if(!i||!e)throw new TypeError("Invalid months for creating creidt assessment term");return`${s}months`},en=Fl;var Xe={},Oe=(s,i)=>{Xe[s]=i},Ts=()=>{Object.keys(Xe).forEach(s=>{clearInterval(Xe[s]),delete Xe[s]})};var tn=f("@wayke-se/ecom"),Cs=s=>tn.creditAssessment.decline(s);var Ds=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t,this.render()}updateBorder(){let e=this.node.querySelector(".waykeecom-input-text");e&&(this.props.error?e?.classList.add("waykeecom-input-text--has-error"):e?.classList.remove("waykeecom-input-text--has-error"))}setError(e,t){this.props.error=e,t&&(this.props.errorMessage=t),this.updateBorder(),this.contexts.error?.setError(e)}render(){let{id:e,options:t,value:o,name:a,title:n,error:l,errorMessage:c,onChange:m}=this.props;this.node.innerHTML=`
|
|
726
726
|
<div class="waykeecom-input-label">
|
|
727
727
|
<label for="wayke-estimated-mileage" class="waykeecom-input-label__label">${n}</label>
|
|
728
728
|
</div>
|
|
@@ -738,7 +738,7 @@
|
|
|
738
738
|
${u.value===o?'selected="selected"':""}
|
|
739
739
|
>${u.title||u.value}</option>`).join("")}
|
|
740
740
|
</select>
|
|
741
|
-
`,this.updateBorder(),c&&(this.contexts.error=new se(this.node,{error:l,errorMessage:c})),this.node.querySelector("select")?.addEventListener("change",u=>m(u))}},Ze=Ds;var Ul="credit-assessment-martial-status",sn=`${Ul}-node`,Ls="credit-assessment-income",bs=`${Ls}-node`,Vl="credit-assessment-employment",on=`${Vl}-node`,Gl="credit-assessment-household-children",an=`${Gl}-node`,yn="credit-assessment-housing-cost",nn=`${yn}-node`,vn="credit-assessment-debt-specification-card-credit",rn=`${vn}-node`,En="credit-assessment-debt-specification-car-loan",cn=`${En}-node`,In="credit-assessment-debt-specification-collateral",ln=`${In}-node`,fn="credit-assessment-debt-specification-leasing-fees",dn=`${fn}-node`,gn="credit-assessment-debt-specification-private-loan",mn=`${gn}-node`,ql="credit-assessment-housing-type",pn=`${ql}-node`,_n="credit-assessment-perform-application",Rs=`${_n}-node`,un="disclaimer-node",hn="disclaimer-safe-node",kn="why-description-node",x={maritalStatus:C.requiredAssessmentMaritalStatus,income:C.requiredNumberGreaterOrEqualThanZero,employment:C.requiredAssessmentEmplyment,householdChildren:C.requiredNumberGreaterOrEqualThanZero,housingCost:C.requiredNumberGreaterOrEqualThanZero,"debtSpecification.cardCredits":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.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:-1,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()||"-1",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:x.maritalStatus(i.maritalStatus),income:x.income(i.income),employment:x.employment(i.employment),householdChildren:x.householdChildren(i.householdChildren),housingCost:x.housingCost(i.housingCost),"debtSpecification.cardCredits":x["debtSpecification.cardCredits"](i["debtSpecification.cardCredits"]),"debtSpecification.carLoan":x["debtSpecification.carLoan"](i["debtSpecification.carLoan"]),"debtSpecification.collateral":x["debtSpecification.collateral"](i["debtSpecification.collateral"]),"debtSpecification.leasingFees":x["debtSpecification.leasingFees"](i["debtSpecification.leasingFees"]),"debtSpecification.privateLoan":x["debtSpecification.privateLoan"](i["debtSpecification.privateLoan"]),housingType:x.housingType(i.housingType)},interact:{maritalStatus:!1,income:!1,employment:!1,householdChildren:!1,housingCost:!1,"debtSpecification.cardCredits":!1,"debtSpecification.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]=x[o](a),this.updateUiError(o),this.updateProceedButton()}onBlur(e){let o=e.currentTarget.name;this.state.interact[o]=!0,this.state.validation[o]=x[o](this.state.value[o]),this.updateUiError(o),this.updateProceedButton()}onChangeSelect(e){let t=e.currentTarget,o=t.name,a=t.value;this.state.value[o]=a,this.state.validation[o]=x[o](a),this.updateProceedButton()}onChangeRadio(e){let t=e.currentTarget,o=t.name,a=t.value;this.state.value[o]=a,this.state.validation[o]=x[o](a),o==="housingType"&&(t.value===S.HousingType.SingleFamily?(this.state.value.housingCost="0",this.state.validation.housingCost=x.housingCost(this.state.value.housingCost)):(this.state.value.housingCost="",this.state.validation.housingCost=x.housingCost(this.state.value.housingCost)),this.render()),this.updateProceedButton()}updateUiError(e){this.contexts[e]?.setError(this.state.interact[e]&&!this.state.validation[e])}updateProceedButton(){this.contexts.performApplicationButton?.disabled(!this.state.validation.maritalStatus||!this.state.validation.income||!this.state.validation.employment||!this.state.validation.householdChildren||!this.state.validation.housingCost||!this.state.validation["debtSpecification.cardCredits"]||!this.state.validation["debtSpecification.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=`
|
|
741
|
+
`,this.updateBorder(),c&&(this.contexts.error=new se(this.node,{error:l,errorMessage:c})),this.node.querySelector("select")?.addEventListener("change",u=>m(u))}},Ze=Ds;var Ul="credit-assessment-martial-status",sn=`${Ul}-node`,Ls="credit-assessment-income",bs=`${Ls}-node`,Vl="credit-assessment-employment",on=`${Vl}-node`,Gl="credit-assessment-household-children",an=`${Gl}-node`,yn="credit-assessment-housing-cost",nn=`${yn}-node`,vn="credit-assessment-debt-specification-card-credit",rn=`${vn}-node`,En="credit-assessment-debt-specification-car-loan",cn=`${En}-node`,In="credit-assessment-debt-specification-collateral",ln=`${In}-node`,fn="credit-assessment-debt-specification-leasing-fees",dn=`${fn}-node`,gn="credit-assessment-debt-specification-private-loan",mn=`${gn}-node`,ql="credit-assessment-housing-type",pn=`${ql}-node`,_n="credit-assessment-perform-application",Rs=`${_n}-node`,un="disclaimer-node",hn="disclaimer-safe-node",kn="why-description-node",x={maritalStatus:C.requiredAssessmentMaritalStatus,income:C.requiredNumberGreaterOrEqualThanZero,employment:C.requiredAssessmentEmplyment,householdChildren:C.requiredNumberGreaterOrEqualThanZero,housingCost:C.requiredNumberGreaterOrEqualThanZero,"debtSpecification.cardCredits":C.optionalNumberGreaterOrEqualThanZero,"debtSpecification.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:-1,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()||"-1",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:x.maritalStatus(i.maritalStatus),income:x.income(i.income),employment:x.employment(i.employment),householdChildren:x.householdChildren(i.householdChildren),housingCost:x.housingCost(i.housingCost),"debtSpecification.cardCredits":x["debtSpecification.cardCredits"](i["debtSpecification.cardCredits"]),"debtSpecification.carLoan":x["debtSpecification.carLoan"](i["debtSpecification.carLoan"]),"debtSpecification.collateral":x["debtSpecification.collateral"](i["debtSpecification.collateral"]),"debtSpecification.leasingFees":x["debtSpecification.leasingFees"](i["debtSpecification.leasingFees"]),"debtSpecification.privateLoan":x["debtSpecification.privateLoan"](i["debtSpecification.privateLoan"]),housingType:x.housingType(i.housingType)},interact:{maritalStatus:!1,income:!1,employment:!1,householdChildren:!1,housingCost:!1,"debtSpecification.cardCredits":!1,"debtSpecification.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]=x[o](a),this.updateUiError(o),this.updateProceedButton()}onBlur(e){let o=e.currentTarget.name;this.state.interact[o]=!0,this.state.validation[o]=x[o](this.state.value[o]),this.updateUiError(o),this.updateProceedButton()}onChangeSelect(e){let t=e.currentTarget,o=t.name,a=t.value;this.state.value[o]=a,this.state.validation[o]=x[o](a),this.updateProceedButton()}onChangeRadio(e){let t=e.currentTarget,o=t.name,a=t.value;this.state.value[o]=a,this.state.validation[o]=x[o](a),o==="housingType"&&(t.value===S.HousingType.SingleFamily?(this.state.value.housingCost="0",this.state.validation.housingCost=x.housingCost(this.state.value.housingCost)):(this.state.value.housingCost="",this.state.validation.housingCost=x.housingCost(this.state.value.housingCost)),this.render()),this.updateProceedButton()}updateUiError(e){this.contexts[e]?.setError(this.state.interact[e]&&!this.state.validation[e])}updateProceedButton(){this.contexts.performApplicationButton?.disabled(!this.state.validation.maritalStatus||!this.state.validation.income||!this.state.validation.employment||!this.state.validation.householdChildren||!this.state.validation.housingCost||!this.state.validation["debtSpecification.cardCredits"]||!this.state.validation["debtSpecification.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(j(),{store:t,creditAssessmentResponse:this.creditAssessmentResponse,onProceed:()=>{O(),a()},onGoBack:()=>this.onAbort()});else if(this.view===2)this.contexts.bankId=new ze(j(),{method:n?S.AuthMethod.SameDevice:S.AuthMethod.QrCode,descriptionQrCode:"F\xF6r att h\xE4mta dina uppgifter, starta din BankID applikation p\xE5 din andra enhet.",descriptionSameDevice:"F\xF6r att h\xE4mta dina uppgifter, starta din BankID-applikation.",onAbort:()=>this.onAbort(),onStart:h=>this.startBankId(h)}),G();else{this.node.innerHTML=`
|
|
742
742
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
743
743
|
<h5 class="waykeecom-heading waykeecom-heading--4">L\xE5neans\xF6kan</h5>
|
|
744
744
|
<div class="waykeecom-content">
|
|
@@ -847,7 +847,7 @@
|
|
|
847
847
|
<div class="waykeecom-stack waykeecom-stack--1" id="${hn}"></div>
|
|
848
848
|
</div>
|
|
849
849
|
</div>
|
|
850
|
-
`,this.contexts.maritalStatus=new
|
|
850
|
+
`,this.contexts.maritalStatus=new Q(this.node.querySelector(`#${sn}`),{checked:this.state.value.maritalStatus,name:"maritalStatus",options:[{id:`maritalStatus-${1}`,value:S.MaritalStatus.Married,title:"Gift/partnerskap"},{id:`maritalStatus-${2}`,value:S.MaritalStatus.CommonLaw,title:"Sambo"},{id:`maritalStatus-${3}`,value:S.MaritalStatus.Single,title:"Ensamst\xE5ende"}],onClick:p=>this.onChangeRadio(p)}),this.contexts.income=new M(this.node.querySelector(`#${bs}`),{title:"Inkomst per m\xE5nad f\xF6re skatt",value:this.state.value.income,id:Ls,error:this.state.interact.income&&!this.state.validation.income,errorMessage:"Ange din inkomst per \xE5r f\xF6re skatt",name:"income",autocomplete:"off",unit:"kr",placeholder:"",type:"number",onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p)}),this.contexts.employment=new Q(this.node.querySelector(`#${on}`),{checked:this.state.value.employment,name:"employment",options:[{id:`employment-${1}`,value:S.Employment.FullTimeEmployed,title:"Fast eller tillsvidareanst\xE4lld"},{id:`employment-${2}`,value:S.Employment.TemporarilyEmployed,title:"Visstidsanst\xE4lld"},{id:`employment-${3}`,value:S.Employment.SelfEmployed,title:"Egen f\xF6retagare"},{id:`employment-${4}`,value:S.Employment.Retired,title:"Pension\xE4r"},{id:`employment-${5}`,value:S.Employment.Student,title:"Student"},{id:`employment-${6}`,value:S.Employment.Other,title:"Annan"}],onClick:p=>this.onChangeRadio(p)}),this.contexts.housingType=new Q(this.node.querySelector(`#${pn}`),{title:"Boendeform",checked:this.state.value.housingType,name:"housingType",options:[{id:`housingType-${1}`,value:S.HousingType.SingleFamily,title:"Villa"},{id:`housingType-${2}`,value:S.HousingType.Condominium,title:"Bostadsr\xE4tt"},{id:`housingType-${3}`,value:S.HousingType.Apartment,title:"Hyresr\xE4tt"}],onClick:p=>this.onChangeRadio(p)}),this.contexts.income=new M(this.node.querySelector(`#${bs}`),{title:"Inkomst per m\xE5nad f\xF6re skatt",value:this.state.value.income,id:Ls,error:this.state.interact.income&&!this.state.validation.income,errorMessage:"Ange din inkomst per \xE5r f\xF6re skatt",name:"income",autocomplete:"off",placeholder:"",unit:"kr",type:"number",information:`
|
|
851
851
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
852
852
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Inkomst per m\xE5nad f\xF6re skatt</span></p>
|
|
853
853
|
<p class="waykeecom-content__p">L\xF6n och/eller pension, inte bidrag eller studiel\xE5n.</p>
|
|
@@ -882,7 +882,7 @@
|
|
|
882
882
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Privatl\xE5n (ej bol\xE5n och CSN)</span></p>
|
|
883
883
|
<p class="waykeecom-content__p">Total skuld, t.ex. blancol\xE5n och sms-l\xE5n</p>
|
|
884
884
|
</div>
|
|
885
|
-
`,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
|
|
885
|
+
`,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 Qe(this.node.querySelector(`#${kn}`),{id:"accordion-why-description",title:`
|
|
886
886
|
<div class="waykeecom-hstack waykeecom-hstack--align-center waykeecom-hstack--spacing-1">
|
|
887
887
|
<div class="waykeecom-hstack__item waykeecom-hstack__item--no-shrink" aria-hidden="true">
|
|
888
888
|
<div class="waykeecom-icon-backdrop waykeecom-icon-backdrop--info-alt">
|
|
@@ -1031,7 +1031,7 @@
|
|
|
1031
1031
|
</div>
|
|
1032
1032
|
</div>
|
|
1033
1033
|
</div>
|
|
1034
|
-
`,this.contexts.loanDetailsMontlyCost=new Cn(this.node.querySelector(`#${Dn}`),{monthlyCost:y}),this.contexts.pieChart=new wn(this.node.querySelector(`#${bn}`),{percentage:w}),this.contexts.loanDetailsBasic=new Nn(this.node.querySelector(`#${Rn}`),{downPayment:t,creditAmount:m,downPaymentPercentage:g,creditAmountPercentage:w}),this.contexts.loanDetailsDetailed=new Tn(this.node.querySelector(`#${Ln}`),{duration:e,administrationFee:o,setupFee:a,totalCreditCost:n,interest:l,effectiveInterest:c,publicUrl:u,loanOrgName:h})}},On=Hs;var Bs=class extends r{constructor(e,t){super(e);this.props=t,this.error=t.error,this.render()}update(e){this.error=e,this.render()}render(){if(!this.error){this.node.innerHTML="";return}this.node.innerHTML=I({tone:"error",children:this.error})}},Mn=Bs;var xn="downpayment-range-node",
|
|
1034
|
+
`,this.contexts.loanDetailsMontlyCost=new Cn(this.node.querySelector(`#${Dn}`),{monthlyCost:y}),this.contexts.pieChart=new wn(this.node.querySelector(`#${bn}`),{percentage:w}),this.contexts.loanDetailsBasic=new Nn(this.node.querySelector(`#${Rn}`),{downPayment:t,creditAmount:m,downPaymentPercentage:g,creditAmountPercentage:w}),this.contexts.loanDetailsDetailed=new Tn(this.node.querySelector(`#${Ln}`),{duration:e,administrationFee:o,setupFee:a,totalCreditCost:n,interest:l,effectiveInterest:c,publicUrl:u,loanOrgName:h})}},On=Hs;var Bs=class extends r{constructor(e,t){super(e);this.props=t,this.error=t.error,this.render()}update(e){this.error=e,this.render()}render(){if(!this.error){this.node.innerHTML="";return}this.node.innerHTML=I({tone:"error",children:this.error})}},Mn=Bs;var xn="downpayment-range-node",jl="downpayment-range",Pn="duration-range-node",Ql="duration-range",$n="residual-range-node",zl="residual-range",Jl="loan-details",Hn=`${Jl}-node`,Bn="credit-assessment-node",Vn="credit-assessment-proceed",Fn=`${Vn}-node`,Un="loan-error-node",Fs=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t;let o=this.props.loan.loanDetails;if(!o)throw"err";this.paymentLookupResponse=this.props.paymentLookupResponse||o,this.paymentState={vehicleId:this.props.vehicleId,dealerId:"",downPayment:this.paymentLookupResponse.downPaymentSpec,duration:this.paymentLookupResponse.durationSpec,residual:this.paymentLookupResponse.residualValueSpec},this.previousState=JSON.parse(JSON.stringify(this.paymentState)),this.render()}async payment(){this.contexts.downPayment?.disabled(!0),this.contexts.duration?.disabled(!0),this.contexts.residual?.disabled(!0),this.contexts.proceedButton?.disabled(!0);try{let e=await ga({vehicleId:this.paymentState.vehicleId,downPayment:this.paymentState.downPayment.current,duration:this.paymentState.duration.current,residual:this.paymentState.residual?.current});this.previousState=JSON.parse(JSON.stringify(this.paymentState)),this.paymentLookupResponse=we(e),this.paymentState={...this.paymentState,downPayment:this.paymentLookupResponse.downPaymentSpec,duration:this.paymentLookupResponse.durationSpec,residual:this.paymentLookupResponse.residualValueSpec},li(e)(this.props.store.dispatch),this.update(),this.contexts.errorAlert?.update(void 0),this.contexts.downPayment?.update(this.paymentState.downPayment.current,this.paymentState.downPayment.min,this.paymentState.downPayment.max),this.contexts.residual?.update(parseInt(`${this.paymentState.residual.current*100}`,10),parseInt(`${this.paymentState.residual.min*100}`,10),parseInt(`${this.paymentState.residual.max*100}`,10)),this.contexts.duration?.update(this.paymentState.duration.current,this.paymentState.duration.min,this.paymentState.duration.max)}catch{this.contexts.errorAlert?.update("Ett fel uppstod, f\xF6rs\xF6k igen."),this.contexts.downPayment?.disabled(!1),this.contexts.duration?.disabled(!1),this.contexts.residual?.disabled(!1),this.contexts.downPayment?.update(this.previousState.downPayment.current,this.previousState.downPayment.min,this.previousState.downPayment.max),this.contexts.residual?.update(parseInt(`${this.previousState.residual.current*100}`,10),parseInt(`${this.previousState.residual.min*100}`,10),parseInt(`${this.previousState.residual.max*100}`,10)),this.contexts.duration?.update(this.previousState.duration.current,this.previousState.duration.min,this.previousState.duration.max)}finally{this.contexts.downPayment?.disabled(!1),this.contexts.duration?.disabled(!1),this.contexts.residual?.disabled(!1),this.contexts.proceedButton?.disabled(!1)}}onChange(e){let t=e.currentTarget,o=t.name,a=t.value;t.value=a,this.paymentState[o].current=o==="residual"?parseInt(a,10)/100:parseInt(a,10),this.payment()}update(){this.contexts.loanDetails?.update({loan:this.props.loan,paymentLookupResponse:this.paymentLookupResponse})}render(){let{store:e,loan:t,onProceed:o}=this.props,{order:a}=e.getState(),n=a?.contactInformation?.name,l=t.loanDetails?.shouldUseCreditScoring;this.node.innerHTML=`
|
|
1035
1035
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1036
1036
|
<hr class="waykeecom-separator" />
|
|
1037
1037
|
</div>
|
|
@@ -1053,13 +1053,13 @@
|
|
|
1053
1053
|
${l?`
|
|
1054
1054
|
<div class="waykeecom-stack waykeecom-stack--3" id="${Bn}"></div>
|
|
1055
1055
|
`:`<div class="waykeecom-stack waykeecom-stack--3" id="${Fn}"></div>`}
|
|
1056
|
-
`,this.contexts.downPayment=new
|
|
1056
|
+
`,this.contexts.downPayment=new je(this.node.querySelector(`#${xn}`),{title:"Kontantinsats",value:this.paymentState.downPayment.current,id:jl,name:"downPayment",onChange:c=>this.onChange(c),min:this.paymentState.downPayment.min,max:this.paymentState.downPayment.max,unit:"kr",information:`
|
|
1057
1057
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1058
1058
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Hur mycket av dina egna pengar vill du l\xE4gga?</span></p>
|
|
1059
1059
|
<p class="waykeecom-content__p">Kontantinsatsen \xE4r en del av bilens pris som du betalar med egna pengar. Den beh\xF6ver vara minst 20% av priset p\xE5 bilen. Kontantinsatsen betalar du senare i samband med avtalsskrivning hos ${n}.</p>
|
|
1060
1060
|
<p class="waykeecom-content__p">Ifall du har en inbytesbil kan du betala kontantinsatsen med den. Detta kommer du \xF6verens om tillsammans med ${n} vid avtalsskrivning. </p>
|
|
1061
1061
|
</div>
|
|
1062
|
-
`,onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DOWNPAYMENT_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts.duration=new
|
|
1062
|
+
`,onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DOWNPAYMENT_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts.duration=new je(this.node.querySelector(`#${Pn}`),{title:"Avbetalning",value:this.paymentState.duration.current,id:Ql,name:"duration",onChange:c=>this.onChange(c),min:this.paymentState.duration.min,max:this.paymentState.duration.max,step:this.paymentState.duration.step,unit:"m\xE5n"}),this.paymentState.residual&&(this.contexts.residual=new je(this.node.querySelector(`#${$n}`),{title:"Restv\xE4rde",value:parseInt(`${this.paymentState.residual.current*100}`,10),id:zl,name:"residual",onChange:c=>this.onChange(c),min:parseInt(`${this.paymentState.residual.min*100}`,10),max:parseInt(`${this.paymentState.residual.max*100}`,10),step:parseInt(`${this.paymentState.residual.step*100}`,10),unit:"%"})),this.contexts.errorAlert=new Mn(this.node.querySelector(`#${Un}`),{}),this.contexts.loanDetails=new On(this.node.querySelector(`#${Hn}`),{loan:t,paymentLookupResponse:this.paymentLookupResponse}),l?new Sn(this.node.querySelector(`#${Bn}`),{store:e,loan:t,paymentLookupResponse:this.paymentLookupResponse,onProceed:()=>o()}):this.contexts.proceedButton=new N(this.node.querySelector(`#${Fn}`),{title:"G\xE5 vidare",id:Vn,onClick:()=>o()})}},Gn=Fs;var Us=f("@wayke-se/ecom");var Xl="credit-assessment-result",qn=`${Xl}-node`,Vs=class extends r{constructor(e,t){super(e,{htmlTag:"div"});this.props=t,this.render()}render(){let{store:e,paymentType:t,loan:o,paymentLookupResponse:a,onEdit:n}=this.props,l=o?.loanDetails;if(t===Us.PaymentType.Loan){let c=this.props.store.getState(),m=a||l;if(!l||!m)throw"Missing loan";let u=m.downPaymentSpec.current,h=m.creditAmount,p=m.durationSpec.current,{interest:y,effectiveInterest:g}=m.interests,{monthlyCost:w}=m.costs,R=[{key:"Kontantinsats",value:k(u,{postfix:"kr"})},{key:"L\xE5nebelopp",value:k(h,{postfix:"kr"})},{key:"Avbetalningsperoid",value:`${p} m\xE5n`},{key:"M\xE5nadskostnad f\xF6r l\xE5net",value:k(w,{postfix:"kr*"})}],$=c.creditAssessmentResponse?.recommendation,X=`*Ber\xE4knat p\xE5 ${k(y*100,{decimals:2})} % r\xE4nta (effektivt ${k(g*100,{decimals:2})} %). Den r\xE4nta du f\xE5r s\xE4tts vid avtalskrivning.`;this.node.innerHTML=`
|
|
1063
1063
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
1064
1064
|
<h4 class="waykeecom-heading waykeecom-heading--4">Bill\xE5n</h4>
|
|
1065
1065
|
<div class="waykeecom-content">
|
|
@@ -1095,15 +1095,15 @@
|
|
|
1095
1095
|
</div>
|
|
1096
1096
|
</div>
|
|
1097
1097
|
`:""}
|
|
1098
|
-
`;n&&this.node.querySelector("button")?.addEventListener("click",()=>n())}},Wn=Vs;var
|
|
1098
|
+
`;n&&this.node.querySelector("button")?.addEventListener("click",()=>n())}},Wn=Vs;var zn="button-financial-proceed",Yn=`${zn}-node`,Zl="financial-option",Kn=`${Zl}-node`,ed="financial-option-second",jn=`${ed}-node`,td="radio-financial-cash",sd="radio-financial-loan",od="radio-financial-lease",Qn="payment-node",Gs=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation",()=>{let n=this.props.store.getState();this.paymentType=n.paymentType,this.render()});let o=this.props.store.getState(),{paymentType:a}=o;this.paymentType=a,this.render()}onChange(e){let o=e.currentTarget.value;switch(this.paymentType=o,this.render(!0),this.paymentType){case F.PaymentType.Cash:d("MAIN","FINANCIAL_CASH_SELECTED","FINANCIAL");break;case F.PaymentType.Lease:d("MAIN","FINANCIAL_LEASE_SELECTED","FINANCIAL");case F.PaymentType.Loan:d("MAIN","FINANCIAL_LOAN_SELECTED","FINANCIAL");default:break}}onProceed(){if(this.paymentType){switch(this.paymentType){case F.PaymentType.Cash:d("MAIN","FINANCIAL_CASH_SET","FINANCIAL");break;case F.PaymentType.Lease:d("MAIN","FINANCIAL_LEASE_SET","FINANCIAL");case F.PaymentType.Loan:d("MAIN","FINANCIAL_LOAN_SET","FINANCIAL");default:break}ci(this.paymentType,this.props.lastStage)(this.props.store.dispatch)}}onEdit(){d("MAIN","FINANCIAL_EDIT","FINANCIAL"),H("main",this.props.index)(this.props.store.dispatch)}render(e){let t=this.props.store.getState(),{id:o,order:a,paymentLookupResponse:n}=t;if(!a)throw"No order available";let l=a.paymentOptions,c=t.topNavigation.stage>this.props.index,m=B(this.node,{completed:c,title:"\xC4gandeform",active:t.navigation.stage===this.props.index,id:"financial"}),u=document.createElement("div");if((t.navigation.stage>this.props.index||c&&t.navigation.stage!==this.props.index)&&this.paymentType){let h=l.find(p=>p.type===F.PaymentType.Loan);new Wn(m,{store:this.props.store,loan:h,paymentType:this.paymentType,paymentLookupResponse:n||h?.loanDetails,onEdit:t.createdOrderId?void 0:()=>this.onEdit()})}else if(t.navigation.stage===this.props.index){let h=t.order?.orderVehicle,p=l.find(L=>L.type===F.PaymentType.Cash),y=l.find(L=>L.type===F.PaymentType.Loan),g=l.find(L=>L.type===F.PaymentType.Lease);u.innerHTML=`
|
|
1099
1099
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1100
1100
|
<h4 class="waykeecom-heading waykeecom-heading--4 waykeecom-no-margin">Hur vill du finansiera din ${h?.title} ${pe(h)}?</h4>
|
|
1101
1101
|
</div>
|
|
1102
1102
|
|
|
1103
1103
|
${p||y?`<div class="waykeecom-stack waykeecom-stack--3" id="${Kn}"></div>`:""}
|
|
1104
|
-
${g?`<div class="waykeecom-stack waykeecom-stack--3" id="${
|
|
1104
|
+
${g?`<div class="waykeecom-stack waykeecom-stack--3" id="${jn}"></div>`:""}
|
|
1105
1105
|
|
|
1106
|
-
<div class="waykeecom-stack waykeecom-stack--3" id="${
|
|
1106
|
+
<div class="waykeecom-stack waykeecom-stack--3" id="${Qn}"></div>
|
|
1107
1107
|
${this.paymentType!==F.PaymentType.Loan?`<div class="waykeecom-stack waykeecom-stack--3" id="${Yn}"></div>`:""}
|
|
1108
1108
|
|
|
1109
1109
|
`,m.appendChild(u);let w=a.contactInformation,R=[];if(p&&R.push({id:td,value:F.PaymentType.Cash,title:"Kontant",description:`
|
|
@@ -1140,15 +1140,15 @@
|
|
|
1140
1140
|
<img src="${y.logo}" alt="${y.name} logotyp" class="waykeecom-image waykeecom-image--loan-logo" />
|
|
1141
1141
|
</div>
|
|
1142
1142
|
</div>`:""}
|
|
1143
|
-
</div>`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${k(L,{postfix:y.unit})}</div>`})}(p||y)&&new
|
|
1143
|
+
</div>`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${k(L,{postfix:y.unit})}</div>`})}(p||y)&&new Q(u.querySelector(`#${Kn}`),{title:"K\xF6p bilen",checked:this.paymentType,name:"paymentType",information:`
|
|
1144
1144
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1145
1145
|
<p class="waykeecom-content__p">Du k\xF6per bilen och \xE4ger den sj\xE4lv, antingen genom att betala hela bilen med egna medel eller genom ett bill\xE5n. Du ansvarar sj\xE4lv f\xF6r f\xF6rs\xE4ljningen av bilen och v\xE4ljer s\xE5klart helt fritt n\xE4r den ska \xE4ga rum.</p>
|
|
1146
1146
|
</div>
|
|
1147
|
-
`,options:R,onClick:L=>this.onChange(L),onClickInformation:()=>{d("MAIN","FINANCIAL_INFORMATION_TOGGLE","FINANCIAL")}});let $=[];g&&($.push({id:od,title:"Privatleasing",value:F.PaymentType.Lease,meta:`<div class="waykeecom-text waykeecom-text--font-bold">Fr\xE5n ${k(g?.price,{postfix:g.unit})}</div>`}),new
|
|
1147
|
+
`,options:R,onClick:L=>this.onChange(L),onClickInformation:()=>{d("MAIN","FINANCIAL_INFORMATION_TOGGLE","FINANCIAL")}});let $=[];g&&($.push({id:od,title:"Privatleasing",value:F.PaymentType.Lease,meta:`<div class="waykeecom-text waykeecom-text--font-bold">Fr\xE5n ${k(g?.price,{postfix:g.unit})}</div>`}),new Q(u.querySelector(`#${jn}`),{title:"Leasa bilen",checked:this.paymentType,name:"paymentType",information:`
|
|
1148
1148
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1149
|
-
<p class="waykeecom-content__p">
|
|
1149
|
+
<p class="waykeecom-content__p">N\xE4r du privatleasar en bil \xE4ger du den inte sj\xE4lv utan betalar en m\xE5nadsavgift under en avtalad tid och som t\xE4cker en viss k\xF6rstr\xE4cka och andra avtalade tj\xE4nster.</p>
|
|
1150
1150
|
</div>
|
|
1151
|
-
`,options:$,onClick:L=>this.onChange(L)}));let X=u.querySelector(`#${
|
|
1151
|
+
`,options:$,onClick:L=>this.onChange(L)}));let X=u.querySelector(`#${Qn}`);X&&(y&&this.paymentType===F.PaymentType.Loan?new Gn(X,{store:this.props.store,loan:y,vehicleId:o,paymentLookupResponse:n,onProceed:()=>this.onProceed()}):new N(u.querySelector(`#${Yn}`),{title:"G\xE5 vidare",id:zn,disabled:!this.paymentType,onClick:()=>this.onProceed()}))}!e&&t.navigation.stage===this.props.index&&m.parentElement?.scrollIntoView()}},Jn=Gs;var U=f("@wayke-se/ecom");var qs=f("@wayke-se/ecom"),Xn=(s,i)=>{let e=s.getState();if(!e.id)throw"No id";let t=qs.insurances.newInsuranceOptionsRequest().forCustomer(e.customer.socialId).forVehicle(e.id).withDrivingDistance(i);return qs.insurances.getOptions(t.build())};var Ws=class extends r{constructor(e,t){super(e,t.append?{htmlTag:"div",className:"waykeecom-input-selection",attributes:[{key:"role",value:"checkbox"}]}:void 0);this.props=t,this.render()}checked(e){this.props.checked!==e&&(this.props.checked=e,this.render())}disabled(e){this.props.disabled!==e&&(this.props.disabled=e,this.render())}render(){let{id:e,title:t,value:o,name:a,checked:n,meta:l,description:c,append:m,disabled:u,onClick:h}=this.props,p=`
|
|
1152
1152
|
<input
|
|
1153
1153
|
type="checkbox"
|
|
1154
1154
|
id="${e}"
|
|
@@ -1185,8 +1185,8 @@
|
|
|
1185
1185
|
${b({type:"inline"})}
|
|
1186
1186
|
</span>`:""}
|
|
1187
1187
|
</button>
|
|
1188
|
-
`,n&&this.node.querySelector("button")?.addEventListener("click",n)}},Zn=Ys;var Ks=class extends r{constructor(i){super(i,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--1"}),this.render()}render(){return this.node.innerHTML='<div class="waykeecom-box"></div>',this.node.querySelector(".waykeecom-box")}},er=Ks;var
|
|
1189
|
-
<div class="waykeecom-nav-banner" id="${
|
|
1188
|
+
`,n&&this.node.querySelector("button")?.addEventListener("click",n)}},Zn=Ys;var Ks=class extends r{constructor(i){super(i,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--1"}),this.render()}render(){return this.node.innerHTML='<div class="waykeecom-box"></div>',this.node.querySelector(".waykeecom-box")}},er=Ks;var js="insurance-button-top-left-node",tr="insurance-button-bottom-left-node",Qs="insurance-add-remove-node",sr="insurance-addons-node",or="insurance-accordion-node",_e=class extends r{constructor(e,t){super(e);this.initialAddons=[];this.addons=[];this.contexts={checkboxes:{}};this.props=t;let{insuranceAddOns:o}=this.props.store.getState();!!o?.insurance&&o.insurance===this.props.insurance.name&&(this.addons=[...o.addOns]),this.initialAddons=[...this.addons],this.render()}static containChanges(e,t){let o=[...e].sort(),a=[...t].sort();return o.join().localeCompare(a.join())!==0}onClick(e){let t=e.currentTarget,{name:o,checked:a}=t,n=this.props.insurance.addOns.find(c=>c.name===o);if(n){if(Object.keys(this.contexts.checkboxes).forEach(c=>{this.contexts.checkboxes[c]?.disabled(!1)}),this.contexts.checkboxes[o]?.checked(a),a)d("MAIN","INSURANCE_ADDON_SELECTED","INSURANCE_IF"),this.addons.push(n);else{d("MAIN","INSURANCE_ADDON_UNSELECTED","INSURANCE_IF");let c=this.addons.findIndex(m=>m.name===n.name);c>-1&&this.addons.splice(c,1)}[...new Set(this.addons.map(c=>c.exclude).flat())].forEach(c=>this.contexts.checkboxes[c]?.disabled(!0))}let l=_e.containChanges(this.initialAddons,this.addons);this.contexts.updateButton?.disabled(this.props.selected?!l:!1)}onUpdate(){let{insurance:e}=this.props.store.getState();!e||e&&this.props.insurance.name!==e.name?d("MAIN","INSURANCE_SELECTED","INSURANCE_IF"):d("MAIN","INSURANCE_UNSELECTED","INSURANCE_IF"),mi(this.props.insurance,this.addons)(this.props.store.dispatch),this.props.onClose()}render(){let{insurance:e,selected:t,onClose:o}=this.props,{name:a,description:n,legalDescription:l,legalUrl:c,insuranceItems:m}=e,u=e.addOns,h=_e.containChanges(this.initialAddons,this.addons);if(this.node.innerHTML=`
|
|
1189
|
+
<div class="waykeecom-nav-banner" id="${js}"></div>
|
|
1190
1190
|
|
|
1191
1191
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1192
1192
|
<div class="waykeecom-hstack waykeecom-hstack--align-center waykeecom-hstack--spacing-3">
|
|
@@ -1225,10 +1225,10 @@
|
|
|
1225
1225
|
<div class="waykeecom-stack waykeecom-stack--3" id="${or}"></div>
|
|
1226
1226
|
`:""}
|
|
1227
1227
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1228
|
-
<div class="waykeecom-stack waykeecom-stack--1" id="${
|
|
1228
|
+
<div class="waykeecom-stack waykeecom-stack--1" id="${Qs}"></div>
|
|
1229
1229
|
<div class="waykeecom-stack waykeecom-stack--1" id="${tr}"></div>
|
|
1230
1230
|
</div>
|
|
1231
|
-
`,new ce(this.node.querySelector(`#${
|
|
1231
|
+
`,new ce(this.node.querySelector(`#${js}`),{title:"Tillbaka",onClick:()=>o()}),u?.length){let p=this.node.querySelector(`#${sr}`);u.forEach(y=>{let g=new er(p);this.contexts.checkboxes[y.name]=new et(g.render(),{id:y.name,name:y.name,title:y.title,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${k(y.monthlyPrice,{postfix:"kr/m\xE5n"})}</div>`,description:`<div class="waykeecom-text waykeecom-text--tone-alt">${y.description}</div>`,append:!0,value:y.name,checked:this.addons.findIndex(w=>w.name===y.name)>-1,onClick:w=>this.onClick(w)})})}if(m?.length){let p=this.node.querySelector(`#${or}`);m.forEach(y=>new Qe(p,{id:y.name,title:y.name,description:y.description,append:!0}))}new ce(this.node.querySelector(`#${js}`),{title:"Tillbaka",onClick:()=>o()}),new te(this.node.querySelector(`#${tr}`),{title:"Tillbaka",onClick:()=>o()}),t?this.contexts.updateButton=new Zn(this.node.querySelector(`#${Qs}`),{title:t?"Uppdatera":"V\xE4lj",disabled:t?!h:void 0,onClick:()=>this.onUpdate()}):this.contexts.updateButton=new ee(this.node.querySelector(`#${Qs}`),{selected:!1,fullSize:!0,disabled:t?!h:void 0,onClick:()=>this.onUpdate()}),G()}},ir=_e;var zs=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.props=t,_(this.props.store,"insurance",()=>{this.render()}),this.render()}onInfoOpen(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE_IF"),this.displayInfo=!0,this.render()}onInfoClose(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE_IF"),this.displayInfo=!1,O(),this.render(),this.node.parentElement?.scrollIntoView()}onClick(){let{insurance:e}=this.props.store.getState();!e||e&&this.props.insurance.name!==e.name?d("MAIN","INSURANCE_SELECTED","INSURANCE_IF"):d("MAIN","INSURANCE_UNSELECTED","INSURANCE_IF"),de(this.props.insurance)(this.props.store.dispatch)}render(){let{store:e,insurance:t,key:o}=this.props,a=e.getState(),n=a.order?.insuranceOption?.logo,l=a.insuranceAddOns?.insurance===t.name?a.insuranceAddOns.addOns.map(m=>({key:m?.title,value:k(m?.monthlyPrice,{postfix:"kr/m\xE5n"})})):void 0,c=a.insurance?JSON.stringify(a.insurance).localeCompare(JSON.stringify(t))===0:!1;this.displayInfo&&new ir(j(),{store:this.props.store,insurance:t,selected:c,onClose:()=>this.onInfoClose()}),new he(this.node,{logo:n,selected:c,id:o,title:t.name,description:t.description,price:k(t.price,{postfix:"kr/m\xE5n"}),priceDetails:l,onClick:()=>this.onClick(),onInfo:()=>this.onInfoOpen()},o)}},ar=zs;var Js=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,insurances:t}=this.props,o=new ue(this.node,{id:"insurance-list",onClick:()=>d("MAIN","INSURANCE_ARROW","INSURANCE_IF")}),{overflowElement:a}=o;a&&(a.innerHTML="",t.forEach((n,l)=>new ar(a,{store:e,insurance:n,key:`insurance-${l}`})))}},nr=Js;var Xs="insurance-grid-list-node",id="button-insurances-proceed",rr=`${Xs}-node`,mr="button-insurances-skip",cr=`${mr}-node`,pr="button-insurance-edit-driving-distance",lr=`${pr}-node`,dr={},Zs=class extends r{constructor(e,t){super(e);this.requestError=!1;this.contexts={listners:[]};this.props=t;let o=_(this.props.store,"drivingDistance",()=>{this.fetchInsurance()});this.contexts.listners.push(o);let a=_(this.props.store,"customer.socialId",()=>{this.fetchInsurance()});this.contexts.listners.push(a);let n=_(this.props.store,"insurance",()=>{this.contexts.buttonProceed?.disabled(!this.props.store.getState().insurance)});this.contexts.listners.push(n),this.fetchInsurance(),this.render()}fetchInsurance(){this.props.store.getState().customer.socialId&&this.getInsurances()}async getInsurances(){let e=this.props.store.getState();this.requestError=!1,this.render();let t=`${e.customer.socialId}-${e.id}-${e.drivingDistance}`,o=dr[t];if(d("MAIN","INSURANCE_GET_INSURANCES_REQUESTED","INSURANCE_IF"),o){this.insurances=o,d("MAIN","INSURANCE_GET_INSURANCES_SUCCEEDED","INSURANCE_IF"),this.render();return}try{let a=await Xn(this.props.store,e.drivingDistance);d("MAIN","INSURANCE_GET_INSURANCES_SUCCEEDED","INSURANCE_IF"),this.insurances=a.getInsuranceOptions(),dr[t]=this.insurances}catch{d("MAIN","INSURANCE_GET_INSURANCES_FAILED","INSURANCE_IF"),this.requestError=!0}finally{this.render()}}onEditDrivingDistance(){this.contexts.listners.forEach(e=>e?.()),this.props.onEdit()}onProceed(){Z(this.props.lastStage)(this.props.store.dispatch)}onSkipInsurances(){d("MAIN","INSURANCE_SKIPPED","INSURANCE_IF"),de()(this.props.store.dispatch),Z(this.props.lastStage)(this.props.store.dispatch)}render(){let{store:e}=this.props,t=e.getState(),{insurance:o,drivingDistance:a}=t;this.node.innerHTML=`
|
|
1232
1232
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1233
1233
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vill du teckna en f\xF6rs\xE4kring p\xE5 din nya bil?</h4>
|
|
1234
1234
|
<div class="waykeecom-content">
|
|
@@ -1302,7 +1302,7 @@
|
|
|
1302
1302
|
<div class="waykeecom-stack waykeecom-stack--1" id="${wr}"></div>
|
|
1303
1303
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Sr}"></div>
|
|
1304
1304
|
</div>
|
|
1305
|
-
`,new ce(this.node.querySelector(`#${_r}`),{title:"Tillbaka",onClick:()=>o()}),new te(this.node.querySelector(`#${Sr}`),{title:"Tillbaka",onClick:()=>o()}),new ee(this.node.querySelector(`#${wr}`),{selected:t,fullSize:!0,onClick:()=>a()}),G()}},Nr=so;var oo=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.props=t,_(this.props.store,"freeInsurance",()=>{this.render()}),this.render()}onInfoOpen(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE"),this.displayInfo=!0,this.render()}onInfoClose(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE"),this.displayInfo=!1,O(),this.render(),this.node.parentElement?.scrollIntoView()}onClick(){let{freeInsurance:e}=this.props.store.getState();e&&this.props.freeInsurance!==e?d("MAIN","INSURANCE_SELECTED","INSURANCE"):d("MAIN","INSURANCE_UNSELECTED","INSURANCE"),pi(this.props.freeInsurance)(this.props.store.dispatch)}render(){let{store:e,freeInsurance:t,key:o}=this.props,a=e.getState(),n=a.order?.insuranceOption?.logo,l=a.freeInsurance?JSON.stringify(a.freeInsurance).localeCompare(JSON.stringify(this.props.freeInsurance))===0:!1;this.displayInfo&&new Nr(
|
|
1305
|
+
`,new ce(this.node.querySelector(`#${_r}`),{title:"Tillbaka",onClick:()=>o()}),new te(this.node.querySelector(`#${Sr}`),{title:"Tillbaka",onClick:()=>o()}),new ee(this.node.querySelector(`#${wr}`),{selected:t,fullSize:!0,onClick:()=>a()}),G()}},Nr=so;var oo=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.props=t,_(this.props.store,"freeInsurance",()=>{this.render()}),this.render()}onInfoOpen(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE"),this.displayInfo=!0,this.render()}onInfoClose(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE"),this.displayInfo=!1,O(),this.render(),this.node.parentElement?.scrollIntoView()}onClick(){let{freeInsurance:e}=this.props.store.getState();e&&this.props.freeInsurance!==e?d("MAIN","INSURANCE_SELECTED","INSURANCE"):d("MAIN","INSURANCE_UNSELECTED","INSURANCE"),pi(this.props.freeInsurance)(this.props.store.dispatch)}render(){let{store:e,freeInsurance:t,key:o}=this.props,a=e.getState(),n=a.order?.insuranceOption?.logo,l=a.freeInsurance?JSON.stringify(a.freeInsurance).localeCompare(JSON.stringify(this.props.freeInsurance))===0:!1;this.displayInfo&&new Nr(j(),{freeInsurance:t,selected:l,onClick:()=>{this.onInfoClose(),this.onClick()},onClose:()=>this.onInfoClose()}),new he(this.node,{logo:n,id:o,title:t.title,description:t.description,price:"Gratis",selected:l,onClick:()=>this.onClick(),onInfo:()=>this.onInfoOpen()},o)}},Ar=oo;var io=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,insurances:t}=this.props,o=new ue(this.node,{id:"insurance-list",onClick:()=>d("MAIN","INSURANCE_ARROW","INSURANCE")}),{overflowElement:a}=o;a&&(a.innerHTML="",t.forEach((n,l)=>new Ar(a,{store:e,freeInsurance:n,key:`insurance-${l}`})))}},Tr=io;var ao="insurance-grid-list-node",ad="button-insurances-proceed",Cr=`${ao}-node`,nd="button-insurances-skip",rd=`${nd}-node`,no=class extends r{constructor(e,t){super(e);this.props=t,this.render()}onProceed(){let{freeInsurance:e}=this.props.store.getState();Z(this.props.lastStage)(this.props.store.dispatch),d("MAIN",e?"INSURANCE_SET":"INSURANCE_SKIPPED","INSURANCE")}render(){let{store:e,insurance:t}=this.props;this.node.innerHTML=`
|
|
1306
1306
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1307
1307
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vill du teckna en f\xF6rs\xE4kring p\xE5 din nya bil?</h4>
|
|
1308
1308
|
<div class="waykeecom-content">
|
|
@@ -1314,7 +1314,7 @@
|
|
|
1314
1314
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Cr}"></div>
|
|
1315
1315
|
<div class="waykeecom-stack waykeecom-stack--1" id="${rd}"></div>
|
|
1316
1316
|
</div>
|
|
1317
|
-
`,new Tr(this.node.querySelector(`#${ao}`),{store:e,insurances:[t]}),new N(this.node.querySelector(`#${Cr}`),{id:ad,title:"G\xE5 vidare",onClick:()=>this.onProceed()})}},Dr=no;var ro=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation",()=>{this.render()}),this.render()}getStep(){let{order:e}=this.props.store.getState();return e?.insuranceOption?.institute==="IF"?"INSURANCE_IF":"INSURANCE"}onSkipInsurances(){de()(this.props.store.dispatch),Z(this.props.lastStage)(this.props.store.dispatch),d("MAIN","INSURANCE_SKIPPED",this.getStep())}onEdit(){d("MAIN","INSURANCE_EDIT",this.getStep()),H("main",this.props.index)(this.props.store.dispatch)}render(){let{store:e,index:t,lastStage:o}=this.props,a=e.getState(),n=a.topNavigation.stage>t,l=a.navigation.stage===t;l&&d("MAIN","INSURANCE_ACTIVE",this.getStep());let c=B(this.node,{completed:n,title:"F\xF6rs\xE4kring",active:l,id:"insurance"});if(a.navigation.stage>t||n&&a.navigation.stage!==t){let m=[];a.insurance?(m.push({key:"Uppskattad k\xF6rstr\xE4cka",value:J[a.drivingDistance]}),m.push({key:a.insurance.name,value:k(a.insurance.price,{postfix:"kr/m\xE5n"})}),a.insuranceAddOns?.insurance===a.insurance.name&&a.insuranceAddOns.addOns.forEach(u=>m.push({key:u.title,value:k(u.monthlyPrice,{postfix:"kr/m\xE5n"})}))):a.freeInsurance?m.push({key:"F\xF6rs\xE4kring",value:a.freeInsurance.title}):m.push({key:"F\xF6rs\xE4kring",value:"Ingen"}),new
|
|
1317
|
+
`,new Tr(this.node.querySelector(`#${ao}`),{store:e,insurances:[t]}),new N(this.node.querySelector(`#${Cr}`),{id:ad,title:"G\xE5 vidare",onClick:()=>this.onProceed()})}},Dr=no;var ro=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation",()=>{this.render()}),this.render()}getStep(){let{order:e}=this.props.store.getState();return e?.insuranceOption?.institute==="IF"?"INSURANCE_IF":"INSURANCE"}onSkipInsurances(){de()(this.props.store.dispatch),Z(this.props.lastStage)(this.props.store.dispatch),d("MAIN","INSURANCE_SKIPPED",this.getStep())}onEdit(){d("MAIN","INSURANCE_EDIT",this.getStep()),H("main",this.props.index)(this.props.store.dispatch)}render(){let{store:e,index:t,lastStage:o}=this.props,a=e.getState(),n=a.topNavigation.stage>t,l=a.navigation.stage===t;l&&d("MAIN","INSURANCE_ACTIVE",this.getStep());let c=B(this.node,{completed:n,title:"F\xF6rs\xE4kring",active:l,id:"insurance"});if(a.navigation.stage>t||n&&a.navigation.stage!==t){let m=[];a.insurance?(m.push({key:"Uppskattad k\xF6rstr\xE4cka",value:J[a.drivingDistance]}),m.push({key:a.insurance.name,value:k(a.insurance.price,{postfix:"kr/m\xE5n"})}),a.insuranceAddOns?.insurance===a.insurance.name&&a.insuranceAddOns.addOns.forEach(u=>m.push({key:u.title,value:k(u.monthlyPrice,{postfix:"kr/m\xE5n"})}))):a.freeInsurance?m.push({key:"F\xF6rs\xE4kring",value:a.freeInsurance.title}):m.push({key:"F\xF6rs\xE4kring",value:"Ingen"}),new z(c,{keyValueList:m,changeButtonTitle:"\xC4ndra f\xF6rs\xE4kring",onEdit:a.createdOrderId?void 0:()=>this.onEdit()})}else if(a.navigation.stage===t){let m=a.order?.insuranceOption;if(!m)throw"Missing insurance";switch(m?.institute){case"IF":new gr(c,{store:e,lastStage:o,onSkip:()=>this.onSkipInsurances()});break;default:new Dr(c,{store:e,lastStage:o,insurance:m});break}}a.navigation.stage===t&&c.parentElement?.scrollIntoView()}},br=ro;var co=f("@wayke-se/ecom"),Rr=s=>{let i=co.vehicles.newLookupRequest().withRegistrationNumber(s.registrationNumber).withMileage(parseInt(s.mileage,10)).withCondition(s.condition);return co.vehicles.lookupVehicle(i.build())};var lo=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t,this.render()}setError(e){this.contexts.error?.setError(e)}render(){let{title:e,value:t,name:o,id:a,error:n,errorMessage:l,placeholder:c,information:m,autocomplete:u,onChange:h,onBlur:p}=this.props;this.node.innerHTML=`
|
|
1318
1318
|
<div class="waykeecom-input-label">
|
|
1319
1319
|
<label for="${a}" class="waykeecom-input-label__label">${e}</label>
|
|
1320
1320
|
</div>
|
|
@@ -1415,7 +1415,7 @@
|
|
|
1415
1415
|
<circle cx="11" cy="10" r="5.5" stroke="#FFF500" stroke-linejoin="round" stroke-dasharray="1 2"/>
|
|
1416
1416
|
<path d="M10.6707 21.692c1.392 0 2.04.564 2.28.996h1.644c-.264-1.08-1.248-2.364-3.924-2.364-2.028 0-3.408.912-3.408 2.436 0 1.536 1.2 2.34 2.904 2.508l1.512.156c.876.108 1.476.372 1.476 1.188 0 .684-.684 1.176-1.98 1.176-1.56 0-2.244-.72-2.472-1.26h-1.716c.336 1.224 1.404 2.628 4.188 2.628 2.412 0 3.624-1.116 3.624-2.652 0-1.8-1.308-2.448-3.012-2.616-.576-.06-.972-.108-1.5-.156-.888-.108-1.392-.444-1.392-1.02 0-.624.612-1.02 1.776-1.02Z" fill="#fff"/>
|
|
1417
1417
|
</svg>
|
|
1418
|
-
`,onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.mileage=new M(this.node.querySelector(`#${Mr}`),{title:"Miltal",value:this.state.value.mileage,id:Ur,error:this.state.interact.mileage&&!this.state.validation.mileage,errorMessage:"Ett miltal mellan 0 till 80 000 mil m\xE5ste anges",name:"mileage",autocomplete:"off",placeholder:"Ange bilens miltal",unit:"mil",pattern:"[0-9]*",inputmode:"numeric",onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.description=new Lr(this.node.querySelector(`#${xr}`),{title:"Beskrivning (valfritt)",value:this.state.value.description,id:Vr,error:this.state.interact.description&&!this.state.validation.description,errorMessage:"????",name:"description",autocomplete:"off",placeholder:"Beskriv bilen",onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),new
|
|
1418
|
+
`,onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.mileage=new M(this.node.querySelector(`#${Mr}`),{title:"Miltal",value:this.state.value.mileage,id:Ur,error:this.state.interact.mileage&&!this.state.validation.mileage,errorMessage:"Ett miltal mellan 0 till 80 000 mil m\xE5ste anges",name:"mileage",autocomplete:"off",placeholder:"Ange bilens miltal",unit:"mil",pattern:"[0-9]*",inputmode:"numeric",onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.description=new Lr(this.node.querySelector(`#${xr}`),{title:"Beskrivning (valfritt)",value:this.state.value.description,id:Vr,error:this.state.interact.description&&!this.state.validation.description,errorMessage:"????",name:"description",autocomplete:"off",placeholder:"Beskriv bilen",onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),new Q(this.node.querySelector(`#${Pr}`),{title:"Bilens skick",checked:this.state.value.condition,name:"condition",options:dd,onClick:e=>this.onChangeRadio(e)}),this.contexts.buttonFetch=new N(this.node.querySelector(`#${$r}`),{title:"H\xE4mta uppskattat v\xE4rde",id:Gr,disabled:!(this.state.validation.registrationNumber&&this.state.validation.mileage&&this.state.validation.condition),onClick:()=>this.onFetchVehicle()}),new K(this.node.querySelector(`#${tt}`),{id:mo,title:"Hoppa \xF6ver detta steg",onClick:()=>this.onNoTradeIn()})}},Wr=po;var jr="button-trade-in-yes",Yr=`${jr}-node`,Qr="button-trade-in-no",Kr=`${Qr}-node`,ho="button-trade-in-change",uo=`${ho}-node`,ko=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation",()=>{this.render()}),this.render()}onEdit(){d("MAIN","TRADE_IN_EDIT","TRADE_IN"),H("main",this.props.index)(this.props.store.dispatch)}onYesTradeIn(){d("MAIN","TRADE_IN_SELECTED","TRADE_IN"),ri(this.props.lastStage)(this.props.store.dispatch)}onNoTradeIn(){d("MAIN","TRADE_IN_SKIPPED","TRADE_IN"),Ne(this.props.lastStage)(this.props.store.dispatch)}render(){let{store:e,index:t,lastStage:o}=this.props,a=this.props.store.getState();if(!a.order?.allowsTradeIn)return;let n=a.topNavigation.stage>t,l=a.navigation.stage===t;l&&d("MAIN","TRADE_IN_ACTIVE",a.navigation.subStage===1?"TRADE_IN":"TRADE_IN_DETAILS");let c=B(this.node,{title:"Inbytesbil",active:l,completed:n,id:"trade-in"});c.innerHTML="";let m=document.createElement("div");if(a.navigation.stage>t||n&&a.navigation.stage!==t){let u=[];a.tradeIn&&a.tradeInVehicle?(u.push({key:"Miltal",value:`${a.tradeIn.mileage} mil`}),a.tradeIn.description&&u.push({key:"Beskrivning",value:`${a.tradeIn.description}`}),a.tradeIn.condition&&u.push({key:"Bilens skick",value:Ee[a.tradeIn.condition]}),m.innerHTML=`
|
|
1419
1419
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1420
1420
|
<div class="waykeecom-balloon">
|
|
1421
1421
|
<div class="waykeecom-stack waykeecom-stack--05">
|
|
@@ -1474,7 +1474,7 @@
|
|
|
1474
1474
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Yr}"></div>
|
|
1475
1475
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Kr}"></div>
|
|
1476
1476
|
</div>
|
|
1477
|
-
`,new N(m.querySelector(`#${Yr}`),{id:
|
|
1477
|
+
`,new N(m.querySelector(`#${Yr}`),{id:jr,title:"Jag har inbytesbil",onClick:()=>this.onYesTradeIn()}),new K(m.querySelector(`#${Kr}`),{id:Qr,title:"Hoppa \xF6ver detta steg",onClick:()=>this.onNoTradeIn()})));c.appendChild(m),a.navigation.stage===t&&c.parentElement?.scrollIntoView()}},zr=ko;var st={customer:{component:pa,name:"customer"},centralStorage:{component:zi,name:"centralStorage"},delivery:{component:fa,name:"delivery"},tradeIn:{component:zr,name:"tradeIn"},financial:{component:Jn,name:"financial"},insurance:{component:br,name:"insurance"},accessories:{component:Gi,name:"accessories"}};var yo=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){this.node.innerHTML=`
|
|
1478
1478
|
<h3 class="waykeecom-heading waykeecom-heading--4">K\xF6p online hos oss</h3>
|
|
1479
1479
|
<ul class="waykeecom-checklist" aria-label="F\xF6rdelar med att k\xF6pa bilen online hos oss">
|
|
1480
1480
|
${this.props.checklistItems.map(e=>` <li class="waykeecom-checklist__item">${e}</li>`).join("")}
|
|
@@ -1525,7 +1525,7 @@
|
|
|
1525
1525
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1526
1526
|
<div id="payment-menu" style="padding: 24px;border: 1px solid #ececeb;"></div>
|
|
1527
1527
|
</div>
|
|
1528
|
-
`}},ic=Eo;var W=f("@wayke-se/ecom");var Io=f("@wayke-se/ecom"),ac=s=>{let i=Io.bankid.newAuthRequest().withMethod(s).build();return Io.bankid.auth(i)};var fo=f("@wayke-se/ecom"),go=s=>{let i=fo.bankid.newCollectRequest().withOrderRef(s).build();return fo.bankid.collect(i)};var P=f("@wayke-se/ecom"),nc=s=>{let i=s.getState();if(!i.address)throw"Missing address";if(!i.paymentType)throw"Missing paymentType";if(!i.vehicle)throw"Missing vehicle";let e=P.customers.newCustomer().withAddress(i.address).withPersonalNumber(i.customer.socialId).withEmail(i.customer.email).withPhoneNumber(i.customer.phone).build(),t=P.orders.newPayment().withType(i.paymentType);if(i.paymentType===P.PaymentType.Loan){let m=i.order?.paymentOptions.find(w=>w.type===P.PaymentType.Loan),u=i.paymentLookupResponse||m?.loanDetails,h=u?.durationSpec.current,p=u?.downPaymentSpec.current,y=u?.residualValueSpec?.current,g=i.order?.paymentOptions.find(w=>w.type===P.PaymentType.Loan)?.externalId;if(t.withDuration(h).withDownPayment(Math.round(p)),y&&t.withResidualValue(y),g&&t.withExternalId(g),i.creditAssessmentResponse){let w=i.creditAssessmentResponse.scoringId,R=i.creditAssessmentResponse.recommendation,$=i.creditAssessmentResponse.decision,X=u?.financialProductCode;if(!w||!R||!$||!X)throw"Missing credit assessment data";let L=P.orders.newCreditAssessment().withScoreId(w).withFinancialProductCode(X).withRecommendation(R).withDecision($).build();t.withCreditAssessment(L)}}let o=t.build(),a=new URLSearchParams(window.location.search);a.set("wayke-ecom-web-id",i.id);let n=`${window.location.origin}${window.location.pathname}?${a.toString()}${window.location.hash}`;a.set("wayke-ecom-web-payment","true");let l=`${window.location.origin}${window.location.pathname}?${a.toString()}${window.location.hash}`,c=P.orders.newCreateRequest().forVehicle(i.id).withCustomer(e).withPayment(o).withUrls(n,l).withDeliveryType(i.homeDelivery?P.DeliveryType.Delivery:P.DeliveryType.Pickup);if(i.insurance){let m=P.orders.newInsurance().withDrivingDistance(i.drivingDistance);i.insuranceAddOns?.addOns.length&&i.insuranceAddOns.insurance===i.insurance.name&&m.withAddOns(i.insuranceAddOns.addOns.map(h=>h.name));let u=m.build();c.withInsurance(u)}else i.freeInsurance&&c.withInsurance({});if(i.accessories.length&&c.withAccessories(i.accessories),i.tradeIn&&i.tradeInVehicle&&i.tradeIn.condition){let m=P.vehicles.newVehicleTrade().forVehicle(i.tradeIn.registrationNumber).withMileage(parseInt(i.tradeIn.mileage,10)).withCondition(i.tradeIn.condition).withComment(i.tradeIn.description).build();c.withTradeIn(m)}return P.orders.create(c.build())};var rc=f("@wayke-se/ecom"),cc=s=>rc.creditAssessment.accept(s);var _o=f("@wayke-se/ecom"),lc=s=>{let i=_o.bankid.newQrCodeRequest().withOrderRef(s).build();return _o.bankid.qrcode(i)};var hc="confirm-conditions",dc=`${hc}-node`,mc="bankid-start-node",hd="bankid-start",pc="address-disclaimer-policy-node",uc="address-disclaimer-reservation-node",So=class extends r{constructor(e,t){super(e,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--2"});this.view=1;this.contexts={};this.ageError=!1;this.requestError=!1;this.socialIdNotMatchingError=!1;this.notAvailable=!1;this.confirmConditions=!1;this.bankidRequestRef=void 0;this.bankidStatus=async e=>{try{let t=await go(e);this.handleBankidStatusResponse(t,W.AuthMethod.QrCode)}catch{this.clearIntervals(),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering.")}};this.qrCode=async e=>{try{let o=(await lc(e)).getQrCode();this.contexts.bankId?.update(W.AuthMethod.QrCode,o)}catch{this.clearIntervals(),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta ny QR-kod f\xF6r BankId signering.")}};this.props=t,this.ageError=!1,this.render()}addWindowEvents(){this.removeWindowEvents(),window.addEventListener("focus",()=>this.onFocus())}removeWindowEvents(){window.removeEventListener("focus",()=>this.onFocus())}clearIntervals(){clearInterval(this.bankidQrCodeInterval),clearInterval(this.bankidStatusInterval)}async onFocus(){clearTimeout(this.focusTimeout),this.focusTimeout=setTimeout(async()=>{if(this.bankidRequestRef?.method===W.AuthMethod.SameDevice)try{let e=await go(this.bankidRequestRef.reference);this.handleBankidStatusResponse(e,this.bankidRequestRef.method)}catch{this.clearIntervals(),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering.")}},500)}onSameDeviceClick(){this.addWindowEvents()}setBankidRequestRef(e,t){this.bankidRequestRef={reference:e,method:t}}clearBankidRequestRef(){this.bankidRequestRef=void 0}async acceptCreditAssessment(){let{caseId:e}=this.props.store.getState();if(e)try{d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_REQUEST","CONFIRMATION"),await cc(e),d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_SUCCEEDED","CONFIRMATION")}catch{d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_FAILED","CONFIRMATION")}}async onCreateOrder(){let{store:e}=this.props;this.notAvailable=!1,this.requestError=!1;try{d("MAIN","CONFIRMATION_CREATE_ORDER_REQUESTED","CONFIRMATION");let{order:t}=e.getState(),o=await nc(e);d("MAIN","CONFIRMATION_CREATE_ORDER_SUCCEEDED","CONFIRMATION"),t?.isPaymentRequired&&O();let n=o.getPayment();ki(o.getOrderNumber(),n)(e.dispatch),this.acceptCreditAssessment()}catch(t){let o=t;this.view=1,d("MAIN","CONFIRMATION_CREATE_ORDER_FAILED","CONFIRMATION"),o.message==="The vehicle is not available for purchase"?(this.requestError=!1,this.notAvailable=!0):(this.notAvailable=!1,this.requestError=!0),O(),this.render()}}async handleBankidStatusResponse(e,t){if(e.isCompleted()){this.removeWindowEvents(),this.clearBankidRequestRef(),this.clearIntervals();let o=e.getAddress(),a=e.getPersonalNumber();if(o&&a){let n=this.props.store.getState();if(C.requiredSsnOver18(a)){if(n.customer.socialId!==a){d("MAIN",t===W.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED_SSN_MISSMATCH":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED_SSN_MISSMATCH","CONFIRMATION"),this.view=1,this.socialIdNotMatchingError=!0,O(),this.render();return}}else{d("MAIN",t===W.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED_NOT_OVER_18":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED_NOT_OVER_18","CONFIRMATION"),this.view=1,this.ageError=!0,O(),this.render();return}d("MAIN",t===W.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED","CONFIRMATION"),this.contexts.bankId?.setDescription("Verifiering klar, ordern skapas nu..."),await this.onCreateOrder()}}}async startBankidSameDevice(e,t,o=!1){o||d("MAIN","CONFIRMATION_BANKID_STATUS_SAME_DEVICE_REQUESTED","CONFIRMATION");try{this.setBankidRequestRef(t,W.AuthMethod.SameDevice);let a=e.getAutoLaunchUrl();this.contexts.bankId?.update(W.AuthMethod.SameDevice,a)}catch(a){this.removeWindowEvents(),this.clearBankidRequestRef();let n=a;this.contexts.bankId?.setErrorMessage(`Error: ${n.message}`)}}async startBankidWithQr(e,t=!1){t||d("MAIN","CONFIRMATION_BANKID_STATUS_QR_REQUESTED","CONFIRMATION"),this.bankidStatusInterval=setInterval(()=>{this.bankidStatus(e)},2e3),Oe("bankidStatusInterval",this.bankidStatusInterval),this.qrCode(e),this.bankidQrCodeInterval=setInterval(async()=>{this.qrCode(e)},1e3),Oe("bankidQrCodeInterval",this.bankidQrCodeInterval)}async onStartBankIdAuth(e,t=!1){this.clearIntervals();try{t||d("MAIN","CONFIRMATION_BANKID_INIT_REQUESTED","CONFIRMATION"),this.contexts.bankId?.update(e),this.contexts.buttonLinkToggle?.disabled(!0);let o=await ac(e);t||d("MAIN","CONFIRMATION_BANKID_INIT_SUCCEEDED","CONFIRMATION");let a=o.getOrderRef();e===W.AuthMethod.QrCode?this.startBankidWithQr(a,t):this.startBankidSameDevice(o,a,t)}catch{d("MAIN","CONFIRMATION_BANKID_INIT_FAILED","CONFIRMATION"),this.contexts.bankId?.setErrorMessage("Det gick tyv\xE4rr inte att initiera BankId. V\xE4nligen f\xF6rs\xF6k igen.")}finally{this.contexts.buttonLinkToggle?.disabled(!1)}}onAbort(){this.clearBankidRequestRef(),this.removeWindowEvents(),this.clearIntervals(),d("MAIN","CONFIRMATION_BANKID_ABORTED","CONFIRMATION"),this.view=1,O(),this.render()}onCheckbox(e){let t=e.currentTarget;this.confirmConditions=t.checked,this.contexts.confirmConditions?.checked(this.confirmConditions),this.contexts.startBankid?.disabled(!this.confirmConditions)}render(){let e=Ie(),{navigation:t,order:o,insurance:a}=this.props.store.getState();if(this.view===2)this.contexts.bankId=new
|
|
1528
|
+
`}},ic=Eo;var W=f("@wayke-se/ecom");var Io=f("@wayke-se/ecom"),ac=s=>{let i=Io.bankid.newAuthRequest().withMethod(s).build();return Io.bankid.auth(i)};var fo=f("@wayke-se/ecom"),go=s=>{let i=fo.bankid.newCollectRequest().withOrderRef(s).build();return fo.bankid.collect(i)};var P=f("@wayke-se/ecom"),nc=s=>{let i=s.getState();if(!i.address)throw"Missing address";if(!i.paymentType)throw"Missing paymentType";if(!i.vehicle)throw"Missing vehicle";let e=P.customers.newCustomer().withAddress(i.address).withPersonalNumber(i.customer.socialId).withEmail(i.customer.email).withPhoneNumber(i.customer.phone).build(),t=P.orders.newPayment().withType(i.paymentType);if(i.paymentType===P.PaymentType.Loan){let m=i.order?.paymentOptions.find(w=>w.type===P.PaymentType.Loan),u=i.paymentLookupResponse||m?.loanDetails,h=u?.durationSpec.current,p=u?.downPaymentSpec.current,y=u?.residualValueSpec?.current,g=i.order?.paymentOptions.find(w=>w.type===P.PaymentType.Loan)?.externalId;if(t.withDuration(h).withDownPayment(Math.round(p)),y&&t.withResidualValue(y),g&&t.withExternalId(g),i.creditAssessmentResponse){let w=i.creditAssessmentResponse.scoringId,R=i.creditAssessmentResponse.recommendation,$=i.creditAssessmentResponse.decision,X=u?.financialProductCode;if(!w||!R||!$||!X)throw"Missing credit assessment data";let L=P.orders.newCreditAssessment().withScoreId(w).withFinancialProductCode(X).withRecommendation(R).withDecision($).build();t.withCreditAssessment(L)}}let o=t.build(),a=new URLSearchParams(window.location.search);a.set("wayke-ecom-web-id",i.id);let n=`${window.location.origin}${window.location.pathname}?${a.toString()}${window.location.hash}`;a.set("wayke-ecom-web-payment","true");let l=`${window.location.origin}${window.location.pathname}?${a.toString()}${window.location.hash}`,c=P.orders.newCreateRequest().forVehicle(i.id).withCustomer(e).withPayment(o).withUrls(n,l).withDeliveryType(i.homeDelivery?P.DeliveryType.Delivery:P.DeliveryType.Pickup);if(i.insurance){let m=P.orders.newInsurance().withDrivingDistance(i.drivingDistance);i.insuranceAddOns?.addOns.length&&i.insuranceAddOns.insurance===i.insurance.name&&m.withAddOns(i.insuranceAddOns.addOns.map(h=>h.name));let u=m.build();c.withInsurance(u)}else i.freeInsurance&&c.withInsurance({});if(i.accessories.length&&c.withAccessories(i.accessories),i.tradeIn&&i.tradeInVehicle&&i.tradeIn.condition){let m=P.vehicles.newVehicleTrade().forVehicle(i.tradeIn.registrationNumber).withMileage(parseInt(i.tradeIn.mileage,10)).withCondition(i.tradeIn.condition).withComment(i.tradeIn.description).build();c.withTradeIn(m)}return P.orders.create(c.build())};var rc=f("@wayke-se/ecom"),cc=s=>rc.creditAssessment.accept(s);var _o=f("@wayke-se/ecom"),lc=s=>{let i=_o.bankid.newQrCodeRequest().withOrderRef(s).build();return _o.bankid.qrcode(i)};var hc="confirm-conditions",dc=`${hc}-node`,mc="bankid-start-node",hd="bankid-start",pc="address-disclaimer-policy-node",uc="address-disclaimer-reservation-node",So=class extends r{constructor(e,t){super(e,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--2"});this.view=1;this.contexts={};this.ageError=!1;this.requestError=!1;this.socialIdNotMatchingError=!1;this.notAvailable=!1;this.confirmConditions=!1;this.bankidRequestRef=void 0;this.bankidStatus=async e=>{try{let t=await go(e);this.handleBankidStatusResponse(t,W.AuthMethod.QrCode)}catch{this.clearIntervals(),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering.")}};this.qrCode=async e=>{try{let o=(await lc(e)).getQrCode();this.contexts.bankId?.update(W.AuthMethod.QrCode,o)}catch{this.clearIntervals(),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta ny QR-kod f\xF6r BankId signering.")}};this.props=t,this.ageError=!1,this.render()}addWindowEvents(){this.removeWindowEvents(),window.addEventListener("focus",()=>this.onFocus())}removeWindowEvents(){window.removeEventListener("focus",()=>this.onFocus())}clearIntervals(){clearInterval(this.bankidQrCodeInterval),clearInterval(this.bankidStatusInterval)}async onFocus(){clearTimeout(this.focusTimeout),this.focusTimeout=setTimeout(async()=>{if(this.bankidRequestRef?.method===W.AuthMethod.SameDevice)try{let e=await go(this.bankidRequestRef.reference);this.handleBankidStatusResponse(e,this.bankidRequestRef.method)}catch{this.clearIntervals(),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering.")}},500)}onSameDeviceClick(){this.addWindowEvents()}setBankidRequestRef(e,t){this.bankidRequestRef={reference:e,method:t}}clearBankidRequestRef(){this.bankidRequestRef=void 0}async acceptCreditAssessment(){let{caseId:e}=this.props.store.getState();if(e)try{d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_REQUEST","CONFIRMATION"),await cc(e),d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_SUCCEEDED","CONFIRMATION")}catch{d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_FAILED","CONFIRMATION")}}async onCreateOrder(){let{store:e}=this.props;this.notAvailable=!1,this.requestError=!1;try{d("MAIN","CONFIRMATION_CREATE_ORDER_REQUESTED","CONFIRMATION");let{order:t}=e.getState(),o=await nc(e);d("MAIN","CONFIRMATION_CREATE_ORDER_SUCCEEDED","CONFIRMATION"),t?.isPaymentRequired&&O();let n=o.getPayment();ki(o.getOrderNumber(),n)(e.dispatch),this.acceptCreditAssessment()}catch(t){let o=t;this.view=1,d("MAIN","CONFIRMATION_CREATE_ORDER_FAILED","CONFIRMATION"),o.message==="The vehicle is not available for purchase"?(this.requestError=!1,this.notAvailable=!0):(this.notAvailable=!1,this.requestError=!0),O(),this.render()}}async handleBankidStatusResponse(e,t){if(e.isCompleted()){this.removeWindowEvents(),this.clearBankidRequestRef(),this.clearIntervals();let o=e.getAddress(),a=e.getPersonalNumber();if(o&&a){let n=this.props.store.getState();if(C.requiredSsnOver18(a)){if(n.customer.socialId!==a){d("MAIN",t===W.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED_SSN_MISSMATCH":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED_SSN_MISSMATCH","CONFIRMATION"),this.view=1,this.socialIdNotMatchingError=!0,O(),this.render();return}}else{d("MAIN",t===W.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED_NOT_OVER_18":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED_NOT_OVER_18","CONFIRMATION"),this.view=1,this.ageError=!0,O(),this.render();return}d("MAIN",t===W.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED","CONFIRMATION"),this.contexts.bankId?.setDescription("Verifiering klar, ordern skapas nu..."),await this.onCreateOrder()}}}async startBankidSameDevice(e,t,o=!1){o||d("MAIN","CONFIRMATION_BANKID_STATUS_SAME_DEVICE_REQUESTED","CONFIRMATION");try{this.setBankidRequestRef(t,W.AuthMethod.SameDevice);let a=e.getAutoLaunchUrl();this.contexts.bankId?.update(W.AuthMethod.SameDevice,a)}catch(a){this.removeWindowEvents(),this.clearBankidRequestRef();let n=a;this.contexts.bankId?.setErrorMessage(`Error: ${n.message}`)}}async startBankidWithQr(e,t=!1){t||d("MAIN","CONFIRMATION_BANKID_STATUS_QR_REQUESTED","CONFIRMATION"),this.bankidStatusInterval=setInterval(()=>{this.bankidStatus(e)},2e3),Oe("bankidStatusInterval",this.bankidStatusInterval),this.qrCode(e),this.bankidQrCodeInterval=setInterval(async()=>{this.qrCode(e)},1e3),Oe("bankidQrCodeInterval",this.bankidQrCodeInterval)}async onStartBankIdAuth(e,t=!1){this.clearIntervals();try{t||d("MAIN","CONFIRMATION_BANKID_INIT_REQUESTED","CONFIRMATION"),this.contexts.bankId?.update(e),this.contexts.buttonLinkToggle?.disabled(!0);let o=await ac(e);t||d("MAIN","CONFIRMATION_BANKID_INIT_SUCCEEDED","CONFIRMATION");let a=o.getOrderRef();e===W.AuthMethod.QrCode?this.startBankidWithQr(a,t):this.startBankidSameDevice(o,a,t)}catch{d("MAIN","CONFIRMATION_BANKID_INIT_FAILED","CONFIRMATION"),this.contexts.bankId?.setErrorMessage("Det gick tyv\xE4rr inte att initiera BankId. V\xE4nligen f\xF6rs\xF6k igen.")}finally{this.contexts.buttonLinkToggle?.disabled(!1)}}onAbort(){this.clearBankidRequestRef(),this.removeWindowEvents(),this.clearIntervals(),d("MAIN","CONFIRMATION_BANKID_ABORTED","CONFIRMATION"),this.view=1,O(),this.render()}onCheckbox(e){let t=e.currentTarget;this.confirmConditions=t.checked,this.contexts.confirmConditions?.checked(this.confirmConditions),this.contexts.startBankid?.disabled(!this.confirmConditions)}render(){let e=Ie(),{navigation:t,order:o,insurance:a}=this.props.store.getState();if(this.view===2)this.contexts.bankId=new ze(j(),{method:e?W.AuthMethod.SameDevice:W.AuthMethod.QrCode,descriptionQrCode:"F\xF6r att verifiera din identitet, starta din BankID applikation p\xE5 din andra enhet.",descriptionSameDevice:"F\xF6r att verifiera din identitet, starta din BankID-applikation.",onAbort:()=>this.onAbort(),onStart:n=>this.onStartBankIdAuth(n),onSameDeviceClick:()=>this.onSameDeviceClick()});else{let n=o?.contactInformation?.name,l=o?.conditionsPdfUri,c="https://www.wayke.se/trygghet-naer-det-kommer-till-dina-personuppgifter";this.node.innerHTML=`
|
|
1529
1529
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1530
1530
|
<h4 class="waykeecom-heading waykeecom-heading--4">Strax klart!</h4>
|
|
1531
1531
|
<div class="waykeecom-content">
|
|
@@ -1879,5 +1879,5 @@
|
|
|
1879
1879
|
<div class="waykeecom-stack waykeecom-stack--1" id="${$c}"></div>
|
|
1880
1880
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Pc}"></div>
|
|
1881
1881
|
</div>
|
|
1882
|
-
`,new Je(this.node.querySelector(`#${$c}`),{title:"Forts\xE4tt min order",onClick:()=>t()}),new xc(this.node.querySelector(`#${Pc}`),{title:"Avbryt min order",onClick:()=>e()})}},Hc=Yo;var Ko=()=>{let s=document.documentElement.clientWidth/100;document.documentElement.style.setProperty("--waykeecom-vw",`${s}px`)},Bc=()=>(Ko(),window.addEventListener("resize",Ko),()=>window.removeEventListener("resize",Ko));var
|
|
1882
|
+
`,new Je(this.node.querySelector(`#${$c}`),{title:"Forts\xE4tt min order",onClick:()=>t()}),new xc(this.node.querySelector(`#${Pc}`),{title:"Avbryt min order",onClick:()=>e()})}},Hc=Yo;var Ko=()=>{let s=document.documentElement.clientWidth/100;document.documentElement.style.setProperty("--waykeecom-vw",`${s}px`)},Bc=()=>(Ko(),window.addEventListener("resize",Ko),()=>window.removeEventListener("resize",Ko));var jo="order",kd="wayke-ecom-web-payment",Qo="wayke-ecom-web-id",Ce="wayke-ecom-modal",yd="ecom.wayketech.se",vd="ecom.wayke.se",Ed=s=>{switch(new URL(s).host){case vd:return"https://cdn.wayke.se";case yd:return"https://test-cdn.wayketech.se";default:return}},zo=class{constructor(i){this.contexts={store:gi()};if(!i.id)throw"Missing id";this.props=i,window.process||(window.process={...window.process||{},env:{}}),Fc.config.bind(i.ecomSdkConfig),this.cdnMedia=Ed(i.ecomSdkConfig.api.address);let e=document.createElement("div");if(e.className="waykeecom-root",this.root=e,this.props.rootId){let l=document.getElementById(this.props.rootId);if(!l)throw"Missing element with id wayke-ecom";l.appendChild(e)}else document.body.appendChild(this.root);this.root.dataset.version=Xo.version,this.stageOrderList=["centralStorage","customer","financial","tradeIn","accessories","insurance","delivery"],si(i.id)(this.contexts.store.dispatch),this.view=this.contexts.store.getState().navigation.view,_(this.contexts.store,"navigation.view",l=>{this.view=l,l!=="preview"&&this.render()},!0);let t=new URLSearchParams(location.search),o=t.get(jo)||void 0,a=!!t.get(kd),n=t.get(Qo);if(n&&n===this.props.id&&(o||a))if(a){let l=sessionStorage.getItem("wayke-ecom-state");sessionStorage.removeItem("wayke-ecom-state");let c=l?JSON.parse(l):void 0;c&&(this.view=c.navigation.view,yi({...c,stateLoadedFromSession:!0})(this.contexts.store.dispatch))}else o&&this.render({orderUrl:o,id:n})}close(){let i=Te();i&&d(i.view,"CLOSE",i.currentStep);let{caseId:e}=this.contexts.store.getState(),t=new URLSearchParams(location.search),o=t.get(jo),a=t.get(Qo),n=!1;o&&(t.delete(jo),n=!0,location.search=t.toString()),a&&(t.delete(Qo),n=!0),n&&(location.search=t.toString()),this.root.innerHTML="",this.contexts?.unsubribeVwListner?.(),Ts(),Ni(),e&&Re(e),sessionStorage.removeItem("wayke-ecom-state"),ti(this.props.id)(this.contexts.store.dispatch),this.props.onEvent&&Ti(this.props.onEvent)}destroy(){this.close(),this.root.remove()}closeWithConfirm(){let{navigation:i,createdOrderId:e}=this.contexts.store.getState(),t=i.view==="preview";if(Ts(),t||e){this.close();return}this.contexts.modal=new qo(this.root,{title:"Wayke Ecom",id:Ce,logo:this.props.logo,logoX2:this.props.logoX2});let o=Te();o&&d(o.view,"CONFIRM_CLOSE_ACTIVE"),new Hc(this.contexts.modal.content,{onConfirmClose:()=>{let a=Te();d(a.view,"CONFIRM_CLOSE_CONFIRMED",a.currentStep),this.close()},onAbortClose:()=>{let a=Te();d(a.view,"CONFIRM_CLOSE_ABORTED",a.currentStep),this.render()}})}start(){this.props.onEvent&&Ai(this.props.onEvent),d("PREVIEW","START"),this.render()}render(i){if(this.contexts.unsubribeVwListner||(this.contexts.unsubribeVwListner=Bc()),this.contexts.modal=new qo(this.root,{title:"Wayke Ecom",id:Ce,logo:this.props.logo,logoX2:this.props.logoX2,onClose:()=>this.closeWithConfirm()}),this.contexts.modal.content){if(this.contexts.modal.content.innerHTML="",i){new Ac(this.contexts.modal.content,{store:this.contexts.store,callbackOrder:i,onClose:()=>this.close()});return}switch(this.view){case"preview":new tc(this.contexts.modal.content,{store:this.contexts.store,stageOrderList:this.stageOrderList,vehicle:this.props.vehicle,cdnMedia:this.cdnMedia});break;case"main":new vc(this.contexts.modal.content,{store:this.contexts.store,cdnMedia:this.cdnMedia});break;case"summary":new Nc(this.contexts.modal.content,{store:this.contexts.store,cdnMedia:this.cdnMedia,onClose:()=>this.close()});break;default:throw"Unknown view..."}}}},Uc=zo;var y_=Uc;})();
|
|
1883
1883
|
//# sourceMappingURL=index.js.map
|