@wayke-se/ecom-web 1.4.8 → 1.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +40 -40
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +35 -35
- package/dist/index.mjs.map +3 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(()=>{var Uc=Object.create;var zo=Object.defineProperty;var Fc=Object.getOwnPropertyDescriptor;var Vc=Object.getOwnPropertyNames;var Gc=Object.getPrototypeOf,qc=Object.prototype.hasOwnProperty;var f=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(i,e)=>(typeof require<"u"?require:i)[e]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+o+'" is not supported')});var Wc=(o,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of Vc(i))!qc.call(o,s)&&s!==e&&zo(o,s,{get:()=>i[s],enumerable:!(t=Fc(i,s))||t.enumerable});return o};var Yc=(o,i,e)=>(e=o!=null?Uc(Gc(o)):{},Wc(i||!o||!o.__esModule?zo(e,"default",{value:o,enumerable:!0}):e,o));var Mc=f("@wayke-se/ecom");var Jo={name:"@wayke-se/ecom-web",version:"1.4.
|
|
1
|
+
"use strict";(()=>{var Uc=Object.create;var zo=Object.defineProperty;var Fc=Object.getOwnPropertyDescriptor;var Vc=Object.getOwnPropertyNames;var Gc=Object.getPrototypeOf,qc=Object.prototype.hasOwnProperty;var f=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(i,e)=>(typeof require<"u"?require:i)[e]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+o+'" is not supported')});var Wc=(o,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of Vc(i))!qc.call(o,s)&&s!==e&&zo(o,s,{get:()=>i[s],enumerable:!(t=Fc(i,s))||t.enumerable});return o};var Yc=(o,i,e)=>(e=o!=null?Uc(Gc(o)):{},Wc(i||!o||!o.__esModule?zo(e,"default",{value:o,enumerable:!0}):e,o));var Mc=f("@wayke-se/ecom");var Jo={name:"@wayke-se/ecom-web",version:"1.4.10",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",cl:"node ./esbuild/cl.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:{"@types/marked":"^4.0.3","@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.8","esbuild-sass-plugin":"^2.2.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:"^4.1.3",stylelint:"^15.2.0","stylelint-config-prettier-scss":"^0.0.1","stylelint-config-standard-scss":"^7.0.1",typescript:"^4.5.5"},dependencies:{"@wayke-se/ecom":"^4.3.0",marked:"^4.0.16","object-path":"^0.11.8",redux:"^4.1.2","sanitize-html":"^2.7.0"},files:["dist"]};var Ii=f("redux");var Ae=f("@wayke-se/ecom");var st=(o,i)=>o!==void 0&&i!==void 0?JSON.stringify(o).localeCompare(JSON.stringify(i))===0:o===i;var Se=o=>({costs:o.getCosts(),fees:o.getFees(),interests:o.getInterests(),durationSpec:o.getDurationSpec(),downPaymentSpec:o.getDownPaymentSpec(),residualValueSpec:o.getResidualValueSpec(),totalResidualValue:o.getTotalResidualValue(),publicURL:o.getPublicURL(),shouldUseCreditScoring:o.shouldUseCreditScoring(),financialProductCode:o.getFinancialProductCode(),price:o.getPrice(),creditAmount:o.getCreditAmount(),hasPrivacyPolicy:o.hasPrivacyPolicy(),privacyPolicyUrl:o.getPrivacyPolicyUrl()}),Xo=o=>({status:o.getStatus(),hasPendingSigning:o.hasPendingSigning(),hintCode:o.getHintCode(),signingMessage:o.getSigningMessage(),shouldRenewSigning:o.shouldRenewSigning(),isSigned:o.isSigned(),address:void 0,pendingScoring:o.hasPendingScoring(),isScored:o.isScored(),hasScoringError:o.hasScoringError(),scoringId:o.getScoringId(),recommendation:o.getRecommendation(),decision:o.getDecision(),isAccepted:o.isAccepted()}),Me=o=>({orderVehicle:o.getOrderVehicle(),accessories:o.getAccessories(),requiresDealerSelection:o.requiresDealerSelection(),dealerSites:o.getDealerSites(),paymentOptions:o.getPaymentOptions().map(e=>({...e,loanDetails:e.loanDetails?Se(e.loanDetails):void 0})),deliveryOptions:o.getDeliveryOptions(),insuranceOption:o.getInsuranceOption(),orderConditions:o.getOrderConditions(),orderReturnConditions:o.getOrderReturnConditions(),conditionsPdfUri:o.getConditionsPdfUri(),contactInformation:o.getContactInformation(),allowsTradeIn:o.allowsTradeIn(),isUnavailable:o.isUnavailable(),isPaymentRequired:o.isPaymentRequired()}),Zo=o=>({vehicle:o.getVehicle()});var ot="RESET",ei=o=>i=>i({type:ot,id:o}),it="SET_ORDER",xe=(o,i)=>e=>e({type:it,order:o,vehicle:i}),nt="SET_ID",ti=o=>i=>i({type:nt,id:o}),at="SET_CONTACT_EMAIL_AND_PHONE",si=o=>i=>i({type:at,value:o}),rt="SET_SOCIAL_ID_AND_ADDRESS",oi=(o,i,e)=>t=>t({type:rt,socialId:o,address:i,lastStage:e}),ct="SET_HOME_DELIVERY",ii=(o,i)=>e=>e({type:ct,homeDelivery:o,lastStage:i}),lt="SET_DEALER",ni=(o,i)=>e=>e({type:lt,dealer:o,lastStage:i}),dt="INIT_TRADE_IN",ai=o=>i=>i({type:dt,lastStage:o}),mt="SET_TRADE_IN",Ne=(o,i,e)=>t=>t({type:mt,lastStage:o,tradeIn:i,tradeInVehicle:e}),pt="SET_FINANCIAL",ri=(o,i)=>e=>e({type:pt,paymentType:o,lastStage:i}),ut="SET_PAYMENT_LOOKUP_RESPONSE",ci=o=>i=>i({type:ut,paymentLookupResponse:Se(o)}),ht="SET_DRIVING_DISTANCE",li=o=>i=>i({type:ht,drivingDistance:o}),kt="COMPLETE_STAGE",Z=o=>i=>i({type:kt,lastStage:o}),yt="SET_OR_REMOVE_INSURANCE",le=o=>i=>i({type:yt,insurance:o}),vt="SET_OR_REMOVE_INSURANCE_ADDONS",di=(o,i)=>e=>e({type:vt,insurance:o,insuranceAddons:i}),Et="SET_OR_REMOVE_FREE_INSURANCE",mi=o=>i=>i({type:Et,freeInsurance:o}),It="SET_OR_REMOVE_ACCESSORY",pi=o=>i=>i({type:It,accessory:o}),ft="GO_TO",M=(o,i,e)=>t=>t({type:ft,view:o,index:i,subStage:e}),_t="SET_STAGES",ui=o=>i=>i({type:_t,stages:o}),gt="SET_CREATED_ORDER_ID",hi=(o,i)=>e=>e({type:gt,id:o,payment:i}),wt="SET_CREDIT_ASSESSMENT_RESPONSE",de=(o,i)=>e=>e({type:wt,caseId:o,creditAssessmentResponse:i}),St="SET_STATE",ki=o=>i=>i({type:St,state:o});var Qc={};var yi={view:"preview",stage:1,subStage:1},vi={id:"",topNavigation:{...yi},navigation:{...yi},customer:{email:"",phone:"",givenName:"",surname:"",socialId:""},homeDelivery:!1,accessories:[],drivingDistance:Ae.DrivingDistance.Between0And1000,...Qc},ne=(o,i)=>i?{view:"summary",stage:1,subStage:1}:{view:"main",stage:o+1,subStage:1},ae=(o,i)=>i.view==="main"?o.stage<i.stage?i:v.topNavigation:{...o,stage:o.stage+1},Nt=o=>o&&o?.length===1&&o?.[0].type===Ae.PaymentType.Cash?Ae.PaymentType.Cash:void 0,v,At,jc=(o=vi,i)=>{let e,t;switch(v={...o},i.type){case ot:return{...vi,id:i.id};case _t:return{...v,stages:i.stages};case nt:return{...v,id:i.id};case it:return{...o,order:i.order,paymentType:Nt(i.order?.paymentOptions),vehicle:{...i.order.orderVehicle,...i.vehicle||{}}};case at:let s={...v,customer:{...o.customer,email:i.value.email,phone:i.value.phone},navigation:{view:"main",stage:o.navigation.stage,subStage:2}};return delete s.wantTradeIn,delete s.tradeIn,delete s.tradeInVehicle,s.paymentType=Nt(o.order?.paymentOptions),delete s.paymentLookupResponse,delete s.insurance,delete s.insuranceAddOns,delete s.freeInsurance,delete s.dealer,s.accessories=[],s;case rt:return e=ne(v.navigation.stage,i.lastStage),t=ae(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,address:i.address,customer:{...o.customer,socialId:i.socialId}},v;case lt:return e=ne(o.navigation.stage,i.lastStage),t={...e},v={...o,navigation:e,topNavigation:t,dealer:i.dealer},delete v.wantTradeIn,delete v.tradeIn,delete v.tradeInVehicle,v.paymentType=Nt(o.order?.paymentOptions),delete v.paymentLookupResponse,delete v.insurance,delete v.insuranceAddOns,delete v.freeInsurance,v.accessories=[],v;case ct:return e=ne(o.navigation.stage,i.lastStage),t=ae(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,homeDelivery:i.homeDelivery},v;case dt:return e={view:"main",stage:o.navigation.stage,subStage:1},t=ae(v.topNavigation,e),v={...o,navigation:e,wantTradeIn:!0,topNavigation:t,tradeIn:o.tradeIn||{registrationNumber:"",mileage:"",description:""}},v;case mt:return e=ne(o.navigation.stage,i.lastStage),t=ae(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,wantTradeIn:!!i.tradeIn,tradeIn:i.tradeIn,tradeInVehicle:i.tradeInVehicle},v;case pt:return e=ne(o.navigation.stage,i.lastStage),t=ae(v.topNavigation,e),{...v,navigation:e,topNavigation:t,paymentType:i.paymentType};case ut:return{...v,paymentLookupResponse:i.paymentLookupResponse};case ht:return{...v,drivingDistance:i.drivingDistance};case kt:return e=ne(o.navigation.stage,i.lastStage),t=ae(v.topNavigation,e),v={...o,navigation:e,topNavigation:t},v;case vt:return v.insurance=i.insurance,v.insuranceAddOns={insurance:i.insurance.name,addOns:i.insuranceAddons},v;case yt:return st(v.insurance,i.insurance)?v.insurance=void 0:v.insurance=i.insurance,v.insuranceAddOns?.insurance&&(v.insuranceAddOns=void 0),v;case Et:return st(v.freeInsurance,i.freeInsurance)?v.freeInsurance=void 0:v.freeInsurance=i.freeInsurance,v;case It:return At=v.accessories.findIndex(n=>n.id===i.accessory.id),v.accessories=[...v.accessories],At>-1?v.accessories.splice(At,1):v.accessories.push(i.accessory),{...v,accessories:[...v.accessories]};case ft:return{...o,navigation:{view:i.view,stage:i.index||1,subStage:i.subStage||1}};case gt:return i.payment?e={view:"main",stage:o.navigation.stage,subStage:2}:e=ne(o.navigation.stage,!0),t=ae(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,createdOrderId:i.id,payment:i.payment},v;case wt:return{...v,caseId:i.caseId,creditAssessmentResponse:i.creditAssessmentResponse};case St:return{...i.state};default:return o}},Ei=jc;var fi=()=>(0,Ii.createStore)(Ei);var Pe=(o,i)=>{if(!i)return o;let e=new URL(o);return`${i}${e.pathname}`};var zc=o=>o.toString().replace(/\s/g,""),Jc=(o,i)=>{if(!i)return o;let e=Math.pow(10,i);return(Math.round(o*e)/e).toFixed(i)},k=(o,i)=>{if(o===void 0)return"???";let e=Jc(o,i?.decimals!==void 0?i.decimals:0);return`${i?.prefix?`${i.prefix}`:""}${zc(e).replace(/\B(?=(\d{3})+(?!\d))/g," ")}${i?.postfix?` ${i.postfix}`:""}`},Xc=(o,i)=>{let e=o.split(" "),t=i.split(" ").map(s=>s.toLowerCase());return e.filter(s=>!t.includes(s.toLowerCase())).join(" ")},me=o=>{if(!!o)return Xc(o.shortDescription||"",o.title||"")};var Zc=({vehicle:o,order:i,meta:e,cdnMedia:t})=>{let s=o?.imageUrls,n=o?.title,a=k(o?.price||NaN),l=i?.contactInformation?.name;return`
|
|
2
2
|
<div class="waykeecom-product-card">
|
|
3
3
|
${s?.length?`
|
|
4
4
|
<div class="waykeecom-product-card__media">
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
</div>
|
|
125
125
|
</div>
|
|
126
126
|
`:""}
|
|
127
|
-
`,s&&this.node.querySelector("button")?.addEventListener("click",()=>s())}},
|
|
127
|
+
`,s&&this.node.querySelector("button")?.addEventListener("click",()=>s())}},j=Rt;var bt=f("object-path"),rl=(o,i)=>o===i,cl=(o,i,e)=>{let t=e||rl,s=(0,bt.get)(o(),i);return n=>()=>{let a=(0,bt.get)(o(),i);if(!t(s,a)){let l=s;s=a,n(a,l,i)}}},wi=[],ll=o=>(wi.push(o),o),Si=()=>wi.forEach(o=>o()),dl=(o,i,e,t)=>{let s=cl(o.getState,i);if(t)o.subscribe(s(e));else return ll(o.subscribe(s(e)))},_=dl;var ml=(o,i)=>{let{title:e,active:t,completed:s,id:n}=i,a=document.getElementById(n),l=a||document.createElement("section");l.setAttribute("aria-label",e),a||l.setAttribute("id",n);let c=["waykeecom-stepper__item"];t?c.push("waykeecom-stepper__item--is-active"):s?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
|
-
`,p&&new F(this.node.querySelector(`#${h}`),{title:"L\xE4s mer",onClick:()=>p()}),new ee(this.node.querySelector(`#${y}`),{selected:m,onClick:()=>u()})}},ue=Ht;var
|
|
218
|
+
`,p&&new F(this.node.querySelector(`#${h}`),{title:"L\xE4s mer",onClick:()=>p()}),new ee(this.node.querySelector(`#${y}`),{selected:m,onClick:()=>u()})}},ue=Ht;var Q=()=>{O();let o=document.getElementById("wayke-ecom-modal-body");o&&o.firstElementChild.setAttribute("hidden","");let i=document.createElement("div");return i.className="waykeecom-portal",o?.appendChild(i),i},O=()=>{let o=document.getElementById("wayke-ecom-modal-body");o&&o.firstElementChild.removeAttribute("hidden"),o?.childNodes.forEach((i,e)=>{e>0&&i.remove()})};var Bt=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{title:e,id:t,onClick:s}=this.props;this.node.innerHTML=`
|
|
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="${Li}"></div>
|
|
296
296
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Oi}"></div>
|
|
297
297
|
</div>
|
|
298
|
-
`,new Di(this.node.querySelector(`#${Mi}`),{id:`gallery-${e.id}`,media:l.map((y,g)=>({url:y.url,alt:`Bild ${g+1}`})),onGalleryImagePaging:()=>this.onGalleryImagePaging()}),new re(this.node.querySelector(`#${bi}`),{title:"Tillbaka",onClick:()=>n()}),new te(this.node.querySelector(`#${Oi}`),{title:"Tillbaka",onClick:()=>n()}),new ee(this.node.querySelector(`#${Li}`),{selected:t,fullSize:!0,onClick:()=>s()}),V()}},xi=qt;var Wt=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.exposureTracked=!1;this.props=t,_(this.props.store,"accessories",(s,n)=>{s.some(a=>a.id===this.props.accessory.id)!==n.some(a=>a.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,n=e.getState().accessories.findIndex(a=>a.id===t.id)>-1;d("MAIN",n?"ACCESSORY_UNSELECTED":"ACCESSORY_SELECTED","ACCESSORY",{id:t.id,label:t.name}),pi(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:s}=this.props,a=e.getState().accessories.findIndex(l=>l.id===t.id)>-1;this.displayInfo&&new xi(
|
|
298
|
+
`,new Di(this.node.querySelector(`#${Mi}`),{id:`gallery-${e.id}`,media:l.map((y,g)=>({url:y.url,alt:`Bild ${g+1}`})),onGalleryImagePaging:()=>this.onGalleryImagePaging()}),new re(this.node.querySelector(`#${bi}`),{title:"Tillbaka",onClick:()=>n()}),new te(this.node.querySelector(`#${Oi}`),{title:"Tillbaka",onClick:()=>n()}),new ee(this.node.querySelector(`#${Li}`),{selected:t,fullSize:!0,onClick:()=>s()}),V()}},xi=qt;var Wt=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.exposureTracked=!1;this.props=t,_(this.props.store,"accessories",(s,n)=>{s.some(a=>a.id===this.props.accessory.id)!==n.some(a=>a.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,n=e.getState().accessories.findIndex(a=>a.id===t.id)>-1;d("MAIN",n?"ACCESSORY_UNSELECTED":"ACCESSORY_SELECTED","ACCESSORY",{id:t.id,label:t.name}),pi(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:s}=this.props,a=e.getState().accessories.findIndex(l=>l.id===t.id)>-1;this.displayInfo&&new xi(Q(),{accessory:t,selected:a,onClick:()=>{this.onInfoClose(),this.onClick()},onClose:()=>this.onInfoClose()}),new ue(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:a,onClick:()=>this.onClick(),onInfo:()=>this.onInfoOpen(),inViewPort:this.exposureTracked?void 0:()=>this.trackExposure()},s)}},Pi=Wt;var Yt=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{accessories:e,store:t}=this.props,s=new pe(this.node,{id:"accessories-list",onClick:()=>d("MAIN","ACCESSORY_ARROWS","ACCESSORY")}),{overflowElement:n}=s;n&&(n.innerHTML="",e.forEach((a,l)=>new Pi(n,{store:t,accessory:a,key:`accessory-${a.id}-${l}`})))}},$i=Yt;var Fi="button-accessories-proceed",Hi=`${Fi}-node`,vl="button-accessories-skip",Bi=`${vl}-node`,Ui="accessory-grid-list-node",Kt=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"),M("main",this.props.index)(this.props.store.dispatch)}render(){let{store:e,index:t}=this.props,s=e.getState(),n=s.topNavigation.stage>t,a=s.navigation.stage===t;a&&d("MAIN","ACCESSORY_ACTIVE","ACCESSORY");let l=x(this.node,{completed:n,title:"Tillbeh\xF6r",active:a,id:"accessories"}),c=document.createElement("div");if(s.navigation.stage>t||n&&s.navigation.stage!==t)new j(l,{keyValueList:s.accessories.length?s.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:s.createdOrderId?void 0:()=>this.onEdit()});else if(s.navigation.stage===t){let m=s.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="${Hi}"></div>
|
|
312
312
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Bi}"></div>
|
|
313
313
|
</div>
|
|
314
|
-
`,new $i(c.querySelector(`#${Ui}`),{store:e,accessories:m}),new w(c.querySelector(`#${Hi}`),{id:Fi,title:"G\xE5 vidare",onClick:()=>this.onProceed()}),new K(c.querySelector(`#${Bi}`),{title:"Hoppa \xF6ver detta steg",onClick:()=>this.onProceed()})}l.appendChild(c),s.navigation.stage===t&&l.parentElement?.scrollIntoView()}},Vi=Kt;var Gi="waykeecom-input-error",
|
|
314
|
+
`,new $i(c.querySelector(`#${Ui}`),{store:e,accessories:m}),new w(c.querySelector(`#${Hi}`),{id:Fi,title:"G\xE5 vidare",onClick:()=>this.onProceed()}),new K(c.querySelector(`#${Bi}`),{title:"Hoppa \xF6ver detta steg",onClick:()=>this.onProceed()})}l.appendChild(c),s.navigation.stage===t&&l.parentElement?.scrollIntoView()}},Vi=Kt;var Gi="waykeecom-input-error",Qt=class extends r{constructor(e,t){super(e);this.props=t,this.render()}setError(e){this.props.error=e,this.render()}render(){let{error:e,errorMessage:t}=this.props,s=this.node.querySelector(`.${Gi}`);if(s)e||s.remove();else if(e){let n=document.createElement("div");n.className=Gi,n.setAttribute("role","alert"),n.innerHTML=t,this.node.appendChild(n)}}},he=Qt;var jt=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{id:e,title:t,value:s,name:n,checked:a,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 p=this.node.querySelector(`#${e}`);p&&u&&p.addEventListener("click",u)}},Re=
|
|
335
|
+
`;let p=this.node.querySelector(`#${e}`);p&&u&&p.addEventListener("click",u)}},Re=jt;var qi="waykeecom-input-label__help",Wi="waykeecom-input-label__foldout",zt=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(`.${qi}`),s=this.node.querySelector(`.${Wi}`),n=t||document.createElement("div");if(t||(n.className=qi),this.open){n.innerHTML=`
|
|
336
336
|
<button class="waykeecom-input-label__help-btn" title="Vad betyder detta?">
|
|
337
337
|
<span class="waykeecom-sr-only">St\xE4ng hj\xE4lp</span>
|
|
338
338
|
<svg
|
|
@@ -381,7 +381,7 @@
|
|
|
381
381
|
${i}
|
|
382
382
|
</div>
|
|
383
383
|
</div>
|
|
384
|
-
`,I=El;var
|
|
384
|
+
`,I=El;var Qi="button-central-storage-proceed",Yi=`${Qi}-node`,Il="central-storage-branch",Ki=`${Il}-node`,Xt=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:s}=this.props.store.getState();try{this.contexts.proceedButton?.loading(!0);let n=await Be(t,e);d("MAIN","CENTRAL_STORAGE_SET","CENTRAL_STORAGE"),xe(Me(n),s),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 s=e.currentTarget.value;this.selectedDealer=s,this.contexts.proceedButton?.disabled(!1),d("MAIN","CENTRAL_STORAGE_SELECTED","CENTRAL_STORAGE")}onEdit(){d("MAIN","CENTRAL_STORAGE_EDIT","CENTRAL_STORAGE"),M("main",this.props.index)(this.props.store.dispatch)}onProceed(){this.selectedDealer&&this.updateOrder(this.selectedDealer)}render(){let{order:e,navigation:t,topNavigation:s,createdOrderId:n}=this.props.store.getState(),{index:a}=this.props,l=e?.dealerSites||[],c=s.stage>a,m=t.stage===a;m&&d("MAIN","CENTRAL_STORAGE_ACTIVE","CENTRAL_STORAGE");let u=x(this.node,{completed:c,active:m,title:"Centrallager",id:"central-storage"});if((t.stage>a||c&&t.stage!==a)&&this.selectedDealer){let p=l.find(h=>h.id===this.selectedDealer);new j(u,{keyValueList:[{key:"Val av anl\xE4ggning",value:p?.name||""}],changeButtonTitle:"\xC4ndra",onEdit:n?void 0:()=>this.onEdit()})}else if(t.stage===a){u.innerHTML=`
|
|
385
385
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
386
386
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vilken anl\xE4ggning vill du k\xF6pa ifr\xE5n?</h4>
|
|
387
387
|
<div class="waykeecom-content">
|
|
@@ -413,7 +413,7 @@
|
|
|
413
413
|
</div>
|
|
414
414
|
</div>
|
|
415
415
|
</div>
|
|
416
|
-
</div>`}});new z(u.querySelector(`#${Ki}`),{checked:this.selectedDealer,name:"dealer",options:p,onClick:h=>this.onChange(h)}),this.contexts.proceedButton=new w(u.querySelector(`#${Yi}`),{title:"G\xE5 vidare",id:
|
|
416
|
+
</div>`}});new z(u.querySelector(`#${Ki}`),{checked:this.selectedDealer,name:"dealer",options:p,onClick:h=>this.onChange(h)}),this.contexts.proceedButton=new w(u.querySelector(`#${Yi}`),{title:"G\xE5 vidare",id:Qi,disabled:!this.selectedDealer,onClick:()=>this.onProceed()})}t.stage===a&&u.parentElement?.scrollIntoView()}},ji=Xt;var oe=o=>o.length<2?o:o.length===2?`${o.substring(0,1)}***`:o.length===3?`${o.substring(0,2)}***`:`${o.substring(0,3)}***`,qe=o=>`${o.substring(0,o.length-4)}****`;var Zt=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t,this.render()}updateBorder(){let e=this.node.querySelector(".waykeecom-input-text");e&&(this.props.error?e?.classList.add("waykeecom-input-text--has-error"):e?.classList.remove("waykeecom-input-text--has-error"))}setError(e,t){this.props.error=e,t&&(this.props.errorMessage=t),this.updateBorder(),this.contexts.error?.setError(e)}render(){let{id:e,title:t,type:s,name:n,value:a,autocomplete:l,placeholder:c,unit:m,error:u,errorMessage:p,information:h,pattern:y,inputmode:g,onChange:S,onBlur:b,onClickInformation:H}=this.props;this.node.innerHTML=`
|
|
417
417
|
<div class="waykeecom-input-label">
|
|
418
418
|
<label for="${e}" class="waykeecom-input-label__label">${t}</label>
|
|
419
419
|
</div>
|
|
@@ -432,7 +432,7 @@
|
|
|
432
432
|
/>
|
|
433
433
|
${m?`<div class="waykeecom-input-text__unit">${m}</div>`:""}
|
|
434
434
|
</div>
|
|
435
|
-
`,this.updateBorder(),p&&(this.contexts.error=new he(this.node,{error:u,errorMessage:p})),h&&new se(this.node.querySelector(".waykeecom-input-label"),{information:h,onClickInformation:H});let Y=this.node.querySelector("input");Y&&(S&&Y.addEventListener("input",S),
|
|
435
|
+
`,this.updateBorder(),p&&(this.contexts.error=new he(this.node,{error:u,errorMessage:p})),h&&new se(this.node.querySelector(".waykeecom-input-label"),{information:h,onClickInformation:H});let Y=this.node.querySelector("input");Y&&(S&&Y.addEventListener("input",S),b&&Y.addEventListener("blur",b))}},U=Zt;var zi=/\S+@\S+\.\S+/,Ji=/^[0-9\-\+\(\)\ ]+$/,Xi=/^[0-9\ \-]+$/,Zi=/^(19|20)(\d{6}(-|\s)\d{4}|(?!19|20)\d{10})$/,en=/[a-zA-Z]{3}\d{2}(d||[a-zA-Z]){1}/,We=/\D/g;var D={requiredEmail:o=>zi.test(o),requiredTelephone:o=>Ji.test(o),requiredSsn:o=>Zi.test(o),requiredSsnOver18:o=>{if(D.requiredSsn(o)){let e=o.replace(We,"").slice(0,8),t=`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`;return new Date(new Date().valueOf()-new Date(t).valueOf()).getFullYear()-1970>17}return!1},requiredZip:o=>Xi.test(o),requiredNumberOrStringNumberInRange:(o,i,e)=>{let t=parseInt(o.toString(),10);return isNaN(t)?!1:t>=i&&t<=e},requiredNumber:o=>{let i=parseInt(o.toString(),10);return!isNaN(i)},requiredRegistrationNumber:o=>{if(!o)return!1;let i=o.replace(" ",""),e=i.length===6,t=en.test(i);return e&&t},requiredMileage:o=>D.requiredNumberOrStringNumberInRange(o||"",0,8e4),optionalString:o=>!!o||!o,requiredCondition:o=>["VeryGood","Good","Ok"].includes(o||""),requiredAssessmentMaritalStatus:o=>["married","single"].includes(o||""),requiredAssessmentEmplyment:o=>["other","retired","fullTimeEmployed","student","temporarilyEmployed","selfEmployed"].includes(o||"")};var tn="contact-email-node",fl="contact-email",sn="contact-phone-node",_l="contact-phone",on="contact-proceed-node",gl="contact-proceed",Ye={email:D.requiredEmail,phone:D.requiredTelephone},wl=o=>{let i={email:o?.email||"",phone:o?.phone||""};return{value:i,validation:{email:Ye.email(i.email),phone:Ye.phone(i.phone)},interact:{email:!1,phone:!1}}},es=class extends r{constructor(e,t){super(e,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--2"});this.contexts={};this.props=t;let s=this.props.store.getState();this.state=wl(s.customer),this.render()}onChange(e){let t=e.currentTarget,s=t.name,n=t.value;this.state.value[s]=n,this.state.validation[s]=Ye[s](n),this.updateUiError(s),this.updateProceedButton()}onBlur(e){let s=e.currentTarget.name;this.state.interact[s]=!0,this.state.validation[s]=Ye[s](this.state.value[s]),this.updateUiError(s),this.updateProceedButton()}updateUiError(e){this.contexts[e]?.setError(this.state.interact[e]&&!this.state.validation[e])}updateProceedButton(){this.contexts.button?.disabled(!this.state.validation.email||!this.state.validation.phone)}onProceed(){d("MAIN","CUSTOMER_EMAIL_AND_PHONE_SET","CUSTOMER_EMAIL_AND_PHONE"),si({email:this.state.value.email.trim(),phone:this.state.value.phone.trim()})(this.props.store.dispatch)}render(){if(this.props.store.getState().navigation.subStage>1){let t=[{key:"E-post",value:this.state.value.email},{key:"Telefonnummer",value:this.state.value.phone}];this.node.innerHTML=`
|
|
436
436
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
437
437
|
<ul class="waykeecom-key-value-list">
|
|
438
438
|
${t.map(s=>E(s)).join("")}
|
|
@@ -504,7 +504,7 @@
|
|
|
504
504
|
${n.map(a=>E(a)).join("")}
|
|
505
505
|
</ul>
|
|
506
506
|
</div>
|
|
507
|
-
`}else this.node.innerHTML="",new dn(this.node,{store:e,lastStage:t})}},mn=as;var rs=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"),M("main",this.props.index)(this.props.store.dispatch)}render(){let{store:e,index:t,lastStage:s}=this.props,n=this.props.store.getState(),a=n.topNavigation.stage>t,l=n.navigation.stage===t&&!n.createdOrderId;l&&d("MAIN","CUSTOMER_ACTIVE",n.navigation.subStage===1?"CUSTOMER_EMAIL_AND_PHONE":"CUSTOMER_ADDRESS");let c=x(this.node,{completed:a,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",n.navigation.stage>t||a&&n.navigation.stage!==t){let p=[{key:"E-post",value:n.customer.email},{key:"Telefonnummer",value:n.customer.phone},{key:"Personnummer",value:qe(n.customer.socialId)},...n.address?[{key:"Namn",value:`${oe(n.address.givenName)} ${oe(n.address.surname)}`},{key:"Adress",value:n.address.street},{key:"Postnummer",value:n.address.postalCode},{key:"Stad",value:n.address.city}]:[]];new
|
|
507
|
+
`}else this.node.innerHTML="",new dn(this.node,{store:e,lastStage:t})}},mn=as;var rs=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"),M("main",this.props.index)(this.props.store.dispatch)}render(){let{store:e,index:t,lastStage:s}=this.props,n=this.props.store.getState(),a=n.topNavigation.stage>t,l=n.navigation.stage===t&&!n.createdOrderId;l&&d("MAIN","CUSTOMER_ACTIVE",n.navigation.subStage===1?"CUSTOMER_EMAIL_AND_PHONE":"CUSTOMER_ADDRESS");let c=x(this.node,{completed:a,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",n.navigation.stage>t||a&&n.navigation.stage!==t){let p=[{key:"E-post",value:n.customer.email},{key:"Telefonnummer",value:n.customer.phone},{key:"Personnummer",value:qe(n.customer.socialId)},...n.address?[{key:"Namn",value:`${oe(n.address.givenName)} ${oe(n.address.surname)}`},{key:"Adress",value:n.address.street},{key:"Postnummer",value:n.address.postalCode},{key:"Stad",value:n.address.city}]:[]];new j(c,{keyValueList:p,changeButtonTitle:"\xC4ndra dina uppgifter",onEdit:n.createdOrderId?void 0:()=>this.onChange()})}else n.navigation.stage===t&&(new nn(c,{store:e}),n.navigation.subStage>1&&new mn(c,{store:e,lastStage:s}));n.navigation.stage===t&&c.parentElement?.scrollIntoView()}},pn=rs;var cs=f("@wayke-se/ecom");var Tl=(o,i)=>{if(!!o)return o.unit==="m"&&i.unit==="km"?Math.round(o.value/1e3):o.unit==="km"&&i.unit==="m"?o.value*1e3:o.value},un=(o,i)=>{let e=Tl(o,i);if(!!e&&!!i.unitPrice)return i.startupCost+i.unitPrice*e};var vn="radio-home-delivery-true",hn=`${vn}-node`,En="radio-home-delivery-false",kn=`${En}-node`,In="button-home-delivery-proceed",yn=`${In}-node`,ls=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation",()=>{this.render()});let s=this.props.store.getState();this.homeDelivery=s.homeDelivery,this.render()}onChange(e){let s=e.currentTarget.value==="true";this.homeDelivery=s,d("MAIN",this.homeDelivery?"DELIVERY_HOME_SELECTED":"DELIVERY_DEALER_SELECTED","DELIVERY")}onProceed(){ii(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"),M("main",this.props.index)(this.props.store.dispatch)}render(){let{store:e,index:t}=this.props,s=e.getState();if(!s.order)throw"Missing order...";let n=s.order.contactInformation;if(!n)throw"Missing dealer contact information";let a=s.topNavigation.stage>t,l=s.navigation.stage===t;l&&d("MAIN","DELIVERY_ACTIVE","DELIVERY");let c=x(this.node,{completed:a,title:"Leverans",active:l,id:"delivery"});if(s.navigation.stage>t||a&&s.navigation.stage!==t)new j(c,{keyValueList:[{key:"Leveranss\xE4tt",value:s.homeDelivery?"Hemleverans":"H\xE4mta hos handlaren"}],changeButtonTitle:"\xC4ndra leveranss\xE4tt",onEdit:s.createdOrderId?void 0:()=>this.onEdit()});else if(s.navigation.stage===t){let m=document.createElement("div");m.innerHTML=`
|
|
508
508
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
509
509
|
<h4 class="waykeecom-heading waykeecom-heading--4">Hur vill du ha din bil levererad?</h4>
|
|
510
510
|
<div class="waykeecom-content">
|
|
@@ -542,9 +542,9 @@
|
|
|
542
542
|
</div>
|
|
543
543
|
</div>
|
|
544
544
|
</div>
|
|
545
|
-
`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${y===0?"Gratis":k(y,{postfix:"kr"})}</div>`,checked:!this.homeDelivery,onClick:H=>this.onChange(H)});break;case cs.DeliveryType.Delivery:let g=s.address?.distance?.value||0,S=p.unitPrice||0,
|
|
545
|
+
`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${y===0?"Gratis":k(y,{postfix:"kr"})}</div>`,checked:!this.homeDelivery,onClick:H=>this.onChange(H)});break;case cs.DeliveryType.Delivery:let g=s.address?.distance?.value||0,S=p.unitPrice||0,b=g>S;new Re(m.querySelector(`#${hn}`),{id:En,name:"homeDelivery",title:"Hemleverans",value:"true",disabled:b,description:`<div class="waykeecom-box">
|
|
546
546
|
<div class="waykeecom-stack waykeecom-stack--2">Till din folkbokf\xF6ringsadress</div>
|
|
547
|
-
${
|
|
547
|
+
${b?`<div class="waykeecom-stack waykeecom-stack--2">${I({tone:"info",children:"Tyv\xE4rr kan vi inte erbjuda hemleverans till din adress."})}</div>`:""}</div>`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${b?"-":k(y,{postfix:"kr"})}</div>`,checked:this.homeDelivery,onClick:H=>this.onChange(H)});break;default:break}}),new w(m.querySelector(`#${yn}`),{title:"G\xE5 vidare",id:In,onClick:()=>this.onProceed()}),c.appendChild(m),s.navigation.stage===t&&c.parentElement?.scrollIntoView()}}},fn=ls;var P=f("@wayke-se/ecom");var ye=f("@wayke-se/ecom");var ve={bankid:"https://cdn.wayke.se/public-assets/bankid-logo.svg",illustrations:{payment:"https://cdn.wayke.se/public-assets/payment.svg"}},Ee={["VeryGood"]:"Mycket bra",["Good"]:"Bra",["Ok"]:"Ok"},J={[ye.DrivingDistance.Between0And1000]:"0\u20131000 mil",[ye.DrivingDistance.Between1000And1500]:"1000\u20131500 mil",[ye.DrivingDistance.Between1500And2000]:"1500\u20132000 mil",[ye.DrivingDistance.Between2000And2500]:"2000\u20132500 mil",[ye.DrivingDistance.Over2500]:"2500+ mil"};var Dl=(o,i)=>i?Math.round(o/i)*i:o,ds=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t,this.value=t.value,this.min=t.min,this.max=t.max,this.isDisabled=t.disabled,this.inputFieldValue=this.value,this.rangeSpan=this.max-this.min,this.currentValueInPercentage=parseInt((100*((this.value-this.min)/this.rangeSpan)).toString(),10),this.render()}update(e,t,s){this.value=e,this.inputFieldValue=e,this.min=t,this.max=s,this.rangeSpan=s-t,this.isDisabled=!this.rangeSpan;let n=parseInt((100*((this.value-t)/this.rangeSpan)).toString(),10);this.currentValueInPercentage=isNaN(n)?0:n,this.render()}disabled(e){this.isDisabled!==e&&(this.isDisabled=e,this.render())}onOpenInformation(){let e=this.node.querySelector(".input-label__foldout");e&&(e.style.display="")}onChange(e){let t=e.currentTarget;this.inputFieldValue=t.valueAsNumber}onBlur(e){let t=this.inputFieldValue;if(!isNaN(t)&&t>=this.min&&t<=this.max){let s=Dl(t,this.props.step);this.value=s,this.props.onChange&&e.currentTarget&&(e.currentTarget.value=s.toString(),this.props.onChange(e)),this.inputFieldValue=this.value,this.currentValueInPercentage=parseInt((100*((this.value-this.min)/this.rangeSpan)).toString(),10),this.render()}else this.inputFieldValue=this.value,this.updateInputField()}onFocus(e){let t=e.currentTarget;t.value=this.value.toString()}onInput(e){let t=e.currentTarget;this.value=parseInt(t.value,10),this.inputFieldValue=this.value,this.currentValueInPercentage=parseInt((100*((this.value-this.min)/this.rangeSpan)).toString(),10),this.updateInputField(),this.updateRangeSliderColor(t)}updateRangeSliderColor(e){let t=e||this.node.querySelector(`#${this.props.id}`);t&&t.style.setProperty("--percentage",`${this.currentValueInPercentage}%`)}updateInputField(){let e=this.node.querySelector(`#${this.props.id}-input`);e&&(e.value=this.inputFieldValue.toString())}render(){let{title:e,step:t,name:s,id:n,information:a,unit:l,onChange:c,onClickInformation:m}=this.props,u=this.min!==this.max;if(this.node.innerHTML=`
|
|
548
548
|
<div class="waykeecom-input-label">
|
|
549
549
|
<label for="${n}" class="waykeecom-input-label__label">${e}</label>
|
|
550
550
|
</div>
|
|
@@ -585,7 +585,7 @@
|
|
|
585
585
|
</div>
|
|
586
586
|
`:""}
|
|
587
587
|
</div>
|
|
588
|
-
`,a&&new se(this.node.querySelector(".waykeecom-input-label"),{information:a,onClickInformation:m}),u){this.contexts.rangeSlider=this.node.querySelector(`#${n}`)||void 0,this.contexts.rangeSlider&&(c&&this.contexts.rangeSlider.addEventListener("change",c),this.contexts.rangeSlider.addEventListener("input",h=>this.onInput(h)),this.updateRangeSliderColor(this.contexts.rangeSlider));let p=this.node.querySelector(`#${n}-input`);p&&(p.addEventListener("change",h=>this.onChange(h)),p.addEventListener("blur",h=>this.onBlur(h)))}}},
|
|
588
|
+
`,a&&new se(this.node.querySelector(".waykeecom-input-label"),{information:a,onClickInformation:m}),u){this.contexts.rangeSlider=this.node.querySelector(`#${n}`)||void 0,this.contexts.rangeSlider&&(c&&this.contexts.rangeSlider.addEventListener("change",c),this.contexts.rangeSlider.addEventListener("input",h=>this.onInput(h)),this.updateRangeSliderColor(this.contexts.rangeSlider));let p=this.node.querySelector(`#${n}-input`);p&&(p.addEventListener("change",h=>this.onChange(h)),p.addEventListener("blur",h=>this.onBlur(h)))}}},Qe=ds;var ms=f("@wayke-se/ecom"),_n=({vehicleId:o,dealerId:i,downPayment:e,duration:t,residual:s})=>{let n=ms.payments.newLookupRequest().forVehicle(o).withDownPayment(e).withDuration(t);return s!==void 0&&n.withResidualValue(s),i!==void 0&&n.forDealer(i),ms.payments.lookupPayment(n.build())};var R=f("@wayke-se/ecom");var ps=class extends r{constructor(e,t){super(e,t.append?{htmlTag:"div",className:"waykeecom-accordion"}:void 0);this.props=t,this.render()}render(){let{title:e,description:t,onClick:s}=this.props,n=`
|
|
589
589
|
<input
|
|
590
590
|
type="checkbox"
|
|
591
591
|
id="${this.props.id}"
|
|
@@ -608,7 +608,7 @@
|
|
|
608
608
|
<div class="waykeecom-accordion__body">${t}</div>
|
|
609
609
|
`;this.props.append&&(this.node.innerHTML=n),this.node.innerHTML=`
|
|
610
610
|
${n}
|
|
611
|
-
`,s&&this.node.querySelector("input")?.addEventListener("click",()=>s())}},
|
|
611
|
+
`,s&&this.node.querySelector("input")?.addEventListener("click",()=>s())}},je=ps;var G=f("@wayke-se/ecom");var Ie=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);var us=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=`
|
|
612
612
|
${e?`
|
|
613
613
|
<div class="waykeecom-stack waykeecom-stack--4">
|
|
614
614
|
<div class="waykeecom-align waykeecom-align--center">
|
|
@@ -663,7 +663,7 @@
|
|
|
663
663
|
<div class="waykeecom-stack waykeecom-stack--2" id="${Nn}"></div>
|
|
664
664
|
</div>
|
|
665
665
|
</div>
|
|
666
|
-
`,!p){s===G.AuthMethod.SameDevice?new wn(this.node.querySelector(`#${ys}`),{autoLaunchUrl:t,errorMessage:n,onClick:()=>this.props?.onSameDeviceClick?.()}):s===G.AuthMethod.QrCode&&new gn(this.node.querySelector(`#${ys}`),{qrCode:e,errorMessage:n});let
|
|
666
|
+
`,!p){s===G.AuthMethod.SameDevice?new wn(this.node.querySelector(`#${ys}`),{autoLaunchUrl:t,errorMessage:n,onClick:()=>this.props?.onSameDeviceClick?.()}):s===G.AuthMethod.QrCode&&new gn(this.node.querySelector(`#${ys}`),{qrCode:e,errorMessage:n});let b=s===G.AuthMethod.SameDevice?"Mitt BankID \xE4r p\xE5 en annan enhet":"\xD6ppna BankID p\xE5 den h\xE4r enheten";new F(this.node.querySelector(`#${Sn}`),{title:b,id:Rl,onClick:()=>h(s===G.AuthMethod.SameDevice?G.AuthMethod.QrCode:G.AuthMethod.SameDevice)})}new F(this.node.querySelector(`#${Nn}`),{title:"Avbryt",id:An,onClick:()=>y()})}},ze=vs;var Es=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){this.node.innerHTML=`
|
|
667
667
|
<div class="waykeecom-disclaimer">
|
|
668
668
|
<div class="waykeecom-disclaimer__text">
|
|
669
669
|
${this.props.text}
|
|
@@ -718,10 +718,10 @@
|
|
|
718
718
|
${C({type:"inline"})}
|
|
719
719
|
</span>`:""}
|
|
720
720
|
</button>
|
|
721
|
-
`,a&&this.node.querySelector("button")?.addEventListener("click",a)}},Je=gs;var Ll="assessment-rejected-result",
|
|
722
|
-
<div class="waykeecom-stack waykeecom-stack--4" id="${jn}"></div>
|
|
721
|
+
`,a&&this.node.querySelector("button")?.addEventListener("click",a)}},Je=gs;var Ll="assessment-rejected-result",Qn=`${Ll}-node`,Jn="assessment-rejected-abort",jn=`${Jn}-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
722
|
<div class="waykeecom-stack waykeecom-stack--4" id="${Qn}"></div>
|
|
724
|
-
|
|
723
|
+
<div class="waykeecom-stack waykeecom-stack--4" id="${jn}"></div>
|
|
724
|
+
`,new ie(this.node.querySelector(`#${Qn}`),{store:e,decision:zn.CreditAssessmentRecommendation.Reject}),new Je(this.node.querySelector(`#${jn}`),{title:"G\xE5 tillbaka",id:Jn,onClick:()=>t()})}},Xn=ws;var Ns=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,creditAssessmentResponse:t,onProceed:s,onGoBack:n}=this.props,a=t.recommendation;a===Ss.CreditAssessmentRecommendation.Approve?new Un(this.node,{store:e,onProceed:()=>s(),onGoBack:()=>n()}):a===Ss.CreditAssessmentRecommendation.AssessManually?new Kn(this.node,{store:e,onProceed:()=>s(),onGoBack:()=>n()}):new Xn(this.node,{store:e,onGoBack:()=>n()})}},Zn=Ns;var Ml=o=>{let i=o>0,e=o%12===0;if(!i||!e)throw new TypeError("Invalid months for creating creidt assessment term");return`${o}months`},ea=Ml;var Xe={},Le=(o,i)=>{Xe[o]=i},As=()=>{Object.keys(Xe).forEach(o=>{clearInterval(Xe[o]),delete Xe[o]})};var xl="credit-assessment-martial-status",ta=`${xl}-node`,Ds="credit-assessment-income",Ts=`${Ds}-node`,Pl="credit-assessment-employment",sa=`${Pl}-node`,da="credit-assessment-household-children",oa=`${da}-node`,ma="credit-assessment-household-income",ia=`${ma}-node`,pa="credit-assessment-household-housing-cost",na=`${pa}-node`,ua="credit-assessment-household-debt",aa=`${ua}-node`,ha="credit-assessment-perform-application",Cs=`${ha}-node`,ra="disclaimer-node",ca="disclaimer-safe-node",la="why-description-node",X={maritalStatus:D.requiredAssessmentMaritalStatus,income:D.requiredNumber,employment:D.requiredAssessmentEmplyment,householdChildren:D.requiredNumber,householdIncome:D.requiredNumber,householdHousingCost:D.requiredNumber,householdDebt:D.requiredNumber},$l={maritalStatus:R.MaritalStatus.Married,income:5e4,employment:R.Employment.FullTimeEmployed,householdChildren:0,householdDebt:0,householdHousingCost:2e3,householdIncome:1e5},Hl=()=>location.hostname==="localhost"?{...$l}:void 0,Bl=o=>{let i={maritalStatus:o?.maritalStatus||"",income:o?.income.toString()||"",employment:o?.employment.toString()||"",householdChildren:o?.householdChildren.toString()||"",householdIncome:o?.householdIncome.toString()||"",householdHousingCost:o?.householdHousingCost.toString()||"",householdDebt:o?.householdDebt.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),householdIncome:X.householdIncome(i.householdIncome),householdHousingCost:X.householdHousingCost(i.householdHousingCost),householdDebt:X.householdDebt(i.householdDebt)},interact:{maritalStatus:!1,income:!1,employment:!1,householdChildren:!1,householdIncome:!1,householdHousingCost:!1,householdDebt:!1}}},Rs=class extends r{constructor(e,t){super(e);this.view=1;this.contexts={};this.bankidError=!1;this.signed=!1;this.props=t,this.state=Bl(Hl()),this.render()}onChange(e){let t=e.currentTarget,s=t.name,n=t.value;this.state.value[s]=n,this.state.validation[s]=X[s](n),this.updateUiError(s),this.updateProceedButton()}onBlur(e){let s=e.currentTarget.name;this.state.interact[s]=!0,this.state.validation[s]=X[s](this.state.value[s]),this.updateUiError(s),this.updateProceedButton()}onChangeRadio(e){let t=e.currentTarget,s=t.name,n=t.value;this.state.value[s]=n,this.state.validation[s]=X[s](n),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.householdIncome||!this.state.validation.householdHousingCost||!this.state.validation.householdDebt)}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&&(be(t),de()(e.dispatch)),O(),this.creditAssessmentResponse=void 0,this.render(!0)}bankIdStatus(e,t,s=!1){s||d("MAIN",t===R.AuthMethod.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_REQUESTED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_REQUESTED","FINANCIAL_CREDIT_SCORING");let n=this.props.store.getState().order?.paymentOptions.find(a=>a.type===R.PaymentType.Loan);this.bankidStatusInterval=setInterval(async()=>{try{let a=await Dn(e),l=a.getStatus();if(!this.signed&&l==="signed"&&(d("MAIN",t===R.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 ${n?.name}...`),this.contexts.bankId?.setDescription(`H\xE4mtar uppgifter fr\xE5n ${n?.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")),a.isScored()?(d("MAIN","FINANCIAL_CREDIT_SCORING_SIGNING_SCORED","FINANCIAL_CREDIT_SCORING"),this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.view=3,this.creditAssessmentResponse=Xo(a),de(e,this.creditAssessmentResponse)(this.props.store.dispatch),O(),this.render()):a.hasScoringError()&&(clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Ett fel uppstod")),!this.signed&&t===R.AuthMethod.QrCode){let c=a.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),Le("bankidStatusInterval-credit",this.bankidStatusInterval)}async onStartBankIdAuth(e,t=!1){let s=this.props.store.getState().caseId;if(!s)throw"Missing caseID";this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval);try{t||d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_REQUESTED","FINANCIAL_CREDIT_SCORING"),this.contexts.bankId?.update(e);let n=await Ln({caseId:s,method:e});if(t||d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.bankIdStatus(s,e,t),e===R.AuthMethod.SameDevice){let a=n.getAutoLaunchUrl();this.contexts.bankId?.update(e,a)}else{let a=n.getQrCode();this.contexts.bankId?.update(e,a)}}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 s=t.getState().caseId;if(this.bankidStatusInterval&&(clearInterval(this.bankidStatusInterval),s&&(await be(s),de()(t.dispatch))),s)de(s)(t.dispatch),this.onStartBankIdAuth(e);else try{d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_REQUESTED","FINANCIAL_CREDIT_SCORING");let n=await this.newCreditAssessmentCase();d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),n&&(de(n)(t.dispatch),this.onStartBankIdAuth(e))}catch{d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_FAILED","FINANCIAL_CREDIT_SCORING")}}async newCreditAssessmentCase(){try{let{store:e,loan:t,paymentLookupResponse:s}=this.props;this.contexts.performApplicationButton?.disabled(!0);let{customer:n}=e.getState(),{monthlyCost:a}=s.costs,{interest:l}=s.interests,c=s.downPaymentSpec.current,m=s.durationSpec.current,u=s.creditAmount,p=s.price,h=s.financialProductCode,y={customer:{...n},householdEconomy:this.state.value,externalId:t.externalId,loan:{downPayment:c,interestRate:l,credit:u,financialProductId:h,monthlyCost:a,price:p,term:ea(m)}};return(await bn(y)).caseId}catch(e){this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.caseError=e?.message||"",this.view=1,this.render(!0);return}finally{this.contexts.performApplicationButton?.disabled(!1)}}render(e){let{store:t,paymentLookupResponse:s,onProceed:n}=this.props,a=Ie(),{order:l}=t.getState(),c=l?.paymentOptions.find(p=>p.type===R.PaymentType.Loan),m=s.creditAmount,u=l?.contactInformation?.name;this.view===3&&this.creditAssessmentResponse?new Zn(Q(),{store:t,creditAssessmentResponse:this.creditAssessmentResponse,onProceed:()=>{O(),n()},onGoBack:()=>this.onAbort()}):this.view===2?(this.contexts.bankId=new ze(Q(),{method:a?R.AuthMethod.SameDevice:R.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:p=>this.startBankId(p)}),V()):(this.node.innerHTML=`
|
|
725
725
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
726
726
|
<h5 class="waykeecom-heading waykeecom-heading--4">L\xE5neans\xF6kan</h5>
|
|
727
727
|
<div class="waykeecom-content">
|
|
@@ -788,7 +788,7 @@
|
|
|
788
788
|
<div class="waykeecom-stack waykeecom-stack--1" id="${ca}"></div>
|
|
789
789
|
</div>
|
|
790
790
|
</div>
|
|
791
|
-
`,this.contexts.maritalStatus=new z(this.node.querySelector(`#${ta}`),{title:"Civilst\xE5nd",checked:this.state.value.maritalStatus,name:"maritalStatus",options:[{id:`maritalStatus-${1}`,value:
|
|
791
|
+
`,this.contexts.maritalStatus=new z(this.node.querySelector(`#${ta}`),{title:"Civilst\xE5nd",checked:this.state.value.maritalStatus,name:"maritalStatus",options:[{id:`maritalStatus-${1}`,value:R.MaritalStatus.Married,title:"Gift eller sambo"},{id:`maritalStatus-${2}`,value:R.MaritalStatus.Single,title:"Ensamst\xE5ende"}],onClick:p=>this.onChangeRadio(p)}),this.contexts.income=new U(this.node.querySelector(`#${Ts}`),{title:"Inkomst per m\xE5nad f\xF6re skatt",value:this.state.value.income,id:Ds,error:this.state.interact.income&&!this.state.validation.income,errorMessage:"Ange din inkomst per \xE5r f\xF6re skatt",name:"income",autocomplete:"off",unit:"kr",placeholder:"",type:"number",onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p)}),this.contexts.employment=new z(this.node.querySelector(`#${sa}`),{title:"Syssels\xE4ttning",checked:this.state.value.employment,name:"employment",options:[{id:`employment-${1}`,value:R.Employment.FullTimeEmployed,title:"Fast- eller tillsvidareanst\xE4lld"},{id:`employment-${2}`,value:R.Employment.TemporarilyEmployed,title:"Visstidsanst\xE4lld"},{id:`employment-${3}`,value:R.Employment.SelfEmployed,title:"Egen f\xF6retagare"},{id:`employment-${4}`,value:R.Employment.Retired,title:"Pension\xE4r"},{id:`employment-${5}`,value:R.Employment.Student,title:"Student"},{id:`employment-${6}`,value:R.Employment.Other,title:"Annan"}],onClick:p=>this.onChangeRadio(p)}),this.contexts.income=new U(this.node.querySelector(`#${Ts}`),{title:"Inkomst per m\xE5nad f\xF6re skatt",value:this.state.value.income,id:Ds,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",onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p)}),this.contexts.householdChildren=new U(this.node.querySelector(`#${oa}`),{title:"Antal hemmavarande barn",value:this.state.value.householdChildren,id:da,error:this.state.interact.householdChildren&&!this.state.validation.householdChildren,errorMessage:"Ange antal hemmavarande barn",name:"householdChildren",autocomplete:"off",placeholder:"",type:"number",information:`
|
|
792
792
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
793
793
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Hur m\xE5nga barn f\xF6rs\xF6rjer du?</span></p>
|
|
794
794
|
<p class="waykeecom-content__p">Fyll i antal barn som f\xE5r barn- eller studiebidrag och som du f\xF6rs\xF6rjer. Barn som bor hemma och arbetar och kan f\xF6rs\xF6rja sig sj\xE4lva beh\xF6ver inte r\xE4knas med.</p>
|
|
@@ -828,7 +828,7 @@
|
|
|
828
828
|
<li class="waykeecom-content__li">Kortkredit</li>
|
|
829
829
|
</ul>
|
|
830
830
|
</div>
|
|
831
|
-
`,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p),onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_HOUSEHOLD_COST_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts.performApplicationButton=new fe(this.node.querySelector(`#${Cs}`),{title:"Genomf\xF6r l\xE5neans\xF6kan",id:ha,disabled:!(this.state.validation.maritalStatus&&this.state.validation.income&&this.state.validation.employment&&this.state.validation.householdChildren&&this.state.validation.householdIncome&&this.state.validation.householdHousingCost&&this.state.validation.householdDebt),onClick:()=>{this.view=2,this.render()}}),new _e(this.node.querySelector(`#${ra}`),{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(`#${ca}`),{text:"Dina uppgifter lagras och sparas s\xE4kert."}),new
|
|
831
|
+
`,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p),onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_HOUSEHOLD_COST_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts.performApplicationButton=new fe(this.node.querySelector(`#${Cs}`),{title:"Genomf\xF6r l\xE5neans\xF6kan",id:ha,disabled:!(this.state.validation.maritalStatus&&this.state.validation.income&&this.state.validation.employment&&this.state.validation.householdChildren&&this.state.validation.householdIncome&&this.state.validation.householdHousingCost&&this.state.validation.householdDebt),onClick:()=>{this.view=2,this.render()}}),new _e(this.node.querySelector(`#${ra}`),{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(`#${ca}`),{text:"Dina uppgifter lagras och sparas s\xE4kert."}),new je(this.node.querySelector(`#${la}`),{id:"accordion-why-description",title:`
|
|
832
832
|
<div class="waykeecom-hstack waykeecom-hstack--align-center waykeecom-hstack--spacing-1">
|
|
833
833
|
<div class="waykeecom-hstack__item waykeecom-hstack__item--no-shrink" aria-hidden="true">
|
|
834
834
|
<div class="waykeecom-icon-backdrop waykeecom-icon-backdrop--info-alt">
|
|
@@ -950,7 +950,7 @@
|
|
|
950
950
|
<ul class="waykeecom-key-value-list waykeecom-key-value-list--large-value">
|
|
951
951
|
${E({key:"M\xE5nadskostnad f\xF6r l\xE5net",value:k(e,{postfix:"kr/m\xE5n*"})})}
|
|
952
952
|
</ul>
|
|
953
|
-
`}},fa=Ms;var _a="finance-details-monthly-cost",ga="finance-details-pie-chart-node",wa="finance-details-basic",Sa="finance-details-detailed",xs=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t,this.render()}extractProps(){let{loan:e,paymentLookupResponse:t}=this.props,{monthlyCost:s,totalCreditCost:n}=t.costs,{interest:a,effectiveInterest:l}=t.interests,c=t.downPaymentSpec.current,m=t.durationSpec.current,{administrationFee:u,setupFee:p}=t.fees,h=t.creditAmount,y=t.publicURL,g=c+h,S=Math.round(c/g*100),
|
|
953
|
+
`}},fa=Ms;var _a="finance-details-monthly-cost",ga="finance-details-pie-chart-node",wa="finance-details-basic",Sa="finance-details-detailed",xs=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t,this.render()}extractProps(){let{loan:e,paymentLookupResponse:t}=this.props,{monthlyCost:s,totalCreditCost:n}=t.costs,{interest:a,effectiveInterest:l}=t.interests,c=t.downPaymentSpec.current,m=t.durationSpec.current,{administrationFee:u,setupFee:p}=t.fees,h=t.creditAmount,y=t.publicURL,g=c+h,S=Math.round(c/g*100),b=Math.round(h/g*100);return{duration:m,downPayment:c,administrationFee:u,setupFee:p,totalCreditCost:n,interest:a,effectiveInterest:l,creditAmount:h,total:g,publicUrl:y,monthlyCost:s,loanOrgName:e.name,loanOrgLogo:e.logo,downPaymentPercentage:S,creditAmountPercentage:b}}update(e){this.props=e;let{duration:t,downPayment:s,administrationFee:n,setupFee:a,monthlyCost:l,totalCreditCost:c,interest:m,effectiveInterest:u,creditAmount:p,publicUrl:h,loanOrgName:y,downPaymentPercentage:g,creditAmountPercentage:S}=this.extractProps();this.contexts.loanDetailsMontlyCost?.update({monthlyCost:l}),this.contexts.pieChart?.update({percentage:S}),this.contexts.loanDetailsBasic?.update({downPayment:s,creditAmount:p,downPaymentPercentage:g,creditAmountPercentage:S}),this.contexts.loanDetailsDetailed?.update({duration:t,administrationFee:n,setupFee:a,totalCreditCost:c,interest:m,effectiveInterest:u,publicUrl:h,loanOrgName:y})}render(){let{duration:e,downPayment:t,administrationFee:s,setupFee:n,totalCreditCost:a,interest:l,effectiveInterest:c,creditAmount:m,publicUrl:u,loanOrgName:p,loanOrgLogo:h,monthlyCost:y,downPaymentPercentage:g,creditAmountPercentage:S}=this.extractProps(),b=`*Ber\xE4knat p\xE5 ${k(l*100,{decimals:2})} % r\xE4nta (effektivt ${k(c*100,{decimals:2})} %). Den r\xE4nta du f\xE5r s\xE4tts vid avtalskrivning.`;this.node.innerHTML=`
|
|
954
954
|
<div class="waykeecom-stepper__break">
|
|
955
955
|
<div class="waykeecom-shadow-box">
|
|
956
956
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
@@ -964,7 +964,7 @@
|
|
|
964
964
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
965
965
|
<div class="waykeecom-stack waykeecom-stack--1" id="${_a}"></div>
|
|
966
966
|
<div class="waykeecom-stack waykeecom-stack--1">
|
|
967
|
-
<div class="waykeecom-disclaimer-text">${
|
|
967
|
+
<div class="waykeecom-disclaimer-text">${b}</div>
|
|
968
968
|
</div>
|
|
969
969
|
</div>
|
|
970
970
|
<div class="waykeecom-stack waykeecom-stack--3" id="${ga}"></div>
|
|
@@ -999,13 +999,13 @@
|
|
|
999
999
|
${l?`
|
|
1000
1000
|
<div class="waykeecom-stack waykeecom-stack--3" id="${ba}"></div>
|
|
1001
1001
|
`:`<div class="waykeecom-stack waykeecom-stack--3" id="${Oa}"></div>`}
|
|
1002
|
-
`,this.contexts.downPayment=new
|
|
1002
|
+
`,this.contexts.downPayment=new Qe(this.node.querySelector(`#${Ta}`),{title:"Kontantinsats",value:this.paymentState.downPayment.current,id:Ul,name:"downPayment",onChange:c=>this.onChange(c),min:this.paymentState.downPayment.min,max:this.paymentState.downPayment.max,unit:"kr",information:`
|
|
1003
1003
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1004
1004
|
<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>
|
|
1005
1005
|
<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 ${a}.</p>
|
|
1006
1006
|
<p class="waykeecom-content__p">Ifall du har en inbytesbil kan du betala kontantinsatsen med den. Detta kommer du \xF6verens om tillsammans med ${a} vid avtalsskrivning. </p>
|
|
1007
1007
|
</div>
|
|
1008
|
-
`,onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DOWNPAYMENT_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts.duration=new
|
|
1008
|
+
`,onClickInformation:()=>{d("MAIN","FINANCIAL_LOAN_DOWNPAYMENT_INFORMATION_TOGGLE","FINANCIAL")}}),this.contexts.duration=new Qe(this.node.querySelector(`#${Ca}`),{title:"Avbetalning",value:this.paymentState.duration.current,id:Fl,name:"duration",onChange:c=>this.onChange(c),min:this.paymentState.duration.min,max:this.paymentState.duration.max,step:this.paymentState.duration.step,unit:"m\xE5n"}),this.paymentState.residual&&(this.contexts.residual=new Qe(this.node.querySelector(`#${Da}`),{title:"Restv\xE4rde",value:parseInt(`${this.paymentState.residual.current*100}`,10),id:Vl,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 Aa(this.node.querySelector(`#${La}`),{}),this.contexts.loanDetails=new Na(this.node.querySelector(`#${Ra}`),{loan:t,paymentLookupResponse:this.paymentLookupResponse}),l?new ka(this.node.querySelector(`#${ba}`),{store:e,loan:t,paymentLookupResponse:this.paymentLookupResponse,onProceed:()=>s()}):this.contexts.proceedButton=new w(this.node.querySelector(`#${Oa}`),{title:"G\xE5 vidare",id:Ma,onClick:()=>s()})}},xa=$s;var Hs=f("@wayke-se/ecom");var ql="credit-assessment-result",Pa=`${ql}-node`,Bs=class extends r{constructor(e,t){super(e,{htmlTag:"div"});this.props=t,this.render()}render(){let{store:e,paymentType:t,loan:s,paymentLookupResponse:n,onEdit:a}=this.props,l=s?.loanDetails;if(t===Hs.PaymentType.Loan){let c=this.props.store.getState(),m=n||l;if(!l||!m)throw"Missing loan";let u=m.downPaymentSpec.current,p=m.creditAmount,h=m.durationSpec.current,{interest:y,effectiveInterest:g}=m.interests,{monthlyCost:S}=m.costs,b=[{key:"Kontantinsats",value:k(u,{postfix:"kr"})},{key:"L\xE5nebelopp",value:k(p,{postfix:"kr"})},{key:"Avbetalningsperoid",value:`${h} m\xE5n`},{key:"M\xE5nadskostnad f\xF6r l\xE5net",value:k(S,{postfix:"kr*"})}],H=c.creditAssessmentResponse?.recommendation,Y=`*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=`
|
|
1009
1009
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
1010
1010
|
<h4 class="waykeecom-heading waykeecom-heading--4">Bill\xE5n</h4>
|
|
1011
1011
|
<div class="waykeecom-content">
|
|
@@ -1016,7 +1016,7 @@
|
|
|
1016
1016
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
1017
1017
|
<div class="waykeecom-stack waykeecom-stack--1">
|
|
1018
1018
|
<ul class="waykeecom-key-value-list">
|
|
1019
|
-
${
|
|
1019
|
+
${b.map(B=>E(B)).join("")}
|
|
1020
1020
|
</ul>
|
|
1021
1021
|
</div>
|
|
1022
1022
|
<div class="waykeecom-stack waykeecom-stack--1">
|
|
@@ -1041,7 +1041,7 @@
|
|
|
1041
1041
|
</div>
|
|
1042
1042
|
</div>
|
|
1043
1043
|
`:""}
|
|
1044
|
-
`;a&&this.node.querySelector("button")?.addEventListener("click",()=>a())}},$a=Bs;var Va="button-financial-proceed",Ha=`${Va}-node`,Wl="financial-option",Ba=`${Wl}-node`,Yl="financial-option-second",Ua=`${Yl}-node`,Kl="radio-financial-cash",
|
|
1044
|
+
`;a&&this.node.querySelector("button")?.addEventListener("click",()=>a())}},$a=Bs;var Va="button-financial-proceed",Ha=`${Va}-node`,Wl="financial-option",Ba=`${Wl}-node`,Yl="financial-option-second",Ua=`${Yl}-node`,Kl="radio-financial-cash",Ql="radio-financial-loan",jl="radio-financial-lease",Fa="payment-node",Us=class extends r{constructor(e,t){super(e);this.props=t,_(this.props.store,"navigation",()=>{let a=this.props.store.getState();this.paymentType=a.paymentType,this.render()});let s=this.props.store.getState(),{paymentType:n}=s;this.paymentType=n,this.render()}onChange(e){let s=e.currentTarget.value;switch(this.paymentType=s,this.render(!0),this.paymentType){case P.PaymentType.Cash:d("MAIN","FINANCIAL_CASH_SELECTED","FINANCIAL");break;case P.PaymentType.Lease:d("MAIN","FINANCIAL_LEASE_SELECTED","FINANCIAL");case P.PaymentType.Loan:d("MAIN","FINANCIAL_LOAN_SELECTED","FINANCIAL");default:break}}onProceed(){if(this.paymentType){switch(this.paymentType){case P.PaymentType.Cash:d("MAIN","FINANCIAL_CASH_SET","FINANCIAL");break;case P.PaymentType.Lease:d("MAIN","FINANCIAL_LEASE_SET","FINANCIAL");case P.PaymentType.Loan:d("MAIN","FINANCIAL_LOAN_SET","FINANCIAL");default:break}ri(this.paymentType,this.props.lastStage)(this.props.store.dispatch)}}onEdit(){d("MAIN","FINANCIAL_EDIT","FINANCIAL"),M("main",this.props.index)(this.props.store.dispatch)}render(e){let t=this.props.store.getState(),{id:s,order:n,paymentLookupResponse:a}=t;if(!n)throw"No order available";let l=n.paymentOptions,c=t.topNavigation.stage>this.props.index,m=x(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 p=l.find(h=>h.type===P.PaymentType.Loan);new $a(m,{store:this.props.store,loan:p,paymentType:this.paymentType,paymentLookupResponse:a||p?.loanDetails,onEdit:t.createdOrderId?void 0:()=>this.onEdit()})}else if(t.navigation.stage===this.props.index){let p=t.order?.orderVehicle,h=l.find(B=>B.type===P.PaymentType.Cash),y=l.find(B=>B.type===P.PaymentType.Loan),g=l.find(B=>B.type===P.PaymentType.Lease);u.innerHTML=`
|
|
1045
1045
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1046
1046
|
<h4 class="waykeecom-heading waykeecom-heading--4 waykeecom-no-margin">Hur vill du finansiera din ${p?.title} ${me(p)}?</h4>
|
|
1047
1047
|
</div>
|
|
@@ -1052,7 +1052,7 @@
|
|
|
1052
1052
|
<div class="waykeecom-stack waykeecom-stack--3" id="${Fa}"></div>
|
|
1053
1053
|
${this.paymentType!==P.PaymentType.Loan?`<div class="waykeecom-stack waykeecom-stack--3" id="${Ha}"></div>`:""}
|
|
1054
1054
|
|
|
1055
|
-
`,m.appendChild(u);let S=n.contactInformation,
|
|
1055
|
+
`,m.appendChild(u);let S=n.contactInformation,b=[];if(h&&b.push({id:Kl,value:P.PaymentType.Cash,title:"Kontant",description:`
|
|
1056
1056
|
<div class="waykeecom-box">
|
|
1057
1057
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1058
1058
|
<ul class="waykeecom-content__ul">
|
|
@@ -1061,7 +1061,7 @@
|
|
|
1061
1061
|
<li class="waykeecom-content__li">Inga kostnader tillkommer.</li>
|
|
1062
1062
|
</ul>
|
|
1063
1063
|
</div>
|
|
1064
|
-
</div>`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${k(h.price,{postfix:h.unit})}</div>`}),y){let B=y.price,Pc=y.loanDetails?.durationSpec.default,$c=y.loanDetails?.interests.interest||NaN,Hc=y.loanDetails?.creditAmount||NaN,Bc=y.loanDetails?.shouldUseCreditScoring;
|
|
1064
|
+
</div>`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${k(h.price,{postfix:h.unit})}</div>`}),y){let B=y.price,Pc=y.loanDetails?.durationSpec.default,$c=y.loanDetails?.interests.interest||NaN,Hc=y.loanDetails?.creditAmount||NaN,Bc=y.loanDetails?.shouldUseCreditScoring;b.push({id:Ql,value:P.PaymentType.Loan,title:"Bill\xE5n",description:`
|
|
1065
1065
|
<div class="waykeecom-box">
|
|
1066
1066
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
1067
1067
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
@@ -1090,7 +1090,7 @@
|
|
|
1090
1090
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1091
1091
|
<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>
|
|
1092
1092
|
</div>
|
|
1093
|
-
`,options:
|
|
1093
|
+
`,options:b,onClick:B=>this.onChange(B),onClickInformation:()=>{d("MAIN","FINANCIAL_INFORMATION_TOGGLE","FINANCIAL")}});let H=[];g&&(H.push({id:jl,title:"Privatleasing",value:P.PaymentType.Lease,description:`
|
|
1094
1094
|
<div class="waykeecom-box">
|
|
1095
1095
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
1096
1096
|
<ul class="waykeecom-content__ul">
|
|
@@ -1149,7 +1149,7 @@
|
|
|
1149
1149
|
${C({type:"inline"})}
|
|
1150
1150
|
</span>`:""}
|
|
1151
1151
|
</button>
|
|
1152
|
-
`,a&&this.node.querySelector("button")?.addEventListener("click",a)}},Ya=qs;var Ws=class{constructor(i,e){if(!i)throw"Missing element";if(!e){this.element=i,this.node=i;return}this.element=i;let t=e.id?this.element.querySelector(`#${e.id}`):void 0;if(t)t.className=e.className||"",e.attributes?.forEach(s=>{t.setAttribute(s.key,s.value)}),this.node=t;else{let s=document.createElement(e.htmlTag);e.id&&(s.id=e.id),s.className=e.className||"",e.attributes?.forEach(n=>{s.setAttribute(n.key,n.value)}),i.appendChild(s),this.node=s}}},Ka=Ws;var Ys=class extends Ka{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")}},
|
|
1152
|
+
`,a&&this.node.querySelector("button")?.addEventListener("click",a)}},Ya=qs;var Ws=class{constructor(i,e){if(!i)throw"Missing element";if(!e){this.element=i,this.node=i;return}this.element=i;let t=e.id?this.element.querySelector(`#${e.id}`):void 0;if(t)t.className=e.className||"",e.attributes?.forEach(s=>{t.setAttribute(s.key,s.value)}),this.node=t;else{let s=document.createElement(e.htmlTag);e.id&&(s.id=e.id),s.className=e.className||"",e.attributes?.forEach(n=>{s.setAttribute(n.key,n.value)}),i.appendChild(s),this.node=s}}},Ka=Ws;var Ys=class extends Ka{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")}},Qa=Ys;var Ks="insurance-button-top-left-node",ja="insurance-button-bottom-left-node",Qs="insurance-add-remove-node",za="insurance-addons-node",Ja="insurance-accordion-node",ge=class extends r{constructor(e,t){super(e);this.initialAddons=[];this.addons=[];this.contexts={checkboxes:{}};this.props=t;let{insuranceAddOns:s}=this.props.store.getState();!!s?.insurance&&s.insurance===this.props.insurance.name&&(this.addons=[...s.addOns]),this.initialAddons=[...this.addons],this.render()}static containChanges(e,t){let s=[...e].sort(),n=[...t].sort();return s.join().localeCompare(n.join())!==0}onClick(e){let t=e.currentTarget,{name:s,checked:n}=t,a=this.props.insurance.addOns.find(c=>c.name===s);if(a){if(Object.keys(this.contexts.checkboxes).forEach(c=>{this.contexts.checkboxes[c]?.disabled(!1)}),this.contexts.checkboxes[s]?.checked(n),n)d("MAIN","INSURANCE_ADDON_SELECTED","INSURANCE_IF"),this.addons.push(a);else{d("MAIN","INSURANCE_ADDON_UNSELECTED","INSURANCE_IF");let c=this.addons.findIndex(m=>m.name===a.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=ge.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"),di(this.props.insurance,this.addons)(this.props.store.dispatch),this.props.onClose()}render(){let{insurance:e,selected:t,onClose:s}=this.props,{name:n,description:a,legalDescription:l,legalUrl:c,insuranceItems:m}=e,u=e.addOns,p=ge.containChanges(this.initialAddons,this.addons);if(this.node.innerHTML=`
|
|
1153
1153
|
<div class="waykeecom-nav-banner" id="${Ks}"></div>
|
|
1154
1154
|
|
|
1155
1155
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
@@ -1189,10 +1189,10 @@
|
|
|
1189
1189
|
<div class="waykeecom-stack waykeecom-stack--3" id="${Ja}"></div>
|
|
1190
1190
|
`:""}
|
|
1191
1191
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1192
|
-
<div class="waykeecom-stack waykeecom-stack--1" id="${
|
|
1193
|
-
<div class="waykeecom-stack waykeecom-stack--1" id="${
|
|
1192
|
+
<div class="waykeecom-stack waykeecom-stack--1" id="${Qs}"></div>
|
|
1193
|
+
<div class="waykeecom-stack waykeecom-stack--1" id="${ja}"></div>
|
|
1194
1194
|
</div>
|
|
1195
|
-
`,new re(this.node.querySelector(`#${Ks}`),{title:"Tillbaka",onClick:()=>s()}),u?.length){let h=this.node.querySelector(`#${za}`);u.forEach(y=>{let g=new
|
|
1195
|
+
`,new re(this.node.querySelector(`#${Ks}`),{title:"Tillbaka",onClick:()=>s()}),u?.length){let h=this.node.querySelector(`#${za}`);u.forEach(y=>{let g=new Qa(h);this.contexts.checkboxes[y.name]=new Ze(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(S=>S.name===y.name)>-1,onClick:S=>this.onClick(S)})})}if(m?.length){let h=this.node.querySelector(`#${Ja}`);m.forEach(y=>new je(h,{id:y.name,title:y.name,description:y.description,append:!0}))}new re(this.node.querySelector(`#${Ks}`),{title:"Tillbaka",onClick:()=>s()}),new te(this.node.querySelector(`#${ja}`),{title:"Tillbaka",onClick:()=>s()}),t?this.contexts.updateButton=new Ya(this.node.querySelector(`#${Qs}`),{title:t?"Uppdatera":"V\xE4lj",disabled:t?!p:void 0,onClick:()=>this.onUpdate()}):this.contexts.updateButton=new ee(this.node.querySelector(`#${Qs}`),{selected:!1,fullSize:!0,disabled:t?!p:void 0,onClick:()=>this.onUpdate()}),V()}},Xa=ge;var js=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.props=t,_(this.props.store,"insurance",()=>{this.render()}),this.render()}onInfoOpen(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE_IF"),this.displayInfo=!0,this.render()}onInfoClose(){d("MAIN","INSURANCE_INFORMATION_TOGGLE","INSURANCE_IF"),this.displayInfo=!1,O(),this.render(),this.node.parentElement?.scrollIntoView()}onClick(){let{insurance:e}=this.props.store.getState();!e||e&&this.props.insurance.name!==e.name?d("MAIN","INSURANCE_SELECTED","INSURANCE_IF"):d("MAIN","INSURANCE_UNSELECTED","INSURANCE_IF"),le(this.props.insurance)(this.props.store.dispatch)}render(){let{store:e,insurance:t,key:s}=this.props,n=e.getState(),a=n.order?.insuranceOption?.logo,l=n.insuranceAddOns?.insurance===t.name?n.insuranceAddOns.addOns.map(m=>({key:m?.title,value:k(m?.monthlyPrice,{postfix:"kr/m\xE5n"})})):void 0,c=n.insurance?JSON.stringify(n.insurance).localeCompare(JSON.stringify(t))===0:!1;this.displayInfo&&new Xa(Q(),{store:this.props.store,insurance:t,selected:c,onClose:()=>this.onInfoClose()}),new ue(this.node,{logo:a,selected:c,id:s,title:t.name,description:t.description,price:k(t.price,{postfix:"kr/m\xE5n"}),priceDetails:l,onClick:()=>this.onClick(),onInfo:()=>this.onInfoOpen()},s)}},Za=js;var zs=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,insurances:t}=this.props,s=new pe(this.node,{id:"insurance-list",onClick:()=>d("MAIN","INSURANCE_ARROW","INSURANCE_IF")}),{overflowElement:n}=s;n&&(n.innerHTML="",t.forEach((a,l)=>new Za(n,{store:e,insurance:a,key:`insurance-${l}`})))}},er=zs;var Js="insurance-grid-list-node",zl="button-insurances-proceed",tr=`${Js}-node`,nr="button-insurances-skip",sr=`${nr}-node`,ar="button-insurance-edit-driving-distance",or=`${ar}-node`,ir={},Xs=class extends r{constructor(e,t){super(e);this.requestError=!1;this.contexts={listners:[]};this.props=t;let s=_(this.props.store,"drivingDistance",()=>{this.fetchInsurance()});this.contexts.listners.push(s);let n=_(this.props.store,"customer.socialId",()=>{this.fetchInsurance()});this.contexts.listners.push(n);let a=_(this.props.store,"insurance",()=>{this.contexts.buttonProceed?.disabled(!this.props.store.getState().insurance)});this.contexts.listners.push(a),this.fetchInsurance(),this.render()}fetchInsurance(){this.props.store.getState().customer.socialId&&this.getInsurances()}async getInsurances(){let e=this.props.store.getState();this.requestError=!1,this.render();let t=`${e.customer.socialId}-${e.id}-${e.drivingDistance}`,s=ir[t];if(d("MAIN","INSURANCE_GET_INSURANCES_REQUESTED","INSURANCE_IF"),s){this.insurances=s,d("MAIN","INSURANCE_GET_INSURANCES_SUCCEEDED","INSURANCE_IF"),this.render();return}try{let n=await Wa(this.props.store,e.drivingDistance);d("MAIN","INSURANCE_GET_INSURANCES_SUCCEEDED","INSURANCE_IF"),this.insurances=n.getInsuranceOptions(),ir[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"),le()(this.props.store.dispatch),Z(this.props.lastStage)(this.props.store.dispatch)}render(){let{store:e}=this.props,t=e.getState(),{insurance:s,drivingDistance:n}=t;this.node.innerHTML=`
|
|
1196
1196
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1197
1197
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vill du teckna en f\xF6rs\xE4kring p\xE5 din nya bil?</h4>
|
|
1198
1198
|
<div class="waykeecom-content">
|
|
@@ -1266,7 +1266,7 @@
|
|
|
1266
1266
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Er}"></div>
|
|
1267
1267
|
<div class="waykeecom-stack waykeecom-stack--1" id="${vr}"></div>
|
|
1268
1268
|
</div>
|
|
1269
|
-
`,new re(this.node.querySelector(`#${yr}`),{title:"Tillbaka",onClick:()=>s()}),new te(this.node.querySelector(`#${vr}`),{title:"Tillbaka",onClick:()=>s()}),new ee(this.node.querySelector(`#${Er}`),{selected:t,fullSize:!0,onClick:()=>n()}),V()}},Ir=to;var so=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"),mi(this.props.freeInsurance)(this.props.store.dispatch)}render(){let{store:e,freeInsurance:t,key:s}=this.props,n=e.getState(),a=n.order?.insuranceOption?.logo,l=n.freeInsurance?JSON.stringify(n.freeInsurance).localeCompare(JSON.stringify(this.props.freeInsurance))===0:!1;this.displayInfo&&new Ir(
|
|
1269
|
+
`,new re(this.node.querySelector(`#${yr}`),{title:"Tillbaka",onClick:()=>s()}),new te(this.node.querySelector(`#${vr}`),{title:"Tillbaka",onClick:()=>s()}),new ee(this.node.querySelector(`#${Er}`),{selected:t,fullSize:!0,onClick:()=>n()}),V()}},Ir=to;var so=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"),mi(this.props.freeInsurance)(this.props.store.dispatch)}render(){let{store:e,freeInsurance:t,key:s}=this.props,n=e.getState(),a=n.order?.insuranceOption?.logo,l=n.freeInsurance?JSON.stringify(n.freeInsurance).localeCompare(JSON.stringify(this.props.freeInsurance))===0:!1;this.displayInfo&&new Ir(Q(),{freeInsurance:t,selected:l,onClick:()=>{this.onInfoClose(),this.onClick()},onClose:()=>this.onInfoClose()}),new ue(this.node,{logo:a,id:s,title:t.title,description:t.description,price:"Gratis",selected:l,onClick:()=>this.onClick(),onInfo:()=>this.onInfoOpen()},s)}},fr=so;var oo=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,insurances:t}=this.props,s=new pe(this.node,{id:"insurance-list",onClick:()=>d("MAIN","INSURANCE_ARROW","INSURANCE")}),{overflowElement:n}=s;n&&(n.innerHTML="",t.forEach((a,l)=>new fr(n,{store:e,freeInsurance:a,key:`insurance-${l}`})))}},_r=oo;var io="insurance-grid-list-node",Jl="button-insurances-proceed",gr=`${io}-node`,Xl="button-insurances-skip",Zl=`${Xl}-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=`
|
|
1270
1270
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1271
1271
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vill du teckna en f\xF6rs\xE4kring p\xE5 din nya bil?</h4>
|
|
1272
1272
|
<div class="waykeecom-content">
|
|
@@ -1278,7 +1278,7 @@
|
|
|
1278
1278
|
<div class="waykeecom-stack waykeecom-stack--1" id="${gr}"></div>
|
|
1279
1279
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Zl}"></div>
|
|
1280
1280
|
</div>
|
|
1281
|
-
`,new _r(this.node.querySelector(`#${io}`),{store:e,insurances:[t]}),new w(this.node.querySelector(`#${gr}`),{id:Jl,title:"G\xE5 vidare",onClick:()=>this.onProceed()})}},wr=no;var ao=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(){le()(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()),M("main",this.props.index)(this.props.store.dispatch)}render(){let{store:e,index:t,lastStage:s}=this.props,n=e.getState(),a=n.topNavigation.stage>t,l=n.navigation.stage===t;l&&d("MAIN","INSURANCE_ACTIVE",this.getStep());let c=x(this.node,{completed:a,title:"F\xF6rs\xE4kring",active:l,id:"insurance"});if(n.navigation.stage>t||a&&n.navigation.stage!==t){let m=[];n.insurance?(m.push({key:"Uppskattad k\xF6rstr\xE4cka",value:J[n.drivingDistance]}),m.push({key:n.insurance.name,value:k(n.insurance.price,{postfix:"kr/m\xE5n"})}),n.insuranceAddOns?.insurance===n.insurance.name&&n.insuranceAddOns.addOns.forEach(u=>m.push({key:u.title,value:k(u.monthlyPrice,{postfix:"kr/m\xE5n"})}))):n.freeInsurance?m.push({key:"F\xF6rs\xE4kring",value:n.freeInsurance.title}):m.push({key:"F\xF6rs\xE4kring",value:"Ingen"}),new
|
|
1281
|
+
`,new _r(this.node.querySelector(`#${io}`),{store:e,insurances:[t]}),new w(this.node.querySelector(`#${gr}`),{id:Jl,title:"G\xE5 vidare",onClick:()=>this.onProceed()})}},wr=no;var ao=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(){le()(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()),M("main",this.props.index)(this.props.store.dispatch)}render(){let{store:e,index:t,lastStage:s}=this.props,n=e.getState(),a=n.topNavigation.stage>t,l=n.navigation.stage===t;l&&d("MAIN","INSURANCE_ACTIVE",this.getStep());let c=x(this.node,{completed:a,title:"F\xF6rs\xE4kring",active:l,id:"insurance"});if(n.navigation.stage>t||a&&n.navigation.stage!==t){let m=[];n.insurance?(m.push({key:"Uppskattad k\xF6rstr\xE4cka",value:J[n.drivingDistance]}),m.push({key:n.insurance.name,value:k(n.insurance.price,{postfix:"kr/m\xE5n"})}),n.insuranceAddOns?.insurance===n.insurance.name&&n.insuranceAddOns.addOns.forEach(u=>m.push({key:u.title,value:k(u.monthlyPrice,{postfix:"kr/m\xE5n"})}))):n.freeInsurance?m.push({key:"F\xF6rs\xE4kring",value:n.freeInsurance.title}):m.push({key:"F\xF6rs\xE4kring",value:"Ingen"}),new j(c,{keyValueList:m,changeButtonTitle:"\xC4ndra f\xF6rs\xE4kring",onEdit:n.createdOrderId?void 0:()=>this.onEdit()})}else if(n.navigation.stage===t){let m=n.order?.insuranceOption;if(!m)throw"Missing insurance";switch(m?.institute){case"IF":new kr(c,{store:e,lastStage:s,onSkip:()=>this.onSkipInsurances()});break;default:new wr(c,{store:e,lastStage:s,insurance:m});break}}n.navigation.stage===t&&c.parentElement?.scrollIntoView()}},Sr=ao;var ro=f("@wayke-se/ecom"),Nr=o=>{let i=ro.vehicles.newLookupRequest().withRegistrationNumber(o.registrationNumber).withMileage(parseInt(o.mileage,10)).withCondition(o.condition);return ro.vehicles.lookupVehicle(i.build())};var co=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t,this.render()}setError(e){this.contexts.error?.setError(e)}render(){let{title:e,value:t,name:s,id:n,error:a,errorMessage:l,placeholder:c,information:m,autocomplete:u,onChange:p,onBlur:h}=this.props;this.node.innerHTML=`
|
|
1282
1282
|
<div class="waykeecom-input-label">
|
|
1283
1283
|
<label for="${n}" class="waykeecom-input-label__label">${e}</label>
|
|
1284
1284
|
</div>
|
|
@@ -1438,12 +1438,12 @@
|
|
|
1438
1438
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Ur}"></div>
|
|
1439
1439
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Fr}"></div>
|
|
1440
1440
|
</div>
|
|
1441
|
-
`,new w(m.querySelector(`#${Ur}`),{id:Vr,title:"Jag har inbytesbil",onClick:()=>this.onYesTradeIn()}),new K(m.querySelector(`#${Fr}`),{id:Gr,title:"Hoppa \xF6ver detta steg",onClick:()=>this.onNoTradeIn()})));c.appendChild(m),n.navigation.stage===t&&c.parentElement?.scrollIntoView()}},qr=ho;var tt={customer:{component:pn,name:"customer"},centralStorage:{component:
|
|
1441
|
+
`,new w(m.querySelector(`#${Ur}`),{id:Vr,title:"Jag har inbytesbil",onClick:()=>this.onYesTradeIn()}),new K(m.querySelector(`#${Fr}`),{id:Gr,title:"Hoppa \xF6ver detta steg",onClick:()=>this.onNoTradeIn()})));c.appendChild(m),n.navigation.stage===t&&c.parentElement?.scrollIntoView()}},qr=ho;var tt={customer:{component:pn,name:"customer"},centralStorage:{component:ji,name:"centralStorage"},delivery:{component:fn,name:"delivery"},tradeIn:{component:qr,name:"tradeIn"},financial:{component:Ga,name:"financial"},insurance:{component:Sr,name:"insurance"},accessories:{component:Vi,name:"accessories"}};var ko=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){this.node.innerHTML=`
|
|
1442
1442
|
<h3 class="waykeecom-heading waykeecom-heading--4">K\xF6p online hos oss</h3>
|
|
1443
1443
|
<ul class="waykeecom-checklist" aria-label="F\xF6rdelar med att k\xF6pa bilen online hos oss">
|
|
1444
1444
|
${this.props.checklistItems.map(e=>` <li class="waykeecom-checklist__item">${e}</li>`).join("")}
|
|
1445
1445
|
</ul>
|
|
1446
|
-
`}},Wr=ko;var
|
|
1446
|
+
`}},Wr=ko;var Qr="preview-proceed",Yr=`${Qr}-node`,id="preview-checklist",Kr=`${id}-node`,yo=class extends r{constructor(e,t){super(e);this.contexts={};this.requestError=!1;this.props=t,this.init(),this.render()}async init(){this.requestError=!1,this.render();let e=this.props.store.getState();try{this.contexts.buttonProceed?.disabled(!0);let t=await Be(e.id),s=Me(t),n=[];this.props.stageOrderList.forEach(a=>{a==="centralStorage"&&!s.requiresDealerSelection||a==="tradeIn"&&!s.allowsTradeIn||a==="insurance"&&!s.insuranceOption||a==="accessories"&&!s.accessories.length||n.push(tt[a])}),ui(n)(this.props.store.dispatch),xe(s,this.props.vehicle)(this.props.store.dispatch),this.render()}catch(t){throw this.requestError=!0,this.render(),t}}onProceed(){d("PREVIEW","PREVIEW_PROCEED"),M("main")(this.props.store.dispatch)}render(){let{store:e,cdnMedia:t}=this.props,s=e.getState();if(!s.order){this.node.innerHTML=`
|
|
1447
1447
|
${this.requestError?I({tone:"error",children:"Ett fel uppstod och det gick inte att initiera modulen. F\xF6rs\xF6k igen."}):C()}
|
|
1448
1448
|
`;return}this.node.innerHTML=`
|
|
1449
1449
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
@@ -1455,7 +1455,7 @@
|
|
|
1455
1455
|
${gi({order:s.order,stageOrderList:s.stages})}
|
|
1456
1456
|
<div class="waykeecom-stack waykeecom-stack--3" id="${Yr}"></div>
|
|
1457
1457
|
<footer class="waykeecom-footer" id="${Kr}"></footer>
|
|
1458
|
-
`,this.contexts.buttonProceed=new w(document.querySelector(`#${Yr}`),{id:
|
|
1458
|
+
`,this.contexts.buttonProceed=new w(document.querySelector(`#${Yr}`),{id:Qr,title:"G\xE5 vidare",onClick:()=>this.onProceed()}),new Wr(document.querySelector(`#${Kr}`),{title:"K\xF6p online hos Wayke",ariaLabel:"F\xF6rdelar med att k\xF6pa bilen online hos Wayke",checklistItems:["Trygg hantering av personuppgifter","Reservera bilen nu \u2013 betalning och avtalsskrivning sker senare med handlaren","Inte bindande f\xF6rr\xE4n avtal skrivits ihop med handlaren","Bara kontrollerade bilar"]})}},jr=yo;var nd=({vehicle:o,order:i,cdnMedia:e})=>{let t=o?.imageUrls?.[0],s=o?.title,n=k(o?.price||NaN),a=i?.contactInformation?.name;return`
|
|
1459
1459
|
<div class="waykeecom-preview-card">
|
|
1460
1460
|
${t?`
|
|
1461
1461
|
<div class="waykeecom-preview-card__media">
|
|
@@ -1489,7 +1489,7 @@
|
|
|
1489
1489
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1490
1490
|
<div id="payment-menu" style="padding: 24px;border: 1px solid #ececeb;"></div>
|
|
1491
1491
|
</div>
|
|
1492
|
-
`}},Xr=vo;var q=f("@wayke-se/ecom");var Eo=f("@wayke-se/ecom"),Zr=o=>{let i=Eo.bankid.newAuthRequest().withMethod(o).build();return Eo.bankid.auth(i)};var Io=f("@wayke-se/ecom"),fo=o=>{let i=Io.bankid.newCollectRequest().withOrderRef(o).build();return Io.bankid.collect(i)};var L=f("@wayke-se/ecom"),ec=o=>{let i=o.getState();if(!i.address)throw"Missing address";if(!i.paymentType)throw"Missing paymentType";if(!i.vehicle)throw"Missing vehicle";let e=L.customers.newCustomer().withAddress(i.address).withPersonalNumber(i.customer.socialId).withEmail(i.customer.email).withPhoneNumber(i.customer.phone).build(),t=L.orders.newPayment().withType(i.paymentType);if(i.paymentType===L.PaymentType.Loan){let m=i.order?.paymentOptions.find(S=>S.type===L.PaymentType.Loan),u=i.paymentLookupResponse||m?.loanDetails,p=u?.durationSpec.current,h=u?.downPaymentSpec.current,y=u?.residualValueSpec?.current,g=i.order?.paymentOptions.find(S=>S.type===L.PaymentType.Loan)?.externalId;if(t.withDuration(p).withDownPayment(Math.round(h)),y&&t.withResidualValue(y),g&&t.withExternalId(g),i.creditAssessmentResponse){let S=i.creditAssessmentResponse.scoringId,
|
|
1492
|
+
`}},Xr=vo;var q=f("@wayke-se/ecom");var Eo=f("@wayke-se/ecom"),Zr=o=>{let i=Eo.bankid.newAuthRequest().withMethod(o).build();return Eo.bankid.auth(i)};var Io=f("@wayke-se/ecom"),fo=o=>{let i=Io.bankid.newCollectRequest().withOrderRef(o).build();return Io.bankid.collect(i)};var L=f("@wayke-se/ecom"),ec=o=>{let i=o.getState();if(!i.address)throw"Missing address";if(!i.paymentType)throw"Missing paymentType";if(!i.vehicle)throw"Missing vehicle";let e=L.customers.newCustomer().withAddress(i.address).withPersonalNumber(i.customer.socialId).withEmail(i.customer.email).withPhoneNumber(i.customer.phone).build(),t=L.orders.newPayment().withType(i.paymentType);if(i.paymentType===L.PaymentType.Loan){let m=i.order?.paymentOptions.find(S=>S.type===L.PaymentType.Loan),u=i.paymentLookupResponse||m?.loanDetails,p=u?.durationSpec.current,h=u?.downPaymentSpec.current,y=u?.residualValueSpec?.current,g=i.order?.paymentOptions.find(S=>S.type===L.PaymentType.Loan)?.externalId;if(t.withDuration(p).withDownPayment(Math.round(h)),y&&t.withResidualValue(y),g&&t.withExternalId(g),i.creditAssessmentResponse){let S=i.creditAssessmentResponse.scoringId,b=i.creditAssessmentResponse.recommendation,H=i.creditAssessmentResponse.decision,Y=u?.financialProductCode;if(!S||!b||!H||!Y)throw"Missing credit assessment data";let B=L.orders.newCreditAssessment().withScoreId(S).withFinancialProductCode(Y).withRecommendation(b).withDecision(H).build();t.withCreditAssessment(B)}}let s=t.build(),n=new URLSearchParams(window.location.search);n.set("wayke-ecom-web-id",i.id);let a=`${window.location.origin}${window.location.pathname}?${n.toString()}${window.location.hash}`;n.set("wayke-ecom-web-payment","true");let l=`${window.location.origin}${window.location.pathname}?${n.toString()}${window.location.hash}`,c=L.orders.newCreateRequest().forVehicle(i.id).withCustomer(e).withPayment(s).withUrls(a,l).withDeliveryType(i.homeDelivery?L.DeliveryType.Delivery:L.DeliveryType.Pickup);if(i.insurance){let m=L.orders.newInsurance().withDrivingDistance(i.drivingDistance);i.insuranceAddOns?.addOns.length&&i.insuranceAddOns.insurance===i.insurance.name&&m.withAddOns(i.insuranceAddOns.addOns.map(p=>p.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=L.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 L.orders.create(c.build())};var tc=f("@wayke-se/ecom"),sc=o=>tc.creditAssessment.accept(o);var _o=f("@wayke-se/ecom"),oc=o=>{let i=_o.bankid.newQrCodeRequest().withOrderRef(o).build();return _o.bankid.qrcode(i)};var cc="confirm-conditions",ic=`${cc}-node`,nc="bankid-start-node",ad="bankid-start",ac="address-disclaimer-policy-node",rc="address-disclaimer-reservation-node",go=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 fo(e);this.handleBankidStatusResponse(t,q.AuthMethod.QrCode)}catch{this.clearIntervals(),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering.")}};this.qrCode=async e=>{try{let s=(await oc(e)).getQrCode();this.contexts.bankId?.update(q.AuthMethod.QrCode,s)}catch{this.clearIntervals(),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta ny QR-kod f\xF6r BankId signering.")}};this.props=t,this.ageError=!1,this.render()}addWindowEvents(){this.removeWindowEvents(),window.addEventListener("focus",()=>this.onFocus())}removeWindowEvents(){window.removeEventListener("focus",()=>this.onFocus())}clearIntervals(){clearInterval(this.bankidQrCodeInterval),clearInterval(this.bankidStatusInterval)}async onFocus(){clearTimeout(this.focusTimeout),this.focusTimeout=setTimeout(async()=>{if(this.bankidRequestRef?.method===q.AuthMethod.SameDevice)try{let e=await fo(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 sc(e),d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_SUCCEEDED","CONFIRMATION")}catch{d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_FAILED","CONFIRMATION")}}async onCreateOrder(){let{store:e}=this.props;this.notAvailable=!1,this.requestError=!1;try{d("MAIN","CONFIRMATION_CREATE_ORDER_REQUESTED","CONFIRMATION");let{order:t}=e.getState(),s=await ec(e);d("MAIN","CONFIRMATION_CREATE_ORDER_SUCCEEDED","CONFIRMATION"),t?.isPaymentRequired&&O();let a=s.getPayment();hi(s.getOrderNumber(),a)(e.dispatch),this.acceptCreditAssessment()}catch(t){let s=t;this.view=1,d("MAIN","CONFIRMATION_CREATE_ORDER_FAILED","CONFIRMATION"),s.message==="The vehicle is not available for purchase"?(this.requestError=!1,this.notAvailable=!0):(this.notAvailable=!1,this.requestError=!0),O(),this.render()}}async handleBankidStatusResponse(e,t){if(e.isCompleted()){this.removeWindowEvents(),this.clearBankidRequestRef(),this.clearIntervals();let s=e.getAddress(),n=e.getPersonalNumber();if(s&&n){let a=this.props.store.getState();if(D.requiredSsnOver18(n)){if(a.customer.socialId!==n){d("MAIN",t===q.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===q.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===q.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED","CONFIRMATION"),this.contexts.bankId?.setDescription("Verifiering klar, ordern skapas nu..."),await this.onCreateOrder()}}}async startBankidSameDevice(e,t,s=!1){s||d("MAIN","CONFIRMATION_BANKID_STATUS_SAME_DEVICE_REQUESTED","CONFIRMATION");try{this.setBankidRequestRef(t,q.AuthMethod.SameDevice);let n=e.getAutoLaunchUrl();this.contexts.bankId?.update(q.AuthMethod.SameDevice,n)}catch(n){this.removeWindowEvents(),this.clearBankidRequestRef();let a=n;this.contexts.bankId?.setErrorMessage(`Error: ${a.message}`)}}async startBankidWithQr(e,t=!1){t||d("MAIN","CONFIRMATION_BANKID_STATUS_QR_REQUESTED","CONFIRMATION"),this.bankidStatusInterval=setInterval(()=>{this.bankidStatus(e)},2e3),Le("bankidStatusInterval",this.bankidStatusInterval),this.qrCode(e),this.bankidQrCodeInterval=setInterval(async()=>{this.qrCode(e)},1e3),Le("bankidQrCodeInterval",this.bankidQrCodeInterval)}async onStartBankIdAuth(e,t=!1){this.clearIntervals();try{t||d("MAIN","CONFIRMATION_BANKID_INIT_REQUESTED","CONFIRMATION"),this.contexts.bankId?.update(e),this.contexts.buttonLinkToggle?.disabled(!0);let s=await Zr(e);t||d("MAIN","CONFIRMATION_BANKID_INIT_SUCCEEDED","CONFIRMATION");let n=s.getOrderRef();e===q.AuthMethod.QrCode?this.startBankidWithQr(n,t):this.startBankidSameDevice(s,n,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:s,insurance:n}=this.props.store.getState();if(this.view===2)this.contexts.bankId=new ze(Q(),{method:e?q.AuthMethod.SameDevice:q.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:a=>this.onStartBankIdAuth(a),onSameDeviceClick:()=>this.onSameDeviceClick()});else{let a=s?.contactInformation?.name,l=s?.conditionsPdfUri,c="https://www.wayke.se/trygghet-naer-det-kommer-till-dina-personuppgifter";this.node.innerHTML=`
|
|
1493
1493
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1494
1494
|
<h4 class="waykeecom-heading waykeecom-heading--4">Strax klart!</h4>
|
|
1495
1495
|
<div class="waykeecom-content">
|
|
@@ -1843,5 +1843,5 @@
|
|
|
1843
1843
|
<div class="waykeecom-stack waykeecom-stack--1" id="${bc}"></div>
|
|
1844
1844
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Rc}"></div>
|
|
1845
1845
|
</div>
|
|
1846
|
-
`,new Je(this.node.querySelector(`#${bc}`),{title:"Forts\xE4tt min order",onClick:()=>t()}),new Dc(this.node.querySelector(`#${Rc}`),{title:"Avbryt min order",onClick:()=>e()})}},Oc=Wo;var Yo=()=>{let o=document.documentElement.clientWidth/100;document.documentElement.style.setProperty("--waykeecom-vw",`${o}px`)},Lc=()=>(Yo(),window.addEventListener("resize",Yo),()=>window.removeEventListener("resize",Yo));var Ko="order",rd="wayke-ecom-web-payment",
|
|
1846
|
+
`,new Je(this.node.querySelector(`#${bc}`),{title:"Forts\xE4tt min order",onClick:()=>t()}),new Dc(this.node.querySelector(`#${Rc}`),{title:"Avbryt min order",onClick:()=>e()})}},Oc=Wo;var Yo=()=>{let o=document.documentElement.clientWidth/100;document.documentElement.style.setProperty("--waykeecom-vw",`${o}px`)},Lc=()=>(Yo(),window.addEventListener("resize",Yo),()=>window.removeEventListener("resize",Yo));var Ko="order",rd="wayke-ecom-web-payment",Qo="wayke-ecom-web-id",Ce="wayke-ecom-modal",cd="ecom.wayketech.se",ld="ecom.wayke.se",dd=o=>{switch(new URL(o).host){case ld:return"https://cdn.wayke.se";case cd:return"https://test-cdn.wayketech.se";default:return}},jo=class{constructor(i){this.contexts={store:fi()};if(!i.id)throw"Missing id";this.props=i,window.process||(window.process={...window.process||{},env:{}}),Mc.config.bind(i.ecomSdkConfig),this.cdnMedia=dd(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=Jo.version,this.stageOrderList=["centralStorage","customer","financial","tradeIn","accessories","insurance","delivery"],ti(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),s=t.get(Ko)||void 0,n=!!t.get(rd),a=t.get(Qo);if(a&&a===this.props.id&&(s||n))if(n){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,ki({...c,stateLoadedFromSession:!0})(this.contexts.store.dispatch))}else s&&this.render({orderUrl:s,id:a})}close(){let i=Te();i&&d(i.view,"CLOSE",i.currentStep);let{caseId:e}=this.contexts.store.getState(),t=new URLSearchParams(location.search),s=t.get(Ko),n=t.get(Qo),a=!1;s&&(t.delete(Ko),a=!0,location.search=t.toString()),n&&(t.delete(Qo),a=!0),a&&(location.search=t.toString()),this.root.innerHTML="",this.contexts?.unsubribeVwListner?.(),As(),Si(),e&&be(e),sessionStorage.removeItem("wayke-ecom-state"),ei(this.props.id)(this.contexts.store.dispatch),this.props.onEvent&&Ai(this.props.onEvent)}destroy(){this.close(),this.root.remove()}closeWithConfirm(){let{navigation:i,createdOrderId:e}=this.contexts.store.getState(),t=i.view==="preview";if(As(),t||e){this.close();return}this.contexts.modal=new Go(this.root,{title:"Wayke Ecom",id:Ce,logo:this.props.logo,logoX2:this.props.logoX2});let s=Te();s&&d(s.view,"CONFIRM_CLOSE_ACTIVE"),new Oc(this.contexts.modal.content,{onConfirmClose:()=>{let n=Te();d(n.view,"CONFIRM_CLOSE_CONFIRMED",n.currentStep),this.close()},onAbortClose:()=>{let n=Te();d(n.view,"CONFIRM_CLOSE_ABORTED",n.currentStep),this.render()}})}start(){this.props.onEvent&&Ni(this.props.onEvent),d("PREVIEW","START"),this.render()}render(i){if(this.contexts.unsubribeVwListner||(this.contexts.unsubribeVwListner=Lc()),this.contexts.modal=new Go(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 fc(this.contexts.modal.content,{store:this.contexts.store,callbackOrder:i,onClose:()=>this.close()});return}switch(this.view){case"preview":new jr(this.contexts.modal.content,{store:this.contexts.store,stageOrderList:this.stageOrderList,vehicle:this.props.vehicle,cdnMedia:this.cdnMedia});break;case"main":new mc(this.contexts.modal.content,{store:this.contexts.store,cdnMedia:this.cdnMedia});break;case"summary":new Ic(this.contexts.modal.content,{store:this.contexts.store,cdnMedia:this.cdnMedia,onClose:()=>this.close()});break;default:throw"Unknown view..."}}}},xc=jo;var ig=xc;})();
|
|
1847
1847
|
//# sourceMappingURL=index.js.map
|