@wayke-se/ecom-web 0.0.8-beta.10 → 0.0.8-beta.11
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 +4 -4
- package/dist/index.js +2 -2
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +2 -2
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1451,18 +1451,18 @@ declare module '@wayke-se/ecom-web/src/Redux/action' {
|
|
|
1451
1451
|
};
|
|
1452
1452
|
export const SET_CREATED_ORDER_ID = "SET_CREATED_ORDER_ID";
|
|
1453
1453
|
export type SET_CREATED_ORDER_ID_TYPE = BaseAction<typeof SET_CREATED_ORDER_ID> & {
|
|
1454
|
-
id: string;
|
|
1454
|
+
id: string | null | undefined;
|
|
1455
1455
|
payment?: {
|
|
1456
1456
|
type: string;
|
|
1457
1457
|
url: string;
|
|
1458
1458
|
};
|
|
1459
1459
|
};
|
|
1460
|
-
export const setCreatedOrderId: (id: string, payment?: {
|
|
1460
|
+
export const setCreatedOrderId: (id: string | null | undefined, payment?: {
|
|
1461
1461
|
type: string;
|
|
1462
1462
|
url: string;
|
|
1463
1463
|
}) => (dispatch: Dispatch) => {
|
|
1464
1464
|
type: string;
|
|
1465
|
-
id: string;
|
|
1465
|
+
id: string | null | undefined;
|
|
1466
1466
|
payment: {
|
|
1467
1467
|
type: string;
|
|
1468
1468
|
url: string;
|
|
@@ -1521,7 +1521,7 @@ declare module '@wayke-se/ecom-web/src/Redux/reducer' {
|
|
|
1521
1521
|
insurance?: IInsuranceOption;
|
|
1522
1522
|
insuranceAddOns?: Insurance;
|
|
1523
1523
|
freeInsurance?: IAvailableInsuranceOption;
|
|
1524
|
-
createdOrderId?: string;
|
|
1524
|
+
createdOrderId?: string | null;
|
|
1525
1525
|
creditAssessmentResponse?: ICreditAssessmentStatus;
|
|
1526
1526
|
caseId?: string;
|
|
1527
1527
|
dealer?: string;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(()=>{var Mc=Object.create;var Go=Object.defineProperty;var xc=Object.getOwnPropertyDescriptor;var Pc=Object.getOwnPropertyNames;var $c=Object.getPrototypeOf,Hc=Object.prototype.hasOwnProperty;var _=(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')});var Bc=(o,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of Pc(i))!Hc.call(o,s)&&s!==e&&Go(o,s,{get:()=>i[s],enumerable:!(t=xc(i,s))||t.enumerable});return o};var Uc=(o,i,e)=>(e=o!=null?Mc($c(o)):{},Bc(i||!o||!o.__esModule?Go(e,"default",{value:o,enumerable:!0}):e,o));var Cc=_("@wayke-se/ecom");var qo={name:"@wayke-se/ecom-web",version:"0.0.8-beta.
|
|
1
|
+
"use strict";(()=>{var Mc=Object.create;var Go=Object.defineProperty;var xc=Object.getOwnPropertyDescriptor;var Pc=Object.getOwnPropertyNames;var $c=Object.getPrototypeOf,Hc=Object.prototype.hasOwnProperty;var _=(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')});var Bc=(o,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of Pc(i))!Hc.call(o,s)&&s!==e&&Go(o,s,{get:()=>i[s],enumerable:!(t=xc(i,s))||t.enumerable});return o};var Uc=(o,i,e)=>(e=o!=null?Mc($c(o)):{},Bc(i||!o||!o.__esModule?Go(e,"default",{value:o,enumerable:!0}):e,o));var Cc=_("@wayke-se/ecom");var qo={name:"@wayke-se/ecom-web",version:"0.0.8-beta.11",description:"Wayke Ecom Web",module:"dist/index.mjs",main:"dist/index.js",types:"dist/index.d.ts",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.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":"^4.0.0",typescript:"^4.5.5"},dependencies:{"@wayke-se/ecom":"^4.1.0-alpha.1",marked:"^4.0.16","object-path":"^0.11.8",redux:"^4.1.2","sanitize-html":"^2.7.0"},files:["dist"]};var pi=_("redux");var Ne=_("@wayke-se/ecom");var Je=(o,i)=>o!==void 0&&i!==void 0?JSON.stringify(o).localeCompare(JSON.stringify(i))===0:o===i;var Se=o=>({costs:o.getCosts(),fees:o.getFees(),interests:o.getInterests(),durationSpec:o.getDurationSpec(),downPaymentSpec:o.getDownPaymentSpec(),residualValueSpec:o.getResidualValueSpec(),totalResidualValue:o.getTotalResidualValue(),publicURL:o.getPublicURL(),shouldUseCreditScoring:o.shouldUseCreditScoring(),financialProductCode:o.getFinancialProductCode(),price:o.getPrice(),creditAmount:o.getCreditAmount(),hasPrivacyPolicy:o.hasPrivacyPolicy(),privacyPolicyUrl:o.getPrivacyPolicyUrl()}),Wo=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?Se(e.loanDetails):void 0})),deliveryOptions:o.getDeliveryOptions(),insuranceOption:o.getInsuranceOption(),orderConditions:o.getOrderConditions(),orderReturnConditions:o.getOrderReturnConditions(),conditionsPdfUri:o.getConditionsPdfUri(),contactInformation:o.getContactInformation(),allowsTradeIn:o.allowsTradeIn(),isUnavailable:o.isUnavailable(),isPaymentRequired:o.isPaymentRequired()}),Ko=o=>({vehicle:o.getVehicle()});var Ze="RESET",Yo=o=>i=>i({type:Ze,id:o}),Xe="SET_ORDER",be=(o,i)=>e=>e({type:Xe,order:o,vehicle:i}),et="SET_ID",Qo=o=>i=>i({type:et,id:o}),tt="SET_CONTACT_EMAIL_AND_PHONE",jo=o=>i=>i({type:tt,value:o}),st="SET_SOCIAL_ID_AND_ADDRESS",zo=(o,i,e)=>t=>t({type:st,socialId:o,address:i,lastStage:e}),ot="SET_HOME_DELIVERY",Jo=(o,i)=>e=>e({type:ot,homeDelivery:o,lastStage:i}),it="SET_DEALER",Zo=(o,i)=>e=>e({type:it,dealer:o,lastStage:i}),nt="INIT_TRADE_IN",Xo=o=>i=>i({type:nt,lastStage:o}),at="SET_TRADE_IN",we=(o,i,e)=>t=>t({type:at,lastStage:o,tradeIn:i,tradeInVehicle:e}),rt="SET_FINANCIAL",ei=(o,i)=>e=>e({type:rt,paymentType:o,lastStage:i}),ct="SET_PAYMENT_LOOKUP_RESPONSE",ti=o=>i=>i({type:ct,paymentLookupResponse:Se(o)}),lt="SET_DRIVING_DISTANCE",si=o=>i=>i({type:lt,drivingDistance:o}),dt="COMPLETE_STAGE",X=o=>i=>i({type:dt,lastStage:o}),mt="SET_OR_REMOVE_INSURANCE",le=o=>i=>i({type:mt,insurance:o}),pt="SET_OR_REMOVE_INSURANCE_ADDONS",oi=(o,i)=>e=>e({type:pt,insurance:o,insuranceAddons:i}),ut="SET_OR_REMOVE_FREE_INSURANCE",ii=o=>i=>i({type:ut,freeInsurance:o}),ht="SET_OR_REMOVE_ACCESSORY",ni=o=>i=>i({type:ht,accessory:o}),kt="GO_TO",M=(o,i,e)=>t=>t({type:kt,view:o,index:i,subStage:e}),yt="SET_STAGES",ai=o=>i=>i({type:yt,stages:o}),vt="SET_CREATED_ORDER_ID",ri=(o,i)=>e=>e({type:vt,id:o,payment:i}),Et="SET_CREDIT_ASSESSMENT_RESPONSE",de=(o,i)=>e=>e({type:Et,caseId:o,creditAssessmentResponse:i}),It="SET_STATE",ci=o=>i=>i({type:It,state:o});var gt={};try{gt=_("../../statemock.json")}catch{gt={}}var li={view:"preview",stage:1,subStage:1},di={id:"",topNavigation:{...li},navigation:{...li},customer:{email:"",phone:"",givenName:"",surname:"",socialId:""},homeDelivery:!1,accessories:[],drivingDistance:Ne.DrivingDistance.Between0And1000,...gt},ne=(o,i)=>i?{view:"summary",stage:1,subStage:1}:{view:"main",stage:o+1,subStage:1},ae=(o,i)=>i.view==="main"?o.stage<i.stage?i:v.topNavigation:{...o,stage:o.stage+1},_t=o=>o&&o?.length===1&&o?.[0].type===Ne.PaymentType.Cash?Ne.PaymentType.Cash:void 0,v,ft,Vc=(o=di,i)=>{let e,t;switch(v={...o},i.type){case Ze:return{...di,id:i.id};case yt:return{...v,stages:i.stages};case et:return{...v,id:i.id};case Xe:return{...o,order:i.order,paymentType:_t(i.order?.paymentOptions),vehicle:{...i.order.orderVehicle,...i.vehicle||{}}};case tt: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 st:return e=ne(v.navigation.stage,i.lastStage),t=ae(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,address:i.address,customer:{...o.customer,socialId:i.socialId}},v;case it:return e=ne(o.navigation.stage,i.lastStage),t={...e},v={...o,navigation:e,topNavigation:t,dealer:i.dealer},delete v.wantTradeIn,delete v.tradeIn,delete v.tradeInVehicle,v.paymentType=_t(o.order?.paymentOptions),delete v.paymentLookupResponse,delete v.insurance,delete v.insuranceAddOns,delete v.freeInsurance,v.accessories=[],v;case ot:return e=ne(o.navigation.stage,i.lastStage),t=ae(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,homeDelivery:i.homeDelivery},v;case nt: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 at:return e=ne(o.navigation.stage,i.lastStage),t=ae(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,wantTradeIn:!!i.tradeIn,tradeIn:i.tradeIn,tradeInVehicle:i.tradeInVehicle},v;case rt:return e=ne(o.navigation.stage,i.lastStage),t=ae(v.topNavigation,e),{...v,navigation:e,topNavigation:t,paymentType:i.paymentType};case ct:return{...v,paymentLookupResponse:i.paymentLookupResponse};case lt:return{...v,drivingDistance:i.drivingDistance};case dt:return e=ne(o.navigation.stage,i.lastStage),t=ae(v.topNavigation,e),v={...o,navigation:e,topNavigation:t},v;case pt:return v.insurance=i.insurance,v.insuranceAddOns={insurance:i.insurance.name,addOns:i.insuranceAddons},v;case mt:return Je(v.insurance,i.insurance)?v.insurance=void 0:v.insurance=i.insurance,v.insuranceAddOns?.insurance&&(v.insuranceAddOns=void 0),v;case ut:return Je(v.freeInsurance,i.freeInsurance)?v.freeInsurance=void 0:v.freeInsurance=i.freeInsurance,v;case ht:return ft=v.accessories.findIndex(n=>n.id===i.accessory.id),v.accessories=[...v.accessories],ft>-1?v.accessories.splice(ft,1):v.accessories.push(i.accessory),{...v,accessories:[...v.accessories]};case kt:return{...o,navigation:{view:i.view,stage:i.index||1,subStage:i.subStage||1}};case vt:return i.payment?e={view:"main",stage:o.navigation.stage,subStage:2}:e=ne(o.navigation.stage,!0),t=ae(v.topNavigation,e),v={...o,navigation:e,topNavigation:t,createdOrderId:i.id,payment:i.payment},v;case Et:return{...v,caseId:i.caseId,creditAssessmentResponse:i.creditAssessmentResponse};case It:return{...i.state};default:return o}},mi=Vc;var ui=()=>(0,pi.createStore)(mi);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}`:""}`};var Wc=({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">
|
|
@@ -1489,7 +1489,7 @@
|
|
|
1489
1489
|
<div class="waykeecom-stack waykeecom-stack--3">
|
|
1490
1490
|
<div id="payment-menu" style="padding: 24px;border: 1px solid #ececeb;"></div>
|
|
1491
1491
|
</div>
|
|
1492
|
-
`}},Kr=po;var Q=_("@wayke-se/ecom");var uo=_("@wayke-se/ecom"),Yr=o=>{let i=uo.bankid.newAuthRequest().withMethod(o).build();return uo.bankid.auth(i)};var ho=_("@wayke-se/ecom"),Qr=o=>{let i=ho.bankid.newCollectRequest().withOrderRef(o).build();return ho.bankid.collect(i)};var b=_("@wayke-se/ecom"),jr=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=b.customers.newCustomer().withAddress(i.address).withPersonalNumber(i.customer.socialId).withEmail(i.customer.email).withPhoneNumber(i.customer.phone).build(),t=b.orders.newPayment().withType(i.paymentType);if(i.paymentType===b.PaymentType.Loan){let m=i.order?.paymentOptions.find(w=>w.type===b.PaymentType.Loan),u=i.paymentLookupResponse||m?.loanDetails,p=u?.durationSpec.current,h=u?.downPaymentSpec.current,y=u?.residualValueSpec?.current,g=i.order?.paymentOptions.find(w=>w.type===b.PaymentType.Loan)?.externalId;if(t.withDuration(p).withDownPayment(h),y&&t.withResidualValue(y),g&&t.withExternalId(g),i.creditAssessmentResponse){let w=i.creditAssessmentResponse.scoringId,T=i.creditAssessmentResponse.recommendation,B=i.creditAssessmentResponse.decision,W=u?.financialProductCode;if(!w||!T||!B||!W)throw"Missing credit assessment data";let U=b.orders.newCreditAssessment().withScoreId(w).withFinancialProductCode(W).withRecommendation(T).withDecision(B).build();t.withCreditAssessment(U)}}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 c=`${window.location.origin}${window.location.pathname}?${n.toString()}${window.location.hash}`,l=b.orders.newCreateRequest().forVehicle(i.id).withCustomer(e).withPayment(s).withUrls(a,c).withDeliveryType(i.homeDelivery?b.DeliveryType.Delivery:b.DeliveryType.Pickup);if(i.insurance){let m=b.orders.newInsurance().withDrivingDistance(i.drivingDistance);i.insuranceAddOns?.addOns.length&&i.insuranceAddOns.insurance===i.insurance.name&&m.withAddOns(i.insuranceAddOns.addOns.map(p=>p.name));let u=m.build();l.withInsurance(u)}else i.freeInsurance&&l.withInsurance({});if(i.accessories.length&&l.withAccessories(i.accessories),i.tradeIn&&i.tradeInVehicle&&i.tradeIn.condition){let m=b.vehicles.newVehicleTrade().forVehicle(i.tradeIn.registrationNumber).withMileage(parseInt(i.tradeIn.mileage,10)).withCondition(i.tradeIn.condition).withComment(i.tradeIn.description).build();l.withTradeIn(m)}return b.orders.create(l.build())};var zr=_("@wayke-se/ecom"),Jr=o=>zr.creditAssessment.accept(o);var sc="confirm-conditions",Zr=`${sc}-node`,Xr="bankid-start-node",Zl="bankid-start",ec="address-disclaimer-policy-node",tc="address-disclaimer-reservation-node",ko=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.props=t,this.ageError=!1,this.render()}async acceptCreditAssessment(){let{caseId:e}=this.props.store.getState();if(e)try{d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_REQUEST","CONFIRMATION"),await Jr(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 jr(e);d("MAIN","CONFIRMATION_CREATE_ORDER_SUCCEEDED","CONFIRMATION"),t?.isPaymentRequired&&L();let a=s.getPayment();ri(s.
|
|
1492
|
+
`}},Kr=po;var Q=_("@wayke-se/ecom");var uo=_("@wayke-se/ecom"),Yr=o=>{let i=uo.bankid.newAuthRequest().withMethod(o).build();return uo.bankid.auth(i)};var ho=_("@wayke-se/ecom"),Qr=o=>{let i=ho.bankid.newCollectRequest().withOrderRef(o).build();return ho.bankid.collect(i)};var b=_("@wayke-se/ecom"),jr=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=b.customers.newCustomer().withAddress(i.address).withPersonalNumber(i.customer.socialId).withEmail(i.customer.email).withPhoneNumber(i.customer.phone).build(),t=b.orders.newPayment().withType(i.paymentType);if(i.paymentType===b.PaymentType.Loan){let m=i.order?.paymentOptions.find(w=>w.type===b.PaymentType.Loan),u=i.paymentLookupResponse||m?.loanDetails,p=u?.durationSpec.current,h=u?.downPaymentSpec.current,y=u?.residualValueSpec?.current,g=i.order?.paymentOptions.find(w=>w.type===b.PaymentType.Loan)?.externalId;if(t.withDuration(p).withDownPayment(h),y&&t.withResidualValue(y),g&&t.withExternalId(g),i.creditAssessmentResponse){let w=i.creditAssessmentResponse.scoringId,T=i.creditAssessmentResponse.recommendation,B=i.creditAssessmentResponse.decision,W=u?.financialProductCode;if(!w||!T||!B||!W)throw"Missing credit assessment data";let U=b.orders.newCreditAssessment().withScoreId(w).withFinancialProductCode(W).withRecommendation(T).withDecision(B).build();t.withCreditAssessment(U)}}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 c=`${window.location.origin}${window.location.pathname}?${n.toString()}${window.location.hash}`,l=b.orders.newCreateRequest().forVehicle(i.id).withCustomer(e).withPayment(s).withUrls(a,c).withDeliveryType(i.homeDelivery?b.DeliveryType.Delivery:b.DeliveryType.Pickup);if(i.insurance){let m=b.orders.newInsurance().withDrivingDistance(i.drivingDistance);i.insuranceAddOns?.addOns.length&&i.insuranceAddOns.insurance===i.insurance.name&&m.withAddOns(i.insuranceAddOns.addOns.map(p=>p.name));let u=m.build();l.withInsurance(u)}else i.freeInsurance&&l.withInsurance({});if(i.accessories.length&&l.withAccessories(i.accessories),i.tradeIn&&i.tradeInVehicle&&i.tradeIn.condition){let m=b.vehicles.newVehicleTrade().forVehicle(i.tradeIn.registrationNumber).withMileage(parseInt(i.tradeIn.mileage,10)).withCondition(i.tradeIn.condition).withComment(i.tradeIn.description).build();l.withTradeIn(m)}return b.orders.create(l.build())};var zr=_("@wayke-se/ecom"),Jr=o=>zr.creditAssessment.accept(o);var sc="confirm-conditions",Zr=`${sc}-node`,Xr="bankid-start-node",Zl="bankid-start",ec="address-disclaimer-policy-node",tc="address-disclaimer-reservation-node",ko=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.props=t,this.ageError=!1,this.render()}async acceptCreditAssessment(){let{caseId:e}=this.props.store.getState();if(e)try{d("MAIN","CONFIRMATION_ACCEPT_CREDIT_ASSESSMENT_REQUEST","CONFIRMATION"),await Jr(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 jr(e);d("MAIN","CONFIRMATION_CREATE_ORDER_SUCCEEDED","CONFIRMATION"),t?.isPaymentRequired&&L();let a=s.getPayment();ri(s.getOrderNumber(),a)(e.dispatch),this.acceptCreditAssessment()}catch(t){let s=t;this.view=1,clearInterval(this.bankidStatusInterval),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),L(),this.render()}}bankIdStatus(e,t){this.bankidStatusInterval=setInterval(async()=>{try{d("MAIN",t===Q.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_REQUESTED":"CONFIRMATION_BANKID_STATUS_QR_REQUESTED","CONFIRMATION");let s=await Qr(e);if(d("MAIN",t===Q.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SUCCEEDED":"CONFIRMATION_BANKID_STATUS_QR_SUCCEEDED","CONFIRMATION"),s.isCompleted()){clearInterval(this.bankidStatusInterval);let n=s.getAddress(),a=s.getPersonalNumber();if(n&&a){let c=this.props.store.getState();if(O.requiredSsnOver18(a)){if(c.customer.socialId!==a){d("MAIN",t===Q.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_COMPLETED_SSN_MISSMATCH":"CONFIRMATION_BANKID_STATUS_QR_COMPLETED_SSN_MISSMATCH","CONFIRMATION"),this.view=1,this.socialIdNotMatchingError=!0,clearInterval(this.bankidStatusInterval),L(),this.render();return}}else{d("MAIN",t===Q.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_COMPLETED_NOT_OVER_18":"CONFIRMATION_BANKID_STATUS_QR_COMPLETED_NOT_OVER_18","CONFIRMATION"),this.view=1,this.ageError=!0,clearInterval(this.bankidStatusInterval),L(),this.render();return}d("MAIN",t===Q.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_COMPLETED":"CONFIRMATION_BANKID_STATUS_QR_COMPLETED","CONFIRMATION"),this.contexts.bankId?.setDescription("Verifiering klar, ordern skapas nu..."),await this.onCreateOrder()}}else s.shouldRenew()&&(d("MAIN",t===Q.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_SHOULD_RENEW":"CONFIRMATION_BANKID_STATUS_QR_SHOULD_RENEW","CONFIRMATION"),this.onStartBankIdAuth(t))}catch{clearInterval(this.bankidStatusInterval),this.contexts.bankId?.setErrorMessage("Det gick inte att h\xE4mta status kring nuvanrade BankId signering."),d("MAIN",t===Q.AuthMethod.SameDevice?"CONFIRMATION_BANKID_STATUS_SAME_DEVICE_FAILED":"CONFIRMATION_BANKID_STATUS_QR_FAILED","CONFIRMATION")}},2e3)}async onStartBankIdAuth(e){this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval);try{d("MAIN","CONFIRMATION_BANKID_INIT_REQUESTED","CONFIRMATION"),this.contexts.bankId?.update(e),this.contexts.buttonLinkToggle?.disabled(!0);let t=await Yr(e);d("MAIN","CONFIRMATION_BANKID_INIT_SUCCEEDED","CONFIRMATION");let s=t.getOrderRef();if(this.bankIdStatus(s,e),e===Q.AuthMethod.SameDevice)try{let n=t.getAutoLaunchUrl();this.contexts.bankId?.update(e,n)}catch(n){let a=n;this.contexts.bankId?.setErrorMessage(`Error: ${a.message}`)}else{let n=t.getQrCode();this.contexts.bankId?.update(e,n)}}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(){d("MAIN","CONFIRMATION_BANKID_ABORTED","CONFIRMATION"),this.view=1,this.bankidStatusInterval&&clearInterval(this.bankidStatusInterval),L(),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=Ee(),{navigation:t,order:s}=this.props.store.getState();if(this.view===2)this.contexts.bankId=new Ke(Y(),{method:e?Q.AuthMethod.SameDevice:Q.AuthMethod.QrCode,descriptionQrCode:"F\xF6r att verifiera din identitet, starta din BankID applikation p\xE5 din andra enhet.",descriptionSameDevice:"F\xF6r att verifiera din identitet, starta din BankID-applikation.",onAbort:()=>this.onAbort(),onStart:n=>this.onStartBankIdAuth(n)});else{let n=s?.contactInformation?.name,a=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">
|