@wayke-se/ecom-web 1.5.1-beta.1 → 1.5.1-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.d.ts +1 -0
- package/dist/index.js +9 -5
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +9 -5
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{config as kd}from"@wayke-se/ecom";var Uo={name:"@wayke-se/ecom-web",version:"1.5.1-beta.
|
|
1
|
+
import{config as kd}from"@wayke-se/ecom";var Uo={name:"@wayke-se/ecom-web",version:"1.5.1-beta.2",description:"Wayke Ecom Web",module:"dist/index.mjs",main:"dist/index.js",types:"dist/index.d.ts",homepage:"https://github.com/wayke-se/wayke-ecom-web",scripts:{start:"node ./esbuild/start.js",clip:"node ./esbuild/clip-ui.js && node ./clip-ui/start.js",build:"npm run clean && node ./esbuild/lib.js && node ./esbuild/cdn.js",clean:"rimraf build && rimraf dist && rimraf dist-cdn",test:"npm run lint && npm run typecheck",typecheck:"tsc -noEmit","typecheck:watch":"tsc -noEmit -watch",lint:"eslint --ext .ts,.js 'src'","lint:fix":"eslint --ext .ts,.js 'src' --fix",stylelint:"stylelint '**/*.scss'",prepare:"husky install"},author:"Wayke",license:"ISC",devDependencies:{"@ourstudio/clip-ui":"^0.0.11","@types/marked":"^4.3.0","@types/node":"^17.0.18","@types/object-path":"^0.11.1","@types/sanitize-html":"^2.6.2","@typescript-eslint/eslint-plugin":"^5.12.0","@typescript-eslint/parser":"^5.12.0",esbuild:"^0.15.10","esbuild-sass-plugin":"2.3.3",eslint:"^8.9.0","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^4.0.0",husky:"^8.0.1","npm-dts":"^1.3.11",prettier:"^2.5.1",rimraf:"^5.0.1",stylelint:"^15.2.0","stylelint-config-prettier-scss":"^1.0.0","stylelint-config-standard-scss":"^9.0.0",typescript:"^5.1.3"},dependencies:{"@wayke-se/ecom":"^4.4.0-beta.5",marked:"^4.3.0","object-path":"^0.11.8",redux:"^4.1.2","sanitize-html":"^2.7.0"},files:["dist"]};import{createStore as Vc}from"redux";import{DrivingDistance as Bc,PaymentType as ni}from"@wayke-se/ecom";var tt=(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()}),Vo=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()}),Le=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()}),Go=o=>({vehicle:o.getVehicle()});var st="RESET",qo=o=>i=>i({type:st,id:o}),ot="SET_ORDER",Oe=(o,i)=>e=>e({type:ot,order:o,vehicle:i}),it="SET_ID",Wo=o=>i=>i({type:it,id:o}),at="SET_CONTACT_EMAIL_AND_PHONE",Yo=o=>i=>i({type:at,value:o}),nt="SET_SOCIAL_ID_AND_ADDRESS",Ko=(o,i,e)=>t=>t({type:nt,socialId:o,address:i,lastStage:e}),rt="SET_HOME_DELIVERY",Qo=(o,i)=>e=>e({type:rt,homeDelivery:o,lastStage:i}),ct="SET_DEALER",zo=(o,i)=>e=>e({type:ct,dealer:o,lastStage:i}),lt="INIT_TRADE_IN",jo=o=>i=>i({type:lt,lastStage:o}),dt="SET_TRADE_IN",Se=(o,i,e)=>t=>t({type:dt,lastStage:o,tradeIn:i,tradeInVehicle:e}),mt="SET_FINANCIAL",Jo=(o,i)=>e=>e({type:mt,paymentType:o,lastStage:i}),pt="SET_PAYMENT_LOOKUP_RESPONSE",Xo=o=>i=>i({type:pt,paymentLookupResponse:_e(o)}),ut="SET_DRIVING_DISTANCE",Zo=o=>i=>i({type:ut,drivingDistance:o}),ht="COMPLETE_STAGE",j=o=>i=>i({type:ht,lastStage:o}),kt="SET_OR_REMOVE_INSURANCE",le=o=>i=>i({type:kt,insurance:o}),yt="SET_OR_REMOVE_INSURANCE_ADDONS",ei=(o,i)=>e=>e({type:yt,insurance:o,insuranceAddons:i}),vt="SET_OR_REMOVE_FREE_INSURANCE",ti=o=>i=>i({type:vt,freeInsurance:o}),Et="SET_OR_REMOVE_ACCESSORY",si=o=>i=>i({type:Et,accessory:o}),It="GO_TO",M=(o,i,e)=>t=>t({type:It,view:o,index:i,subStage:e}),ft="SET_STAGES",oi=o=>i=>i({type:ft,stages:o}),gt="SET_CREATED_ORDER_ID",ii=(o,i)=>e=>e({type:gt,id:o,payment:i}),_t="SET_CREDIT_ASSESSMENT_RESPONSE",de=(o,i)=>e=>e({type:_t,caseId:o,creditAssessmentResponse:i}),St="SET_STATE",ai=o=>i=>i({type:St,state:o});var Fc={};var ri={view:"preview",stage:1,subStage:1},ci={id:"",topNavigation:{...ri},navigation:{...ri},customer:{email:"",phone:"",givenName:"",surname:"",socialId:""},homeDelivery:!1,accessories:[],drivingDistance:Bc.Between0And1000,...Fc},ie=(o,i)=>i?{view:"summary",stage:1,subStage:1}:{view:"main",stage:o+1,subStage:1},ae=(o,i)=>i.view==="main"?o.stage<i.stage?i:v.topNavigation:{...o,stage:o.stage+1},wt=o=>o&&o?.length===1&&o?.[0].type===ni.Cash?ni.Cash:void 0,v,Nt,Uc=(o=ci,i)=>{let e,t;switch(v={...o},i.type){case st:return{...ci,id:i.id};case ft:return{...v,stages:i.stages};case it:return{...v,id:i.id};case ot:return{...o,order:i.order,paymentType:wt(i.order?.paymentOptions),vehicle:{...i.order.orderVehicle,...i.vehicle||{}}};case at:let s={...v,customer:{...o.customer,email:i.value.email,phone:i.value.phone},navigation:{view:"main",stage:o.navigation.stage,subStage:2}};return delete s.wantTradeIn,delete s.tradeIn,delete s.tradeInVehicle,s.paymentType=wt(o.order?.paymentOptions),delete s.paymentLookupResponse,delete s.insurance,delete s.insuranceAddOns,delete s.freeInsurance,delete s.dealer,s.accessories=[],s;case nt:return e=ie(v.navigation.stage,i.lastStage),t=ae(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,address:i.address,customer:{...o.customer,socialId:i.socialId}},v;case ct: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=wt(o.order?.paymentOptions),delete v.paymentLookupResponse,delete v.insurance,delete v.insuranceAddOns,delete v.freeInsurance,v.accessories=[],v;case rt:return e=ie(o.navigation.stage,i.lastStage),t=ae(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,homeDelivery:i.homeDelivery},v;case lt:return e={view:"main",stage:o.navigation.stage,subStage:1},t=ae(v.topNavigation,e),v={...o,navigation:e,wantTradeIn:!0,topNavigation:t,tradeIn:o.tradeIn||{registrationNumber:"",mileage:"",description:""}},v;case dt:return e=ie(o.navigation.stage,i.lastStage),t=ae(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,wantTradeIn:!!i.tradeIn,tradeIn:i.tradeIn,tradeInVehicle:i.tradeInVehicle},v;case mt:return e=ie(o.navigation.stage,i.lastStage),t=ae(v.topNavigation,e),{...v,navigation:e,topNavigation:t,paymentType:i.paymentType};case pt:return{...v,paymentLookupResponse:i.paymentLookupResponse};case ut:return{...v,drivingDistance:i.drivingDistance};case ht:return e=ie(o.navigation.stage,i.lastStage),t=ae(v.topNavigation,e),v={...o,navigation:e,topNavigation:t},v;case yt:return v.insurance=i.insurance,v.insuranceAddOns={insurance:i.insurance.name,addOns:i.insuranceAddons},v;case kt:return tt(v.insurance,i.insurance)?v.insurance=void 0:v.insurance=i.insurance,v.insuranceAddOns?.insurance&&(v.insuranceAddOns=void 0),v;case vt:return tt(v.freeInsurance,i.freeInsurance)?v.freeInsurance=void 0:v.freeInsurance=i.freeInsurance,v;case Et:return Nt=v.accessories.findIndex(a=>a.id===i.accessory.id),v.accessories=[...v.accessories],Nt>-1?v.accessories.splice(Nt,1):v.accessories.push(i.accessory),{...v,accessories:[...v.accessories]};case It:return{...o,navigation:{view:i.view,stage:i.index||1,subStage:i.subStage||1}};case gt:return i.payment?e={view:"main",stage:o.navigation.stage,subStage:2}:e=ie(o.navigation.stage,!0),t=ae(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,createdOrderId:i.id,payment:i.payment},v;case _t:return{...v,caseId:i.caseId,creditAssessmentResponse:i.creditAssessmentResponse};case St:return{...i.state};default:return o}},li=Uc;var di=()=>Vc(li);var Me=(o,i)=>{if(!i)return o;let e=new URL(o);return`${i}${e.pathname}`};var Gc=o=>o.toString().replace(/\s/g,""),qc=(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=qc(o,i?.decimals!==void 0?i.decimals:0);return`${i?.prefix?`${i.prefix}`:""}${Gc(e).replace(/\B(?=(\d{3})+(?!\d))/g," ")}${i?.postfix?` ${i.postfix}`:""}`},Wc=(o,i)=>{let e=o.split(" "),t=i.split(" ").map(s=>s.toLowerCase());return e.filter(s=>!t.includes(s.toLowerCase())).join(" ")},me=o=>{if(!!o)return Wc(o.shortDescription||"",o.title||"")};var Yc=({vehicle:o,order:i,meta:e,cdnMedia:t})=>{let s=o?.imageUrls,a=o?.title,n=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">
|
|
@@ -732,9 +732,13 @@ import{config as kd}from"@wayke-se/ecom";var Uo={name:"@wayke-se/ecom-web",versi
|
|
|
732
732
|
${a?`name="${a}"`:""}
|
|
733
733
|
${e?`id="${e}"`:""}
|
|
734
734
|
>
|
|
735
|
-
${t.map(u=>`<option
|
|
735
|
+
${t.map(u=>`<option
|
|
736
|
+
value="${u.value}"
|
|
737
|
+
${u.disabled?"disabled":""}
|
|
738
|
+
${u.value===s?'selected="selected"':""}
|
|
739
|
+
>${u.title||u.value}</option>`).join("")}
|
|
736
740
|
</select>
|
|
737
|
-
`,this.updateBorder(),c&&(this.contexts.error=new ee(this.node,{error:l,errorMessage:c})),this.node.querySelector("select")?.addEventListener("change",u=>m(u))}},je=ws;var Hl="credit-assessment-martial-status",Ga=`${Hl}-node`,Ts="credit-assessment-income",Ns=`${Ts}-node`,Bl="credit-assessment-employment",qa=`${Bl}-node`,Fl="credit-assessment-household-children",Wa=`${Fl}-node`,sn="credit-assessment-housing-cost",Ya=`${sn}-node`,on="credit-assessment-debt-specification-card-credit",Ka=`${on}-node`,an="credit-assessment-debt-specification-car-loan",Qa=`${an}-node`,nn="credit-assessment-debt-specification-collateral",za=`${nn}-node`,rn="credit-assessment-debt-specification-leasing-fees",ja=`${rn}-node`,cn="credit-assessment-debt-specification-private-loan",Ja=`${cn}-node`,Ul="credit-assessment-housing-type",Xa=`${Ul}-node`,ln="credit-assessment-perform-application",As=`${ln}-node`,Za="disclaimer-node",en="disclaimer-safe-node",tn="why-description-node",P={maritalStatus:A.requiredAssessmentMaritalStatus,income:A.requiredNumberGreaterOrEqualThanZero,employment:A.requiredAssessmentEmplyment,householdChildren:A.requiredNumberGreaterOrEqualThanZero,housingCost:A.requiredNumberGreaterOrEqualThanZero,"debtSpecification.cardCredits":A.optionalNumberGreaterOrEqualThanZero,"debtSpecification.carLoan":A.optionalNumberGreaterOrEqualThanZero,"debtSpecification.collateral":A.optionalNumberGreaterOrEqualThanZero,"debtSpecification.leasingFees":A.optionalNumberGreaterOrEqualThanZero,"debtSpecification.privateLoan":A.optionalNumberGreaterOrEqualThanZero,housingType:A.requiredHousingType},Vl={maritalStatus:Je.Married,income:5e4,employment:re.FullTimeEmployed,householdChildren:0,housingCost:2e3,debtSpecification:{cardCredits:0,carLoan:0,collateral:0,leasingFees:0,privateLoan:0},housingType:J.Apartment},Gl=()=>location.hostname==="localhost"?{...Vl}:void 0,ql=o=>{let i={maritalStatus:o?.maritalStatus||"",income:o?.income.toString()||"",employment:o?.employment.toString()||"",householdChildren:o?.householdChildren.toString()||"",housingCost:o?.housingCost.toString()||"","debtSpecification.cardCredits":o?.debtSpecification.cardCredits.toString()||"","debtSpecification.carLoan":o?.debtSpecification.carLoan.toString()||"","debtSpecification.collateral":o?.debtSpecification.collateral.toString()||"","debtSpecification.leasingFees":o?.debtSpecification.leasingFees.toString()||"","debtSpecification.privateLoan":o?.debtSpecification.privateLoan.toString()||"",housingType:o?.housingType.toString()||""};return{value:i,validation:{maritalStatus:P.maritalStatus(i.maritalStatus),income:P.income(i.income),employment:P.employment(i.employment),householdChildren:P.householdChildren(i.householdChildren),housingCost:P.housingCost(i.housingCost),"debtSpecification.cardCredits":P["debtSpecification.cardCredits"](i["debtSpecification.cardCredits"]),"debtSpecification.carLoan":P["debtSpecification.carLoan"](i["debtSpecification.carLoan"]),"debtSpecification.collateral":P["debtSpecification.collateral"](i["debtSpecification.collateral"]),"debtSpecification.leasingFees":P["debtSpecification.leasingFees"](i["debtSpecification.leasingFees"]),"debtSpecification.privateLoan":P["debtSpecification.privateLoan"](i["debtSpecification.privateLoan"]),housingType:P.housingType(i.housingType)},interact:{maritalStatus:!1,income:!1,employment:!1,householdChildren:!1,housingCost:!1,"debtSpecification.cardCredits":!1,"debtSpecification.carLoan":!1,"debtSpecification.collateral":!1,"debtSpecification.leasingFees":!1,"debtSpecification.privateLoan":!1,housingType:!1}}},Cs=class extends r{constructor(e,t){super(e);this.view=1;this.contexts={};this.bankidError=!1;this.signed=!1;this.props=t,this.state=ql(Gl()),this.render()}onChange(e){let t=e.currentTarget,s=t.name,a=t.value;this.state.value[s]=a,this.state.validation[s]=P[s](a),this.updateUiError(s),this.updateProceedButton()}onBlur(e){let s=e.currentTarget.name;this.state.interact[s]=!0,this.state.validation[s]=P[s](this.state.value[s]),this.updateUiError(s),this.updateProceedButton()}onChangeSelect(e){let t=e.currentTarget,s=t.name,a=t.value;this.state.value[s]=a,this.state.validation[s]=P[s](a),this.updateProceedButton()}onChangeRadio(e){let t=e.currentTarget,s=t.name,a=t.value;this.state.value[s]=a,this.state.validation[s]=P[s](a),s==="housingType"&&(t.value===J.SingleFamily&&(this.state.value.housingCost="0",this.state.validation.housingCost=P.housingCost(this.state.value.housingCost)),this.render()),this.updateProceedButton()}updateUiError(e){this.contexts[e]?.setError(this.state.interact[e]&&!this.state.validation[e])}updateProceedButton(){this.contexts.performApplicationButton?.disabled(!this.state.validation.maritalStatus||!this.state.validation.income||!this.state.validation.employment||!this.state.validation.householdChildren||!this.state.validation.housingCost||!this.state.validation["debtSpecification.cardCredits"]||!this.state.validation["debtSpecification.carLoan"]||!this.state.validation["debtSpecification.collateral"]||!this.state.validation["debtSpecification.leasingFees"]||!this.state.validation["debtSpecification.privateLoan"]||!this.state.validation.housingType)}async onAbort(){d("MAIN","FINANCIAL_CREDIT_SCORING_ABORTED","FINANCIAL_CREDIT_SCORING");let{store:e}=this.props;this.view=1,this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval);let t=e.getState().caseId;t&&(await Ce(t),await Ss(t),de()(e.dispatch)),R(),this.creditAssessmentResponse=void 0,this.render(!0)}bankIdStatus(e,t,s=!1){s||d("MAIN",t===fe.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_REQUESTED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_REQUESTED","FINANCIAL_CREDIT_SCORING");let a=this.props.store.getState().order?.paymentOptions.find(n=>n.type===Va.Loan);this.bankidStatusInterval=setInterval(async()=>{try{let n=await Ia(e),l=n.getStatus();if(!this.signed&&l==="signed"&&(d("MAIN",t===fe.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_SUCCEEDED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.signed=!0,this.contexts.bankId?.setTitle(`V\xE4ntar p\xE5 ${a?.name}...`),this.contexts.bankId?.setDescription(`H\xE4mtar uppgifter fr\xE5n ${a?.name}. V\xE4nta kvar det kan ta n\xE5gra sekunder.`),this.contexts.bankId?.setFinalizing(!0),d("MAIN","FINANCIAL_CREDIT_SCORING_SIGNING_SIGNED","FINANCIAL_CREDIT_SCORING")),l==="signingFailed"){clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Ett fel uppstod");return}if(n.isScored()?(d("MAIN","FINANCIAL_CREDIT_SCORING_SIGNING_SCORED","FINANCIAL_CREDIT_SCORING"),this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.view=3,this.creditAssessmentResponse=Vo(n),de(e,this.creditAssessmentResponse)(this.props.store.dispatch),R(),this.render()):n.hasScoringError()&&(clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Ett fel uppstod")),!this.signed&&t===fe.QrCode){let c=n.getQrCode();this.contexts.bankId?.update(t,c)}}catch{clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering")}},1e3),De("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 a=await ga({caseId:s,method:e});if(t||d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.bankIdStatus(s,e,t),e===fe.SameDevice){let n=a.getAutoLaunchUrl();this.contexts.bankId?.update(e,n)}else{let n=a.getQrCode();this.contexts.bankId?.update(e,n)}}catch{d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_FAILED","FINANCIAL_CREDIT_SCORING"),this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.bankidError=!0,this.view=1,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 Ce(s),await Ss(s),de()(t.dispatch))),s){let a=await this.newCreditAssessmentCase();de(a)(t.dispatch),this.onStartBankIdAuth(e)}else try{d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_REQUESTED","FINANCIAL_CREDIT_SCORING");let a=await this.newCreditAssessmentCase();d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),a&&(de(a)(t.dispatch),this.onStartBankIdAuth(e))}catch{d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_FAILED","FINANCIAL_CREDIT_SCORING")}}async newCreditAssessmentCase(){try{let{store:e,loan:t,paymentLookupResponse:s}=this.props;this.contexts.performApplicationButton?.disabled(!0);let{customer:a}=e.getState(),{monthlyCost:n}=s.costs,{interest:l}=s.interests,c=s.downPaymentSpec.current,m=s.durationSpec.current,u=s.creditAmount,h=s.price,p=s.financialProductCode,y={employment:this.state.value.employment,householdChildren:parseInt(this.state.value.householdChildren,10),housingCost:parseInt(this.state.value.housingCost||"0",10),housingType:this.state.value.housingType,income:parseInt(this.state.value.income||"0",10),maritalStatus:this.state.value.maritalStatus,debtSpecification:{cardCredits:parseInt(this.state.value["debtSpecification.cardCredits"]||"0",10),carLoan:parseInt(this.state.value["debtSpecification.carLoan"]||"0",10),collateral:parseInt(this.state.value["debtSpecification.collateral"]||"0",10),leasingFees:parseInt(this.state.value["debtSpecification.leasingFees"]||"0",10),privateLoan:parseInt(this.state.value["debtSpecification.privateLoan"]||"0",10)}},f={customer:{...a},householdEconomy:y,externalId:t.externalId,loan:{downPayment:c,interestRate:l,credit:u,financialProductId:p,monthlyCost:n,price:h,term:Ua(m)}};return(await fa(f)).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:a}=this.props,n=ve(),{order:l}=t.getState(),c=l?.paymentOptions.find(h=>h.type===Va.Loan),m=s.creditAmount,u=l?.contactInformation?.name;if(this.view===3&&this.creditAssessmentResponse)new Fa(q(),{store:t,creditAssessmentResponse:this.creditAssessmentResponse,onProceed:()=>{R(),a()},onGoBack:()=>this.onAbort()});else if(this.view===2)this.contexts.bankId=new Ke(q(),{method:n?fe.SameDevice:fe.QrCode,descriptionQrCode:"F\xF6r att h\xE4mta dina uppgifter, starta din BankID applikation p\xE5 din andra enhet.",descriptionSameDevice:"F\xF6r att h\xE4mta dina uppgifter, starta din BankID-applikation.",onAbort:()=>this.onAbort(),onStart:h=>this.startBankId(h)}),F();else{this.node.innerHTML=`
|
|
741
|
+
`,this.updateBorder(),c&&(this.contexts.error=new ee(this.node,{error:l,errorMessage:c})),this.node.querySelector("select")?.addEventListener("change",u=>m(u))}},je=ws;var Hl="credit-assessment-martial-status",Ga=`${Hl}-node`,Ts="credit-assessment-income",Ns=`${Ts}-node`,Bl="credit-assessment-employment",qa=`${Bl}-node`,Fl="credit-assessment-household-children",Wa=`${Fl}-node`,sn="credit-assessment-housing-cost",Ya=`${sn}-node`,on="credit-assessment-debt-specification-card-credit",Ka=`${on}-node`,an="credit-assessment-debt-specification-car-loan",Qa=`${an}-node`,nn="credit-assessment-debt-specification-collateral",za=`${nn}-node`,rn="credit-assessment-debt-specification-leasing-fees",ja=`${rn}-node`,cn="credit-assessment-debt-specification-private-loan",Ja=`${cn}-node`,Ul="credit-assessment-housing-type",Xa=`${Ul}-node`,ln="credit-assessment-perform-application",As=`${ln}-node`,Za="disclaimer-node",en="disclaimer-safe-node",tn="why-description-node",P={maritalStatus:A.requiredAssessmentMaritalStatus,income:A.requiredNumberGreaterOrEqualThanZero,employment:A.requiredAssessmentEmplyment,householdChildren:A.requiredNumberGreaterOrEqualThanZero,housingCost:A.requiredNumberGreaterOrEqualThanZero,"debtSpecification.cardCredits":A.optionalNumberGreaterOrEqualThanZero,"debtSpecification.carLoan":A.optionalNumberGreaterOrEqualThanZero,"debtSpecification.collateral":A.optionalNumberGreaterOrEqualThanZero,"debtSpecification.leasingFees":A.optionalNumberGreaterOrEqualThanZero,"debtSpecification.privateLoan":A.optionalNumberGreaterOrEqualThanZero,housingType:A.requiredHousingType},Vl={maritalStatus:Je.Married,income:5e4,employment:re.FullTimeEmployed,householdChildren:-1,housingCost:2e3,debtSpecification:{cardCredits:0,carLoan:0,collateral:0,leasingFees:0,privateLoan:0},housingType:J.Apartment},Gl=()=>location.hostname==="localhost"?{...Vl}:void 0,ql=o=>{let i={maritalStatus:o?.maritalStatus||"",income:o?.income.toString()||"",employment:o?.employment.toString()||"",householdChildren:o?.householdChildren.toString()||"-1",housingCost:o?.housingCost.toString()||"","debtSpecification.cardCredits":o?.debtSpecification.cardCredits.toString()||"","debtSpecification.carLoan":o?.debtSpecification.carLoan.toString()||"","debtSpecification.collateral":o?.debtSpecification.collateral.toString()||"","debtSpecification.leasingFees":o?.debtSpecification.leasingFees.toString()||"","debtSpecification.privateLoan":o?.debtSpecification.privateLoan.toString()||"",housingType:o?.housingType.toString()||""};return{value:i,validation:{maritalStatus:P.maritalStatus(i.maritalStatus),income:P.income(i.income),employment:P.employment(i.employment),householdChildren:P.householdChildren(i.householdChildren),housingCost:P.housingCost(i.housingCost),"debtSpecification.cardCredits":P["debtSpecification.cardCredits"](i["debtSpecification.cardCredits"]),"debtSpecification.carLoan":P["debtSpecification.carLoan"](i["debtSpecification.carLoan"]),"debtSpecification.collateral":P["debtSpecification.collateral"](i["debtSpecification.collateral"]),"debtSpecification.leasingFees":P["debtSpecification.leasingFees"](i["debtSpecification.leasingFees"]),"debtSpecification.privateLoan":P["debtSpecification.privateLoan"](i["debtSpecification.privateLoan"]),housingType:P.housingType(i.housingType)},interact:{maritalStatus:!1,income:!1,employment:!1,householdChildren:!1,housingCost:!1,"debtSpecification.cardCredits":!1,"debtSpecification.carLoan":!1,"debtSpecification.collateral":!1,"debtSpecification.leasingFees":!1,"debtSpecification.privateLoan":!1,housingType:!1}}},Cs=class extends r{constructor(e,t){super(e);this.view=1;this.contexts={};this.bankidError=!1;this.signed=!1;this.props=t,this.state=ql(Gl()),this.render()}onChange(e){let t=e.currentTarget,s=t.name,a=t.value;this.state.value[s]=a,this.state.validation[s]=P[s](a),this.updateUiError(s),this.updateProceedButton()}onBlur(e){let s=e.currentTarget.name;this.state.interact[s]=!0,this.state.validation[s]=P[s](this.state.value[s]),this.updateUiError(s),this.updateProceedButton()}onChangeSelect(e){let t=e.currentTarget,s=t.name,a=t.value;this.state.value[s]=a,this.state.validation[s]=P[s](a),this.updateProceedButton()}onChangeRadio(e){let t=e.currentTarget,s=t.name,a=t.value;this.state.value[s]=a,this.state.validation[s]=P[s](a),s==="housingType"&&(t.value===J.SingleFamily&&(this.state.value.housingCost="0",this.state.validation.housingCost=P.housingCost(this.state.value.housingCost)),this.render()),this.updateProceedButton()}updateUiError(e){this.contexts[e]?.setError(this.state.interact[e]&&!this.state.validation[e])}updateProceedButton(){this.contexts.performApplicationButton?.disabled(!this.state.validation.maritalStatus||!this.state.validation.income||!this.state.validation.employment||!this.state.validation.householdChildren||!this.state.validation.housingCost||!this.state.validation["debtSpecification.cardCredits"]||!this.state.validation["debtSpecification.carLoan"]||!this.state.validation["debtSpecification.collateral"]||!this.state.validation["debtSpecification.leasingFees"]||!this.state.validation["debtSpecification.privateLoan"]||!this.state.validation.housingType)}async onAbort(){d("MAIN","FINANCIAL_CREDIT_SCORING_ABORTED","FINANCIAL_CREDIT_SCORING");let{store:e}=this.props;this.view=1,this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval);let t=e.getState().caseId;t&&(await Ce(t),await Ss(t),de()(e.dispatch)),R(),this.creditAssessmentResponse=void 0,this.render(!0)}bankIdStatus(e,t,s=!1){s||d("MAIN",t===fe.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_REQUESTED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_REQUESTED","FINANCIAL_CREDIT_SCORING");let a=this.props.store.getState().order?.paymentOptions.find(n=>n.type===Va.Loan);this.bankidStatusInterval=setInterval(async()=>{try{let n=await Ia(e),l=n.getStatus();if(!this.signed&&l==="signed"&&(d("MAIN",t===fe.SameDevice?"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_SAME_DEVICE_SUCCEEDED":"FINANCIAL_CREDIT_SCORING_BANKID_STATUS_QR_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.signed=!0,this.contexts.bankId?.setTitle(`V\xE4ntar p\xE5 ${a?.name}...`),this.contexts.bankId?.setDescription(`H\xE4mtar uppgifter fr\xE5n ${a?.name}. V\xE4nta kvar det kan ta n\xE5gra sekunder.`),this.contexts.bankId?.setFinalizing(!0),d("MAIN","FINANCIAL_CREDIT_SCORING_SIGNING_SIGNED","FINANCIAL_CREDIT_SCORING")),l==="signingFailed"){clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Ett fel uppstod");return}if(n.isScored()?(d("MAIN","FINANCIAL_CREDIT_SCORING_SIGNING_SCORED","FINANCIAL_CREDIT_SCORING"),this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.view=3,this.creditAssessmentResponse=Vo(n),de(e,this.creditAssessmentResponse)(this.props.store.dispatch),R(),this.render()):n.hasScoringError()&&(clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Ett fel uppstod")),!this.signed&&t===fe.QrCode){let c=n.getQrCode();this.contexts.bankId?.update(t,c)}}catch{clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setFinalizing(!1),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering")}},1e3),De("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 a=await ga({caseId:s,method:e});if(t||d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),this.bankIdStatus(s,e,t),e===fe.SameDevice){let n=a.getAutoLaunchUrl();this.contexts.bankId?.update(e,n)}else{let n=a.getQrCode();this.contexts.bankId?.update(e,n)}}catch{d("MAIN","FINANCIAL_CREDIT_SCORING_BANKID_INIT_FAILED","FINANCIAL_CREDIT_SCORING"),this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),this.bankidError=!0,this.view=1,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 Ce(s),await Ss(s),de()(t.dispatch))),s){let a=await this.newCreditAssessmentCase();de(a)(t.dispatch),this.onStartBankIdAuth(e)}else try{d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_REQUESTED","FINANCIAL_CREDIT_SCORING");let a=await this.newCreditAssessmentCase();d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_SUCCEEDED","FINANCIAL_CREDIT_SCORING"),a&&(de(a)(t.dispatch),this.onStartBankIdAuth(e))}catch{d("MAIN","FINANCIAL_CREDIT_SCORING_CREATE_CASE_FAILED","FINANCIAL_CREDIT_SCORING")}}async newCreditAssessmentCase(){try{let{store:e,loan:t,paymentLookupResponse:s}=this.props;this.contexts.performApplicationButton?.disabled(!0);let{customer:a}=e.getState(),{monthlyCost:n}=s.costs,{interest:l}=s.interests,c=s.downPaymentSpec.current,m=s.durationSpec.current,u=s.creditAmount,h=s.price,p=s.financialProductCode,y={employment:this.state.value.employment,householdChildren:parseInt(this.state.value.householdChildren,10),housingCost:parseInt(this.state.value.housingCost||"0",10),housingType:this.state.value.housingType,income:parseInt(this.state.value.income||"0",10),maritalStatus:this.state.value.maritalStatus,debtSpecification:{cardCredits:parseInt(this.state.value["debtSpecification.cardCredits"]||"0",10),carLoan:parseInt(this.state.value["debtSpecification.carLoan"]||"0",10),collateral:parseInt(this.state.value["debtSpecification.collateral"]||"0",10),leasingFees:parseInt(this.state.value["debtSpecification.leasingFees"]||"0",10),privateLoan:parseInt(this.state.value["debtSpecification.privateLoan"]||"0",10)}},f={customer:{...a},householdEconomy:y,externalId:t.externalId,loan:{downPayment:c,interestRate:l,credit:u,financialProductId:p,monthlyCost:n,price:h,term:Ua(m)}};return(await fa(f)).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:a}=this.props,n=ve(),{order:l}=t.getState(),c=l?.paymentOptions.find(h=>h.type===Va.Loan),m=s.creditAmount,u=l?.contactInformation?.name;if(this.view===3&&this.creditAssessmentResponse)new Fa(q(),{store:t,creditAssessmentResponse:this.creditAssessmentResponse,onProceed:()=>{R(),a()},onGoBack:()=>this.onAbort()});else if(this.view===2)this.contexts.bankId=new Ke(q(),{method:n?fe.SameDevice:fe.QrCode,descriptionQrCode:"F\xF6r att h\xE4mta dina uppgifter, starta din BankID applikation p\xE5 din andra enhet.",descriptionSameDevice:"F\xF6r att h\xE4mta dina uppgifter, starta din BankID-applikation.",onAbort:()=>this.onAbort(),onStart:h=>this.startBankId(h)}),F();else{this.node.innerHTML=`
|
|
738
742
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
739
743
|
<h5 class="waykeecom-heading waykeecom-heading--4">L\xE5neans\xF6kan</h5>
|
|
740
744
|
<div class="waykeecom-content">
|
|
@@ -843,12 +847,12 @@ import{config as kd}from"@wayke-se/ecom";var Uo={name:"@wayke-se/ecom-web",versi
|
|
|
843
847
|
<div class="waykeecom-stack waykeecom-stack--1" id="${en}"></div>
|
|
844
848
|
</div>
|
|
845
849
|
</div>
|
|
846
|
-
`,this.contexts.maritalStatus=new W(this.node.querySelector(`#${Ga}`),{
|
|
850
|
+
`,this.contexts.maritalStatus=new W(this.node.querySelector(`#${Ga}`),{checked:this.state.value.maritalStatus,name:"maritalStatus",options:[{id:`maritalStatus-${1}`,value:Je.Married,title:"Gift/partnerskap"},{id:`maritalStatus-${2}`,value:Je.CommonLaw,title:"Sambo"},{id:`maritalStatus-${3}`,value:Je.Single,title:"Ensamst\xE5ende"}],onClick:p=>this.onChangeRadio(p)}),this.contexts.income=new L(this.node.querySelector(`#${Ns}`),{title:"Inkomst per m\xE5nad f\xF6re skatt",value:this.state.value.income,id:Ts,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 W(this.node.querySelector(`#${qa}`),{checked:this.state.value.employment,name:"employment",options:[{id:`employment-${1}`,value:re.FullTimeEmployed,title:"Fast eller tillsvidareanst\xE4lld"},{id:`employment-${2}`,value:re.TemporarilyEmployed,title:"Visstidsanst\xE4lld"},{id:`employment-${3}`,value:re.SelfEmployed,title:"Egen f\xF6retagare"},{id:`employment-${4}`,value:re.Retired,title:"Pension\xE4r"},{id:`employment-${5}`,value:re.Student,title:"Student"},{id:`employment-${6}`,value:re.Other,title:"Annan"}],onClick:p=>this.onChangeRadio(p)}),this.contexts.housingType=new W(this.node.querySelector(`#${Xa}`),{title:"Boendeform",checked:this.state.value.housingType,name:"housingType",options:[{id:`housingType-${1}`,value:J.SingleFamily,title:"Villa"},{id:`housingType-${2}`,value:J.Condominium,title:"Bostadsr\xE4tt"},{id:`housingType-${3}`,value:J.Apartment,title:"Hyresr\xE4tt"}],onClick:p=>this.onChangeRadio(p)}),this.contexts.income=new L(this.node.querySelector(`#${Ns}`),{title:"Inkomst per m\xE5nad f\xF6re skatt",value:this.state.value.income,id:Ts,error:this.state.interact.income&&!this.state.validation.income,errorMessage:"Ange din inkomst per \xE5r f\xF6re skatt",name:"income",autocomplete:"off",placeholder:"",unit:"kr",type:"number",information:`
|
|
847
851
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
848
852
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Inkomst per m\xE5nad f\xF6re skatt</span></p>
|
|
849
853
|
<p class="waykeecom-content__p">L\xF6n och/eller pension, inte bidrag eller studiel\xE5n.</p>
|
|
850
854
|
</div>
|
|
851
|
-
`,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p)}),this.contexts.householdChildren=new je(this.node.querySelector(`#${Wa}`),{title:"Antal barn under 18 \xE5r",value:this.state.value.householdChildren,name:"householdChildren",options:[{value:"0"},{value:"1"},{value:"2"},{value:"3"},{value:"4"},{value:"5"},{value:"6"},{value:"7"},{value:"8"},{value:"9"},{value:"10",title:"10 eller fler"}],onChange:p=>this.onChangeSelect(p)});let h=this.node.querySelector(`#${Ya}`);h&&(this.contexts.housingCost=new L(h,{title:this.state.value.housingType===J.Condominium?"Min del av m\xE5nadsavgiften":this.state.value.housingType===J.Apartment?"Min del av m\xE5nadshyran":"Boendekostnad",value:this.state.value.housingCost,id:sn,error:this.state.interact.housingCost&&!this.state.validation.housingCost,errorMessage:"Ange boendekostnader per m\xE5nad",name:"housingCost",autocomplete:"off",placeholder:"",unit:"kr",type:"number",min:0,information:this.state.value.housingType===J.Condominium?`
|
|
855
|
+
`,onChange:p=>this.onChange(p),onBlur:p=>this.onBlur(p)}),this.contexts.householdChildren=new je(this.node.querySelector(`#${Wa}`),{title:"Antal barn under 18 \xE5r",value:this.state.value.householdChildren,name:"householdChildren",error:this.state.interact.householdChildren&&!this.state.validation.householdChildren,errorMessage:"V\xE4lj antal barn",options:[{value:"-1",title:"V\xE4lj antal barn",disabled:!0},{value:"0"},{value:"1"},{value:"2"},{value:"3"},{value:"4"},{value:"5"},{value:"6"},{value:"7"},{value:"8"},{value:"9"},{value:"10",title:"10 eller fler"}],onChange:p=>this.onChangeSelect(p)});let h=this.node.querySelector(`#${Ya}`);h&&(this.contexts.housingCost=new L(h,{title:this.state.value.housingType===J.Condominium?"Min del av m\xE5nadsavgiften":this.state.value.housingType===J.Apartment?"Min del av m\xE5nadshyran":"Boendekostnad",value:this.state.value.housingCost,id:sn,error:this.state.interact.housingCost&&!this.state.validation.housingCost,errorMessage:"Ange boendekostnader per m\xE5nad",name:"housingCost",autocomplete:"off",placeholder:"",unit:"kr",type:"number",min:0,information:this.state.value.housingType===J.Condominium?`
|
|
852
856
|
<div class="waykeecom-content waykeecom-content--inherit-size">
|
|
853
857
|
<p class="waykeecom-content__p"><span class="waykeecom-text waykeecom-text--font-medium">Min del av m\xE5nadsavgiften</span></p>
|
|
854
858
|
<p class="waykeecom-content__p">Exklusive r\xE4nta och amortering</p>
|