@wayke-se/ecom-web 0.0.4 → 0.0.7-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3 -3
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Sc=(o=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(o,{get:(i,e)=>(typeof require!="undefined"?require:i)[e]}):o)(function(o){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+o+'" is not supported')});import{config as id}from"@wayke-se/ecom";var wc="@wayke-se/ecom-web",Nc="0.0.
|
|
1
|
+
var Sc=(o=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(o,{get:(i,e)=>(typeof require!="undefined"?require:i)[e]}):o)(function(o){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+o+'" is not supported')});import{config as id}from"@wayke-se/ecom";var wc="@wayke-se/ecom-web",Nc="0.0.7-beta.2",Ac="Wayke Ecom Web",Tc="dist/index.mjs",Cc="dist/index.js",Dc="dist/index.d.ts",Rc={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"},Lc="Wayke",Oc="ISC",bc={"@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.14.22","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:"^3.0.2",stylelint:"^14.5.1","stylelint-config-prettier-scss":"^0.0.1","stylelint-config-standard-scss":"^3.0.0",typescript:"^4.5.5"},Mc={"@wayke-se/ecom":"^3.7.0-alpha.10",marked:"^4.0.16","object-path":"^0.11.8",redux:"^4.1.2","sanitize-html":"^2.7.0"},xc=["dist"],Ro={name:wc,version:Nc,description:Ac,module:Tc,main:Cc,types:Dc,scripts:Rc,author:Lc,license:Oc,devDependencies:bc,dependencies:Mc,files:xc};import{createStore as Hc}from"redux";import{DrivingDistance as Pc,PaymentType as jo}from"@wayke-se/ecom";var Ye=(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()}),Lo=o=>({status:o.getStatus(),hasPendingSigning:o.hasPendingSigning(),hintCode:o.getHintCode(),signingMessage:o.getSigningMessage(),shouldRenewSigning:o.shouldRenewSigning(),isSigned:o.isSigned(),address:o.getAddress(),pendingScoring:o.hasPendingScoring(),isScored:o.isScored(),hasScoringError:o.hasScoringError(),scoringId:o.getScoringId(),recommendation:o.getRecommendation(),decision:o.getDecision(),isAccepted:o.isAccepted()}),Re=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()}),Oo=o=>({vehicle:o.getVehicle()});var Qe="RESET",bo=o=>i=>i({type:Qe,id:o}),je="SET_ORDER",Le=(o,i)=>e=>e({type:je,order:o,vehicle:i}),ze="SET_ID",Mo=o=>i=>i({type:ze,id:o}),Je="SET_CONTACT_EMAIL_AND_PHONE",xo=o=>i=>i({type:Je,value:o}),Ze="SET_SOCIAL_ID_AND_ADDRESS",Po=(o,i,e)=>t=>t({type:Ze,socialId:o,address:i,lastStage:e}),Xe="SET_HOME_DELIVERY",$o=(o,i)=>e=>e({type:Xe,homeDelivery:o,lastStage:i}),et="SET_DEALER",Ho=(o,i)=>e=>e({type:et,dealer:o,lastStage:i}),tt="INIT_TRADE_IN",Bo=o=>i=>i({type:tt,lastStage:o}),st="SET_TRADE_IN",fe=(o,i,e)=>t=>t({type:st,lastStage:o,tradeIn:i,tradeInVehicle:e}),ot="SET_FINANCIAL",Uo=(o,i)=>e=>e({type:ot,paymentType:o,lastStage:i}),it="SET_PAYMENT_LOOKUP_RESPONSE",Fo=o=>i=>i({type:it,paymentLookupResponse:_e(o)}),nt="SET_DRIVING_DISTANCE",Vo=o=>i=>i({type:nt,drivingDistance:o}),at="COMPLETE_STAGE",j=o=>i=>i({type:at,lastStage:o}),rt="SET_OR_REMOVE_INSURANCE",de=o=>i=>i({type:rt,insurance:o}),ct="SET_OR_REMOVE_INSURANCE_ADDONS",Go=(o,i)=>e=>e({type:ct,insurance:o,insuranceAddons:i}),lt="SET_OR_REMOVE_FREE_INSURANCE",qo=o=>i=>i({type:lt,freeInsurance:o}),dt="SET_OR_REMOVE_ACCESSORY",Wo=o=>i=>i({type:dt,accessory:o}),mt="GO_TO",L=(o,i,e)=>t=>t({type:mt,view:o,index:i,subStage:e}),pt="SET_STAGES",Ko=o=>i=>i({type:pt,stages:o}),ut="SET_CREATED_ORDER_ID",Yo=(o,i)=>e=>e({type:ut,id:o,payment:i}),ht="SET_CREDIT_ASSESSMENT_RESPONSE",ge=(o,i)=>e=>e({type:ht,caseId:o,creditAssessmentResponse:i}),kt="SET_STATE",Qo=o=>i=>i({type:kt,state:o});var Et={};try{Et=Sc("../../statemock.json")}catch{Et={}}var zo={view:"preview",stage:1,subStage:1},Jo={id:"",topNavigation:{...zo},navigation:{...zo},customer:{email:"",phone:"",givenName:"",surname:"",socialId:""},homeDelivery:!1,accessories:[],drivingDistance:Pc.Between0And1000,...Et},ie=(o,i)=>i?{view:"summary",stage:1,subStage:1}:{view:"main",stage:o+1,subStage:1},ne=(o,i)=>i.view==="main"?o.stage<i.stage?i:v.topNavigation:{...o,stage:o.stage+1},yt=o=>o&&o?.length===1&&o?.[0].type===jo.Cash?jo.Cash:void 0,v,vt,$c=(o=Jo,i)=>{let e,t;switch(v={...o},i.type){case Qe:return{...Jo,id:i.id};case pt:return{...v,stages:i.stages};case ze:return{...v,id:i.id};case je:return{...o,order:i.order,paymentType:yt(i.order?.paymentOptions),vehicle:{...i.order.orderVehicle,...i.vehicle||{}}};case Je: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=yt(o.order?.paymentOptions),delete s.paymentLookupResponse,delete s.insurance,delete s.insuranceAddOns,delete s.freeInsurance,delete s.dealer,s.accessories=[],s;case Ze:return e=ie(v.navigation.stage,i.lastStage),t=ne(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,address:i.address,customer:{...o.customer,socialId:i.socialId}},v;case et:return e=ie(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=yt(o.order?.paymentOptions),delete v.paymentLookupResponse,delete v.insurance,delete v.insuranceAddOns,delete v.freeInsurance,v.accessories=[],v;case Xe:return e=ie(o.navigation.stage,i.lastStage),t=ne(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,homeDelivery:i.homeDelivery},v;case tt:return e={view:"main",stage:o.navigation.stage,subStage:1},t=ne(v.topNavigation,e),v={...o,navigation:e,wantTradeIn:!0,topNavigation:t,tradeIn:o.tradeIn||{registrationNumber:"",mileage:"",description:""}},v;case st:return e=ie(o.navigation.stage,i.lastStage),t=ne(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,wantTradeIn:!!i.tradeIn,tradeIn:i.tradeIn,tradeInVehicle:i.tradeInVehicle},v;case ot:return e=ie(o.navigation.stage,i.lastStage),t=ne(v.topNavigation,e),{...v,navigation:e,topNavigation:t,paymentType:i.paymentType};case it:return{...v,paymentLookupResponse:i.paymentLookupResponse};case nt:return{...v,drivingDistance:i.drivingDistance};case at:return e=ie(o.navigation.stage,i.lastStage),t=ne(v.topNavigation,e),v={...o,navigation:e,topNavigation:t},v;case ct:return v.insurance=i.insurance,v.insuranceAddOns={insurance:i.insurance.name,addOns:i.insuranceAddons},v;case rt:return Ye(v.insurance,i.insurance)?v.insurance=void 0:v.insurance=i.insurance,v.insuranceAddOns?.insurance&&(v.insuranceAddOns=void 0),v;case lt:return Ye(v.freeInsurance,i.freeInsurance)?v.freeInsurance=void 0:v.freeInsurance=i.freeInsurance,v;case dt:return vt=v.accessories.findIndex(n=>n.id===i.accessory.id),v.accessories=[...v.accessories],vt>-1?v.accessories.splice(vt,1):v.accessories.push(i.accessory),{...v,accessories:[...v.accessories]};case mt:return{...o,navigation:{view:i.view,stage:i.index||1,subStage:i.subStage||1}};case ut:return i.payment?e={view:"main",stage:o.navigation.stage,subStage:2}:e=ie(o.navigation.stage,!0),t=ne(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,createdOrderId:i.id,payment:i.payment},v;case ht:return{...v,caseId:i.caseId,creditAssessmentResponse:i.creditAssessmentResponse};case kt:return{...i.state};default:return o}},Zo=$c;var Xo=()=>Hc(Zo);var Bc=o=>o.toString().replace(/\s/g,""),Uc=(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=Uc(o,i?.decimals!==void 0?i.decimals:0);return`${i?.prefix?`${i.prefix}`:""}${Bc(e).replace(/\B(?=(\d{3})+(?!\d))/g," ")}${i?.postfix?` ${i.postfix}`:""}`};var Fc=({vehicle:o,order:i,meta:e})=>{let t=o?.imageUrls,s=o?.title,n=o?.shortDescription,a=k(o?.price||NaN),c=i?.contactInformation?.name;return`
|
|
2
2
|
<div class="waykeecom-product-card">
|
|
3
3
|
${t?.length?`
|
|
4
4
|
<div class="waykeecom-product-card__media">
|
|
@@ -718,7 +718,7 @@ var Sc=(o=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Pro
|
|
|
718
718
|
`,a&&this.node.querySelector("button")?.addEventListener("click",a)}},Ge=ps;var Cl="assessment-rejected-result",Nn=`${Cl}-node`,Tn="assessment-rejected-abort",An=`${Tn}-node`,us=class extends r{constructor(e,t){super(e);this.props=t,this.render()}render(){let{store:e,onGoBack:t}=this.props;this.node.innerHTML=`
|
|
719
719
|
<div class="waykeecom-stack waykeecom-stack--4" id="${Nn}"></div>
|
|
720
720
|
<div class="waykeecom-stack waykeecom-stack--4" id="${An}"></div>
|
|
721
|
-
`,new oe(this.node.querySelector(`#${Nn}`),{store:e,decision:Tl.Reject}),new Ge(this.node.querySelector(`#${An}`),{title:"G\xE5 tillbaka",id:Tn,onClick:()=>t()})}},Cn=us;var hs=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===Dn.Approve?new En(this.node,{store:e,onProceed:()=>s(),onGoBack:()=>n()}):a===Dn.AssessManually?new wn(this.node,{store:e,onProceed:()=>s(),onGoBack:()=>n()}):new Cn(this.node,{store:e,onGoBack:()=>n()})}},Rn=hs;var Dl=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`},Ln=Dl;var Rl="credit-assessment-martial-status",Mn=`${Rl}-node`,vs="credit-assessment-income",ks=`${vs}-node`,Ll="credit-assessment-employment",xn=`${Ll}-node`,Gn="credit-assessment-household-children",Pn=`${Gn}-node`,qn="credit-assessment-household-income",$n=`${qn}-node`,Wn="credit-assessment-household-housing-cost",Hn=`${Wn}-node`,Kn="credit-assessment-household-debt",Bn=`${Kn}-node`,Yn="credit-assessment-perform-application",ys=`${Yn}-node`,Un="disclaimer-node",Fn="disclaimer-safe-node",Vn="why-description-node",Y={maritalStatus:C.requiredAssessmentMaritalStatus,income:C.requiredNumber,employment:C.requiredAssessmentEmplyment,householdChildren:C.requiredNumber,householdIncome:C.requiredNumber,householdHousingCost:C.requiredNumber,householdDebt:C.requiredNumber},Ol=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:Y.maritalStatus(i.maritalStatus),income:Y.income(i.income),employment:Y.employment(i.employment),householdChildren:Y.householdChildren(i.householdChildren),householdIncome:Y.householdIncome(i.householdIncome),householdHousingCost:Y.householdHousingCost(i.householdHousingCost),householdDebt:Y.householdDebt(i.householdDebt)},interact:{maritalStatus:!1,income:!1,employment:!1,householdChildren:!1,householdIncome:!1,householdHousingCost:!1,householdDebt:!1}}},Es=class extends r{constructor(e,t){super(e);this.view=1;this.contexts={};this.bankidError=!1;this.props=t,this.state=Ol(),this.render()}onChange(e){let t=e.currentTarget,s=t.name,n=t.value;this.state.value[s]=n,this.state.validation[s]=Y[s](n),this.updateUiError(s),this.updateProceedButton()}onBlur(e){let s=e.currentTarget.name;this.state.interact[s]=!0,this.state.validation[s]=Y[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]=Y[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(){l("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),ge()(e.dispatch)),R(),this.creditAssessmentResponse=void 0,this.render(!0)}bankIdStatus(e,t){let s=this.props.store.getState().order?.paymentOptions.find(n=>n.type===bn.Loan);this.bankidStatusInterval=setInterval(async()=>{try{l("MAIN",t===ce.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_REQUESTED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_REQUESTED","FINANCIAL_CREDIT_SCORING");let n=await ln(e);l("MAIN",t===ce.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_SUCCEEDED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),n.getStatus()==="signed"&&(this.contexts.bankId?.setTitle(`V\xE4ntar p\xE5 ${s?.name}...`),this.contexts.bankId?.setDescription(`H\xE4mtar uppgifter fr\xE5n ${s?.name}. V\xE4nta kvar det kan ta n\xE5gra sekunder.`),this.contexts.bankId?.setFinalizing(!0),l("MAIN","FINANCIAL_CREDIT_SCORING_SIGNING_SIGNED","FINANCIAL_CREDIT_SCORING")),n.isScored()?(l("MAIN","FINANCIAL_CREDIT_SCORING_SIGNING_SCORED","FINANCIAL_CREDIT_SCORING"),this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.view=3,this.creditAssessmentResponse=Lo(n),ge(e,this.creditAssessmentResponse)(this.props.store.dispatch),R(),this.render()):n.shouldRenewSigning()&&(l("MAIN",t===ce.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_SHOULD_RENEW":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_SHOULD_RENEW","FINANCIAL_CREDIT_SCORING"),this.onStartBankIdAuth(t))}catch{clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering. Nytt f\xF6rs\xF6k sker igenom om 2 sekunder"),l("MAIN",t===ce.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_FAILED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_FAILED","FINANCIAL_CREDIT_SCORING")}},2e3)}async onStartBankIdAuth(e){let t=this.props.store.getState().caseId;if(!t)throw"Missing caseID";this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval);try{l("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_REQUESTED","FINANCIAL_CREDIT_SCORING"),this.contexts.bankId?.update(e);let s=await mn({caseId:t,method:e});if(l("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.bankIdStatus(t,e),e===ce.SameDevice){let n=s.getAutoLaunchUrl();this.contexts.bankId?.update(e,n)}else{let n=s.getQrCode();this.contexts.bankId?.update(e,n)}}catch{l("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;
|
|
721
|
+
`,new oe(this.node.querySelector(`#${Nn}`),{store:e,decision:Tl.Reject}),new Ge(this.node.querySelector(`#${An}`),{title:"G\xE5 tillbaka",id:Tn,onClick:()=>t()})}},Cn=us;var hs=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===Dn.Approve?new En(this.node,{store:e,onProceed:()=>s(),onGoBack:()=>n()}):a===Dn.AssessManually?new wn(this.node,{store:e,onProceed:()=>s(),onGoBack:()=>n()}):new Cn(this.node,{store:e,onGoBack:()=>n()})}},Rn=hs;var Dl=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`},Ln=Dl;var Rl="credit-assessment-martial-status",Mn=`${Rl}-node`,vs="credit-assessment-income",ks=`${vs}-node`,Ll="credit-assessment-employment",xn=`${Ll}-node`,Gn="credit-assessment-household-children",Pn=`${Gn}-node`,qn="credit-assessment-household-income",$n=`${qn}-node`,Wn="credit-assessment-household-housing-cost",Hn=`${Wn}-node`,Kn="credit-assessment-household-debt",Bn=`${Kn}-node`,Yn="credit-assessment-perform-application",ys=`${Yn}-node`,Un="disclaimer-node",Fn="disclaimer-safe-node",Vn="why-description-node",Y={maritalStatus:C.requiredAssessmentMaritalStatus,income:C.requiredNumber,employment:C.requiredAssessmentEmplyment,householdChildren:C.requiredNumber,householdIncome:C.requiredNumber,householdHousingCost:C.requiredNumber,householdDebt:C.requiredNumber},Ol=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:Y.maritalStatus(i.maritalStatus),income:Y.income(i.income),employment:Y.employment(i.employment),householdChildren:Y.householdChildren(i.householdChildren),householdIncome:Y.householdIncome(i.householdIncome),householdHousingCost:Y.householdHousingCost(i.householdHousingCost),householdDebt:Y.householdDebt(i.householdDebt)},interact:{maritalStatus:!1,income:!1,employment:!1,householdChildren:!1,householdIncome:!1,householdHousingCost:!1,householdDebt:!1}}},Es=class extends r{constructor(e,t){super(e);this.view=1;this.contexts={};this.bankidError=!1;this.props=t,this.state=Ol(),this.render()}onChange(e){let t=e.currentTarget,s=t.name,n=t.value;this.state.value[s]=n,this.state.validation[s]=Y[s](n),this.updateUiError(s),this.updateProceedButton()}onBlur(e){let s=e.currentTarget.name;this.state.interact[s]=!0,this.state.validation[s]=Y[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]=Y[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(){l("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),ge()(e.dispatch)),R(),this.creditAssessmentResponse=void 0,this.render(!0)}bankIdStatus(e,t){let s=this.props.store.getState().order?.paymentOptions.find(n=>n.type===bn.Loan);this.bankidStatusInterval=setInterval(async()=>{try{l("MAIN",t===ce.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_REQUESTED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_REQUESTED","FINANCIAL_CREDIT_SCORING");let n=await ln(e);l("MAIN",t===ce.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_SUCCEEDED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),n.getStatus()==="signed"&&(this.contexts.bankId?.setTitle(`V\xE4ntar p\xE5 ${s?.name}...`),this.contexts.bankId?.setDescription(`H\xE4mtar uppgifter fr\xE5n ${s?.name}. V\xE4nta kvar det kan ta n\xE5gra sekunder.`),this.contexts.bankId?.setFinalizing(!0),l("MAIN","FINANCIAL_CREDIT_SCORING_SIGNING_SIGNED","FINANCIAL_CREDIT_SCORING")),n.isScored()?(l("MAIN","FINANCIAL_CREDIT_SCORING_SIGNING_SCORED","FINANCIAL_CREDIT_SCORING"),this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.view=3,this.creditAssessmentResponse=Lo(n),ge(e,this.creditAssessmentResponse)(this.props.store.dispatch),R(),this.render()):n.shouldRenewSigning()&&(l("MAIN",t===ce.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_SHOULD_RENEW":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_SHOULD_RENEW","FINANCIAL_CREDIT_SCORING"),this.onStartBankIdAuth(t))}catch{clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering. Nytt f\xF6rs\xF6k sker igenom om 2 sekunder"),l("MAIN",t===ce.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_FAILED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_FAILED","FINANCIAL_CREDIT_SCORING")}},2e3)}async onStartBankIdAuth(e){let t=this.props.store.getState().caseId;if(!t)throw"Missing caseID";this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval);try{l("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_REQUESTED","FINANCIAL_CREDIT_SCORING"),this.contexts.bankId?.update(e);let s=await mn({caseId:t,method:e});if(l("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.bankIdStatus(t,e),e===ce.SameDevice){let n=s.getAutoLaunchUrl();this.contexts.bankId?.update(e,n)}else{let n=s.getQrCode();this.contexts.bankId?.update(e,n)}}catch{l("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;let s=t.getState().caseId;this.bankidStatusInterval&&(clearInterval(this.bankidStatusInterval),s&&(await Te(s),ge()(t.dispatch)));try{l("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_REQUESTED","FINANCIAL_CREDIT_SCORING");let n=s||await this.newCreditAssessmentCase();l("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),n&&(ge(n)(t.dispatch),this.onStartBankIdAuth(e))}catch{l("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:c}=s.interests,d=s.downPaymentSpec.current,m=s.durationSpec.current,u=s.creditAmount,p=s.price,y=s.financialProductCode,h={customer:{...n},householdEconomy:this.state.value,externalId:t.externalId,loan:{downPayment:d,interestRate:c,credit:u,financialProductId:y,monthlyCost:a,price:p,term:Ln(m)}};return(await dn(h)).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:c}=t.getState(),d=c?.paymentOptions.find(p=>p.type===bn.Loan),m=s.creditAmount,u=c?.contactInformation?.name;this.view===3&&this.creditAssessmentResponse?new Rn(G(),{store:t,creditAssessmentResponse:this.creditAssessmentResponse,onProceed:()=>{R(),n()},onGoBack:()=>this.onAbort()}):this.view===2?(this.contexts.bankId=new Ve(G(),{method:a?ce.SameDevice:ce.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)}),H()):(this.node.innerHTML=`
|
|
722
722
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
723
723
|
<h5 class="waykeecom-heading waykeecom-heading--4">L\xE5neans\xF6kan</h5>
|
|
724
724
|
<div class="waykeecom-content">
|
|
@@ -1827,5 +1827,5 @@ var Sc=(o=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Pro
|
|
|
1827
1827
|
<div class="waykeecom-stack waykeecom-stack--1" id="${kc}"></div>
|
|
1828
1828
|
<div class="waykeecom-stack waykeecom-stack--1" id="${hc}"></div>
|
|
1829
1829
|
</div>
|
|
1830
|
-
`,new Ge(this.node.querySelector(`#${kc}`),{title:"Forts\xE4tt min order",onClick:()=>t()}),new uc(this.node.querySelector(`#${hc}`),{title:"Avbryt min order",onClick:()=>e()})}},yc=No;var Ao=()=>{let o=document.documentElement.clientWidth/100;document.documentElement.style.setProperty("--waykeecom-vw",`${o}px`)},vc=()=>(Ao(),window.addEventListener("resize",Ao),()=>window.removeEventListener("resize",Ao));var To="order",nd="wayke-ecom-web-payment",Co="wayke-ecom-web-id",Ne="wayke-ecom-modal",Do=class{constructor(i){this.contexts={store:Xo()};if(!i.id)throw"Missing id";this.props=i,window.process||(window.process={...window.process||{},env:{}}),id.bind(i.ecomSdkConfig);let e=document.createElement("div");if(e.className="waykeecom-root",this.root=e,this.props.rootId){let c=document.getElementById(this.props.rootId);if(!c)throw"Missing element with id wayke-ecom";c.appendChild(e)}else document.body.appendChild(this.root);this.root.dataset.version=Ro.version,this.stageOrderList=["centralStorage","customer","financial","tradeIn","accessories","insurance","delivery"],Mo(i.id)(this.contexts.store.dispatch),this.view=this.contexts.store.getState().navigation.view,_(this.contexts.store,"navigation.view",c=>{this.view=c,c!=="preview"&&this.render()},!0);let t=new URLSearchParams(location.search),s=t.get(To)||void 0,n=!!t.get(nd),a=t.get(Co);if(a&&a===this.props.id&&(s||n))if(n){let c=sessionStorage.getItem("wayke-ecom-state");sessionStorage.removeItem("wayke-ecom-state");let d=c?JSON.parse(c):void 0;d&&(this.view=d.navigation.view,Qo({...d,stateLoadedFromSession:!0})(this.contexts.store.dispatch))}else s&&this.render({orderUrl:s,id:a})}close(){let i=we();l(i.view,"CLOSE",i.currentStep);let{caseId:e}=this.contexts.store.getState(),t=new URLSearchParams(location.search),s=t.get(To),n=t.get(Co),a=!1;s&&(t.delete(To),a=!0,location.search=t.toString()),n&&(t.delete(Co),a=!0),a&&(location.search=t.toString()),this.root.innerHTML="",this.contexts?.unsubribeVwListner?.(),ii(),e&&Te(e),sessionStorage.removeItem("wayke-ecom-state"),bo(this.props.id)(this.contexts.store.dispatch),this.props.onEvent&&ai(this.props.onEvent)}closeWithConfirm(){let{navigation:i,createdOrderId:e}=this.contexts.store.getState();if(i.view==="preview"||e){this.close();return}this.contexts.modal=new So(this.root,{title:"Wayke Ecom",id:Ne});let s=we();l(s.view,"CONFIRM_CLOSE_ACTIVE"),new yc(this.contexts.modal.content,{onConfirmClose:()=>{let n=we();l(n.view,"CONFIRM_CLOSE_CONFIRMED",n.currentStep),this.close()},onAbortClose:()=>{let n=we();l(n.view,"CONFIRM_CLOSE_ABORTED",n.currentStep),this.render()}})}start(){this.props.onEvent&&ni(this.props.onEvent),l("PREVIEW","START"),this.render()}render(i){if(this.contexts.unsubribeVwListner||(this.contexts.unsubribeVwListner=vc()),this.contexts.modal=new So(this.root,{title:"Wayke Ecom",id:Ne,onClose:()=>this.closeWithConfirm()}),this.contexts.modal.content){if(this.contexts.modal.content.innerHTML="",i){new ic(this.contexts.modal.content,{store:this.contexts.store,callbackOrder:i,onClose:()=>this.close()});return}switch(this.view){case"preview":new Lr(this.contexts.modal.content,{store:this.contexts.store,stageOrderList:this.stageOrderList,vehicle:this.props.vehicle});break;case"main":new jr(this.contexts.modal.content,{store:this.contexts.store});break;case"summary":new oc(this.contexts.modal.content,{store:this.contexts.store,onClose:()=>this.close()});break;default:throw"Unknown view..."}}}},Ec=Do;var vg=Ec;export{vg as default};
|
|
1830
|
+
`,new Ge(this.node.querySelector(`#${kc}`),{title:"Forts\xE4tt min order",onClick:()=>t()}),new uc(this.node.querySelector(`#${hc}`),{title:"Avbryt min order",onClick:()=>e()})}},yc=No;var Ao=()=>{let o=document.documentElement.clientWidth/100;document.documentElement.style.setProperty("--waykeecom-vw",`${o}px`)},vc=()=>(Ao(),window.addEventListener("resize",Ao),()=>window.removeEventListener("resize",Ao));var To="order",nd="wayke-ecom-web-payment",Co="wayke-ecom-web-id",Ne="wayke-ecom-modal",Do=class{constructor(i){this.contexts={store:Xo()};if(!i.id)throw"Missing id";this.props=i,window.process||(window.process={...window.process||{},env:{}}),id.bind(i.ecomSdkConfig);let e=document.createElement("div");if(e.className="waykeecom-root",this.root=e,this.props.rootId){let c=document.getElementById(this.props.rootId);if(!c)throw"Missing element with id wayke-ecom";c.appendChild(e)}else document.body.appendChild(this.root);this.root.dataset.version=Ro.version,this.stageOrderList=["centralStorage","customer","financial","tradeIn","accessories","insurance","delivery"],Mo(i.id)(this.contexts.store.dispatch),this.view=this.contexts.store.getState().navigation.view,_(this.contexts.store,"navigation.view",c=>{this.view=c,c!=="preview"&&this.render()},!0);let t=new URLSearchParams(location.search),s=t.get(To)||void 0,n=!!t.get(nd),a=t.get(Co);if(a&&a===this.props.id&&(s||n))if(n){let c=sessionStorage.getItem("wayke-ecom-state");sessionStorage.removeItem("wayke-ecom-state");let d=c?JSON.parse(c):void 0;d&&(this.view=d.navigation.view,Qo({...d,stateLoadedFromSession:!0})(this.contexts.store.dispatch))}else s&&this.render({orderUrl:s,id:a})}close(){let i=we();i&&l(i.view,"CLOSE",i.currentStep);let{caseId:e}=this.contexts.store.getState(),t=new URLSearchParams(location.search),s=t.get(To),n=t.get(Co),a=!1;s&&(t.delete(To),a=!0,location.search=t.toString()),n&&(t.delete(Co),a=!0),a&&(location.search=t.toString()),this.root.innerHTML="",this.contexts?.unsubribeVwListner?.(),ii(),e&&Te(e),sessionStorage.removeItem("wayke-ecom-state"),bo(this.props.id)(this.contexts.store.dispatch),this.props.onEvent&&ai(this.props.onEvent)}closeWithConfirm(){let{navigation:i,createdOrderId:e}=this.contexts.store.getState();if(i.view==="preview"||e){this.close();return}this.contexts.modal=new So(this.root,{title:"Wayke Ecom",id:Ne});let s=we();s&&l(s.view,"CONFIRM_CLOSE_ACTIVE"),new yc(this.contexts.modal.content,{onConfirmClose:()=>{let n=we();l(n.view,"CONFIRM_CLOSE_CONFIRMED",n.currentStep),this.close()},onAbortClose:()=>{let n=we();l(n.view,"CONFIRM_CLOSE_ABORTED",n.currentStep),this.render()}})}start(){this.props.onEvent&&ni(this.props.onEvent),l("PREVIEW","START"),this.render()}render(i){if(this.contexts.unsubribeVwListner||(this.contexts.unsubribeVwListner=vc()),this.contexts.modal=new So(this.root,{title:"Wayke Ecom",id:Ne,onClose:()=>this.closeWithConfirm()}),this.contexts.modal.content){if(this.contexts.modal.content.innerHTML="",i){new ic(this.contexts.modal.content,{store:this.contexts.store,callbackOrder:i,onClose:()=>this.close()});return}switch(this.view){case"preview":new Lr(this.contexts.modal.content,{store:this.contexts.store,stageOrderList:this.stageOrderList,vehicle:this.props.vehicle});break;case"main":new jr(this.contexts.modal.content,{store:this.contexts.store});break;case"summary":new oc(this.contexts.modal.content,{store:this.contexts.store,onClose:()=>this.close()});break;default:throw"Unknown view..."}}}},Ec=Do;var vg=Ec;export{vg as default};
|
|
1831
1831
|
//# sourceMappingURL=index.mjs.map
|