@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.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",version:"1.4.
|
|
1
|
+
import{config as ad}from"@wayke-se/ecom";var Bo={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"]};import{createStore as Pc}from"redux";import{DrivingDistance as Lc,PaymentType as ii}from"@wayke-se/ecom";var Xe=(o,i)=>o!==void 0&&i!==void 0?JSON.stringify(o).localeCompare(JSON.stringify(i))===0:o===i;var _e=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()}),Uo=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()}),be=o=>({orderVehicle:o.getOrderVehicle(),accessories:o.getAccessories(),requiresDealerSelection:o.requiresDealerSelection(),dealerSites:o.getDealerSites(),paymentOptions:o.getPaymentOptions().map(e=>({...e,loanDetails:e.loanDetails?_e(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()}),Fo=o=>({vehicle:o.getVehicle()});var Ze="RESET",Vo=o=>i=>i({type:Ze,id:o}),et="SET_ORDER",Oe=(o,i)=>e=>e({type:et,order:o,vehicle:i}),tt="SET_ID",Go=o=>i=>i({type:tt,id:o}),st="SET_CONTACT_EMAIL_AND_PHONE",qo=o=>i=>i({type:st,value:o}),ot="SET_SOCIAL_ID_AND_ADDRESS",Wo=(o,i,e)=>t=>t({type:ot,socialId:o,address:i,lastStage:e}),it="SET_HOME_DELIVERY",Yo=(o,i)=>e=>e({type:it,homeDelivery:o,lastStage:i}),nt="SET_DEALER",Ko=(o,i)=>e=>e({type:nt,dealer:o,lastStage:i}),at="INIT_TRADE_IN",Qo=o=>i=>i({type:at,lastStage:o}),rt="SET_TRADE_IN",ge=(o,i,e)=>t=>t({type:rt,lastStage:o,tradeIn:i,tradeInVehicle:e}),ct="SET_FINANCIAL",jo=(o,i)=>e=>e({type:ct,paymentType:o,lastStage:i}),lt="SET_PAYMENT_LOOKUP_RESPONSE",zo=o=>i=>i({type:lt,paymentLookupResponse:_e(o)}),dt="SET_DRIVING_DISTANCE",Jo=o=>i=>i({type:dt,drivingDistance:o}),mt="COMPLETE_STAGE",z=o=>i=>i({type:mt,lastStage:o}),pt="SET_OR_REMOVE_INSURANCE",re=o=>i=>i({type:pt,insurance:o}),ut="SET_OR_REMOVE_INSURANCE_ADDONS",Xo=(o,i)=>e=>e({type:ut,insurance:o,insuranceAddons:i}),ht="SET_OR_REMOVE_FREE_INSURANCE",Zo=o=>i=>i({type:ht,freeInsurance:o}),kt="SET_OR_REMOVE_ACCESSORY",ei=o=>i=>i({type:kt,accessory:o}),yt="GO_TO",b=(o,i,e)=>t=>t({type:yt,view:o,index:i,subStage:e}),vt="SET_STAGES",ti=o=>i=>i({type:vt,stages:o}),Et="SET_CREATED_ORDER_ID",si=(o,i)=>e=>e({type:Et,id:o,payment:i}),It="SET_CREDIT_ASSESSMENT_RESPONSE",ce=(o,i)=>e=>e({type:It,caseId:o,creditAssessmentResponse:i}),ft="SET_STATE",oi=o=>i=>i({type:ft,state:o});var Mc={};var ni={view:"preview",stage:1,subStage:1},ai={id:"",topNavigation:{...ni},navigation:{...ni},customer:{email:"",phone:"",givenName:"",surname:"",socialId:""},homeDelivery:!1,accessories:[],drivingDistance:Lc.Between0And1000,...Mc},se=(o,i)=>i?{view:"summary",stage:1,subStage:1}:{view:"main",stage:o+1,subStage:1},oe=(o,i)=>i.view==="main"?o.stage<i.stage?i:v.topNavigation:{...o,stage:o.stage+1},_t=o=>o&&o?.length===1&&o?.[0].type===ii.Cash?ii.Cash:void 0,v,gt,xc=(o=ai,i)=>{let e,t;switch(v={...o},i.type){case Ze:return{...ai,id:i.id};case vt:return{...v,stages:i.stages};case tt:return{...v,id:i.id};case et:return{...o,order:i.order,paymentType:_t(i.order?.paymentOptions),vehicle:{...i.order.orderVehicle,...i.vehicle||{}}};case st: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=_t(o.order?.paymentOptions),delete s.paymentLookupResponse,delete s.insurance,delete s.insuranceAddOns,delete s.freeInsurance,delete s.dealer,s.accessories=[],s;case ot:return e=se(v.navigation.stage,i.lastStage),t=oe(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,address:i.address,customer:{...o.customer,socialId:i.socialId}},v;case nt:return e=se(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=_t(o.order?.paymentOptions),delete v.paymentLookupResponse,delete v.insurance,delete v.insuranceAddOns,delete v.freeInsurance,v.accessories=[],v;case it:return e=se(o.navigation.stage,i.lastStage),t=oe(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,homeDelivery:i.homeDelivery},v;case at:return e={view:"main",stage:o.navigation.stage,subStage:1},t=oe(v.topNavigation,e),v={...o,navigation:e,wantTradeIn:!0,topNavigation:t,tradeIn:o.tradeIn||{registrationNumber:"",mileage:"",description:""}},v;case rt:return e=se(o.navigation.stage,i.lastStage),t=oe(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,wantTradeIn:!!i.tradeIn,tradeIn:i.tradeIn,tradeInVehicle:i.tradeInVehicle},v;case ct:return e=se(o.navigation.stage,i.lastStage),t=oe(v.topNavigation,e),{...v,navigation:e,topNavigation:t,paymentType:i.paymentType};case lt:return{...v,paymentLookupResponse:i.paymentLookupResponse};case dt:return{...v,drivingDistance:i.drivingDistance};case mt:return e=se(o.navigation.stage,i.lastStage),t=oe(v.topNavigation,e),v={...o,navigation:e,topNavigation:t},v;case ut:return v.insurance=i.insurance,v.insuranceAddOns={insurance:i.insurance.name,addOns:i.insuranceAddons},v;case pt:return Xe(v.insurance,i.insurance)?v.insurance=void 0:v.insurance=i.insurance,v.insuranceAddOns?.insurance&&(v.insuranceAddOns=void 0),v;case ht:return Xe(v.freeInsurance,i.freeInsurance)?v.freeInsurance=void 0:v.freeInsurance=i.freeInsurance,v;case kt:return gt=v.accessories.findIndex(n=>n.id===i.accessory.id),v.accessories=[...v.accessories],gt>-1?v.accessories.splice(gt,1):v.accessories.push(i.accessory),{...v,accessories:[...v.accessories]};case yt:return{...o,navigation:{view:i.view,stage:i.index||1,subStage:i.subStage||1}};case Et:return i.payment?e={view:"main",stage:o.navigation.stage,subStage:2}:e=se(o.navigation.stage,!0),t=oe(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,createdOrderId:i.id,payment:i.payment},v;case It:return{...v,caseId:i.caseId,creditAssessmentResponse:i.creditAssessmentResponse};case ft:return{...i.state};default:return o}},ri=xc;var ci=()=>Pc(ri);var Le=(o,i)=>{if(!i)return o;let e=new URL(o);return`${i}${e.pathname}`};var $c=o=>o.toString().replace(/\s/g,""),Hc=(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=Hc(o,i?.decimals!==void 0?i.decimals:0);return`${i?.prefix?`${i.prefix}`:""}${$c(e).replace(/\B(?=(\d{3})+(?!\d))/g," ")}${i?.postfix?` ${i.postfix}`:""}`},Bc=(o,i)=>{let e=o.split(" "),t=i.split(" ").map(s=>s.toLowerCase());return e.filter(s=>!t.includes(s.toLowerCase())).join(" ")},le=o=>{if(!!o)return Bc(o.shortDescription||"",o.title||"")};var Uc=({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 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
124
124
|
</div>
|
|
125
125
|
</div>
|
|
126
126
|
`:""}
|
|
127
|
-
`,s&&this.node.querySelector("button")?.addEventListener("click",()=>s())}},Y=Ct;import{get as mi}from"object-path";var
|
|
127
|
+
`,s&&this.node.querySelector("button")?.addEventListener("click",()=>s())}},Y=Ct;import{get as mi}from"object-path";var Qc=(o,i)=>o===i,jc=(o,i,e)=>{let t=e||Qc,s=mi(o(),i);return n=>()=>{let a=mi(o(),i);if(!t(s,a)){let l=s;s=a,n(a,l,i)}}},pi=[],zc=o=>(pi.push(o),o),ui=()=>pi.forEach(o=>o()),Jc=(o,i,e,t)=>{let s=jc(o.getState,i);if(t)o.subscribe(s(e));else return zc(o.subscribe(s(e)))},f=Jc;var Xc=(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">
|
|
@@ -146,7 +146,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
146
146
|
</h3>
|
|
147
147
|
</header>
|
|
148
148
|
<div class="waykeecom-stepper__body"></div>
|
|
149
|
-
`,a||o.appendChild(l);let m=l.querySelector(".waykeecom-stepper__body");if(!m)throw"Err no element";return m},O=Xc;var $e=[],hi=o=>{$e.push(o)},ki=o=>{let i=$e.findIndex(e=>e===o);i>-1&&$e.splice(i,1)},Dt=[],
|
|
149
|
+
`,a||o.appendChild(l);let m=l.querySelector(".waykeecom-stepper__body");if(!m)throw"Err no element";return m},O=Xc;var $e=[],hi=o=>{$e.push(o)},ki=o=>{let i=$e.findIndex(e=>e===o);i>-1&&$e.splice(i,1)},Dt=[],we=()=>Dt[Dt.length-1],Zc=(o,i,e,t)=>{Dt.push({view:o,ecomEvent:i,currentStep:e}),$e.forEach(s=>s(o,i,e,t))},d=Zc;var Rt=class extends r{constructor(e,t){super(e);this.props=t,this.render()}hide(e){this.props.hide!==e&&(this.props.hide=e,this.render())}render(){if(this.props.hide){this.node.innerHTML="";return}let{title:e,dataIcon:t,path:s}=this.props.direction==="left"?{title:"Visa f\xF6reg\xE5ende",dataIcon:"Chevron left",path:'<path d="m5.4 7 5.2-5 1 1-5.2 5 5.2 5-1.1 1-5.2-5-1-1 1.1-1z" />'}:{title:"Visa n\xE4sta",dataIcon:"Chevron right",path:'<path d="m10.5 9-5.2 5-1-1 5.2-5-5.2-5 1.1-1 5.2 5 1 1-1.1 1z" />'};this.node.innerHTML=`
|
|
150
150
|
<button type="button" title="${e}" class="waykeecom-icon-button">
|
|
151
151
|
<svg
|
|
152
152
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -238,7 +238,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
238
238
|
</span>
|
|
239
239
|
<span class="waykeecom-link__content">${e}</span>
|
|
240
240
|
</button>
|
|
241
|
-
`,n&&this.node.querySelector("button")?.addEventListener("click",n)}},ie=$t;var B=()=>{let o=document.getElementById(
|
|
241
|
+
`,n&&this.node.querySelector("button")?.addEventListener("click",n)}},ie=$t;var B=()=>{let o=document.getElementById(Se),i=document.getElementById(`${Se}-dialog`);o&&(o.scrollTop=0),i&&(i.scrollTop=0)};var Ht=class extends r{constructor(e,t){super(e);this.props=t,this.render()}hide(e){this.props.hide!==e&&(this.props.hide=e,this.render())}render(){if(this.props.hide){this.node.innerHTML="";return}let{title:e,dataIcon:t,path:s}=this.props.direction==="left"?{title:"Visa f\xF6reg\xE5ende bild",dataIcon:"Chevron left",path:'<path d="m5.4 7 5.2-5 1 1-5.2 5 5.2 5-1.1 1-5.2-5-1-1 1.1-1z" />'}:{title:"Visa n\xE4sta bild",dataIcon:"Chevron right",path:'<path d="m10.5 9-5.2 5-1-1 5.2-5-5.2-5 1.1-1 5.2 5 1 1-1.1 1z" />'};this.node.innerHTML=`
|
|
242
242
|
<button type="button" title="${e}" class="waykeecom-icon-button">
|
|
243
243
|
<svg
|
|
244
244
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -332,7 +332,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
332
332
|
</label>
|
|
333
333
|
`:""}
|
|
334
334
|
</div>
|
|
335
|
-
`;let p=this.node.querySelector(`#${e}`);p&&u&&p.addEventListener("click",u)}},
|
|
335
|
+
`;let p=this.node.querySelector(`#${e}`);p&&u&&p.addEventListener("click",u)}},Ne=Yt;var Oi="waykeecom-input-label__help",Li="waykeecom-input-label__foldout",Kt=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(`.${Oi}`),s=this.node.querySelector(`.${Li}`),n=t||document.createElement("div");if(t||(n.className=Oi),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
|
|
@@ -358,12 +358,12 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
358
358
|
<path d="M8 0C3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 14c-3.3 0-6-2.7-6-6s2.7-6 6-6 6 2.7 6 6-2.7 6-6 6zm-1.4-3.8h1.9V12H6.6v-1.8zm3.8-3.4c0 1-.5 1.5-1.4 2l-.4.3c-.3.1-.3.2-.3.4v.1H6.7v-.3c0-.6.1-.9.8-1.3l.7-.4c.3-.2.6-.4.6-.8s-.3-.7-.7-.7c-.5 0-.8.3-.8.8v.3H5.7v-.4c0-1.2.8-2 2.3-2 1.5 0 2.4.7 2.4 2z" />
|
|
359
359
|
</svg>
|
|
360
360
|
</button>
|
|
361
|
-
`;n.querySelector("button")?.addEventListener("click",()=>this.onClick()),t||this.node.appendChild(n)}}},Z=Kt;var
|
|
361
|
+
`;n.querySelector("button")?.addEventListener("click",()=>this.onClick()),t||this.node.appendChild(n)}}},Z=Kt;var Qt=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){this.props.error=e,this.updateBorder(),this.contexts.error?.setError(e)}render(){let{title:e,options:t,name:s,checked:n,error:a,errorMessage:l,information:c,onClick:m,onClickInformation:u}=this.props;this.node.innerHTML=`
|
|
362
362
|
<fieldset class="waykeecom-input-group" role="radiogroup" aria-required="true">
|
|
363
363
|
${e?`<legend class="waykeecom-input-label"><div class="waykeecom-input-label__label">${e}</div></legend>`:""}
|
|
364
364
|
${t.map(p=>`<div class="waykeecom-input-group__item" id="${p.id}-node"></div>`).join("")}
|
|
365
365
|
</fieldset>
|
|
366
|
-
`,this.updateBorder(),l&&(this.contexts.error=new pe(this.node,{error:a,errorMessage:l})),t.forEach(p=>new
|
|
366
|
+
`,this.updateBorder(),l&&(this.contexts.error=new pe(this.node,{error:a,errorMessage:l})),t.forEach(p=>new Ne(this.node.querySelector(`#${p.id}-node`),{id:p.id,name:s,title:p.title||p.value,value:p.value,checked:n===p.value,description:p.description,meta:p.meta,onClick:h=>m(h)})),c&&new Z(this.node.querySelector(".waykeecom-input-label"),{information:c,onClickInformation:u})}},K=Qt;var al=({tone:o,children:i})=>`
|
|
367
367
|
<div class="waykeecom-alert ${o?`waykeecom-alert--${o}`:""}" role="alert">
|
|
368
368
|
<div class="waykeecom-alert__icon">
|
|
369
369
|
<div class="waykeecom-alert__icon-badge">
|
|
@@ -381,7 +381,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
381
381
|
${i}
|
|
382
382
|
</div>
|
|
383
383
|
</div>
|
|
384
|
-
`,I=al;var Pi="button-central-storage-proceed",Mi=`${Pi}-node`,rl="central-storage-branch",xi=`${rl}-node`,
|
|
384
|
+
`,I=al;var Pi="button-central-storage-proceed",Mi=`${Pi}-node`,rl="central-storage-branch",xi=`${rl}-node`,jt=class extends r{constructor(e,t){super(e);this.requestError=!1;this.contexts={};this.props=t,f(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 xe(t,e);d("MAIN","CENTRAL_STORAGE_SET","CENTRAL_STORAGE"),Oe(be(n),s),Ko(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"),b("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=O(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 Y(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 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
413
413
|
</div>
|
|
414
414
|
</div>
|
|
415
415
|
</div>
|
|
416
|
-
</div>`}});new K(u.querySelector(`#${xi}`),{checked:this.selectedDealer,name:"dealer",options:p,onClick:h=>this.onChange(h)}),this.contexts.proceedButton=new g(u.querySelector(`#${Mi}`),{title:"G\xE5 vidare",id:Pi,disabled:!this.selectedDealer,onClick:()=>this.onProceed()})}t.stage===a&&u.parentElement?.scrollIntoView()}},$i=
|
|
416
|
+
</div>`}});new K(u.querySelector(`#${xi}`),{checked:this.selectedDealer,name:"dealer",options:p,onClick:h=>this.onChange(h)}),this.contexts.proceedButton=new g(u.querySelector(`#${Mi}`),{title:"G\xE5 vidare",id:Pi,disabled:!this.selectedDealer,onClick:()=>this.onProceed()})}t.stage===a&&u.parentElement?.scrollIntoView()}},$i=jt;var ee=o=>o.length<2?o:o.length===2?`${o.substring(0,1)}***`:o.length===3?`${o.substring(0,2)}***`:`${o.substring(0,3)}***`,Ue=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:_,onChange:w,onBlur:D,onClickInformation:L}=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>
|
|
@@ -465,7 +465,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
465
465
|
</div>
|
|
466
466
|
<span class="waykeecom-disclaimer__text">${this.props.text}</span>
|
|
467
467
|
</div>
|
|
468
|
-
`}},ue=Xt;import{customers as Ki}from"@wayke-se/ecom";var
|
|
468
|
+
`}},ue=Xt;import{customers as Ki}from"@wayke-se/ecom";var Qi=o=>{let i=Ki.newAddressLookupRequest().forCustomer(o).build();return Ki.lookupAddress(i)};var ji=(o,i)=>o?i:"";var Zt="contact-socialId-node",Ge="contact-socialId",pl="contact-social-id-info",ul=`${Ge}-proceed`,zi=`${Ge}-proceed-node`,Ji=`${Ge}-disclaimer-node`,es={socialId:C.requiredSsnOver18},hl=o=>{let i={socialId:o?.socialId||""};return{value:i,validation:{socialId:es.socialId(i.socialId)},interact:{socialId:!1}}},ts=class extends r{constructor(e,t){super(e,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--2"});this.requestError=!1;this.contexts={};this.props=t;let s=this.props.store.getState();this.state=hl(s.customer),this.render()}async onFetchAddress(){let{store:e,lastStage:t}=this.props;this.requestError=!1,this.render();try{d("MAIN","CUSTOMER_ADDRESS_BY_SSN_REQUESTED","CUSTOMER_ADDRESS"),this.contexts.buttonFetch?.loading(!0);let s=await Qi(this.state.value.socialId);d("MAIN","CUSTOMER_ADDRESS_BY_SSN_SUCCEEDED","CUSTOMER_ADDRESS");let n=s.getAddress();Wo(this.state.value.socialId.replace(Fe,""),n,t)(e.dispatch),d("MAIN","CUSTOMER_ADDRESS_SET","CUSTOMER_ADDRESS")}catch{this.requestError=!0,d("MAIN","CUSTOMER_ADDRESS_BY_SSN_FAILED","CUSTOMER_ADDRESS")}finally{this.contexts.buttonFetch?.loading(!1),this.render()}}onChange(e){let t=e.currentTarget,s=t.name,n=t.value;this.state.value[s]=n,this.state.validation[s]=es[s](n),this.updateUiError(s),this.updateProceedButton()}onBlur(e){let s=e.currentTarget.name;this.state.interact[s]=!0,this.state.validation[s]=es[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.buttonFetch?.disabled(!this.state.validation.socialId)}render(){let e="https://www.wayke.se/trygghet-naer-det-kommer-till-dina-personuppgifter";this.node.innerHTML=`
|
|
469
469
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
470
470
|
<hr class="waykeecom-separator" />
|
|
471
471
|
</div>
|
|
@@ -478,7 +478,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
478
478
|
</div>
|
|
479
479
|
<div class="waykeecom-stack waykeecom-stack--3" id="${Zt}"></div>
|
|
480
480
|
|
|
481
|
-
${
|
|
481
|
+
${ji(this.requestError,`
|
|
482
482
|
<div class="waykeecom-stack waykeecom-stack--3" id="${Zt}">
|
|
483
483
|
${I({tone:"error",children:"Tyv\xE4rr fick vi ingen tr\xE4ff p\xE5 personnumret du angav."})}
|
|
484
484
|
</div>`)}
|
|
@@ -521,7 +521,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
521
521
|
</div>
|
|
522
522
|
|
|
523
523
|
<div class="waykeecom-stack waykeecom-stack--3" id="${an}"></div>
|
|
524
|
-
`,s.order.deliveryOptions.forEach(p=>{let h=s.address?.distance,y=tn(h,p)||0;switch(p.type){case sn.Pickup:new
|
|
524
|
+
`,s.order.deliveryOptions.forEach(p=>{let h=s.address?.distance,y=tn(h,p)||0;switch(p.type){case sn.Pickup:new Ne(m.querySelector(`#${nn}`),{id:rn,name:"homeDelivery",title:"H\xE4mta hos handlaren",value:"false",description:`
|
|
525
525
|
<div class="waykeecom-box">
|
|
526
526
|
<div class="waykeecom-icon-content">
|
|
527
527
|
<div class="waykeecom-icon-content__icon">
|
|
@@ -542,9 +542,9 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
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:L=>this.onChange(L)});break;case sn.Delivery:let _=s.address?.distance?.value||0,w=p.unitPrice||0,D=_>w;new
|
|
545
|
+
`,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${y===0?"Gratis":k(y,{postfix:"kr"})}</div>`,checked:!this.homeDelivery,onClick:L=>this.onChange(L)});break;case sn.Delivery:let _=s.address?.distance?.value||0,w=p.unitPrice||0,D=_>w;new Ne(m.querySelector(`#${on}`),{id:cn,name:"homeDelivery",title:"Hemleverans",value:"true",disabled:D,description:`<div class="waykeecom-box">
|
|
546
546
|
<div class="waykeecom-stack waykeecom-stack--2">Till din folkbokf\xF6ringsadress</div>
|
|
547
|
-
${D?`<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">${D?"-":k(y,{postfix:"kr"})}</div>`,checked:this.homeDelivery,onClick:L=>this.onChange(L)});break;default:break}}),new g(m.querySelector(`#${an}`),{title:"G\xE5 vidare",id:ln,onClick:()=>this.onProceed()}),c.appendChild(m),s.navigation.stage===t&&c.parentElement?.scrollIntoView()}}},dn=is;import{PaymentType as P}from"@wayke-se/ecom";import{DrivingDistance as
|
|
547
|
+
${D?`<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">${D?"-":k(y,{postfix:"kr"})}</div>`,checked:this.homeDelivery,onClick:L=>this.onChange(L)});break;default:break}}),new g(m.querySelector(`#${an}`),{title:"G\xE5 vidare",id:ln,onClick:()=>this.onProceed()}),c.appendChild(m),s.navigation.stage===t&&c.parentElement?.scrollIntoView()}}},dn=is;import{PaymentType as P}from"@wayke-se/ecom";import{DrivingDistance as Ae}from"@wayke-se/ecom";var he={bankid:"https://cdn.wayke.se/public-assets/bankid-logo.svg",illustrations:{payment:"https://cdn.wayke.se/public-assets/payment.svg"}},ke={["VeryGood"]:"Mycket bra",["Good"]:"Bra",["Ok"]:"Ok"},Q={[Ae.Between0And1000]:"0\u20131000 mil",[Ae.Between1000And1500]:"1000\u20131500 mil",[Ae.Between1500And2000]:"1500\u20132000 mil",[Ae.Between2000And2500]:"2000\u20132500 mil",[Ae.Over2500]:"2500+ mil"};var vl=(o,i)=>i?Math.round(o/i)*i:o,ns=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=vl(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 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
585
585
|
</div>
|
|
586
586
|
`:""}
|
|
587
587
|
</div>
|
|
588
|
-
`,a&&new Z(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=ns;import{payments as mn}from"@wayke-se/ecom";var pn=({vehicleId:o,dealerId:i,downPayment:e,duration:t,residual:s})=>{let n=mn.newLookupRequest().forVehicle(o).withDownPayment(e).withDuration(t);return s!==void 0&&n.withResidualValue(s),i!==void 0&&n.forDealer(i),mn.lookupPayment(n.build())};import{AuthMethod as
|
|
588
|
+
`,a&&new Z(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=ns;import{payments as mn}from"@wayke-se/ecom";var pn=({vehicleId:o,dealerId:i,downPayment:e,duration:t,residual:s})=>{let n=mn.newLookupRequest().forVehicle(o).withDownPayment(e).withDuration(t);return s!==void 0&&n.withResidualValue(s),i!==void 0&&n.forDealer(i),mn.lookupPayment(n.build())};import{AuthMethod as Ie,Employment as ne,MaritalStatus as gs,PaymentType as Fn}from"@wayke-se/ecom";var as=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}"
|
|
@@ -669,7 +669,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
669
669
|
${this.props.text}
|
|
670
670
|
</div>
|
|
671
671
|
</div>
|
|
672
|
-
`}},Ee=ps;import{creditAssessment as Il}from"@wayke-se/ecom";var
|
|
672
|
+
`}},Ee=ps;import{creditAssessment as Il}from"@wayke-se/ecom";var Te=o=>Il.cancelSigning(o);import{creditAssessment as fl}from"@wayke-se/ecom";var En=o=>fl.getStatus(o);import{creditAssessment as _l}from"@wayke-se/ecom";var In=o=>_l.newCase(o);import{creditAssessment as gl}from"@wayke-se/ecom";var fn=o=>gl.signCase(o);import{CreditAssessmentRecommendation as Hn}from"@wayke-se/ecom";import{CreditAssessmentRecommendation as Sl}from"@wayke-se/ecom";import{CreditAssessmentRecommendation as _n,PaymentType as wl}from"@wayke-se/ecom";var us=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,decision:t}=this.props,s=e.getState(),{order:n}=s,a=n?.paymentOptions.find(c=>c.type===wl.Loan),l=n?.contactInformation;t===_n.Approve?this.node.innerHTML=`
|
|
673
673
|
${I({tone:"success",children:`
|
|
674
674
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
675
675
|
<p class="waykeecom-content__p"><string>Grattis! Din l\xE5neans\xF6kan har beviljats av ${a?.name}.</strong></p>
|
|
@@ -721,7 +721,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
721
721
|
`,a&&this.node.querySelector("button")?.addEventListener("click",a)}},Ke=ys;var Dl="assessment-rejected-result",Mn=`${Dl}-node`,Pn="assessment-rejected-abort",xn=`${Pn}-node`,vs=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,onGoBack:t}=this.props;this.node.innerHTML=`
|
|
722
722
|
<div class="waykeecom-stack waykeecom-stack--4" id="${Mn}"></div>
|
|
723
723
|
<div class="waykeecom-stack waykeecom-stack--4" id="${xn}"></div>
|
|
724
|
-
`,new te(this.node.querySelector(`#${Mn}`),{store:e,decision:Cl.Reject}),new Ke(this.node.querySelector(`#${xn}`),{title:"G\xE5 tillbaka",id:Pn,onClick:()=>t()})}},$n=vs;var Es=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===Hn.Approve?new Tn(this.node,{store:e,onProceed:()=>s(),onGoBack:()=>n()}):a===Hn.AssessManually?new Ln(this.node,{store:e,onProceed:()=>s(),onGoBack:()=>n()}):new $n(this.node,{store:e,onGoBack:()=>n()})}},Bn=Es;var Rl=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`},Un=Rl;var
|
|
724
|
+
`,new te(this.node.querySelector(`#${Mn}`),{store:e,decision:Cl.Reject}),new Ke(this.node.querySelector(`#${xn}`),{title:"G\xE5 tillbaka",id:Pn,onClick:()=>t()})}},$n=vs;var Es=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===Hn.Approve?new Tn(this.node,{store:e,onProceed:()=>s(),onGoBack:()=>n()}):a===Hn.AssessManually?new Ln(this.node,{store:e,onProceed:()=>s(),onGoBack:()=>n()}):new $n(this.node,{store:e,onGoBack:()=>n()})}},Bn=Es;var Rl=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`},Un=Rl;var Qe={},Ce=(o,i)=>{Qe[o]=i},Is=()=>{Object.keys(Qe).forEach(o=>{clearInterval(Qe[o]),delete Qe[o]})};var bl="credit-assessment-martial-status",Vn=`${bl}-node`,ws="credit-assessment-income",fs=`${ws}-node`,Ol="credit-assessment-employment",Gn=`${Ol}-node`,Jn="credit-assessment-household-children",qn=`${Jn}-node`,Xn="credit-assessment-household-income",Wn=`${Xn}-node`,Zn="credit-assessment-household-housing-cost",Yn=`${Zn}-node`,ea="credit-assessment-household-debt",Kn=`${ea}-node`,ta="credit-assessment-perform-application",_s=`${ta}-node`,Qn="disclaimer-node",jn="disclaimer-safe-node",zn="why-description-node",j={maritalStatus:C.requiredAssessmentMaritalStatus,income:C.requiredNumber,employment:C.requiredAssessmentEmplyment,householdChildren:C.requiredNumber,householdIncome:C.requiredNumber,householdHousingCost:C.requiredNumber,householdDebt:C.requiredNumber},Ll={maritalStatus:gs.Married,income:5e4,employment:ne.FullTimeEmployed,householdChildren:0,householdDebt:0,householdHousingCost:2e3,householdIncome:1e5},Ml=()=>location.hostname==="localhost"?{...Ll}:void 0,xl=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:j.maritalStatus(i.maritalStatus),income:j.income(i.income),employment:j.employment(i.employment),householdChildren:j.householdChildren(i.householdChildren),householdIncome:j.householdIncome(i.householdIncome),householdHousingCost:j.householdHousingCost(i.householdHousingCost),householdDebt:j.householdDebt(i.householdDebt)},interact:{maritalStatus:!1,income:!1,employment:!1,householdChildren:!1,householdIncome:!1,householdHousingCost:!1,householdDebt:!1}}},Ss=class extends r{constructor(e,t){super(e);this.view=1;this.contexts={};this.bankidError=!1;this.signed=!1;this.props=t,this.state=xl(Ml()),this.render()}onChange(e){let t=e.currentTarget,s=t.name,n=t.value;this.state.value[s]=n,this.state.validation[s]=j[s](n),this.updateUiError(s),this.updateProceedButton()}onBlur(e){let s=e.currentTarget.name;this.state.interact[s]=!0,this.state.validation[s]=j[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]=j[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&&(Te(t),ce()(e.dispatch)),R(),this.creditAssessmentResponse=void 0,this.render(!0)}bankIdStatus(e,t,s=!1){s||d("MAIN",t===Ie.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===Fn.Loan);this.bankidStatusInterval=setInterval(async()=>{try{let a=await En(e),l=a.getStatus();if(!this.signed&&l==="signed"&&(d("MAIN",t===Ie.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=Uo(a),ce(e,this.creditAssessmentResponse)(this.props.store.dispatch),R(),this.render()):a.hasScoringError()&&(clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Ett fel uppstod")),!this.signed&&t===Ie.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),Ce("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 fn({caseId:s,method:e});if(t||d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.bankIdStatus(s,e,t),e===Ie.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,R(),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 Te(s),ce()(t.dispatch))),s)ce(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&&(ce(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:Un(m)}};return(await In(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=ye(),{order:l}=t.getState(),c=l?.paymentOptions.find(p=>p.type===Fn.Loan),m=s.creditAmount,u=l?.contactInformation?.name;this.view===3&&this.creditAssessmentResponse?new Bn(q(),{store:t,creditAssessmentResponse:this.creditAssessmentResponse,onProceed:()=>{R(),n()},onGoBack:()=>this.onAbort()}):this.view===2?(this.contexts.bankId=new Ye(q(),{method:a?Ie.SameDevice:Ie.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)}),B()):(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">
|
|
@@ -784,8 +784,8 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
784
784
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
785
785
|
<div class="waykeecom-stack waykeecom-stack--2" id="${_s}"></div>
|
|
786
786
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
787
|
-
<div class="waykeecom-stack waykeecom-stack--1" id="${jn}"></div>
|
|
788
787
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Qn}"></div>
|
|
788
|
+
<div class="waykeecom-stack waykeecom-stack--1" id="${jn}"></div>
|
|
789
789
|
</div>
|
|
790
790
|
</div>
|
|
791
791
|
`,this.contexts.maritalStatus=new K(this.node.querySelector(`#${Vn}`),{title:"Civilst\xE5nd",checked:this.state.value.maritalStatus,name:"maritalStatus",options:[{id:`maritalStatus-${1}`,value:gs.Married,title:"Gift eller sambo"},{id:`maritalStatus-${2}`,value:gs.Single,title:"Ensamst\xE5ende"}],onClick:p=>this.onChangeRadio(p)}),this.contexts.income=new x(this.node.querySelector(`#${fs}`),{title:"Inkomst per m\xE5nad f\xF6re skatt",value:this.state.value.income,id:ws,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 K(this.node.querySelector(`#${Gn}`),{title:"Syssels\xE4ttning",checked:this.state.value.employment,name:"employment",options:[{id:`employment-${1}`,value:ne.FullTimeEmployed,title:"Fast- eller tillsvidareanst\xE4lld"},{id:`employment-${2}`,value:ne.TemporarilyEmployed,title:"Visstidsanst\xE4lld"},{id:`employment-${3}`,value:ne.SelfEmployed,title:"Egen f\xF6retagare"},{id:`employment-${4}`,value:ne.Retired,title:"Pension\xE4r"},{id:`employment-${5}`,value:ne.Student,title:"Student"},{id:`employment-${6}`,value:ne.Other,title:"Annan"}],onClick:p=>this.onChangeRadio(p)}),this.contexts.income=new x(this.node.querySelector(`#${fs}`),{title:"Inkomst per m\xE5nad f\xF6re skatt",value:this.state.value.income,id:ws,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 x(this.node.querySelector(`#${qn}`),{title:"Antal hemmavarande barn",value:this.state.value.householdChildren,id:Jn,error:this.state.interact.householdChildren&&!this.state.validation.householdChildren,errorMessage:"Ange antal hemmavarande barn",name:"householdChildren",autocomplete:"off",placeholder:"",type:"number",information:`
|
|
@@ -828,7 +828,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
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 ve(this.node.querySelector(`#${_s}`),{title:"Genomf\xF6r l\xE5neans\xF6kan",id:ta,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 Ee(this.node.querySelector(`#${
|
|
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 ve(this.node.querySelector(`#${_s}`),{title:"Genomf\xF6r l\xE5neans\xF6kan",id:ta,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 Ee(this.node.querySelector(`#${Qn}`),{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 ue(this.node.querySelector(`#${jn}`),{text:"Dina uppgifter lagras och sparas s\xE4kert."}),new We(this.node.querySelector(`#${zn}`),{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">
|
|
@@ -977,7 +977,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
977
977
|
</div>
|
|
978
978
|
</div>
|
|
979
979
|
</div>
|
|
980
|
-
`,this.contexts.loanDetailsMontlyCost=new ra(this.node.querySelector(`#${ca}`),{monthlyCost:y}),this.contexts.pieChart=new oa(this.node.querySelector(`#${la}`),{percentage:w}),this.contexts.loanDetailsBasic=new ia(this.node.querySelector(`#${da}`),{downPayment:t,creditAmount:m,downPaymentPercentage:_,creditAmountPercentage:w}),this.contexts.loanDetailsDetailed=new aa(this.node.querySelector(`#${ma}`),{duration:e,administrationFee:s,setupFee:n,totalCreditCost:a,interest:l,effectiveInterest:c,publicUrl:u,loanOrgName:p})}},pa=Ds;var Rs=class extends r{constructor(e,t){super(e);this.props=t,this.error=t.error,this.render()}update(e){this.error=e,this.render()}render(){if(!this.error){this.node.innerHTML="";return}this.node.innerHTML=I({tone:"error",children:this.error})}},ua=Rs;var ha="downpayment-range-node",Pl="downpayment-range",ka="duration-range-node",$l="duration-range",ya="residual-range-node",Hl="residual-range",Bl="loan-details",va=`${Bl}-node`,Ea="credit-assessment-node",_a="credit-assessment-proceed",Ia=`${_a}-node`,fa="loan-error-node",bs=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t;let s=this.props.loan.loanDetails;if(!s)throw"err";this.paymentLookupResponse=this.props.paymentLookupResponse||s,this.paymentState={vehicleId:this.props.vehicleId,dealerId:"",downPayment:this.paymentLookupResponse.downPaymentSpec,duration:this.paymentLookupResponse.durationSpec,residual:this.paymentLookupResponse.residualValueSpec},this.previousState=JSON.parse(JSON.stringify(this.paymentState)),this.render()}async payment(){this.contexts.downPayment?.disabled(!0),this.contexts.duration?.disabled(!0),this.contexts.residual?.disabled(!0),this.contexts.proceedButton?.disabled(!0);try{let e=await pn({vehicleId:this.paymentState.vehicleId,downPayment:this.paymentState.downPayment.current,duration:this.paymentState.duration.current,residual:this.paymentState.residual?.current});this.previousState=JSON.parse(JSON.stringify(this.paymentState)),this.paymentLookupResponse=
|
|
980
|
+
`,this.contexts.loanDetailsMontlyCost=new ra(this.node.querySelector(`#${ca}`),{monthlyCost:y}),this.contexts.pieChart=new oa(this.node.querySelector(`#${la}`),{percentage:w}),this.contexts.loanDetailsBasic=new ia(this.node.querySelector(`#${da}`),{downPayment:t,creditAmount:m,downPaymentPercentage:_,creditAmountPercentage:w}),this.contexts.loanDetailsDetailed=new aa(this.node.querySelector(`#${ma}`),{duration:e,administrationFee:s,setupFee:n,totalCreditCost:a,interest:l,effectiveInterest:c,publicUrl:u,loanOrgName:p})}},pa=Ds;var Rs=class extends r{constructor(e,t){super(e);this.props=t,this.error=t.error,this.render()}update(e){this.error=e,this.render()}render(){if(!this.error){this.node.innerHTML="";return}this.node.innerHTML=I({tone:"error",children:this.error})}},ua=Rs;var ha="downpayment-range-node",Pl="downpayment-range",ka="duration-range-node",$l="duration-range",ya="residual-range-node",Hl="residual-range",Bl="loan-details",va=`${Bl}-node`,Ea="credit-assessment-node",_a="credit-assessment-proceed",Ia=`${_a}-node`,fa="loan-error-node",bs=class extends r{constructor(e,t){super(e);this.contexts={};this.props=t;let s=this.props.loan.loanDetails;if(!s)throw"err";this.paymentLookupResponse=this.props.paymentLookupResponse||s,this.paymentState={vehicleId:this.props.vehicleId,dealerId:"",downPayment:this.paymentLookupResponse.downPaymentSpec,duration:this.paymentLookupResponse.durationSpec,residual:this.paymentLookupResponse.residualValueSpec},this.previousState=JSON.parse(JSON.stringify(this.paymentState)),this.render()}async payment(){this.contexts.downPayment?.disabled(!0),this.contexts.duration?.disabled(!0),this.contexts.residual?.disabled(!0),this.contexts.proceedButton?.disabled(!0);try{let e=await pn({vehicleId:this.paymentState.vehicleId,downPayment:this.paymentState.downPayment.current,duration:this.paymentState.duration.current,residual:this.paymentState.residual?.current});this.previousState=JSON.parse(JSON.stringify(this.paymentState)),this.paymentLookupResponse=_e(e),this.paymentState={...this.paymentState,downPayment:this.paymentLookupResponse.downPaymentSpec,duration:this.paymentLookupResponse.durationSpec,residual:this.paymentLookupResponse.residualValueSpec},zo(e)(this.props.store.dispatch),this.update(),this.contexts.errorAlert?.update(void 0),this.contexts.downPayment?.update(this.paymentState.downPayment.current,this.paymentState.downPayment.min,this.paymentState.downPayment.max),this.contexts.residual?.update(parseInt(`${this.paymentState.residual.current*100}`,10),parseInt(`${this.paymentState.residual.min*100}`,10),parseInt(`${this.paymentState.residual.max*100}`,10)),this.contexts.duration?.update(this.paymentState.duration.current,this.paymentState.duration.min,this.paymentState.duration.max)}catch{this.contexts.errorAlert?.update("Ett fel uppstod, f\xF6rs\xF6k igen."),this.contexts.downPayment?.disabled(!1),this.contexts.duration?.disabled(!1),this.contexts.residual?.disabled(!1),this.contexts.downPayment?.update(this.previousState.downPayment.current,this.previousState.downPayment.min,this.previousState.downPayment.max),this.contexts.residual?.update(parseInt(`${this.previousState.residual.current*100}`,10),parseInt(`${this.previousState.residual.min*100}`,10),parseInt(`${this.previousState.residual.max*100}`,10)),this.contexts.duration?.update(this.previousState.duration.current,this.previousState.duration.min,this.previousState.duration.max)}finally{this.contexts.downPayment?.disabled(!1),this.contexts.duration?.disabled(!1),this.contexts.residual?.disabled(!1),this.contexts.proceedButton?.disabled(!1)}}onChange(e){let t=e.currentTarget,s=t.name,n=t.value;t.value=n,this.paymentState[s].current=s==="residual"?parseInt(n,10)/100:parseInt(n,10),this.payment()}update(){this.contexts.loanDetails?.update({loan:this.props.loan,paymentLookupResponse:this.paymentLookupResponse})}render(){let{store:e,loan:t,onProceed:s}=this.props,{order:n}=e.getState(),a=n?.contactInformation?.name,l=t.loanDetails?.shouldUseCreditScoring;this.node.innerHTML=`
|
|
981
981
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
982
982
|
<hr class="waykeecom-separator" />
|
|
983
983
|
</div>
|
|
@@ -1041,7 +1041,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
1041
1041
|
</div>
|
|
1042
1042
|
</div>
|
|
1043
1043
|
`:""}
|
|
1044
|
-
`;a&&this.node.querySelector("button")?.addEventListener("click",()=>a())}},Na=Os;var Ra="button-financial-proceed",Aa=`${Ra}-node`,Fl="financial-option",Ta=`${Fl}-node`,Vl="financial-option-second",Ca=`${Vl}-node`,Gl="radio-financial-cash",ql="radio-financial-loan",Wl="radio-financial-lease",Da="payment-node",Ls=class extends r{constructor(e,t){super(e);this.props=t,f(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.Cash:d("MAIN","FINANCIAL_CASH_SELECTED","FINANCIAL");break;case P.Lease:d("MAIN","FINANCIAL_LEASE_SELECTED","FINANCIAL");case P.Loan:d("MAIN","FINANCIAL_LOAN_SELECTED","FINANCIAL");default:break}}onProceed(){if(this.paymentType){switch(this.paymentType){case P.Cash:d("MAIN","FINANCIAL_CASH_SET","FINANCIAL");break;case P.Lease:d("MAIN","FINANCIAL_LEASE_SET","FINANCIAL");case P.Loan:d("MAIN","FINANCIAL_LOAN_SET","FINANCIAL");default:break}
|
|
1044
|
+
`;a&&this.node.querySelector("button")?.addEventListener("click",()=>a())}},Na=Os;var Ra="button-financial-proceed",Aa=`${Ra}-node`,Fl="financial-option",Ta=`${Fl}-node`,Vl="financial-option-second",Ca=`${Vl}-node`,Gl="radio-financial-cash",ql="radio-financial-loan",Wl="radio-financial-lease",Da="payment-node",Ls=class extends r{constructor(e,t){super(e);this.props=t,f(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.Cash:d("MAIN","FINANCIAL_CASH_SELECTED","FINANCIAL");break;case P.Lease:d("MAIN","FINANCIAL_LEASE_SELECTED","FINANCIAL");case P.Loan:d("MAIN","FINANCIAL_LOAN_SELECTED","FINANCIAL");default:break}}onProceed(){if(this.paymentType){switch(this.paymentType){case P.Cash:d("MAIN","FINANCIAL_CASH_SET","FINANCIAL");break;case P.Lease:d("MAIN","FINANCIAL_LEASE_SET","FINANCIAL");case P.Loan:d("MAIN","FINANCIAL_LOAN_SET","FINANCIAL");default:break}jo(this.paymentType,this.props.lastStage)(this.props.store.dispatch)}}onEdit(){d("MAIN","FINANCIAL_EDIT","FINANCIAL"),b("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=O(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.Loan);new Na(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(M=>M.type===P.Cash),y=l.find(M=>M.type===P.Loan),_=l.find(M=>M.type===P.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} ${le(p)}?</h4>
|
|
1047
1047
|
</div>
|
|
@@ -1135,7 +1135,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
1135
1135
|
<div class="waykeecom-input-selection" role="checkbox">
|
|
1136
1136
|
${h}
|
|
1137
1137
|
</div>
|
|
1138
|
-
`;let y=this.node.querySelector(`#${e}`);y&&p&&y.addEventListener("click",p)}},
|
|
1138
|
+
`;let y=this.node.querySelector(`#${e}`);y&&p&&y.addEventListener("click",p)}},je=xs;var Ps=class extends r{constructor(e,t){super(e);this.props=t,this.render()}isDisabled(){return this.props.disabled}disabled(e){this.props.disabled!==e&&(this.props.disabled=e,this.render())}loading(e){this.props.loading!==e&&(this.props.loading=e,this.props.disabled=e,this.render())}render(){let{title:e,id:t,disabled:s,loading:n,onClick:a}=this.props;this.node.innerHTML=`
|
|
1139
1139
|
<button
|
|
1140
1140
|
type="button"
|
|
1141
1141
|
${t?`id="${t}"`:""}
|
|
@@ -1149,7 +1149,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
1149
1149
|
${T({type:"inline"})}
|
|
1150
1150
|
</span>`:""}
|
|
1151
1151
|
</button>
|
|
1152
|
-
`,a&&this.node.querySelector("button")?.addEventListener("click",a)}},xa=Ps;var $s=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}}},Pa=$s;var Hs=class extends Pa{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")}},$a=Hs;var Bs="insurance-button-top-left-node",Ha="insurance-button-bottom-left-node",Us="insurance-add-remove-node",Ba="insurance-addons-node",Ua="insurance-accordion-node",
|
|
1152
|
+
`,a&&this.node.querySelector("button")?.addEventListener("click",a)}},xa=Ps;var $s=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}}},Pa=$s;var Hs=class extends Pa{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")}},$a=Hs;var Bs="insurance-button-top-left-node",Ha="insurance-button-bottom-left-node",Us="insurance-add-remove-node",Ba="insurance-addons-node",Ua="insurance-accordion-node",fe=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=fe.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"),Xo(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=fe.containChanges(this.initialAddons,this.addons);if(this.node.innerHTML=`
|
|
1153
1153
|
<div class="waykeecom-nav-banner" id="${Bs}"></div>
|
|
1154
1154
|
|
|
1155
1155
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
@@ -1192,7 +1192,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
1192
1192
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Us}"></div>
|
|
1193
1193
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Ha}"></div>
|
|
1194
1194
|
</div>
|
|
1195
|
-
`,new ie(this.node.querySelector(`#${Bs}`),{title:"Tillbaka",onClick:()=>s()}),u?.length){let h=this.node.querySelector(`#${Ba}`);u.forEach(y=>{let _=new $a(h);this.contexts.checkboxes[y.name]=new
|
|
1195
|
+
`,new ie(this.node.querySelector(`#${Bs}`),{title:"Tillbaka",onClick:()=>s()}),u?.length){let h=this.node.querySelector(`#${Ba}`);u.forEach(y=>{let _=new $a(h);this.contexts.checkboxes[y.name]=new je(_.render(),{id:y.name,name:y.name,title:y.title,meta:`<div class="waykeecom-text waykeecom-text--font-bold">${k(y.monthlyPrice,{postfix:"kr/m\xE5n"})}</div>`,description:`<div class="waykeecom-text waykeecom-text--tone-alt">${y.description}</div>`,append:!0,value:y.name,checked:this.addons.findIndex(w=>w.name===y.name)>-1,onClick:w=>this.onClick(w)})})}if(m?.length){let h=this.node.querySelector(`#${Ua}`);m.forEach(y=>new We(h,{id:y.name,title:y.name,description:y.description,append:!0}))}new ie(this.node.querySelector(`#${Bs}`),{title:"Tillbaka",onClick:()=>s()}),new X(this.node.querySelector(`#${Ha}`),{title:"Tillbaka",onClick:()=>s()}),t?this.contexts.updateButton=new xa(this.node.querySelector(`#${Us}`),{title:t?"Uppdatera":"V\xE4lj",disabled:t?!p:void 0,onClick:()=>this.onUpdate()}):this.contexts.updateButton=new J(this.node.querySelector(`#${Us}`),{selected:!1,fullSize:!0,disabled:t?!p:void 0,onClick:()=>this.onUpdate()}),B()}},Fa=fe;var Fs=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.props=t,f(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,R(),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"),re(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 Fa(q(),{store:this.props.store,insurance:t,selected:c,onClose:()=>this.onInfoClose()}),new me(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)}},Va=Fs;var Vs=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,insurances:t}=this.props,s=new de(this.node,{id:"insurance-list",onClick:()=>d("MAIN","INSURANCE_ARROW","INSURANCE_IF")}),{overflowElement:n}=s;n&&(n.innerHTML="",t.forEach((a,l)=>new Va(n,{store:e,insurance:a,key:`insurance-${l}`})))}},Ga=Vs;var Gs="insurance-grid-list-node",Yl="button-insurances-proceed",qa=`${Gs}-node`,Qa="button-insurances-skip",Wa=`${Qa}-node`,ja="button-insurance-edit-driving-distance",Ya=`${ja}-node`,Ka={},qs=class extends r{constructor(e,t){super(e);this.requestError=!1;this.contexts={listners:[]};this.props=t;let s=f(this.props.store,"drivingDistance",()=>{this.fetchInsurance()});this.contexts.listners.push(s);let n=f(this.props.store,"customer.socialId",()=>{this.fetchInsurance()});this.contexts.listners.push(n);let a=f(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=Ka[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 Ma(this.props.store,e.drivingDistance);d("MAIN","INSURANCE_GET_INSURANCES_SUCCEEDED","INSURANCE_IF"),this.insurances=n.getInsuranceOptions(),Ka[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"),re()(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">
|
|
@@ -1202,7 +1202,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
1202
1202
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1203
1203
|
<div class="waykeecom-stack waykeecom-stack--1">
|
|
1204
1204
|
<ul class="waykeecom-key-value-list">
|
|
1205
|
-
${E({key:"Uppskattad k\xF6rstr\xE4cka",value:
|
|
1205
|
+
${E({key:"Uppskattad k\xF6rstr\xE4cka",value:Q[n]})}
|
|
1206
1206
|
</ul>
|
|
1207
1207
|
</div>
|
|
1208
1208
|
<div class="waykeecom-stack waykeecom-stack--1">
|
|
@@ -1216,7 +1216,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
1216
1216
|
<div class="waykeecom-stack waykeecom-stack--1" id="${qa}"></div>
|
|
1217
1217
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Wa}"></div>
|
|
1218
1218
|
</div>
|
|
1219
|
-
`;let a=this.node.querySelector(`#${Gs}`);if(a)if(this.requestError)a.innerHTML=I({tone:"error",children:'Det gick inte att h\xE4mta f\xF6rs\xE4kringar. <button type="button" titlte="F\xF6rs\xF6k igen" class="waykeecom-link waykeecom-link--align-baseline waykeecom-link--current-color">Klicka h\xE4r f\xF6r att f\xF6rs\xF6ka igen</button>.'}),a.querySelector("button")?.addEventListener("click",()=>this.getInsurances());else{let l=this.insurances;l?.length?new Ga(a,{store:e,insurances:l}):a.innerHTML=T()}new H(this.node.querySelector(`#${Ya}`),{id:
|
|
1219
|
+
`;let a=this.node.querySelector(`#${Gs}`);if(a)if(this.requestError)a.innerHTML=I({tone:"error",children:'Det gick inte att h\xE4mta f\xF6rs\xE4kringar. <button type="button" titlte="F\xF6rs\xF6k igen" class="waykeecom-link waykeecom-link--align-baseline waykeecom-link--current-color">Klicka h\xE4r f\xF6r att f\xF6rs\xF6ka igen</button>.'}),a.querySelector("button")?.addEventListener("click",()=>this.getInsurances());else{let l=this.insurances;l?.length?new Ga(a,{store:e,insurances:l}):a.innerHTML=T()}new H(this.node.querySelector(`#${Ya}`),{id:ja,title:"\xC4ndra",onClick:()=>this.onEditDrivingDistance()}),this.contexts.buttonProceed=new g(this.node.querySelector(`#${qa}`),{id:Yl,disabled:!s,title:"G\xE5 vidare",onClick:()=>this.onProceed()}),new G(this.node.querySelector(`#${Wa}`),{id:Qa,title:"Hoppa \xF6ver detta steg",onClick:()=>this.onSkipInsurances()})}},za=qs;var sr="select-insurance-distance",Ja=`${sr}-node`,Xa="insurance-info-node",Ys="button-insurances-show",Za=`${Ys}-node`,er=`${Ys}-disclaimer-node`,or="button-insurances-skip",tr=`${or}-node`,Ws=class extends r{constructor(e,t){super(e);this.showInsurances=!1;this.props=t,this.showInsurances=!!this.props.store.getState().insurance,this.render()}onChangeDistance(e){this.showInsurances=!1;let s=e.currentTarget.value;switch(Jo(s)(this.props.store.dispatch),s){case $.Between0And1000:d("MAIN","INSURANCE_MILEAGE_BETWEEN_0_AND_1000_SELECTED","INSURANCE_IF");break;case $.Between1000And1500:d("MAIN","INSURANCE_MILEAGE_BETWEEN_1000_AND_1500_SELECTED","INSURANCE_IF");break;case $.Between1500And2000:d("MAIN","INSURANCE_MILEAGE_BETWEEN_1500_AND_2000_SELECTED","INSURANCE_IF");break;case $.Between2000And2500:d("MAIN","INSURANCE_MILEAGE_BETWEEN_2000_AND_2500_SELECTED","INSURANCE_IF");break;case $.Over2500:d("MAIN","INSURANCE_MILEAGE_OVER_2500_SELECTED","INSURANCE_IF");break;default:break}}onShowInsurances(){this.showInsurances=!0,d("MAIN","INSURANCE_SHOW","INSURANCE_IF"),this.render()}onEdit(){this.showInsurances=!1,d("MAIN","INSURANCE_EDIT_MILEAGE","INSURANCE_IF"),this.render()}render(){let{store:e,lastStage:t,onSkip:s}=this.props,n=e.getState(),a=n.order?.insuranceOption?.title||"[Ok\xE4nt f\xF6rs\xE4kringsbolag]";if(this.showInsurances)new za(this.node,{store:e,lastStage:t,onEdit:()=>this.onEdit()});else{this.node.innerHTML=`
|
|
1220
1220
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1221
1221
|
<h4 class="waykeecom-heading waykeecom-heading--4">Vill du teckna en f\xF6rs\xE4kring p\xE5 din nya bil?</h4>
|
|
1222
1222
|
<div class="waykeecom-content">
|
|
@@ -1232,7 +1232,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
1232
1232
|
<div class="waykeecom-stack waykeecom-stack--1" id="${tr}"></div>
|
|
1233
1233
|
<div class="waykeecom-stack waykeecom-stack--1" id="${er}"></div>
|
|
1234
1234
|
</div>
|
|
1235
|
-
`,new Oa(this.node.querySelector(`#${Ja}`),{id:sr,title:"Visa f\xF6rs\xE4kringar",name:"distance",value:n.drivingDistance,options:[{value:$.Between0And1000,title:
|
|
1235
|
+
`,new Oa(this.node.querySelector(`#${Ja}`),{id:sr,title:"Visa f\xF6rs\xE4kringar",name:"distance",value:n.drivingDistance,options:[{value:$.Between0And1000,title:Q[$.Between0And1000]},{value:$.Between1000And1500,title:Q[$.Between1000And1500]},{value:$.Between1500And2000,title:Q[$.Between1500And2000]},{value:$.Between2000And2500,title:Q[$.Between2000And2500]},{value:$.Over2500,title:Q[$.Over2500]}],onChange:c=>this.onChangeDistance(c)}),new g(this.node.querySelector(`#${Za}`),{id:Ys,title:"Visa f\xF6rs\xE4kringar",onClick:()=>this.onShowInsurances()});let l=this.node.querySelector(`#${Xa}`);l&&(l.innerHTML=I({tone:"info",children:`Vi \xE4r anknutna f\xF6rs\xE4kringsf\xF6rmedlare till ${a}, If Skadef\xF6rs\xE4kring. F\xF6rs\xE4kringsgivare \xE4r If Skadef\xF6rs\xE4kring (publ). Vad detta inneb\xE4r kan du l\xE4sa mer om p\xE5 f\xF6rs\xE4kringsf\xF6rmedlarens hemsida.`})),new Ee(this.node.querySelector(`#${er}`),{text:`Genom att du klickar p\xE5 Visa f\xF6rs\xE4kringar s\xE5 godk\xE4nner du att vi skickar dina uppgifter vidare till ${a} f\xF6r att de ska kunna ge dig ett pris p\xE5 f\xF6rs\xE4kring. Hur de hanterar dina personuppgifter kan du l\xE4sa om p\xE5 deras hemsida.`}),new G(this.node.querySelector(`#${tr}`),{id:or,title:"Hoppa \xF6ver detta steg",onClick:()=>s()})}}},ir=Ws;var nr="insurance-button-top-left-node",ar="insurance-button-bottom-left-node",rr="insurance-add-remove-node",Ks=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{freeInsurance:e,selected:t,onClose:s,onClick:n}=this.props,{title:a,description:l,logo:c,longDescription:m}=e;this.node.innerHTML=`
|
|
1236
1236
|
<div class="waykeecom-nav-banner" id="${nr}"></div>
|
|
1237
1237
|
|
|
1238
1238
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
@@ -1266,7 +1266,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
1266
1266
|
<div class="waykeecom-stack waykeecom-stack--1" id="${rr}"></div>
|
|
1267
1267
|
<div class="waykeecom-stack waykeecom-stack--1" id="${ar}"></div>
|
|
1268
1268
|
</div>
|
|
1269
|
-
`,new ie(this.node.querySelector(`#${nr}`),{title:"Tillbaka",onClick:()=>s()}),new X(this.node.querySelector(`#${ar}`),{title:"Tillbaka",onClick:()=>s()}),new J(this.node.querySelector(`#${rr}`),{selected:t,fullSize:!0,onClick:()=>n()}),B()}},cr=Ks;var
|
|
1269
|
+
`,new ie(this.node.querySelector(`#${nr}`),{title:"Tillbaka",onClick:()=>s()}),new X(this.node.querySelector(`#${ar}`),{title:"Tillbaka",onClick:()=>s()}),new J(this.node.querySelector(`#${rr}`),{selected:t,fullSize:!0,onClick:()=>n()}),B()}},cr=Ks;var Qs=class extends r{constructor(e,t){super(e);this.displayInfo=!1;this.props=t,f(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,R(),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"),Zo(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 cr(q(),{freeInsurance:t,selected:l,onClick:()=>{this.onInfoClose(),this.onClick()},onClose:()=>this.onInfoClose()}),new me(this.node,{logo:a,id:s,title:t.title,description:t.description,price:"Gratis",selected:l,onClick:()=>this.onClick(),onInfo:()=>this.onInfoOpen()},s)}},lr=Qs;var js=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,insurances:t}=this.props,s=new de(this.node,{id:"insurance-list",onClick:()=>d("MAIN","INSURANCE_ARROW","INSURANCE")}),{overflowElement:n}=s;n&&(n.innerHTML="",t.forEach((a,l)=>new lr(n,{store:e,freeInsurance:a,key:`insurance-${l}`})))}},dr=js;var zs="insurance-grid-list-node",Kl="button-insurances-proceed",mr=`${zs}-node`,Ql="button-insurances-skip",jl=`${Ql}-node`,Js=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">
|
|
@@ -1276,9 +1276,9 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
1276
1276
|
<div class="waykeecom-stack waykeecom-stack--3" id="${zs}"></div>
|
|
1277
1277
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1278
1278
|
<div class="waykeecom-stack waykeecom-stack--1" id="${mr}"></div>
|
|
1279
|
-
<div class="waykeecom-stack waykeecom-stack--1" id="${
|
|
1279
|
+
<div class="waykeecom-stack waykeecom-stack--1" id="${jl}"></div>
|
|
1280
1280
|
</div>
|
|
1281
|
-
`,new dr(this.node.querySelector(`#${zs}`),{store:e,insurances:[t]}),new g(this.node.querySelector(`#${mr}`),{id:Kl,title:"G\xE5 vidare",onClick:()=>this.onProceed()})}},pr=Js;var Xs=class extends r{constructor(e,t){super(e);this.props=t,f(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(){re()(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()),b("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=O(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:
|
|
1281
|
+
`,new dr(this.node.querySelector(`#${zs}`),{store:e,insurances:[t]}),new g(this.node.querySelector(`#${mr}`),{id:Kl,title:"G\xE5 vidare",onClick:()=>this.onProceed()})}},pr=Js;var Xs=class extends r{constructor(e,t){super(e);this.props=t,f(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(){re()(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()),b("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=O(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:Q[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 Y(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 ir(c,{store:e,lastStage:s,onSkip:()=>this.onSkipInsurances()});break;default:new pr(c,{store:e,lastStage:s,insurance:m});break}}n.navigation.stage===t&&c.parentElement?.scrollIntoView()}},ur=Xs;import{vehicles as hr}from"@wayke-se/ecom";var kr=o=>{let i=hr.newLookupRequest().withRegistrationNumber(o.registrationNumber).withMileage(parseInt(o.mileage,10)).withCondition(o.condition);return hr.lookupVehicle(i.build())};var Zs=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>
|
|
@@ -1316,7 +1316,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
1316
1316
|
<li class="waykeecom-content__li">D\xE4ck som beh\xF6ver bytas (m\xF6nsterdjup under 3 mm)</li>
|
|
1317
1317
|
</ul>
|
|
1318
1318
|
</div>
|
|
1319
|
-
</div>`}],Zl=o=>{let i={registrationNumber:o?.registrationNumber||"",mileage:o?.mileage||"",description:o?.description||"",condition:o?.condition};return{value:i,validation:{registrationNumber:ae.registrationNumber(i.registrationNumber),mileage:ae.mileage(i.mileage),description:ae.description(i.description),condition:ae.condition(i.condition)},interact:{registrationNumber:!1,mileage:!1,description:!1,condition:!1}}},to=class extends r{constructor(e,t){super(e);this.contexts={};this.requestError=!1;this.props=t;let s=this.props.store.getState();this.state=Zl(s.tradeIn),this.render()}async onFetchVehicle(){this.requestError=!1,this.render();try{if(d("MAIN","TRADE_IN_VALUATION_REQUESTED","TRADE_IN_DETAILS"),this.contexts.buttonFetch?.loading(!0),this.state.validation.registrationNumber&&this.state.validation.mileage&&this.state.validation.description&&this.state.validation.condition){let e=this.state.value,t=await kr(e),s=Fo(t);this.response=s,this.render(),d("MAIN","TRADE_IN_VALUATION_SUCCEEDED","TRADE_IN_DETAILS")}}catch{this.requestError=!0,this.render(),d("MAIN","TRADE_IN_VALUATION_FAILED","TRADE_IN_DETAILS")}finally{this.contexts.buttonFetch?.loading(!1)}}onEdit(){this.response=void 0,this.render(),d("MAIN","TRADE_IN_SKIPPED","TRADE_IN_DETAILS")}onProceed(){if(this.response){let e=this.response.vehicle,t=this.state.value;
|
|
1319
|
+
</div>`}],Zl=o=>{let i={registrationNumber:o?.registrationNumber||"",mileage:o?.mileage||"",description:o?.description||"",condition:o?.condition};return{value:i,validation:{registrationNumber:ae.registrationNumber(i.registrationNumber),mileage:ae.mileage(i.mileage),description:ae.description(i.description),condition:ae.condition(i.condition)},interact:{registrationNumber:!1,mileage:!1,description:!1,condition:!1}}},to=class extends r{constructor(e,t){super(e);this.contexts={};this.requestError=!1;this.props=t;let s=this.props.store.getState();this.state=Zl(s.tradeIn),this.render()}async onFetchVehicle(){this.requestError=!1,this.render();try{if(d("MAIN","TRADE_IN_VALUATION_REQUESTED","TRADE_IN_DETAILS"),this.contexts.buttonFetch?.loading(!0),this.state.validation.registrationNumber&&this.state.validation.mileage&&this.state.validation.description&&this.state.validation.condition){let e=this.state.value,t=await kr(e),s=Fo(t);this.response=s,this.render(),d("MAIN","TRADE_IN_VALUATION_SUCCEEDED","TRADE_IN_DETAILS")}}catch{this.requestError=!0,this.render(),d("MAIN","TRADE_IN_VALUATION_FAILED","TRADE_IN_DETAILS")}finally{this.contexts.buttonFetch?.loading(!1)}}onEdit(){this.response=void 0,this.render(),d("MAIN","TRADE_IN_SKIPPED","TRADE_IN_DETAILS")}onProceed(){if(this.response){let e=this.response.vehicle,t=this.state.value;ge(this.props.lastStage,t,e)(this.props.store.dispatch),d("MAIN","TRADE_IN_SET","TRADE_IN_DETAILS")}}onChangeRadio(e){let t=e.currentTarget,s=t.name,n=t.value;switch(this.state.value[s]=n,this.state.validation[s]=ae[s](n),this.updateProceedButton(),n){case"VeryGood":d("MAIN","TRADE_IN_CONDITION_VERY_GOOD_SELECTED","TRADE_IN_DETAILS");break;case"Good":d("MAIN","TRADE_IN_CONDITION_GOOD_SELECTED","TRADE_IN_DETAILS");break;case"Ok":d("MAIN","TRADE_IN_CONDITION_OK_SELECTED","TRADE_IN_DETAILS");break;default:break}}onChange(e){let t=e.currentTarget,s=t.name;s==="registrationNumber"&&(t.value=t.value.toUpperCase());let n=t.value;this.state.value[s]=n,this.state.validation[s]=ae[s](n),this.updateUiError(s),this.updateProceedButton()}onBlur(e){let s=e.currentTarget.name;this.state.interact[s]=!0,this.state.validation[s]=ae[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.buttonFetch?.disabled(!(this.state.validation.registrationNumber&&this.state.validation.mileage&&this.state.validation.description&&this.state.validation.condition))}onNoTradeIn(){ge(this.props.lastStage)(this.props.store.dispatch),d("MAIN","TRADE_IN_SELECTED","TRADE_IN_DETAILS")}render(){if(this.response){let e=[],t=this.response.vehicle;e.push({key:"Miltal",value:`${this.state.value.mileage} mil`}),this.state.value.description&&e.push({key:"Beskrivning",value:`${this.state.value.description}`}),this.state.value.condition&&e.push({key:"Bilens skick",value:ke[this.state.value.condition]}),this.node.innerHTML=`
|
|
1320
1320
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1321
1321
|
<div class="waykeecom-balloon">
|
|
1322
1322
|
<div class="waykeecom-stack waykeecom-stack--05">
|
|
@@ -1379,7 +1379,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
1379
1379
|
<circle cx="11" cy="10" r="5.5" stroke="#FFF500" stroke-linejoin="round" stroke-dasharray="1 2"/>
|
|
1380
1380
|
<path d="M10.6707 21.692c1.392 0 2.04.564 2.28.996h1.644c-.264-1.08-1.248-2.364-3.924-2.364-2.028 0-3.408.912-3.408 2.436 0 1.536 1.2 2.34 2.904 2.508l1.512.156c.876.108 1.476.372 1.476 1.188 0 .684-.684 1.176-1.98 1.176-1.56 0-2.244-.72-2.472-1.26h-1.716c.336 1.224 1.404 2.628 4.188 2.628 2.412 0 3.624-1.116 3.624-2.652 0-1.8-1.308-2.448-3.012-2.616-.576-.06-.972-.108-1.5-.156-.888-.108-1.392-.444-1.392-1.02 0-.624.612-1.02 1.776-1.02Z" fill="#fff"/>
|
|
1381
1381
|
</svg>
|
|
1382
|
-
`,onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.mileage=new x(this.node.querySelector(`#${Er}`),{title:"Miltal",value:this.state.value.mileage,id:Nr,error:this.state.interact.mileage&&!this.state.validation.mileage,errorMessage:"Ett miltal mellan 0 till 80 000 mil m\xE5ste anges",name:"mileage",autocomplete:"off",placeholder:"Ange bilens miltal",unit:"mil",pattern:"[0-9]*",inputmode:"numeric",onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.description=new yr(this.node.querySelector(`#${Ir}`),{title:"Beskrivning (valfritt)",value:this.state.value.description,id:Ar,error:this.state.interact.description&&!this.state.validation.description,errorMessage:"????",name:"description",autocomplete:"off",placeholder:"Beskriv bilen",onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),new K(this.node.querySelector(`#${fr}`),{title:"Bilens skick",checked:this.state.value.condition,name:"condition",options:Xl,onClick:e=>this.onChangeRadio(e)}),this.contexts.buttonFetch=new g(this.node.querySelector(`#${_r}`),{title:"H\xE4mta uppskattat v\xE4rde",id:Tr,disabled:!(this.state.validation.registrationNumber&&this.state.validation.mileage&&this.state.validation.condition),onClick:()=>this.onFetchVehicle()}),new G(this.node.querySelector(`#${ze}`),{id:eo,title:"Hoppa \xF6ver detta steg",onClick:()=>this.onNoTradeIn()})}},Dr=to;var Or="button-trade-in-yes",Rr=`${Or}-node`,Lr="button-trade-in-no",br=`${Lr}-node`,oo="button-trade-in-change",so=`${oo}-node`,io=class extends r{constructor(e,t){super(e);this.props=t,f(this.props.store,"navigation",()=>{this.render()}),this.render()}onEdit(){d("MAIN","TRADE_IN_EDIT","TRADE_IN"),b("main",this.props.index)(this.props.store.dispatch)}onYesTradeIn(){d("MAIN","TRADE_IN_SELECTED","TRADE_IN"),
|
|
1382
|
+
`,onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.mileage=new x(this.node.querySelector(`#${Er}`),{title:"Miltal",value:this.state.value.mileage,id:Nr,error:this.state.interact.mileage&&!this.state.validation.mileage,errorMessage:"Ett miltal mellan 0 till 80 000 mil m\xE5ste anges",name:"mileage",autocomplete:"off",placeholder:"Ange bilens miltal",unit:"mil",pattern:"[0-9]*",inputmode:"numeric",onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),this.contexts.description=new yr(this.node.querySelector(`#${Ir}`),{title:"Beskrivning (valfritt)",value:this.state.value.description,id:Ar,error:this.state.interact.description&&!this.state.validation.description,errorMessage:"????",name:"description",autocomplete:"off",placeholder:"Beskriv bilen",onChange:e=>this.onChange(e),onBlur:e=>this.onBlur(e)}),new K(this.node.querySelector(`#${fr}`),{title:"Bilens skick",checked:this.state.value.condition,name:"condition",options:Xl,onClick:e=>this.onChangeRadio(e)}),this.contexts.buttonFetch=new g(this.node.querySelector(`#${_r}`),{title:"H\xE4mta uppskattat v\xE4rde",id:Tr,disabled:!(this.state.validation.registrationNumber&&this.state.validation.mileage&&this.state.validation.condition),onClick:()=>this.onFetchVehicle()}),new G(this.node.querySelector(`#${ze}`),{id:eo,title:"Hoppa \xF6ver detta steg",onClick:()=>this.onNoTradeIn()})}},Dr=to;var Or="button-trade-in-yes",Rr=`${Or}-node`,Lr="button-trade-in-no",br=`${Lr}-node`,oo="button-trade-in-change",so=`${oo}-node`,io=class extends r{constructor(e,t){super(e);this.props=t,f(this.props.store,"navigation",()=>{this.render()}),this.render()}onEdit(){d("MAIN","TRADE_IN_EDIT","TRADE_IN"),b("main",this.props.index)(this.props.store.dispatch)}onYesTradeIn(){d("MAIN","TRADE_IN_SELECTED","TRADE_IN"),Qo(this.props.lastStage)(this.props.store.dispatch)}onNoTradeIn(){d("MAIN","TRADE_IN_SKIPPED","TRADE_IN"),ge(this.props.lastStage)(this.props.store.dispatch)}render(){let{store:e,index:t,lastStage:s}=this.props,n=this.props.store.getState();if(!n.order?.allowsTradeIn)return;let a=n.topNavigation.stage>t,l=n.navigation.stage===t;l&&d("MAIN","TRADE_IN_ACTIVE",n.navigation.subStage===1?"TRADE_IN":"TRADE_IN_DETAILS");let c=O(this.node,{title:"Inbytesbil",active:l,completed:a,id:"trade-in"});c.innerHTML="";let m=document.createElement("div");if(n.navigation.stage>t||a&&n.navigation.stage!==t){let u=[];n.tradeIn&&n.tradeInVehicle?(u.push({key:"Miltal",value:`${n.tradeIn.mileage} mil`}),n.tradeIn.description&&u.push({key:"Beskrivning",value:`${n.tradeIn.description}`}),n.tradeIn.condition&&u.push({key:"Bilens skick",value:ke[n.tradeIn.condition]}),m.innerHTML=`
|
|
1383
1383
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1384
1384
|
<div class="waykeecom-balloon">
|
|
1385
1385
|
<div class="waykeecom-stack waykeecom-stack--05">
|
|
@@ -1489,7 +1489,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
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
|
-
`}},Vr=ro;import{AuthMethod as W}from"@wayke-se/ecom";import{bankid as Gr}from"@wayke-se/ecom";var qr=o=>{let i=Gr.newAuthRequest().withMethod(o).build();return Gr.auth(i)};import{bankid as Wr}from"@wayke-se/ecom";var co=o=>{let i=Wr.newCollectRequest().withOrderRef(o).build();return Wr.collect(i)};import{customers as sd,DeliveryType as Yr,orders as De,PaymentType as lo,vehicles as od}from"@wayke-se/ecom";var Kr=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=sd.newCustomer().withAddress(i.address).withPersonalNumber(i.customer.socialId).withEmail(i.customer.email).withPhoneNumber(i.customer.phone).build(),t=De.newPayment().withType(i.paymentType);if(i.paymentType===lo.Loan){let m=i.order?.paymentOptions.find(w=>w.type===lo.Loan),u=i.paymentLookupResponse||m?.loanDetails,p=u?.durationSpec.current,h=u?.downPaymentSpec.current,y=u?.residualValueSpec?.current,_=i.order?.paymentOptions.find(w=>w.type===lo.Loan)?.externalId;if(t.withDuration(p).withDownPayment(Math.round(h)),y&&t.withResidualValue(y),_&&t.withExternalId(_),i.creditAssessmentResponse){let w=i.creditAssessmentResponse.scoringId,D=i.creditAssessmentResponse.recommendation,L=i.creditAssessmentResponse.decision,V=u?.financialProductCode;if(!w||!D||!L||!V)throw"Missing credit assessment data";let M=De.newCreditAssessment().withScoreId(w).withFinancialProductCode(V).withRecommendation(D).withDecision(L).build();t.withCreditAssessment(M)}}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=De.newCreateRequest().forVehicle(i.id).withCustomer(e).withPayment(s).withUrls(a,l).withDeliveryType(i.homeDelivery?Yr.Delivery:Yr.Pickup);if(i.insurance){let m=De.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=od.newVehicleTrade().forVehicle(i.tradeIn.registrationNumber).withMileage(parseInt(i.tradeIn.mileage,10)).withCondition(i.tradeIn.condition).withComment(i.tradeIn.description).build();c.withTradeIn(m)}return De.create(c.build())};import{creditAssessment as id}from"@wayke-se/ecom";var
|
|
1492
|
+
`}},Vr=ro;import{AuthMethod as W}from"@wayke-se/ecom";import{bankid as Gr}from"@wayke-se/ecom";var qr=o=>{let i=Gr.newAuthRequest().withMethod(o).build();return Gr.auth(i)};import{bankid as Wr}from"@wayke-se/ecom";var co=o=>{let i=Wr.newCollectRequest().withOrderRef(o).build();return Wr.collect(i)};import{customers as sd,DeliveryType as Yr,orders as De,PaymentType as lo,vehicles as od}from"@wayke-se/ecom";var Kr=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=sd.newCustomer().withAddress(i.address).withPersonalNumber(i.customer.socialId).withEmail(i.customer.email).withPhoneNumber(i.customer.phone).build(),t=De.newPayment().withType(i.paymentType);if(i.paymentType===lo.Loan){let m=i.order?.paymentOptions.find(w=>w.type===lo.Loan),u=i.paymentLookupResponse||m?.loanDetails,p=u?.durationSpec.current,h=u?.downPaymentSpec.current,y=u?.residualValueSpec?.current,_=i.order?.paymentOptions.find(w=>w.type===lo.Loan)?.externalId;if(t.withDuration(p).withDownPayment(Math.round(h)),y&&t.withResidualValue(y),_&&t.withExternalId(_),i.creditAssessmentResponse){let w=i.creditAssessmentResponse.scoringId,D=i.creditAssessmentResponse.recommendation,L=i.creditAssessmentResponse.decision,V=u?.financialProductCode;if(!w||!D||!L||!V)throw"Missing credit assessment data";let M=De.newCreditAssessment().withScoreId(w).withFinancialProductCode(V).withRecommendation(D).withDecision(L).build();t.withCreditAssessment(M)}}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=De.newCreateRequest().forVehicle(i.id).withCustomer(e).withPayment(s).withUrls(a,l).withDeliveryType(i.homeDelivery?Yr.Delivery:Yr.Pickup);if(i.insurance){let m=De.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=od.newVehicleTrade().forVehicle(i.tradeIn.registrationNumber).withMileage(parseInt(i.tradeIn.mileage,10)).withCondition(i.tradeIn.condition).withComment(i.tradeIn.description).build();c.withTradeIn(m)}return De.create(c.build())};import{creditAssessment as id}from"@wayke-se/ecom";var Qr=o=>id.accept(o);import{bankid as jr}from"@wayke-se/ecom";var zr=o=>{let i=jr.newQrCodeRequest().withOrderRef(o).build();return jr.qrcode(i)};var tc="confirm-conditions",Jr=`${tc}-node`,Xr="bankid-start-node",nd="bankid-start",Zr="address-disclaimer-policy-node",ec="address-disclaimer-reservation-node",mo=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 co(e);this.handleBankidStatusResponse(t,W.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 zr(e)).getQrCode();this.contexts.bankId?.update(W.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===W.SameDevice)try{let e=await co(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 Qr(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 Kr(e);d("MAIN","CONFIRMATION_CREATE_ORDER_SUCCEEDED","CONFIRMATION"),t?.isPaymentRequired&&R();let a=s.getPayment();si(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),R(),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(C.requiredSsnOver18(n)){if(a.customer.socialId!==n){d("MAIN",t===W.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED_SSN_MISSMATCH":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED_SSN_MISSMATCH","CONFIRMATION"),this.view=1,this.socialIdNotMatchingError=!0,R(),this.render();return}}else{d("MAIN",t===W.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,R(),this.render();return}d("MAIN",t===W.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,W.SameDevice);let n=e.getAutoLaunchUrl();this.contexts.bankId?.update(W.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),Ce("bankidStatusInterval",this.bankidStatusInterval),this.qrCode(e),this.bankidQrCodeInterval=setInterval(async()=>{this.qrCode(e)},1e3),Ce("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 qr(e);t||d("MAIN","CONFIRMATION_BANKID_INIT_SUCCEEDED","CONFIRMATION");let n=s.getOrderRef();e===W.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,R(),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=ye(),{navigation:t,order:s,insurance:n}=this.props.store.getState();if(this.view===2)this.contexts.bankId=new Ye(q(),{method:e?W.SameDevice:W.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">
|
|
@@ -1520,7 +1520,7 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
1520
1520
|
<div class="waykeecom-stack waykeecom-stack--1" id="${ec}"></div>
|
|
1521
1521
|
</div>
|
|
1522
1522
|
</div>
|
|
1523
|
-
`,this.contexts.confirmConditions=new
|
|
1523
|
+
`,this.contexts.confirmConditions=new je(this.node.querySelector(`#${Jr}`),{checked:this.confirmConditions,id:tc,disabled:this.notAvailable,name:"confirmConditions",title:`<div>Jag godk\xE4nner <a href="${l}" title="" target="_blank" rel="noopener noreferrer" class="waykeecom-link">k\xF6pvillkor och villkor f\xF6r \xE5ngerr\xE4tt</a>${n?' <span class="waykeecom-text waykeecom-text--margin-left">samt har tagit del av information kring f\xF6rs\xE4kringsf\xF6rmedling</span>':""}.</div>`,value:"confirmConditions",onClick:m=>this.onCheckbox(m)}),this.contexts.startBankid=new ve(this.node.querySelector(`#${Xr}`),{title:"Reservera bilen",id:nd,disabled:!this.confirmConditions||this.notAvailable,onClick:()=>{this.view=2,this.render()}}),new ue(this.node.querySelector(`#${Zr}`),{text:`Dina personuppgifter behandlas och sparas i enlighet med v\xE5r <a href="${c}" title="personuppgiftspolicy" target="_blank" rel="noopener noreferrer" class="waykeecom-link">personuppgiftspolicy</a>.`}),new Ee(this.node.querySelector(`#${ec}`),{text:"Vi reserverar oss f\xF6r eventuell \xE4ndring i tillg\xE5ngen av utbjudna bilar."}),t.stage===this.props.index&&this.node.parentElement?.scrollIntoView()}}},sc=mo;var po=class extends r{constructor(e,t){super(e);this.view=1;this.props=t,f(this.props.store,"navigation",()=>{this.render()}),this.render()}render(){let{store:e,index:t}=this.props,{topNavigation:s,navigation:n,order:a}=e.getState(),l=s.stage>t,c=O(this.node,{completed:l,title:a?.isPaymentRequired?"Betalning":"Slutf\xF6r ordern",id:"confirmation",active:n.stage===t});n.stage===t&&(n.subStage===2?new Vr(c,{store:e}):new sc(c,{lastStage:!0,index:t,store:this.props.store}),c.parentElement?.scrollIntoView())}},oc=po;var uo=class extends r{constructor(e,t){super(e);this.props=t,f(this.props.store,"navigation.view",s=>{s===2&&this.render()}),this.render(),this.node.scrollTop=0}render(){let{store:e,cdnMedia:t}=this.props,s=e.getState(),{order:n,stages:a}=s;if(!n)throw"No order available";this.node.innerHTML="";let l=document.createElement("div");this.node.appendChild(l);let c=document.createElement("aside");c.className="waykeecom-cart",c.setAttribute("aria-label","Fordonsinformation"),c.innerHTML=Ur({vehicle:s.vehicle,order:s.order,cdnMedia:t}),l.appendChild(c);let m=document.createElement("div");m.className="waykeecom-stepper",l.appendChild(m);let u=a?.length;a?.forEach((p,h)=>new Je[p.name].component(m,{store:e,index:h+1,lastStage:!1})),new oc(m,{store:e,index:(u||0)+1,lastStage:!0})}},ic=uo;var ho=class extends r{constructor(i){super(i,{htmlTag:"div",className:"waykeecom-stack waykeecom-stack--4"})}},F=ho;var ko=class extends F{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e}=this.props,t=e.getState(),{order:s,tradeIn:n,tradeInVehicle:a}=t;!s?.allowsTradeIn||(this.node.innerHTML=`
|
|
1524
1524
|
<div class="waykeecom-stack waykeecom-stack--4">
|
|
1525
1525
|
<div class="waykeecom-stack waykeecom-stack--2">
|
|
1526
1526
|
<h4 class="waykeecom-heading waykeecom-heading--4 waykeecom-no-margin">Inbytesbil</h4>
|
|
@@ -1843,5 +1843,5 @@ import{config as ad}from"@wayke-se/ecom";var Bo={name:"@wayke-se/ecom-web",versi
|
|
|
1843
1843
|
<div class="waykeecom-stack waykeecom-stack--1" id="${Sc}"></div>
|
|
1844
1844
|
<div class="waykeecom-stack waykeecom-stack--1" id="${wc}"></div>
|
|
1845
1845
|
</div>
|
|
1846
|
-
`,new Ke(this.node.querySelector(`#${Sc}`),{title:"Forts\xE4tt min order",onClick:()=>t()}),new gc(this.node.querySelector(`#${wc}`),{title:"Avbryt min order",onClick:()=>e()})}},Nc=Mo;var xo=()=>{let o=document.documentElement.clientWidth/100;document.documentElement.style.setProperty("--waykeecom-vw",`${o}px`)},Ac=()=>(xo(),window.addEventListener("resize",xo),()=>window.removeEventListener("resize",xo));var Po="order",rd="wayke-ecom-web-payment",$o="wayke-ecom-web-id",
|
|
1846
|
+
`,new Ke(this.node.querySelector(`#${Sc}`),{title:"Forts\xE4tt min order",onClick:()=>t()}),new gc(this.node.querySelector(`#${wc}`),{title:"Avbryt min order",onClick:()=>e()})}},Nc=Mo;var xo=()=>{let o=document.documentElement.clientWidth/100;document.documentElement.style.setProperty("--waykeecom-vw",`${o}px`)},Ac=()=>(xo(),window.addEventListener("resize",xo),()=>window.removeEventListener("resize",xo));var Po="order",rd="wayke-ecom-web-payment",$o="wayke-ecom-web-id",Se="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}},Ho=class{constructor(i){this.contexts={store:ci()};if(!i.id)throw"Missing id";this.props=i,window.process||(window.process={...window.process||{},env:{}}),ad.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=Bo.version,this.stageOrderList=["centralStorage","customer","financial","tradeIn","accessories","insurance","delivery"],Go(i.id)(this.contexts.store.dispatch),this.view=this.contexts.store.getState().navigation.view,f(this.contexts.store,"navigation.view",l=>{this.view=l,l!=="preview"&&this.render()},!0);let t=new URLSearchParams(location.search),s=t.get(Po)||void 0,n=!!t.get(rd),a=t.get($o);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,oi({...c,stateLoadedFromSession:!0})(this.contexts.store.dispatch))}else s&&this.render({orderUrl:s,id:a})}close(){let i=we();i&&d(i.view,"CLOSE",i.currentStep);let{caseId:e}=this.contexts.store.getState(),t=new URLSearchParams(location.search),s=t.get(Po),n=t.get($o),a=!1;s&&(t.delete(Po),a=!0,location.search=t.toString()),n&&(t.delete($o),a=!0),a&&(location.search=t.toString()),this.root.innerHTML="",this.contexts?.unsubribeVwListner?.(),Is(),ui(),e&&Te(e),sessionStorage.removeItem("wayke-ecom-state"),Vo(this.props.id)(this.contexts.store.dispatch),this.props.onEvent&&ki(this.props.onEvent)}destroy(){this.close(),this.root.remove()}closeWithConfirm(){let{navigation:i,createdOrderId:e}=this.contexts.store.getState(),t=i.view==="preview";if(Is(),t||e){this.close();return}this.contexts.modal=new Oo(this.root,{title:"Wayke Ecom",id:Se,logo:this.props.logo,logoX2:this.props.logoX2});let s=we();s&&d(s.view,"CONFIRM_CLOSE_ACTIVE"),new Nc(this.contexts.modal.content,{onConfirmClose:()=>{let n=we();d(n.view,"CONFIRM_CLOSE_CONFIRMED",n.currentStep),this.close()},onAbortClose:()=>{let n=we();d(n.view,"CONFIRM_CLOSE_ABORTED",n.currentStep),this.render()}})}start(){this.props.onEvent&&hi(this.props.onEvent),d("PREVIEW","START"),this.render()}render(i){if(this.contexts.unsubribeVwListner||(this.contexts.unsubribeVwListner=Ac()),this.contexts.modal=new Oo(this.root,{title:"Wayke Ecom",id:Se,logo:this.props.logo,logoX2:this.props.logoX2,onClose:()=>this.closeWithConfirm()}),this.contexts.modal.content){if(this.contexts.modal.content.innerHTML="",i){new uc(this.contexts.modal.content,{store:this.contexts.store,callbackOrder:i,onClose:()=>this.close()});return}switch(this.view){case"preview":new Br(this.contexts.modal.content,{store:this.contexts.store,stageOrderList:this.stageOrderList,vehicle:this.props.vehicle,cdnMedia:this.cdnMedia});break;case"main":new ic(this.contexts.modal.content,{store:this.contexts.store,cdnMedia:this.cdnMedia});break;case"summary":new pc(this.contexts.modal.content,{store:this.contexts.store,cdnMedia:this.cdnMedia,onClose:()=>this.close()});break;default:throw"Unknown view..."}}}},Tc=Ho;var Hg=Tc;export{Hg as default};
|
|
1847
1847
|
//# sourceMappingURL=index.mjs.map
|