@ikas/storefront 2.0.52 → 2.0.54
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/build/api/checkout/__generated__/addCouponCodeToCheckout.d.ts +1 -1
- package/build/api/checkout/index.d.ts +1 -1
- package/build/api/checkout/index.js +1 -1
- package/build/api/customer/__generated__/registerCustomer.d.ts +5 -1
- package/build/components/checkout/components/cart-summary/index.js +1 -1
- package/build/components/checkout/model.d.ts +0 -1
- package/build/components/checkout/model.js +1 -1
- package/build/components/page/head.d.ts +1 -0
- package/build/components/page/head.js +1 -1
- package/build/components/page/index.d.ts +1 -0
- package/build/components/page/index.js +1 -1
- package/build/ikas.js +2 -2
- package/build/models/theme/page/index.d.ts +1 -0
- package/build/models/theme/page/index.js +1 -1
- package/build/providers/page-data-get.d.ts +1 -0
- package/build/providers/page-data-get.js +1 -1
- package/build/providers/page-data-next.d.ts +6 -0
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ export declare class IkasCheckoutAPI {
|
|
|
14
14
|
static retrieveInstallmentInfo(input: IkasInstallmentInfoInput): Promise<IkasInstallmentInfo | undefined>;
|
|
15
15
|
static checkStocks(lines: CheckStocksLineInput[], stockLocationIdList: string[]): Promise<CheckStocksTypes.checkStocks_checkStocks | undefined>;
|
|
16
16
|
static listCheckoutSettings(): Promise<IkasCheckoutSettings[] | undefined>;
|
|
17
|
-
static addCouponCodeToCheckout(checkoutId: string, couponCode: string): Promise<true | undefined>;
|
|
17
|
+
static addCouponCodeToCheckout(checkoutId: string, couponCode: string | null): Promise<true | undefined>;
|
|
18
18
|
}
|
|
19
19
|
declare type CheckStocksLineInput = {
|
|
20
20
|
quantity: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as n,__generator as e,__makeTemplateObject as t}from'../../ext/tslib/tslib.es6.js';import i from'../../ext/graphql-tag/src/index.js';import{apollo as a}from"../apollo.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import{IkasCheckout as r}from"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"mobx";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import{IkasOrder as o}from"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{IkasPaymentGateway as d}from"../../models/data/payment-gateway/index.js";import{IkasStorefrontConfig as s}from"../../storefront/index.js";import{IkasCheckoutSettings as c}from"../../models/data/checkout-settings/index.js";var u,l,m,p,g,h,y,I,f,v,C=function(){function C(){}return C.getCheckoutId=function(r){return n(this,void 0,void 0,(function(){var n,o,d,s,c;return e(this,(function(e){switch(e.label){case 0:n=i(u||(u=t(["\n query getCheckoutByCartId($cartId: String!) {\n getCheckoutByCartId(cartId: $cartId) {\n id\n }\n }\n "],["\n query getCheckoutByCartId($cartId: String!) {\n getCheckoutByCartId(cartId: $cartId) {\n id\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().query({query:n,variables:{cartId:r}})];case 2:return o=e.sent(),d=o.data,(s=o.errors)&&s.length&&console.log(s),d?[2,d.getCheckoutByCartId.id]:[3,4];case 3:return c=e.sent(),console.log(c),[3,4];case 4:return[2]}}))}))},C.getCheckoutById=function(o){return n(this,void 0,void 0,(function(){var n,d,s,c,u;return e(this,(function(e){switch(e.label){case 0:n=i(l||(l=t(["\n query getCheckoutById($id: String!) {\n getCheckoutById(id: $id) {\n totalFinalPrice\n note\n availableShippingMethods {\n price\n rateName\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n }\n billingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n code\n id\n name\n iso2\n iso3\n }\n district {\n code\n id\n name\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n code\n id\n name\n }\n taxNumber\n taxOffice\n }\n cartId\n couponCode\n createdAt\n customer {\n email\n firstName\n id\n lastName\n notificationsAccepted\n }\n deleted\n id\n merchantId\n orderId\n orderNumber\n recoverEmailStatus\n recoveryStatus\n shippingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n id\n code\n name\n iso2\n iso3\n }\n district {\n name\n id\n code\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n name\n id\n code\n }\n taxNumber\n taxOffice\n }\n shippingLines {\n title\n taxValue\n price\n shippingSettingsId\n shippingZoneRateId\n }\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n status\n updatedAt\n cart {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n taxLines {\n price\n rate\n }\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n slug\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n options {\n name\n productOptionId\n productOptionsSetId\n type\n values {\n name\n price\n value\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n adjustments {\n amount\n amountType\n name\n order\n type\n couponId\n appliedOrderLines {\n amount\n appliedQuantity\n orderLineId\n }\n }\n giftPackageLines {\n price\n taxValue\n }\n isGiftPackage\n giftPackageNote\n }\n }\n "],["\n query getCheckoutById($id: String!) {\n getCheckoutById(id: $id) {\n totalFinalPrice\n note\n availableShippingMethods {\n price\n rateName\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n }\n billingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n code\n id\n name\n iso2\n iso3\n }\n district {\n code\n id\n name\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n code\n id\n name\n }\n taxNumber\n taxOffice\n }\n cartId\n couponCode\n createdAt\n customer {\n email\n firstName\n id\n lastName\n notificationsAccepted\n }\n deleted\n id\n merchantId\n orderId\n orderNumber\n recoverEmailStatus\n recoveryStatus\n shippingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n id\n code\n name\n iso2\n iso3\n }\n district {\n name\n id\n code\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n name\n id\n code\n }\n taxNumber\n taxOffice\n }\n shippingLines {\n title\n taxValue\n price\n shippingSettingsId\n shippingZoneRateId\n }\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n status\n updatedAt\n cart {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n taxLines {\n price\n rate\n }\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n slug\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n options {\n name\n productOptionId\n productOptionsSetId\n type\n values {\n name\n price\n value\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n adjustments {\n amount\n amountType\n name\n order\n type\n couponId\n appliedOrderLines {\n amount\n appliedQuantity\n orderLineId\n }\n }\n giftPackageLines {\n price\n taxValue\n }\n isGiftPackage\n giftPackageNote\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().query({query:n,variables:{id:o}})];case 2:return d=e.sent(),s=d.data,(c=d.errors)&&c.length&&console.log(c),s?[2,new r(s.getCheckoutById)]:[3,4];case 3:return u=e.sent(),console.log(u),[3,4];case 4:return[2]}}))}))},C.getOrder=function(r){return n(this,void 0,void 0,(function(){var n,d,s;return e(this,(function(e){switch(e.label){case 0:n=i(m||(m=t(["\n query getOrder($orderId: String!) {\n getOrder(orderId: $orderId) {\n billingAddress {\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n name\n id\n code\n }\n district {\n name\n id\n code\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n name\n id\n code\n }\n taxNumber\n taxOffice\n }\n cancelledAt\n cancelReason\n createdAt\n currencyCode\n currencyRates {\n rate\n originalRate\n code\n }\n customer {\n lastName\n firstName\n email\n id\n }\n deleted\n id\n merchantId\n note\n orderedAt\n orderAdjustments {\n type\n order\n name\n amountType\n amount\n }\n orderLineItems {\n createdAt\n currencyCode\n deleted\n discount {\n reason\n amountType\n amount\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n variantValueName\n variantValueId\n variantTypeName\n variantTypeId\n order\n }\n }\n options {\n name\n productOptionId\n productOptionsSetId\n type\n values {\n name\n price\n value\n }\n }\n }\n orderNumber\n orderPackages {\n updatedAt\n trackingInfo {\n trackingNumber\n trackingLink\n isSendNotification\n cargoCompany\n }\n stockLocationId\n orderPackageNumber\n orderPackageFulfillStatus\n orderLineItemIds\n id\n deleted\n createdAt\n }\n orderPackageStatus\n orderPaymentStatus\n orderTagIds\n shippingAddress {\n taxOffice\n taxNumber\n state {\n name\n id\n code\n }\n postalCode\n phone\n lastName\n isDefault\n identityNumber\n firstName\n district {\n name\n id\n code\n }\n country {\n name\n id\n code\n }\n company\n city {\n id\n code\n name\n }\n addressLine2\n addressLine1\n }\n shippingLines {\n title\n taxValue\n price\n }\n shippingMethod\n status\n taxLines {\n rate\n price\n }\n totalFinalPrice\n totalPrice\n updatedAt\n }\n }\n "],["\n query getOrder($orderId: String!) {\n getOrder(orderId: $orderId) {\n billingAddress {\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n name\n id\n code\n }\n district {\n name\n id\n code\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n name\n id\n code\n }\n taxNumber\n taxOffice\n }\n cancelledAt\n cancelReason\n createdAt\n currencyCode\n currencyRates {\n rate\n originalRate\n code\n }\n customer {\n lastName\n firstName\n email\n id\n }\n deleted\n id\n merchantId\n note\n orderedAt\n orderAdjustments {\n type\n order\n name\n amountType\n amount\n }\n orderLineItems {\n createdAt\n currencyCode\n deleted\n discount {\n reason\n amountType\n amount\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n variantValueName\n variantValueId\n variantTypeName\n variantTypeId\n order\n }\n }\n options {\n name\n productOptionId\n productOptionsSetId\n type\n values {\n name\n price\n value\n }\n }\n }\n orderNumber\n orderPackages {\n updatedAt\n trackingInfo {\n trackingNumber\n trackingLink\n isSendNotification\n cargoCompany\n }\n stockLocationId\n orderPackageNumber\n orderPackageFulfillStatus\n orderLineItemIds\n id\n deleted\n createdAt\n }\n orderPackageStatus\n orderPaymentStatus\n orderTagIds\n shippingAddress {\n taxOffice\n taxNumber\n state {\n name\n id\n code\n }\n postalCode\n phone\n lastName\n isDefault\n identityNumber\n firstName\n district {\n name\n id\n code\n }\n country {\n name\n id\n code\n }\n company\n city {\n id\n code\n name\n }\n addressLine2\n addressLine1\n }\n shippingLines {\n title\n taxValue\n price\n }\n shippingMethod\n status\n taxLines {\n rate\n price\n }\n totalFinalPrice\n totalPrice\n updatedAt\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().query({query:n,variables:{orderId:r}})];case 2:return d=e.sent(),(s=d.data)&&s.getOrder?[2,new o(s.getOrder)]:[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},C.saveCheckout=function(r){var o,d,s,c;return n(this,void 0,void 0,(function(){var n,u,l,m,g;return e(this,(function(e){switch(e.label){case 0:n=i(p||(p=t(["\n mutation saveCheckout($input: SaveCheckoutInput!) {\n saveCheckout(input: $input) {\n id\n }\n }\n "],["\n mutation saveCheckout($input: SaveCheckoutInput!) {\n saveCheckout(input: $input) {\n id\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().mutate({mutation:n,variables:{input:{id:r.id,cartId:r.cartId,shippingMethod:r.shippingMethod,shippingSettingsId:r.shippingSettingsId,shippingZoneRateId:r.shippingZoneRateId,billingAddress:r.billingAddress&&r.billingAddress.addressLine1?{id:r.billingAddress.id,addressLine1:r.billingAddress.addressLine1||"",addressLine2:r.billingAddress.addressLine2||null,city:r.billingAddress.city,country:r.billingAddress.country,state:r.billingAddress.state,district:r.billingAddress.district||null,firstName:r.billingAddress.firstName,lastName:r.billingAddress.lastName,postalCode:r.billingAddress.postalCode,company:r.billingAddress.company||null,phone:r.billingAddress.phone||null,taxNumber:r.billingAddress.taxNumber||null,taxOffice:r.billingAddress.taxOffice||null,isDefault:r.billingAddress.isDefault||!1,identityNumber:r.billingAddress.identityNumber||null}:null,shippingAddress:r.shippingAddress&&r.shippingAddress.addressLine1?{id:r.shippingAddress.id,addressLine1:r.shippingAddress.addressLine1||"",addressLine2:r.shippingAddress.addressLine2||null,city:r.shippingAddress.city,country:r.shippingAddress.country,state:r.shippingAddress.state,district:r.shippingAddress.district||null,firstName:r.shippingAddress.firstName,lastName:r.shippingAddress.lastName,postalCode:r.shippingAddress.postalCode,company:r.shippingAddress.company||null,phone:r.shippingAddress.phone||null,taxNumber:r.shippingAddress.taxNumber||null,taxOffice:r.shippingAddress.taxOffice||null,isDefault:r.shippingAddress.isDefault||!1,identityNumber:r.shippingAddress.identityNumber||null}:null,couponCode:r.couponCode||null,customer:r.customer?{id:null===(o=r.customer)||void 0===o?void 0:o.id,email:null===(d=r.customer)||void 0===d?void 0:d.email,firstName:null===(s=r.customer)||void 0===s?void 0:s.firstName,lastName:null===(c=r.customer)||void 0===c?void 0:c.lastName,notificationsAccepted:r.customer.notificationsAccepted||!1}:null,note:r.note,isGiftPackage:r.isGiftPackage,giftPackageNote:r.giftPackageNote}}})];case 2:return u=e.sent(),l=u.data,m=u.errors,[2,{data:(null==l?void 0:l.saveCheckout.id)||void 0,errors:m}];case 3:return g=e.sent(),console.log(g),g&&g.graphQLErrors?[2,{data:void 0,errors:g.graphQLErrors}]:[3,4];case 4:return[2]}}))}))},C.createSaleTransactionWithCheckout=function(r,o,d){return n(this,void 0,void 0,(function(){var n,s,c,u,l;return e(this,(function(e){switch(e.label){case 0:n=i(g||(g=t(["\n mutation createSaleTransactionWithCheckout(\n $input: CreateSaleTransactionWithCheckoutInput!\n ) {\n createSaleTransactionWithCheckout(input: $input) {\n orderId\n orderNumber\n transactionId\n transactionStatus\n returnSlug\n error {\n code\n declineCode\n message\n }\n }\n }\n "],["\n mutation createSaleTransactionWithCheckout(\n $input: CreateSaleTransactionWithCheckoutInput!\n ) {\n createSaleTransactionWithCheckout(input: $input) {\n orderId\n orderNumber\n transactionId\n transactionStatus\n returnSlug\n error {\n code\n declineCode\n message\n }\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().mutate({mutation:n,variables:{input:{checkoutId:r,paymentGatewayId:o,paymentMethodDetail:d}}})];case 2:return s=e.sent(),c=s.data,(u=s.errors)&&u.length?[2]:c?[2,c.createSaleTransactionWithCheckout]:[3,4];case 3:return l=e.sent(),console.log(l),[3,4];case 4:return[2]}}))}))},C.listPaymentGateway=function(r){return n(this,void 0,void 0,(function(){var n,o,c,u,l;return e(this,(function(e){switch(e.label){case 0:n=i(h||(h=t(["\n query listPaymentGateway($id: StringFilterInput, $locale: String) {\n listPaymentGateway(id: $id, locale: $locale) {\n paymentMethods {\n name\n logoUrl\n }\n paymentMethodType\n id\n name\n description\n testMode\n code\n type\n logoUrl\n additionalPrices {\n amount\n amountType\n name\n type\n }\n translations {\n description\n locale\n name\n }\n supportedCurrencies\n availableCountries\n }\n }\n "],["\n query listPaymentGateway($id: StringFilterInput, $locale: String) {\n listPaymentGateway(id: $id, locale: $locale) {\n paymentMethods {\n name\n logoUrl\n }\n paymentMethodType\n id\n name\n description\n testMode\n code\n type\n logoUrl\n additionalPrices {\n amount\n amountType\n name\n type\n }\n translations {\n description\n locale\n name\n }\n supportedCurrencies\n availableCountries\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().query({query:n,variables:{id:r?{in:r}:void 0,locale:s.getCurrentLocale()}})];case 2:return o=e.sent(),c=o.data,(u=o.errors)&&u.length&&console.log(u),c?[2,c.listPaymentGateway.map((function(n){return new d(n)}))]:[3,4];case 3:return l=e.sent(),console.log(l),[3,4];case 4:return[2]}}))}))},C.retrieveInstallmentInfo=function(r){return n(this,void 0,void 0,(function(){var n,o,d,s,c;return e(this,(function(e){switch(e.label){case 0:n=i(y||(y=t(["\n mutation retrieveInstallmentInfo($input: RetrieveInstallmentInfoInput!) {\n retrieveInstallmentInfo(input: $input) {\n bankName\n binNumber\n cardAssociation\n cardFamily\n cardType\n installmentPrices {\n totalPrice\n installmentPrice\n installmentCount\n }\n price\n }\n }\n "],["\n mutation retrieveInstallmentInfo($input: RetrieveInstallmentInfoInput!) {\n retrieveInstallmentInfo(input: $input) {\n bankName\n binNumber\n cardAssociation\n cardFamily\n cardType\n installmentPrices {\n totalPrice\n installmentPrice\n installmentCount\n }\n price\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().mutate({mutation:n,variables:{input:r}})];case 2:return o=e.sent(),d=o.data,(s=o.errors)&&s.length&&console.log(s),d?[2,d.retrieveInstallmentInfo]:[3,4];case 3:return c=e.sent(),console.log(c),[3,4];case 4:return[2]}}))}))},C.checkStocks=function(r,o){return n(this,void 0,void 0,(function(){var n,d,s,c,u;return e(this,(function(e){switch(e.label){case 0:n=i(I||(I=t(["\n query checkStocks(\n $lines: [CheckStocksLineInput!]!\n $stockLocationIdList: [String!]\n ) {\n checkStocks(lines: $lines, stockLocationIdList: $stockLocationIdList) {\n lines {\n stockCount\n isAvailable\n variantId\n }\n }\n }\n "],["\n query checkStocks(\n $lines: [CheckStocksLineInput!]!\n $stockLocationIdList: [String!]\n ) {\n checkStocks(lines: $lines, stockLocationIdList: $stockLocationIdList) {\n lines {\n stockCount\n isAvailable\n variantId\n }\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().query({query:n,variables:{lines:r,stockLocationIdList:o.length?o:null}})];case 2:return d=e.sent(),s=d.data,(c=d.errors)&&c.length&&console.log(c),s?[2,s.checkStocks]:[3,4];case 3:return u=e.sent(),console.log(u),[3,4];case 4:return[2]}}))}))},C.listCheckoutSettings=function(){return n(this,void 0,void 0,(function(){var n,r,o,d,u;return e(this,(function(e){switch(e.label){case 0:n=i(f||(f=t(["\n query listCheckoutSettings($storefrontId: StringFilterInput!) {\n listCheckoutSettings(storefrontId: $storefrontId) {\n createdAt\n id\n identityNumberRequirement\n isAccountRequired\n isTermsAndConditionsDefaultChecked\n options {\n name\n required\n }\n phoneRequirement\n showCheckoutNote\n showTermsAndConditionsCheckbox\n storefrontId\n updatedAt\n isGiftPackageEnabled\n giftPackagePriceList {\n currencyCode\n price\n }\n postalCodeRequirement\n }\n }\n "],["\n query listCheckoutSettings($storefrontId: StringFilterInput!) {\n listCheckoutSettings(storefrontId: $storefrontId) {\n createdAt\n id\n identityNumberRequirement\n isAccountRequired\n isTermsAndConditionsDefaultChecked\n options {\n name\n required\n }\n phoneRequirement\n showCheckoutNote\n showTermsAndConditionsCheckbox\n storefrontId\n updatedAt\n isGiftPackageEnabled\n giftPackagePriceList {\n currencyCode\n price\n }\n postalCodeRequirement\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().query({query:n,variables:{storefrontId:{eq:s.storefrontId}}})];case 2:return r=e.sent(),o=r.data,(d=r.errors)&&d.length&&console.log(d),o?[2,o.listCheckoutSettings.map((function(n){return new c(n)}))]:[3,4];case 3:return u=e.sent(),console.log(u),[3,4];case 4:return[2]}}))}))},C.addCouponCodeToCheckout=function(r,o){return n(this,void 0,void 0,(function(){var n,d;return e(this,(function(e){switch(e.label){case 0:n=i(v||(v=t(["\n mutation addCouponCodeToCheckout(\n $checkoutId: String!\n $couponCode: String!\n ) {\n addCouponCodeToCheckout(\n checkoutId: $checkoutId\n couponCode: $couponCode\n ) {\n id\n }\n }\n "],["\n mutation addCouponCodeToCheckout(\n $checkoutId: String!\n $couponCode: String!\n ) {\n addCouponCodeToCheckout(\n checkoutId: $checkoutId\n couponCode: $couponCode\n ) {\n id\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().query({query:n,variables:{checkoutId:r,couponCode:o}})];case 2:return(d=e.sent().data)&&d.addCouponCodeToCheckout.id?[2,!0]:[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},C}();export{C as IkasCheckoutAPI};
|
|
1
|
+
import{__awaiter as n,__generator as e,__makeTemplateObject as t}from'../../ext/tslib/tslib.es6.js';import i from'../../ext/graphql-tag/src/index.js';import{apollo as a}from"../apollo.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import{IkasCheckout as r}from"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"mobx";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import{IkasOrder as o}from"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{IkasPaymentGateway as d}from"../../models/data/payment-gateway/index.js";import{IkasStorefrontConfig as s}from"../../storefront/index.js";import{IkasCheckoutSettings as c}from"../../models/data/checkout-settings/index.js";var u,l,m,p,g,h,y,I,f,v,C=function(){function C(){}return C.getCheckoutId=function(r){return n(this,void 0,void 0,(function(){var n,o,d,s,c;return e(this,(function(e){switch(e.label){case 0:n=i(u||(u=t(["\n query getCheckoutByCartId($cartId: String!) {\n getCheckoutByCartId(cartId: $cartId) {\n id\n }\n }\n "],["\n query getCheckoutByCartId($cartId: String!) {\n getCheckoutByCartId(cartId: $cartId) {\n id\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().query({query:n,variables:{cartId:r}})];case 2:return o=e.sent(),d=o.data,(s=o.errors)&&s.length&&console.log(s),d?[2,d.getCheckoutByCartId.id]:[3,4];case 3:return c=e.sent(),console.log(c),[3,4];case 4:return[2]}}))}))},C.getCheckoutById=function(o){return n(this,void 0,void 0,(function(){var n,d,s,c,u;return e(this,(function(e){switch(e.label){case 0:n=i(l||(l=t(["\n query getCheckoutById($id: String!) {\n getCheckoutById(id: $id) {\n totalFinalPrice\n note\n availableShippingMethods {\n price\n rateName\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n }\n billingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n code\n id\n name\n iso2\n iso3\n }\n district {\n code\n id\n name\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n code\n id\n name\n }\n taxNumber\n taxOffice\n }\n cartId\n couponCode\n createdAt\n customer {\n email\n firstName\n id\n lastName\n notificationsAccepted\n }\n deleted\n id\n merchantId\n orderId\n orderNumber\n recoverEmailStatus\n recoveryStatus\n shippingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n id\n code\n name\n iso2\n iso3\n }\n district {\n name\n id\n code\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n name\n id\n code\n }\n taxNumber\n taxOffice\n }\n shippingLines {\n title\n taxValue\n price\n shippingSettingsId\n shippingZoneRateId\n }\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n status\n updatedAt\n cart {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n taxLines {\n price\n rate\n }\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n slug\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n options {\n name\n productOptionId\n productOptionsSetId\n type\n values {\n name\n price\n value\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n adjustments {\n amount\n amountType\n name\n order\n type\n couponId\n appliedOrderLines {\n amount\n appliedQuantity\n orderLineId\n }\n }\n giftPackageLines {\n price\n taxValue\n }\n isGiftPackage\n giftPackageNote\n }\n }\n "],["\n query getCheckoutById($id: String!) {\n getCheckoutById(id: $id) {\n totalFinalPrice\n note\n availableShippingMethods {\n price\n rateName\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n }\n billingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n code\n id\n name\n iso2\n iso3\n }\n district {\n code\n id\n name\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n code\n id\n name\n }\n taxNumber\n taxOffice\n }\n cartId\n couponCode\n createdAt\n customer {\n email\n firstName\n id\n lastName\n notificationsAccepted\n }\n deleted\n id\n merchantId\n orderId\n orderNumber\n recoverEmailStatus\n recoveryStatus\n shippingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n id\n code\n name\n iso2\n iso3\n }\n district {\n name\n id\n code\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n name\n id\n code\n }\n taxNumber\n taxOffice\n }\n shippingLines {\n title\n taxValue\n price\n shippingSettingsId\n shippingZoneRateId\n }\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n status\n updatedAt\n cart {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n taxLines {\n price\n rate\n }\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n slug\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n options {\n name\n productOptionId\n productOptionsSetId\n type\n values {\n name\n price\n value\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n adjustments {\n amount\n amountType\n name\n order\n type\n couponId\n appliedOrderLines {\n amount\n appliedQuantity\n orderLineId\n }\n }\n giftPackageLines {\n price\n taxValue\n }\n isGiftPackage\n giftPackageNote\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().query({query:n,variables:{id:o}})];case 2:return d=e.sent(),s=d.data,(c=d.errors)&&c.length&&console.log(c),s?[2,new r(s.getCheckoutById)]:[3,4];case 3:return u=e.sent(),console.log(u),[3,4];case 4:return[2]}}))}))},C.getOrder=function(r){return n(this,void 0,void 0,(function(){var n,d,s;return e(this,(function(e){switch(e.label){case 0:n=i(m||(m=t(["\n query getOrder($orderId: String!) {\n getOrder(orderId: $orderId) {\n billingAddress {\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n name\n id\n code\n }\n district {\n name\n id\n code\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n name\n id\n code\n }\n taxNumber\n taxOffice\n }\n cancelledAt\n cancelReason\n createdAt\n currencyCode\n currencyRates {\n rate\n originalRate\n code\n }\n customer {\n lastName\n firstName\n email\n id\n }\n deleted\n id\n merchantId\n note\n orderedAt\n orderAdjustments {\n type\n order\n name\n amountType\n amount\n }\n orderLineItems {\n createdAt\n currencyCode\n deleted\n discount {\n reason\n amountType\n amount\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n variantValueName\n variantValueId\n variantTypeName\n variantTypeId\n order\n }\n }\n options {\n name\n productOptionId\n productOptionsSetId\n type\n values {\n name\n price\n value\n }\n }\n }\n orderNumber\n orderPackages {\n updatedAt\n trackingInfo {\n trackingNumber\n trackingLink\n isSendNotification\n cargoCompany\n }\n stockLocationId\n orderPackageNumber\n orderPackageFulfillStatus\n orderLineItemIds\n id\n deleted\n createdAt\n }\n orderPackageStatus\n orderPaymentStatus\n orderTagIds\n shippingAddress {\n taxOffice\n taxNumber\n state {\n name\n id\n code\n }\n postalCode\n phone\n lastName\n isDefault\n identityNumber\n firstName\n district {\n name\n id\n code\n }\n country {\n name\n id\n code\n }\n company\n city {\n id\n code\n name\n }\n addressLine2\n addressLine1\n }\n shippingLines {\n title\n taxValue\n price\n }\n shippingMethod\n status\n taxLines {\n rate\n price\n }\n totalFinalPrice\n totalPrice\n updatedAt\n }\n }\n "],["\n query getOrder($orderId: String!) {\n getOrder(orderId: $orderId) {\n billingAddress {\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n name\n id\n code\n }\n district {\n name\n id\n code\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n name\n id\n code\n }\n taxNumber\n taxOffice\n }\n cancelledAt\n cancelReason\n createdAt\n currencyCode\n currencyRates {\n rate\n originalRate\n code\n }\n customer {\n lastName\n firstName\n email\n id\n }\n deleted\n id\n merchantId\n note\n orderedAt\n orderAdjustments {\n type\n order\n name\n amountType\n amount\n }\n orderLineItems {\n createdAt\n currencyCode\n deleted\n discount {\n reason\n amountType\n amount\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n variantValueName\n variantValueId\n variantTypeName\n variantTypeId\n order\n }\n }\n options {\n name\n productOptionId\n productOptionsSetId\n type\n values {\n name\n price\n value\n }\n }\n }\n orderNumber\n orderPackages {\n updatedAt\n trackingInfo {\n trackingNumber\n trackingLink\n isSendNotification\n cargoCompany\n }\n stockLocationId\n orderPackageNumber\n orderPackageFulfillStatus\n orderLineItemIds\n id\n deleted\n createdAt\n }\n orderPackageStatus\n orderPaymentStatus\n orderTagIds\n shippingAddress {\n taxOffice\n taxNumber\n state {\n name\n id\n code\n }\n postalCode\n phone\n lastName\n isDefault\n identityNumber\n firstName\n district {\n name\n id\n code\n }\n country {\n name\n id\n code\n }\n company\n city {\n id\n code\n name\n }\n addressLine2\n addressLine1\n }\n shippingLines {\n title\n taxValue\n price\n }\n shippingMethod\n status\n taxLines {\n rate\n price\n }\n totalFinalPrice\n totalPrice\n updatedAt\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().query({query:n,variables:{orderId:r}})];case 2:return d=e.sent(),(s=d.data)&&s.getOrder?[2,new o(s.getOrder)]:[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},C.saveCheckout=function(r){var o,d,s,c;return n(this,void 0,void 0,(function(){var n,u,l,m,g;return e(this,(function(e){switch(e.label){case 0:n=i(p||(p=t(["\n mutation saveCheckout($input: SaveCheckoutInput!) {\n saveCheckout(input: $input) {\n id\n }\n }\n "],["\n mutation saveCheckout($input: SaveCheckoutInput!) {\n saveCheckout(input: $input) {\n id\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().mutate({mutation:n,variables:{input:{id:r.id,cartId:r.cartId,shippingMethod:r.shippingMethod,shippingSettingsId:r.shippingSettingsId,shippingZoneRateId:r.shippingZoneRateId,billingAddress:r.billingAddress&&r.billingAddress.addressLine1?{id:r.billingAddress.id,addressLine1:r.billingAddress.addressLine1||"",addressLine2:r.billingAddress.addressLine2||null,city:r.billingAddress.city,country:r.billingAddress.country,state:r.billingAddress.state,district:r.billingAddress.district||null,firstName:r.billingAddress.firstName,lastName:r.billingAddress.lastName,postalCode:r.billingAddress.postalCode,company:r.billingAddress.company||null,phone:r.billingAddress.phone||null,taxNumber:r.billingAddress.taxNumber||null,taxOffice:r.billingAddress.taxOffice||null,isDefault:r.billingAddress.isDefault||!1,identityNumber:r.billingAddress.identityNumber||null}:null,shippingAddress:r.shippingAddress&&r.shippingAddress.addressLine1?{id:r.shippingAddress.id,addressLine1:r.shippingAddress.addressLine1||"",addressLine2:r.shippingAddress.addressLine2||null,city:r.shippingAddress.city,country:r.shippingAddress.country,state:r.shippingAddress.state,district:r.shippingAddress.district||null,firstName:r.shippingAddress.firstName,lastName:r.shippingAddress.lastName,postalCode:r.shippingAddress.postalCode,company:r.shippingAddress.company||null,phone:r.shippingAddress.phone||null,taxNumber:r.shippingAddress.taxNumber||null,taxOffice:r.shippingAddress.taxOffice||null,isDefault:r.shippingAddress.isDefault||!1,identityNumber:r.shippingAddress.identityNumber||null}:null,couponCode:r.couponCode||null,customer:r.customer?{id:null===(o=r.customer)||void 0===o?void 0:o.id,email:null===(d=r.customer)||void 0===d?void 0:d.email,firstName:null===(s=r.customer)||void 0===s?void 0:s.firstName,lastName:null===(c=r.customer)||void 0===c?void 0:c.lastName,notificationsAccepted:r.customer.notificationsAccepted||!1}:null,note:r.note,isGiftPackage:r.isGiftPackage,giftPackageNote:r.giftPackageNote}}})];case 2:return u=e.sent(),l=u.data,m=u.errors,[2,{data:(null==l?void 0:l.saveCheckout.id)||void 0,errors:m}];case 3:return g=e.sent(),console.log(g),g&&g.graphQLErrors?[2,{data:void 0,errors:g.graphQLErrors}]:[3,4];case 4:return[2]}}))}))},C.createSaleTransactionWithCheckout=function(r,o,d){return n(this,void 0,void 0,(function(){var n,s,c,u,l;return e(this,(function(e){switch(e.label){case 0:n=i(g||(g=t(["\n mutation createSaleTransactionWithCheckout(\n $input: CreateSaleTransactionWithCheckoutInput!\n ) {\n createSaleTransactionWithCheckout(input: $input) {\n orderId\n orderNumber\n transactionId\n transactionStatus\n returnSlug\n error {\n code\n declineCode\n message\n }\n }\n }\n "],["\n mutation createSaleTransactionWithCheckout(\n $input: CreateSaleTransactionWithCheckoutInput!\n ) {\n createSaleTransactionWithCheckout(input: $input) {\n orderId\n orderNumber\n transactionId\n transactionStatus\n returnSlug\n error {\n code\n declineCode\n message\n }\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().mutate({mutation:n,variables:{input:{checkoutId:r,paymentGatewayId:o,paymentMethodDetail:d}}})];case 2:return s=e.sent(),c=s.data,(u=s.errors)&&u.length?[2]:c?[2,c.createSaleTransactionWithCheckout]:[3,4];case 3:return l=e.sent(),console.log(l),[3,4];case 4:return[2]}}))}))},C.listPaymentGateway=function(r){return n(this,void 0,void 0,(function(){var n,o,c,u,l;return e(this,(function(e){switch(e.label){case 0:n=i(h||(h=t(["\n query listPaymentGateway($id: StringFilterInput, $locale: String) {\n listPaymentGateway(id: $id, locale: $locale) {\n paymentMethods {\n name\n logoUrl\n }\n paymentMethodType\n id\n name\n description\n testMode\n code\n type\n logoUrl\n additionalPrices {\n amount\n amountType\n name\n type\n }\n translations {\n description\n locale\n name\n }\n supportedCurrencies\n availableCountries\n }\n }\n "],["\n query listPaymentGateway($id: StringFilterInput, $locale: String) {\n listPaymentGateway(id: $id, locale: $locale) {\n paymentMethods {\n name\n logoUrl\n }\n paymentMethodType\n id\n name\n description\n testMode\n code\n type\n logoUrl\n additionalPrices {\n amount\n amountType\n name\n type\n }\n translations {\n description\n locale\n name\n }\n supportedCurrencies\n availableCountries\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().query({query:n,variables:{id:r?{in:r}:void 0,locale:s.getCurrentLocale()}})];case 2:return o=e.sent(),c=o.data,(u=o.errors)&&u.length&&console.log(u),c?[2,c.listPaymentGateway.map((function(n){return new d(n)}))]:[3,4];case 3:return l=e.sent(),console.log(l),[3,4];case 4:return[2]}}))}))},C.retrieveInstallmentInfo=function(r){return n(this,void 0,void 0,(function(){var n,o,d,s,c;return e(this,(function(e){switch(e.label){case 0:n=i(y||(y=t(["\n mutation retrieveInstallmentInfo($input: RetrieveInstallmentInfoInput!) {\n retrieveInstallmentInfo(input: $input) {\n bankName\n binNumber\n cardAssociation\n cardFamily\n cardType\n installmentPrices {\n totalPrice\n installmentPrice\n installmentCount\n }\n price\n }\n }\n "],["\n mutation retrieveInstallmentInfo($input: RetrieveInstallmentInfoInput!) {\n retrieveInstallmentInfo(input: $input) {\n bankName\n binNumber\n cardAssociation\n cardFamily\n cardType\n installmentPrices {\n totalPrice\n installmentPrice\n installmentCount\n }\n price\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().mutate({mutation:n,variables:{input:r}})];case 2:return o=e.sent(),d=o.data,(s=o.errors)&&s.length&&console.log(s),d?[2,d.retrieveInstallmentInfo]:[3,4];case 3:return c=e.sent(),console.log(c),[3,4];case 4:return[2]}}))}))},C.checkStocks=function(r,o){return n(this,void 0,void 0,(function(){var n,d,s,c,u;return e(this,(function(e){switch(e.label){case 0:n=i(I||(I=t(["\n query checkStocks(\n $lines: [CheckStocksLineInput!]!\n $stockLocationIdList: [String!]\n ) {\n checkStocks(lines: $lines, stockLocationIdList: $stockLocationIdList) {\n lines {\n stockCount\n isAvailable\n variantId\n }\n }\n }\n "],["\n query checkStocks(\n $lines: [CheckStocksLineInput!]!\n $stockLocationIdList: [String!]\n ) {\n checkStocks(lines: $lines, stockLocationIdList: $stockLocationIdList) {\n lines {\n stockCount\n isAvailable\n variantId\n }\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().query({query:n,variables:{lines:r,stockLocationIdList:o.length?o:null}})];case 2:return d=e.sent(),s=d.data,(c=d.errors)&&c.length&&console.log(c),s?[2,s.checkStocks]:[3,4];case 3:return u=e.sent(),console.log(u),[3,4];case 4:return[2]}}))}))},C.listCheckoutSettings=function(){return n(this,void 0,void 0,(function(){var n,r,o,d,u;return e(this,(function(e){switch(e.label){case 0:n=i(f||(f=t(["\n query listCheckoutSettings($storefrontId: StringFilterInput!) {\n listCheckoutSettings(storefrontId: $storefrontId) {\n createdAt\n id\n identityNumberRequirement\n isAccountRequired\n isTermsAndConditionsDefaultChecked\n options {\n name\n required\n }\n phoneRequirement\n showCheckoutNote\n showTermsAndConditionsCheckbox\n storefrontId\n updatedAt\n isGiftPackageEnabled\n giftPackagePriceList {\n currencyCode\n price\n }\n postalCodeRequirement\n }\n }\n "],["\n query listCheckoutSettings($storefrontId: StringFilterInput!) {\n listCheckoutSettings(storefrontId: $storefrontId) {\n createdAt\n id\n identityNumberRequirement\n isAccountRequired\n isTermsAndConditionsDefaultChecked\n options {\n name\n required\n }\n phoneRequirement\n showCheckoutNote\n showTermsAndConditionsCheckbox\n storefrontId\n updatedAt\n isGiftPackageEnabled\n giftPackagePriceList {\n currencyCode\n price\n }\n postalCodeRequirement\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().query({query:n,variables:{storefrontId:{eq:s.storefrontId}}})];case 2:return r=e.sent(),o=r.data,(d=r.errors)&&d.length&&console.log(d),o?[2,o.listCheckoutSettings.map((function(n){return new c(n)}))]:[3,4];case 3:return u=e.sent(),console.log(u),[3,4];case 4:return[2]}}))}))},C.addCouponCodeToCheckout=function(r,o){return n(this,void 0,void 0,(function(){var n,d;return e(this,(function(e){switch(e.label){case 0:n=i(v||(v=t(["\n mutation addCouponCodeToCheckout(\n $checkoutId: String!\n $couponCode: String\n ) {\n addCouponCodeToCheckout(\n checkoutId: $checkoutId\n couponCode: $couponCode\n ) {\n id\n }\n }\n "],["\n mutation addCouponCodeToCheckout(\n $checkoutId: String!\n $couponCode: String\n ) {\n addCouponCodeToCheckout(\n checkoutId: $checkoutId\n couponCode: $couponCode\n ) {\n id\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().query({query:n,variables:{checkoutId:r,couponCode:o}})];case 2:return(d=e.sent().data)&&d.addCouponCodeToCheckout.id?[2,!0]:[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},C}();export{C as IkasCheckoutAPI};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomerAttributeValueInput, CustomerAccountStatusEnum } from "./../../../__generated__/global-types";
|
|
1
|
+
import { CustomerAttributeValueInput, CustomerAccountStatusEnum, CustomerEmailSubscriptionStatusesEnum } from "./../../../__generated__/global-types";
|
|
2
2
|
export interface registerCustomer_registerCustomer_customer_addresses_city {
|
|
3
3
|
__typename: "CustomerAddressCity";
|
|
4
4
|
/**
|
|
@@ -145,6 +145,10 @@ export interface registerCustomer_registerCustomer_customer {
|
|
|
145
145
|
* The customer's first name.
|
|
146
146
|
*/
|
|
147
147
|
firstName: string;
|
|
148
|
+
/**
|
|
149
|
+
* CustomerEmailSubscriptionStatusesEnum
|
|
150
|
+
*/
|
|
151
|
+
subscriptionStatus: CustomerEmailSubscriptionStatusesEnum | null;
|
|
148
152
|
/**
|
|
149
153
|
* Groups that the store owner attaches to the customer.
|
|
150
154
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t}from'../../../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as a}from"mobx-react-lite";import n from'../../../../ext/lodash/sortBy.js';import c from"../input-with-button/index.js";import l from"../notification-box/index.js";import{CheckoutStep as r}from"../../model.js";import{IkasStorefrontConfig as i}from"../../../../storefront/index.js";import'../../../../ext/lodash/isArguments.js';import'../../../../ext/lodash/isBuffer.js';import'../../../../ext/lodash/isTypedArray.js';import'../../../../ext/lodash/_baseGetTag.js';import{formatMoney as s}from"../../../../utils/currency.js";import{useTranslation as u}from"../../../../utils/i18n.js";import{CartItem as m}from"./cart-item/index.js";import{FormItem as d}from"../form-item/index.js";import{FormItemType as p}from"../form-item/model.js";import E from"../tooltip/index.js";import v from"../svg/arrow-down.js";import C from"../svg/cross.js";import h from"../svg/gift.js";import f from"./style.module.scss.js";import g from"../svg/ikas.js";var k=a((function(e){var t,a,n,c=e.vm,d=e.allowExpand,p=c.cart,E=c.checkout,C=u().t,h=o.useState(!d),k=h[0],x=h[1],j=o.useState(!1),
|
|
1
|
+
import{__awaiter as e,__generator as t}from'../../../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as a}from"mobx-react-lite";import n from'../../../../ext/lodash/sortBy.js';import c from"../input-with-button/index.js";import l from"../notification-box/index.js";import{CheckoutStep as r}from"../../model.js";import{IkasStorefrontConfig as i}from"../../../../storefront/index.js";import'../../../../ext/lodash/isArguments.js';import'../../../../ext/lodash/isBuffer.js';import'../../../../ext/lodash/isTypedArray.js';import'../../../../ext/lodash/_baseGetTag.js';import{formatMoney as s}from"../../../../utils/currency.js";import{useTranslation as u}from"../../../../utils/i18n.js";import{CartItem as m}from"./cart-item/index.js";import{FormItem as d}from"../form-item/index.js";import{FormItemType as p}from"../form-item/model.js";import E from"../tooltip/index.js";import v from"../svg/arrow-down.js";import C from"../svg/cross.js";import h from"../svg/gift.js";import f from"./style.module.scss.js";import g from"../svg/ikas.js";var k=a((function(e){var t,a,n,c=e.vm,d=e.allowExpand,p=c.cart,E=c.checkout,C=u().t,h=o.useState(!d),k=h[0],x=h[1],j=o.useState(!1),A=j[0],w=j[1],P=o.useState(0),I=P[0],L=P[1],R=o.useState(null),D=R[0],B=R[1],_=o.useState(!1),U=_[0],F=_[1],V=o.useState(!1),G=V[0],M=V[1];o.useEffect((function(){d&&(k?D&&L(D.getBoundingClientRect().height):L(0))}),[k,D,d,U,G,A]);var O=[f.CartSummary,d?f.HideOnDesktop:""].join(" "),z=d?{height:I+"px"}:void 0,H=[f.ArrowDown,k?f.Rotated:""].join(" ");return p?o.createElement(o.Fragment,null,!!d&&o.createElement(o.Fragment,null,o.createElement("div",{id:"checkout-mobile-summary-header"}),o.createElement("div",{className:f.ExpandHeader,onClick:function(){if(!k){var e=document.getElementById("Checkout"),t=document.getElementById("checkout-mobile-summary-header");e&&t&&e.scrollTo({top:t.offsetTop,behavior:"smooth"})}x(!k)}},o.createElement("div",{className:f.Left},C("checkout-page:summary")),o.createElement("div",{className:f.Price},o.createElement("span",{className:f.PriceText},"".concat(s(c.finalPrice||0,p.currencyCode)," (").concat(null===(t=c.cart)||void 0===t?void 0:t.items.length," ").concat(C("checkout-page:cartItemProduct"),")")),o.createElement("span",{className:H},o.createElement(v,null))))),o.createElement("div",{className:O},o.createElement("div",{className:f.DetailsContainer,style:z},o.createElement("div",{className:f.Details,ref:B},null==p?void 0:p.items.map((function(e,t){return o.createElement("div",{key:t},o.createElement(m,{vm:c,cartItem:e,currencyCode:p.currencyCode}))})),o.createElement("div",{className:f.Divider}),o.createElement("div",{className:f.SubTotalInfo},A&&o.createElement("div",{className:f.NotificationContainer},o.createElement(l,{type:"warning",title:C("checkout-page:giftCodeErrorTitle"),content:C("checkout-page:giftCodeErrorDescription"),onClose:function(){return w(!1)}})),o.createElement(N,{label:C("checkout-page:subtotal"),value:s(p.totalPrice,p.currencyCode),tooltipText:C("checkout-page:subtotalTooltip")}),!!(null===(a=E.shippingLines)||void 0===a?void 0:a.length)&&o.createElement(N,{label:C("checkout-page:cartShippingTitle"),value:E.shippingTotal?s(E.shippingTotal,p.currencyCode):C("checkout-page:free")}),!!c.checkout.totalTax&&!!(null===(n=c.customizationProps)||void 0===n?void 0:n.showTax)&&o.createElement(N,{label:C("checkout-page:cartTaxTitle"),value:s(c.checkout.totalTax,p.currencyCode)}),!!c.installmentExtraPrice&&o.createElement(N,{label:C("checkout-page:cartInterest"),value:s(c.installmentExtraPrice,p.currencyCode)}),o.createElement(y,{vm:c}),o.createElement(T,{vm:c}),(c.step===r.SUCCESS&&(!!c.checkout.note||!!c.checkout.appliedCouponCode)||c.step!==r.SUCCESS)&&o.createElement("div",{className:f.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),o.createElement(S,{vm:c,isAddingCoupon:G,setAddingCoupon:M,setCouponError:w}),o.createElement(b,{vm:c,isAddingNote:U,setAddingNote:F})),o.createElement("div",{className:f.TotalContainer},o.createElement("div",{className:f.TitleContainer},o.createElement("div",{className:f.Title},C("checkout-page:total"))),o.createElement("div",{className:f.TotalPrice},s(c.finalPrice||0,p.currencyCode))),o.createElement("div",{className:f.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===i.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(g,null))))))):null})),N=a((function(e){var t=e.label,a=e.value,n=e.tooltipText;return o.createElement("div",{className:f.InfoRow},o.createElement("div",{className:f.Label},o.createElement("span",null,t),!!n&&o.createElement(E,{text:n,style:{marginLeft:"8px"}})),o.createElement("div",{className:f.Value},a))})),y=a((function(e){var t=e.vm,a=u().t;return t.cart?o.createElement(o.Fragment,null,n(t.checkout.nonCouponAdjustments||[],"order").map((function(e,n){return o.createElement("div",{className:f.InfoRow,key:n},o.createElement("div",{className:f.Label},"INTEREST"===e.name?a("checkout-page:cartInterest"):e.name),o.createElement("div",{className:f.Value},o.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",o.createElement("span",null,s(e.amount,t.cart.currencyCode))))}))):null})),T=a((function(e){var t,a,n=e.vm,c=u().t;return n.cart?o.createElement(o.Fragment,null,n.step!==r.SUCCESS&&((null===(t=n.checkout.selectedPaymentGateway)||void 0===t?void 0:t.getCalculatedAdditionalPrices(n.checkout.totalFinalPrice||0,n.checkout.shippingLines||null))||[]).filter((function(e){return 0!==e.amount})).map((function(e,t){return o.createElement("div",{className:f.InfoRow,key:t},o.createElement("div",{className:f.Label},e.name),o.createElement("div",{className:f.Value},o.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",o.createElement("span",null,s(e.amount,n.cart.currencyCode))))})),null===(a=n.checkout.giftPackageLines)||void 0===a?void 0:a.map((function(e,t){return o.createElement("div",{className:f.InfoRow,key:t},o.createElement("div",{className:f.Label},o.createElement("div",{className:f.GiftLabel},o.createElement(h,{style:{position:"relative",top:"-1px"}}),o.createElement("span",null,c("checkout-page:giftPackage")))),o.createElement("div",{className:f.Value},o.createElement("span",null,s(e.price,n.cart.currencyCode))))}))):null})),S=a((function(a){var n=a.vm,l=a.isAddingCoupon,i=a.setAddingCoupon,m=a.setCouponError,d=u().t,p=o.useState(""),E=p[0],v=p[1],h=o.useState(!1),g=h[0],k=h[1];if(n.step===r.SUCCESS&&!n.checkout.appliedCouponCode)return null;var N=n.checkout.couponAdjustment;return o.createElement("div",{className:f.InfoRow},!n.checkout.appliedCouponCode&&!l&&o.createElement("div",{className:f.ActionTextBtn,onClick:function(){return i(!0)}},d("checkout-page:addCouponCode")),l&&o.createElement(c,{value:E,placeholder:d("checkout-page:couponCode"),buttonLabel:d("checkout-page:actions.apply"),onClick:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return n.checkout.couponCode=E,k(!0),[4,n.onCouponCodeApply()];case 1:return e.sent(),k(!1),v(""),n.checkout.appliedCouponCode?(i(!1),m(!1)):(m(!0),n.checkout.couponCode=null),[2]}}))}))},isLoading:g,onChange:v}),!!n.checkout.appliedCouponCode&&!l&&o.createElement("div",{className:[f.ActionTextBtn,f.NoUnderline,f.Light].join(" ")},d("checkout-page:couponCode"),o.createElement("span",{className:f.AppliedCoupon},o.createElement("span",{className:f.CouponCode},n.checkout.appliedCouponCode),n.step!==r.SUCCESS&&o.createElement("span",{className:f.ClearCoupon,onClick:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return n.checkout.couponCode=null,k(!0),[4,n.onCouponCodeApply()];case 1:return e.sent(),k(!1),[2]}}))}))}},o.createElement(C,null)))),!!n.checkout.appliedCouponCode&&!l&&o.createElement("div",{className:f.Value},o.createElement("span",null,"DECREMENT"===(null==N?void 0:N.type)?"- ":"")," ",o.createElement("span",null,s((null==N?void 0:N.amount)||0,n.cart.currencyCode))))})),b=a((function(e){var t=e.vm,a=e.isAddingNote,n=e.setAddingNote,c=u().t,l=o.useState(t.checkout.note?c("checkout-page:editOrderNote"):c("checkout-page:addOrderNote"))[0],i=o.useCallback((function(){n(!0)}),[]),s=o.useCallback((function(e){t.checkout.note=e}),[t,t.checkout]);if(!t.checkoutSettings.showCheckoutNote)return null;var m=t.step===r.SUCCESS;return m&&!t.checkout.note?null:o.createElement("div",{className:f.InfoRow},!a&&!m&&o.createElement("div",{className:f.ActionTextBtn,onClick:i},l),(a||m)&&o.createElement("div",{className:[f.CheckoutNoteContainer,m?f.Success:""].join(" ")},o.createElement("div",{className:f.Title},c("checkout-page:orderNote")),m?o.createElement("div",{className:f.CheckoutNoteDisplay},t.checkout.note):o.createElement(d,{style:{width:"100%"},type:p.TEXT_AREA,disableResize:!0,label:"",value:t.checkout.note||"",onChange:s})))}));export{k as CartSummary};
|
|
@@ -73,7 +73,6 @@ export default class CheckoutViewModel {
|
|
|
73
73
|
createBillingAddress: () => void;
|
|
74
74
|
onShippingMethodChange: (shippingMethod: IkasAvailableShippingMethod) => Promise<void>;
|
|
75
75
|
onCouponCodeApply: () => Promise<void>;
|
|
76
|
-
onCouponCodeDelete: () => Promise<void>;
|
|
77
76
|
onSelectedShippingAddressIdChange: (value: string) => void;
|
|
78
77
|
onSelectedBillingAddressIdChange: (value: string) => void;
|
|
79
78
|
onTermsAndConditionsCheckedChange: (value: boolean) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as i}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from'../../ext/lodash/cloneDeep.js';import r from'../../ext/lodash/sortBy.js';import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import{IkasCheckout as o,IkasCheckoutCustomer as a}from"../../models/data/checkout/index.js";import{IkasCustomerAddress as c}from"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import{IkasTransactionStatusEnum as d}from"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{IkasOrderAddress as u}from"../../models/data/order/address/index.js";import{IkasPaymentMethodType as h,IkasPaymentGatewayType as l}from"../../models/data/payment-gateway/index.js";import"../../api/blog/index.js";import"../../api/brand/index.js";import"../../api/cart/index.js";import"../../api/category/index.js";import{IkasCheckoutAPI as p}from"../../api/checkout/index.js";import"../../api/city/index.js";import{IkasCountryAPI as m}from"../../api/country/index.js";import{IkasCustomerAPI as f}from"../../api/customer/index.js";import"../../api/customer-review/index.js";import"../../api/customer-review-summary/index.js";import"../../api/district/index.js";import"../../api/html-meta-data/index.js";import{IkasMerchantAPI as g}from"../../api/merchant/index.js";import"../../api/product-search/index.js";import"../../api/apollo.js";import"../../api/favorite-product/index.js";import"../../api/contact-form/index.js";import"../../api/state/index.js";import"../../api/product-option-set/index.js";import"../../api/raffle/index.js";import"../../api/back-in-stock-reminder/index.js";import"../../api/product-campaign/index.js";import v from"./components/credit-card-form/model.js";import{IkasStorefrontConfig as S}from"../../storefront/index.js";import{IkasCheckoutSettings as k}from"../../models/data/checkout-settings/index.js";import{Analytics as y}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import b from'../../ext/uuid/dist/esm-browser/v4.js';var C,I,P=/^\d+$/,A="undefined"==typeof localStorage,j=function(){function P(P,j,R,x,E,T,O,D,G){var _=this;this.checkout=new o,this.checkoutSettings=new k,this.storefront=null,this.store=S.store,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=C.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.policyModalTitle="",this.policyModalText="",this.error=null,this.init=function(){return t(_,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.store.customerStore.waitUntilInitialized()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getMerchantSettings()];case 2:return t.sent(),[4,this.initStep()];case 3:return t.sent(),[2]}}))}))},this.initStep=function(){return t(_,void 0,void 0,(function(){var t,i,s,n,r,o;return e(this,(function(e){switch(e.label){case 0:if(S.isEditor)return this.step=C.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),i=t.get("step"),s=t.get("failed"),n=t.get("error"),i){if(this.step=i,this.step===C.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(C.INFO)];if(this.step===C.PAYMENT&&!this.canProceedToPayment)return[2,this.changeStep(C.INFO)];if(![C.INFO,C.SUCCESS,C.SHIPPING,C.PAYMENT].includes(this.step))return[2,this.changeStep(C.INFO)]}return s&&(this.error={type:I.PAYMENT_ERROR,data:n||null}),this.step!==C.INFO?[3,2]:[4,this.getShippingCountries()];case 1:e.sent(),this.checkShippingCountries(),e.label=2;case 2:return this.step!==C.SHIPPING||1!==this.checkout.availableShippingMethods.length||this.checkoutSettings.isGiftPackageEnabled||(this.step=C.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==C.SHIPPING||this.checkout.availableShippingMethods.length?this.step!==C.PAYMENT&&this.step!==C.SUCCESS?[3,4]:[4,this.listPaymentGateways()]:(this.error={type:I.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 3:if(e.sent(),!this.paymentGateways.length)return this.error={type:I.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=4;case 4:return this.step===C.SUCCESS?[3,8]:this.checkout.isComplete?[2,this.changeStep(C.SUCCESS)]:[3,5];case 5:return[4,this.initialStockCheck()];case 6:e.sent(),e.label=7;case 7:return[3,11];case 8:return r=this,[4,p.getOrder(this.checkout.orderId)];case 9:return r.order=e.sent(),[4,this.getSuccessTransaction()];case 10:e.sent(),this.successTransaction&&(o=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===o}))),e.label=11;case 11:return this.isCheckoutLoaded=!0,y.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getMerchantSettings=function(){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.merchantSettings?[3,2]:(t=this,[4,g.listMerchantSettings()]);case 1:t.merchantSettings=e.sent(),e.label=2;case 2:return[2]}}))}))},this.getSuccessTransaction=function(){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,f.getOrderTransactions({orderId:this.checkout.orderId})];case 1:return t=e.sent(),this.successTransaction=t.length?t[0]:void 0,[2]}}))}))},this.saveCheckout=function(){return t(_,void 0,void 0,(function(){var t,i,s;return e(this,(function(e){switch(e.label){case 0:return[4,p.saveCheckout(this.checkout)];case 1:if((null==(t=e.sent())?void 0:t.errors)&&t.errors.length)throw i=t.errors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(s=i.extensions)||void 0===s?void 0:s.code)?{type:I.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:I.API_ERROR};return[2]}}))}))},this.checkStocks=function(){return t(_,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,h;return e(this,(function(e){switch(e.label){case 0:return t=this.cart.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,p.checkStocks(t,S.stockLocationIds||[])];case 1:if(!(i=e.sent()))throw{type:I.API_ERROR};if(null==(s=null===(u=i.lines)||void 0===u?void 0:u.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=null===(h=o.store.cartStore.cart)||void 0===h?void 0:h.items.find((function(e){return e.variant.id===t.variantId}));e&&n.push(e)},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:I.STOCK_ERROR,data:n}}return[2]}}))}))},this.removeUnavailableItems=function(i){return t(_,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:t=0,s=i,e.label=1;case 1:return t<s.length?(n=s[t],[4,this.store.cartStore.removeItem(n)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,m.listShippingCountries(S.salesChannelId)];case 1:return t.shippingCountryIds=e.sent(),[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=_.shippingCountryIds)||void 0===t?void 0:t.length)||(_.error={type:I.NO_SHIPPING_ERROR})},this.initialStockCheck=function(){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return e.sent(),[3,3];case 2:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:I.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(_,void 0,void 0,(function(){var t,i,s,n,o,a,c=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=S.paymentGateways.map((function(t){return t.id})),[4,p.listPaymentGateway(t?void 0:i)];case 1:return(s=e.sent())&&s.length?(this.step===C.PAYMENT&&(s=s.filter((function(t){return!t.supportedCurrencies.length||t.supportedCurrencies.includes(c.checkout.cart.currencyCode)})),(n=null===(a=this.checkout.shippingAddress)||void 0===a?void 0:a.country)&&n.iso2&&(s=s.filter((function(t){return!t.availableCountries.length||t.availableCountries.includes(n.iso2||"")})))),o=[],r(S.paymentGateways,"order").forEach((function(t){var e=null==s?void 0:s.find((function(e){return e.id===t.id}));e&&o.push(e)})),this.paymentGateways=t?s:o,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),[2]):(this.error={type:I.API_ERROR},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,p.retrieveInstallmentInfo(i)];case 1:return null==(t=e.sent())||t.installmentPrices.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=t,[2]}}))}))},this.createCustomer=function(){_.store.customerStore.customer?(_.store.customerStore.customer.addresses.forEach((function(t){return t.checkoutSettings=_.checkoutSettings})),_.checkout.customer=new a(_.store.customerStore.customer)):_.checkout.customer||(_.checkout.customer=new a({}))},this.createShippingAddress=function(){var t;if(_.checkout.shippingAddress)_.selectedShippingAddressId=_.checkout.shippingAddress.id||"-1",_.checkout.shippingAddress.checkoutSettings=_.checkoutSettings;else{var e=null===(t=_.store.customerStore.customer)||void 0===t?void 0:t.addresses;_.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}},this.createBillingAddress=function(){"undefined"!=typeof localStorage&&(_.useDifferentAddress=!!localStorage.getItem("sAddr"),_.useDifferentAddress?(_.checkout.billingAddress&&(_.selectedBillingAddressId=_.checkout.billingAddress.id||"-1"),_.checkout.billingAddress=_.checkout.billingAddress||new u):_.checkout.billingAddress=new u(n(_.checkout.shippingAddress)||{}),_.checkout.billingAddress.checkoutSettings=_.checkoutSettings)},this.onShippingMethodChange=function(i){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCheckout()]);case 1:return e.sent(),[4,p.getCheckoutById(this.checkout.id)];case 2:return(t=e.sent())&&(this.checkout=t),this.isChangingShippingMethod=!1,[2]}}))}))},this.onCouponCodeApply=function(){return t(_,void 0,void 0,(function(){var t,s,n,r,a;return e(this,(function(e){switch(e.label){case 0:if(!this.checkout.couponCode)return[2];e.label=1;case 1:return e.trys.push([1,7,,8]),[4,p.addCouponCodeToCheckout(this.checkout.id,this.checkout.couponCode)];case 2:return e.sent()?[4,p.getCheckoutById(this.checkout.id)]:[3,6];case 3:return(t=e.sent())?(s=null===(a=null===(r=this.cardData)||void 0===r?void 0:r.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.step===C.PAYMENT&&(null==s?void 0:s.length)&&s.length>=6?[4,this.retrieveInstallmentInfo({binNumber:s.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:t.totalFinalPrice})]:[3,5]):[3,6];case 4:e.sent(),e.label=5;case 5:n=this.checkout,this.checkout=new o(i(i({},t),{shippingAddress:n.shippingAddress,billingAddress:n.billingAddress,customer:n.customer,selectedPaymentGateway:n.selectedPaymentGateway})),e.label=6;case 6:return[3,8];case 7:return e.sent(),[3,8];case 8:return[2]}}))}))},this.onCouponCodeDelete=function(){return t(_,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,this.saveCheckout()];case 1:return e.sent(),[4,p.getCheckoutById(this.checkout.id)];case 2:return(t=e.sent())&&(s=this.checkout,this.checkout=new o(i(i({},t),{shippingAddress:s.shippingAddress,billingAddress:s.billingAddress,customer:s.customer,selectedPaymentGateway:s.selectedPaymentGateway}))),[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e;if(_.selectedShippingAddressId=t,"-1"===t)_.checkout.shippingAddress=new u;else{var i=null===(e=_.store.customerStore.customer)||void 0===e?void 0:e.addresses.find((function(e){return e.id===t}));i&&(_.checkout.shippingAddress=new u(i))}_.checkout.shippingAddress&&(_.checkout.shippingAddress.checkoutSettings=_.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e;if(_.selectedBillingAddressId=t,"-1"===t)_.checkout.billingAddress=new u;else{var i=null===(e=_.store.customerStore.customer)||void 0===e?void 0:e.addresses.find((function(e){return e.id===t}));i&&(_.checkout.billingAddress=new u(i))}_.checkout.billingAddress&&(_.checkout.billingAddress.checkoutSettings=_.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){_.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(_.cardData&&(!(t.length>_.cardData.cardNumber.length)||N(t))){var e=(_.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!_.installmentInfo?_.retrieveInstallmentInfo({binNumber:i.slice(0,6),paymentGatewayId:_.checkout.selectedPaymentGateway.id,price:_.checkout.totalFinalPrice}):i.length<6&&e.length>i.length&&(_.cardData.installmentCount=1,_.installmentInfo=void 0),_.cardData.cardNumber=w(i,4).join(" "))}},this.onCardHolderNameChange=function(t){_.cardData&&(_.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(_.cardData&&(!(t.length>_.cardData.expirationDate.length)||N(t))){if(0===(null===(e=_.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(_.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&4===n.length){o=parseInt(s),r=parseInt(n.slice(2));if(!isNaN(r)&&!isNaN(o))return void(_.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var a=t.split(" / ").join("");a.length>4||(_.cardData.expirationDate=w(a,2).join(" / "))}},this.onCvcChange=function(t){_.cardData&&(t.length>_.cardData.cvv.length&&!N(t)||t.length>4||(_.cardData.cvv=t))},this.saveAddress=function(s){return t(_,void 0,void 0,(function(){var t,r,o,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,this.store.customerStore.customer.addresses.find((function(e){return e.id===(null==t?void 0:t.id)}))?[2]:(r=new c(i(i({},t),{title:this.addressTitle||(null==t?void 0:t.title)||this.t("checkout-page:newAddress"),id:b()})),(o=n(this.store.customerStore.customer)).addresses.push(r),[4,this.store.customerStore.saveCustomer(o)])):[3,2];case 1:e.sent(),"shipping"===s?(this.checkout.shippingAddress.id=r.id,this.selectedShippingAddressId=r.id||"-1"):(this.checkout.billingAddress.id=r.id,this.selectedBillingAddressId=r.id||"-1"),e.label=2;case 2:return[3,4];case 3:return a=e.sent(),console.error(a),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){_.router.push("/cart")},this.onBackToShoppingClick=function(){_.router.push("/")},this.onProceedToShippingClick=function(){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,5,,6]),this.isStepLoading=!0,[4,this.saveAddress("shipping")];case 2:return e.sent(),[4,this.checkStocks()];case 3:return e.sent(),[4,this.saveCheckout()];case 4:return e.sent(),this.changeStep(C.SHIPPING),[3,6];case 5:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:I.UNKNOWN}),this.isStepLoading=!1,[3,6];case 6:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCheckout()];case 3:return e.sent(),this.error=void 0,this.changeStep(C.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:I.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canPerformPayment)return this.isErrorsVisible=!0,[2];this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),e.label=1;case 1:return e.trys.push([1,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveAddress("billing")];case 3:return e.sent(),[4,this.saveCheckout()];case 4:return e.sent(),[4,this.createSaleTransaction()];case 5:return e.sent(),[3,7];case 6:return(t=e.sent()).type?this.error=t:this.error={type:I.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return t(_,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?[4,p.createSaleTransactionWithCheckout(this.checkout.id,this.checkout.selectedPaymentGateway.id,this.checkout.selectedPaymentGateway.paymentMethodType===h.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===l.INTERNAL&&this.cardData?this.cardData.toInput():void 0)]:[2];case 1:return t=e.sent(),i=null==t?void 0:t.transactionStatus,s=i&&[d.SUCCESS,d.AUTHORIZED].includes(i),n=i===d.PENDING,s?[4,this.getSuccessTransaction()]:[3,4];case 2:return e.sent(),this.successTransaction&&y.purchase(this.checkout,this.successTransaction),[4,this.onCheckoutTransactionSuccess()];case 3:return e.sent(),[3,5];case 4:if(!n||!(null==t?void 0:t.returnSlug))throw{type:I.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+t.returnSlug,e.label=5;case 5:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(_,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return localStorage.removeItem("sAddr"),(null===(t=this.checkout.customer)||void 0===t?void 0:t.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.changeStep(C.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){_.changeStep(C.INFO)},this.onBackToShippingClick=function(){_.changeStep(C.SHIPPING)},this.setCustomerConsentGranted=function(t){_.checkout.customer&&(_.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){_.useDifferentAddress=t,_.useDifferentAddress?(localStorage.setItem("sAddr","1"),_.checkout.billingAddress=_.checkout.billingAddress||new u):(localStorage.removeItem("sAddr"),_.checkout.billingAddress=_.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){_.shouldSaveAddress=t},this.setAddressTitle=function(t){_.addressTitle=t},this.setPaymentGateway=function(t){if(_.paymentGateways.length){var e=_.paymentGateways[t];_.checkout.selectedPaymentGateway=e,_.step!==C.SUCCESS&&(e.paymentMethodType===h.CREDIT_CARD&&e.type===l.INTERNAL&&(_.cardData=new v),_.installmentInfo=void 0)}},this.setInstallmentCount=function(t){_.cardData&&(_.cardData.installmentCount=t)},this.changeStep=function(i){return t(_,void 0,void 0,(function(){return e(this,(function(t){return A||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(_,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=void 0,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCheckout()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){_.isContactModalVisible=t},this.checkout=P,this.checkoutSettings=j,this.router=x,this.returnPolicy=E,this.privacyPolicy=T,this.termsOfService=O,this.t=D,this.customizationProps=G,R&&(this.merchantSettings=R),this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked,this.store.cartStore.cart=this.checkout.cart,this.init(),s(this)}return Object.defineProperty(P.prototype,"cart",{get:function(){return this.checkout.cart},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"selectedPaymentGatewayIndex",{get:function(){var t=this;return this.paymentGateways.findIndex((function(e){var i;return e.id===(null===(i=t.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"selectedInstallmentIndex",{get:function(){var t,e=this;return(null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices.findIndex((function(t){var i;return t.installmentCount===(null===(i=e.cardData)||void 0===i?void 0:i.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"customerAddressOptions",{get:function(){var t,e={label:this.t("checkout-page:newAddress"),value:"-1"},i=(null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[e].concat(i)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"installmentPrice",{get:function(){var t,e,i=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(e=this.installmentInfo.installmentPrices.find((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===e?void 0:e.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"finalPrice",{get:function(){return this.step===C.SUCCESS?this.order?this.order.totalFinalPrice:this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===I.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canProceedToShipping",{get:function(){var t,e;return(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValid)&&this.checkout.hasValidCustomerEmail&&(null===(e=this.error)||void 0===e?void 0:e.type)!==I.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway;return this.canProceedToShipping&&!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid)&&((null==i?void 0:i.paymentMethodType)===h.CREDIT_CARD&&i.type===l.INTERNAL?null===(e=this.cardData)||void 0===e?void 0:e.isValid:!!i)},enumerable:!1,configurable:!0}),P}();function w(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function N(t){return t&&P.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(C||(C={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.API_ERROR=1]="API_ERROR",t[t.STOCK_ERROR=2]="STOCK_ERROR",t[t.PAYMENT_ERROR=3]="PAYMENT_ERROR",t[t.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",t[t.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(I||(I={}));export{C as CheckoutStep,I as ErrorType,j as default};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as i}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from'../../ext/lodash/cloneDeep.js';import r from'../../ext/lodash/sortBy.js';import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import{IkasCheckout as o,IkasCheckoutCustomer as a}from"../../models/data/checkout/index.js";import{IkasCustomerAddress as c}from"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import{IkasTransactionStatusEnum as d}from"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{IkasOrderAddress as u}from"../../models/data/order/address/index.js";import{IkasPaymentMethodType as h,IkasPaymentGatewayType as l}from"../../models/data/payment-gateway/index.js";import"../../api/blog/index.js";import"../../api/brand/index.js";import"../../api/cart/index.js";import"../../api/category/index.js";import{IkasCheckoutAPI as p}from"../../api/checkout/index.js";import"../../api/city/index.js";import{IkasCountryAPI as m}from"../../api/country/index.js";import{IkasCustomerAPI as f}from"../../api/customer/index.js";import"../../api/customer-review/index.js";import"../../api/customer-review-summary/index.js";import"../../api/district/index.js";import"../../api/html-meta-data/index.js";import{IkasMerchantAPI as g}from"../../api/merchant/index.js";import"../../api/product-search/index.js";import"../../api/apollo.js";import"../../api/favorite-product/index.js";import"../../api/contact-form/index.js";import"../../api/state/index.js";import"../../api/product-option-set/index.js";import"../../api/raffle/index.js";import"../../api/back-in-stock-reminder/index.js";import"../../api/product-campaign/index.js";import v from"./components/credit-card-form/model.js";import{IkasStorefrontConfig as S}from"../../storefront/index.js";import{IkasCheckoutSettings as k}from"../../models/data/checkout-settings/index.js";import{Analytics as y}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import b from'../../ext/uuid/dist/esm-browser/v4.js';var C,I,P=/^\d+$/,A="undefined"==typeof localStorage,j=function(){function P(P,j,R,x,E,T,O,D,G){var _=this;this.checkout=new o,this.checkoutSettings=new k,this.storefront=null,this.store=S.store,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=C.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.policyModalTitle="",this.policyModalText="",this.error=null,this.init=function(){return t(_,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.store.customerStore.waitUntilInitialized()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getMerchantSettings()];case 2:return t.sent(),[4,this.initStep()];case 3:return t.sent(),[2]}}))}))},this.initStep=function(){return t(_,void 0,void 0,(function(){var t,i,s,n,r,o;return e(this,(function(e){switch(e.label){case 0:if(S.isEditor)return this.step=C.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),i=t.get("step"),s=t.get("failed"),n=t.get("error"),i){if(this.step=i,this.step===C.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(C.INFO)];if(this.step===C.PAYMENT&&!this.canProceedToPayment)return[2,this.changeStep(C.INFO)];if(![C.INFO,C.SUCCESS,C.SHIPPING,C.PAYMENT].includes(this.step))return[2,this.changeStep(C.INFO)]}return s&&(this.error={type:I.PAYMENT_ERROR,data:n||null}),this.step!==C.INFO?[3,2]:[4,this.getShippingCountries()];case 1:e.sent(),this.checkShippingCountries(),e.label=2;case 2:return this.step!==C.SHIPPING||1!==this.checkout.availableShippingMethods.length||this.checkoutSettings.isGiftPackageEnabled||(this.step=C.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==C.SHIPPING||this.checkout.availableShippingMethods.length?this.step!==C.PAYMENT&&this.step!==C.SUCCESS?[3,4]:[4,this.listPaymentGateways()]:(this.error={type:I.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 3:if(e.sent(),!this.paymentGateways.length)return this.error={type:I.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=4;case 4:return this.step===C.SUCCESS?[3,8]:this.checkout.isComplete?[2,this.changeStep(C.SUCCESS)]:[3,5];case 5:return[4,this.initialStockCheck()];case 6:e.sent(),e.label=7;case 7:return[3,11];case 8:return r=this,[4,p.getOrder(this.checkout.orderId)];case 9:return r.order=e.sent(),[4,this.getSuccessTransaction()];case 10:e.sent(),this.successTransaction&&(o=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===o}))),e.label=11;case 11:return this.isCheckoutLoaded=!0,y.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getMerchantSettings=function(){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.merchantSettings?[3,2]:(t=this,[4,g.listMerchantSettings()]);case 1:t.merchantSettings=e.sent(),e.label=2;case 2:return[2]}}))}))},this.getSuccessTransaction=function(){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,f.getOrderTransactions({orderId:this.checkout.orderId})];case 1:return t=e.sent(),this.successTransaction=t.length?t[0]:void 0,[2]}}))}))},this.saveCheckout=function(){return t(_,void 0,void 0,(function(){var t,i,s;return e(this,(function(e){switch(e.label){case 0:return[4,p.saveCheckout(this.checkout)];case 1:if((null==(t=e.sent())?void 0:t.errors)&&t.errors.length)throw i=t.errors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(s=i.extensions)||void 0===s?void 0:s.code)?{type:I.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:I.API_ERROR};return[2]}}))}))},this.checkStocks=function(){return t(_,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,h;return e(this,(function(e){switch(e.label){case 0:return t=this.cart.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,p.checkStocks(t,S.stockLocationIds||[])];case 1:if(!(i=e.sent()))throw{type:I.API_ERROR};if(null==(s=null===(u=i.lines)||void 0===u?void 0:u.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=null===(h=o.store.cartStore.cart)||void 0===h?void 0:h.items.find((function(e){return e.variant.id===t.variantId}));e&&n.push(e)},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:I.STOCK_ERROR,data:n}}return[2]}}))}))},this.removeUnavailableItems=function(i){return t(_,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:t=0,s=i,e.label=1;case 1:return t<s.length?(n=s[t],[4,this.store.cartStore.removeItem(n)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,m.listShippingCountries(S.salesChannelId)];case 1:return t.shippingCountryIds=e.sent(),[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=_.shippingCountryIds)||void 0===t?void 0:t.length)||(_.error={type:I.NO_SHIPPING_ERROR})},this.initialStockCheck=function(){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return e.sent(),[3,3];case 2:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:I.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(_,void 0,void 0,(function(){var t,i,s,n,o,a,c=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=S.paymentGateways.map((function(t){return t.id})),[4,p.listPaymentGateway(t?void 0:i)];case 1:return(s=e.sent())&&s.length?(this.step===C.PAYMENT&&(s=s.filter((function(t){return!t.supportedCurrencies.length||t.supportedCurrencies.includes(c.checkout.cart.currencyCode)})),(n=null===(a=this.checkout.shippingAddress)||void 0===a?void 0:a.country)&&n.iso2&&(s=s.filter((function(t){return!t.availableCountries.length||t.availableCountries.includes(n.iso2||"")})))),o=[],r(S.paymentGateways,"order").forEach((function(t){var e=null==s?void 0:s.find((function(e){return e.id===t.id}));e&&o.push(e)})),this.paymentGateways=t?s:o,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),[2]):(this.error={type:I.API_ERROR},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,p.retrieveInstallmentInfo(i)];case 1:return null==(t=e.sent())||t.installmentPrices.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=t,[2]}}))}))},this.createCustomer=function(){_.store.customerStore.customer?(_.store.customerStore.customer.addresses.forEach((function(t){return t.checkoutSettings=_.checkoutSettings})),_.checkout.customer=new a(_.store.customerStore.customer)):_.checkout.customer||(_.checkout.customer=new a({}))},this.createShippingAddress=function(){var t;if(_.checkout.shippingAddress)_.selectedShippingAddressId=_.checkout.shippingAddress.id||"-1",_.checkout.shippingAddress.checkoutSettings=_.checkoutSettings;else{var e=null===(t=_.store.customerStore.customer)||void 0===t?void 0:t.addresses;_.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}},this.createBillingAddress=function(){"undefined"!=typeof localStorage&&(_.useDifferentAddress=!!localStorage.getItem("sAddr"),_.useDifferentAddress?(_.checkout.billingAddress&&(_.selectedBillingAddressId=_.checkout.billingAddress.id||"-1"),_.checkout.billingAddress=_.checkout.billingAddress||new u):_.checkout.billingAddress=new u(n(_.checkout.shippingAddress)||{}),_.checkout.billingAddress.checkoutSettings=_.checkoutSettings)},this.onShippingMethodChange=function(i){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCheckout()]);case 1:return e.sent(),[4,p.getCheckoutById(this.checkout.id)];case 2:return(t=e.sent())&&(this.checkout=t),this.isChangingShippingMethod=!1,[2]}}))}))},this.onCouponCodeApply=function(){return t(_,void 0,void 0,(function(){var t,s,n,r,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,6,,7]),[4,p.addCouponCodeToCheckout(this.checkout.id,this.checkout.couponCode||null)];case 1:return e.sent()?[4,p.getCheckoutById(this.checkout.id)]:[3,5];case 2:return(t=e.sent())?(s=null===(a=null===(r=this.cardData)||void 0===r?void 0:r.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.step===C.PAYMENT&&(null==s?void 0:s.length)&&s.length>=6?[4,this.retrieveInstallmentInfo({binNumber:s.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:t.totalFinalPrice})]:[3,4]):[3,5];case 3:e.sent(),e.label=4;case 4:n=this.checkout,this.checkout=new o(i(i({},t),{shippingAddress:n.shippingAddress,billingAddress:n.billingAddress,customer:n.customer,selectedPaymentGateway:n.selectedPaymentGateway})),e.label=5;case 5:return[3,7];case 6:return e.sent(),[3,7];case 7:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e;if(_.selectedShippingAddressId=t,"-1"===t)_.checkout.shippingAddress=new u;else{var i=null===(e=_.store.customerStore.customer)||void 0===e?void 0:e.addresses.find((function(e){return e.id===t}));i&&(_.checkout.shippingAddress=new u(i))}_.checkout.shippingAddress&&(_.checkout.shippingAddress.checkoutSettings=_.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e;if(_.selectedBillingAddressId=t,"-1"===t)_.checkout.billingAddress=new u;else{var i=null===(e=_.store.customerStore.customer)||void 0===e?void 0:e.addresses.find((function(e){return e.id===t}));i&&(_.checkout.billingAddress=new u(i))}_.checkout.billingAddress&&(_.checkout.billingAddress.checkoutSettings=_.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){_.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(_.cardData&&(!(t.length>_.cardData.cardNumber.length)||N(t))){var e=(_.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!_.installmentInfo?_.retrieveInstallmentInfo({binNumber:i.slice(0,6),paymentGatewayId:_.checkout.selectedPaymentGateway.id,price:_.checkout.totalFinalPrice}):i.length<6&&e.length>i.length&&(_.cardData.installmentCount=1,_.installmentInfo=void 0),_.cardData.cardNumber=w(i,4).join(" "))}},this.onCardHolderNameChange=function(t){_.cardData&&(_.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(_.cardData&&(!(t.length>_.cardData.expirationDate.length)||N(t))){if(0===(null===(e=_.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(_.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&4===n.length){o=parseInt(s),r=parseInt(n.slice(2));if(!isNaN(r)&&!isNaN(o))return void(_.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var a=t.split(" / ").join("");a.length>4||(_.cardData.expirationDate=w(a,2).join(" / "))}},this.onCvcChange=function(t){_.cardData&&(t.length>_.cardData.cvv.length&&!N(t)||t.length>4||(_.cardData.cvv=t))},this.saveAddress=function(s){return t(_,void 0,void 0,(function(){var t,r,o,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,this.store.customerStore.customer.addresses.find((function(e){return e.id===(null==t?void 0:t.id)}))?[2]:(r=new c(i(i({},t),{title:this.addressTitle||(null==t?void 0:t.title)||this.t("checkout-page:newAddress"),id:b()})),(o=n(this.store.customerStore.customer)).addresses.push(r),[4,this.store.customerStore.saveCustomer(o)])):[3,2];case 1:e.sent(),"shipping"===s?(this.checkout.shippingAddress.id=r.id,this.selectedShippingAddressId=r.id||"-1"):(this.checkout.billingAddress.id=r.id,this.selectedBillingAddressId=r.id||"-1"),e.label=2;case 2:return[3,4];case 3:return a=e.sent(),console.error(a),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){_.router.push("/cart")},this.onBackToShoppingClick=function(){_.router.push("/")},this.onProceedToShippingClick=function(){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,5,,6]),this.isStepLoading=!0,[4,this.saveAddress("shipping")];case 2:return e.sent(),[4,this.checkStocks()];case 3:return e.sent(),[4,this.saveCheckout()];case 4:return e.sent(),this.changeStep(C.SHIPPING),[3,6];case 5:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:I.UNKNOWN}),this.isStepLoading=!1,[3,6];case 6:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCheckout()];case 3:return e.sent(),this.error=void 0,this.changeStep(C.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:I.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(_,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canPerformPayment)return this.isErrorsVisible=!0,[2];this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),e.label=1;case 1:return e.trys.push([1,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveAddress("billing")];case 3:return e.sent(),[4,this.saveCheckout()];case 4:return e.sent(),[4,this.createSaleTransaction()];case 5:return e.sent(),[3,7];case 6:return(t=e.sent()).type?this.error=t:this.error={type:I.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return t(_,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?[4,p.createSaleTransactionWithCheckout(this.checkout.id,this.checkout.selectedPaymentGateway.id,this.checkout.selectedPaymentGateway.paymentMethodType===h.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===l.INTERNAL&&this.cardData?this.cardData.toInput():void 0)]:[2];case 1:return t=e.sent(),i=null==t?void 0:t.transactionStatus,s=i&&[d.SUCCESS,d.AUTHORIZED].includes(i),n=i===d.PENDING,s?[4,this.getSuccessTransaction()]:[3,4];case 2:return e.sent(),this.successTransaction&&y.purchase(this.checkout,this.successTransaction),[4,this.onCheckoutTransactionSuccess()];case 3:return e.sent(),[3,5];case 4:if(!n||!(null==t?void 0:t.returnSlug))throw{type:I.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+t.returnSlug,e.label=5;case 5:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(_,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return localStorage.removeItem("sAddr"),(null===(t=this.checkout.customer)||void 0===t?void 0:t.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.changeStep(C.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){_.changeStep(C.INFO)},this.onBackToShippingClick=function(){_.changeStep(C.SHIPPING)},this.setCustomerConsentGranted=function(t){_.checkout.customer&&(_.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){_.useDifferentAddress=t,_.useDifferentAddress?(localStorage.setItem("sAddr","1"),_.checkout.billingAddress=_.checkout.billingAddress||new u):(localStorage.removeItem("sAddr"),_.checkout.billingAddress=_.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){_.shouldSaveAddress=t},this.setAddressTitle=function(t){_.addressTitle=t},this.setPaymentGateway=function(t){if(_.paymentGateways.length){var e=_.paymentGateways[t];_.checkout.selectedPaymentGateway=e,_.step!==C.SUCCESS&&(e.paymentMethodType===h.CREDIT_CARD&&e.type===l.INTERNAL&&(_.cardData=new v),_.installmentInfo=void 0)}},this.setInstallmentCount=function(t){_.cardData&&(_.cardData.installmentCount=t)},this.changeStep=function(i){return t(_,void 0,void 0,(function(){return e(this,(function(t){return A||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(_,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=void 0,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCheckout()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){_.isContactModalVisible=t},this.checkout=P,this.checkoutSettings=j,this.router=x,this.returnPolicy=E,this.privacyPolicy=T,this.termsOfService=O,this.t=D,this.customizationProps=G,R&&(this.merchantSettings=R),this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked,this.store.cartStore.cart=this.checkout.cart,this.init(),s(this)}return Object.defineProperty(P.prototype,"cart",{get:function(){return this.checkout.cart},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"selectedPaymentGatewayIndex",{get:function(){var t=this;return this.paymentGateways.findIndex((function(e){var i;return e.id===(null===(i=t.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"selectedInstallmentIndex",{get:function(){var t,e=this;return(null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices.findIndex((function(t){var i;return t.installmentCount===(null===(i=e.cardData)||void 0===i?void 0:i.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"customerAddressOptions",{get:function(){var t,e={label:this.t("checkout-page:newAddress"),value:"-1"},i=(null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[e].concat(i)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"installmentPrice",{get:function(){var t,e,i=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(e=this.installmentInfo.installmentPrices.find((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===e?void 0:e.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"finalPrice",{get:function(){return this.step===C.SUCCESS?this.order?this.order.totalFinalPrice:this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===I.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canProceedToShipping",{get:function(){var t,e;return(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValid)&&this.checkout.hasValidCustomerEmail&&(null===(e=this.error)||void 0===e?void 0:e.type)!==I.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway;return this.canProceedToShipping&&!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid)&&((null==i?void 0:i.paymentMethodType)===h.CREDIT_CARD&&i.type===l.INTERNAL?null===(e=this.cardData)||void 0===e?void 0:e.isValid:!!i)},enumerable:!1,configurable:!0}),P}();function w(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function N(t){return t&&P.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(C||(C={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.API_ERROR=1]="API_ERROR",t[t.STOCK_ERROR=2]="STOCK_ERROR",t[t.PAYMENT_ERROR=3]="PAYMENT_ERROR",t[t.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",t[t.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(I||(I={}));export{C as CheckoutStep,I as ErrorType,j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as t,__spreadArray as e}from'../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as i}from"mobx-react-lite";import r from"next/head.js";import"../../models/data/blog/index.js";import{IkasBrand as a}from"../../models/data/brand/index.js";import{IkasCategory as n}from"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"mobx";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import{IkasMerchantSettings as s}from"../../models/data/merchant-settings/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as d}from"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductDetail as m}from"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{IkasStorefrontConfig as p}from"../../storefront/index.js";import{IkasPageDataInit as l}from"../../providers/page-data-init.js";var c=i((function(i){var c=i.pageType,u=i.pageTitle,f=i.pageDescription,g=i.pageSpecificDataStr,
|
|
1
|
+
import{__assign as t,__spreadArray as e}from'../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as i}from"mobx-react-lite";import r from"next/head.js";import"../../models/data/blog/index.js";import{IkasBrand as a}from"../../models/data/brand/index.js";import{IkasCategory as n}from"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"mobx";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import{IkasMerchantSettings as s}from"../../models/data/merchant-settings/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as d}from"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductDetail as m}from"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{IkasStorefrontConfig as p}from"../../storefront/index.js";import{IkasPageDataInit as l}from"../../providers/page-data-init.js";var c=i((function(i){var c=i.pageType,u=i.pageTitle,f=i.pageDescription,h=i.canonicalUrl,g=i.pageSpecificDataStr,v=i.merchantSettingsStr,j=i.addOgpMetas,x=i.productReviewSummary,y="undefined"!=typeof window;o.useEffect((function(){var t;document.documentElement.lang=(null===(t=p.routings.find((function(t){return t.id===p.storefrontRoutingId})))||void 0===t?void 0:t.locale)||"tr"}),[c]);var b=o.useMemo((function(){if(v)return new s(JSON.parse(v))}),[v]),w=o.useMemo((function(){if(!g)return g;var t=JSON.parse(g);switch(c){case d.PRODUCT:return new m(t.product,t.selectedVariantValues);case d.CATEGORY:return new n(t);case d.BRAND:return new a(t);default:return g}}),[g]),O=o.useMemo((function(){if(w&&w.href)return"https://".concat(p.domain).concat(w.href)}),[w]),S=o.useMemo((function(){var t,e=[];if(j)if(e.push({property:"og:type",content:"website"}),e.push({property:"og:site_name",content:"https://"+p.domain}),u&&e.push({property:"og:title",content:u}),f&&e.push({property:"og:description",content:f}),e.push({property:"og:url",content:O||(y?window.location.href:"")||"https://".concat(p.domain)}),w&&c===d.PRODUCT){var o=w;o.selectedVariant.mainImage&&e.push({property:"og:image",content:null===(t=o.selectedVariant.mainImage)||void 0===t?void 0:t.src})}else b&&e.push({property:"og:image",content:b.logo.src});return e}),[u,w,O,f,b,j,b]),V=o.useMemo((function(){var o=[];if(b){var i={"@context":"https://schema.org","@type":"Website",url:"https://"+p.domain},r=function(t){var e,o;return{"@context":"https://schema.org","@type":"Store",name:null==t?void 0:t.merchantName,logo:null===(e=null==t?void 0:t.logo)||void 0===e?void 0:e.src,image:null===(o=null==t?void 0:t.logo)||void 0===o?void 0:o.src,url:"https://"+p.domain}}(b);o.push(i),o.push(r)}if(w&&c===d.PRODUCT){var a=function(e,o){var i,r;try{"undefined"!=typeof window&&l._initProductDetailOnBrowser(e);var a="https://".concat(p.domain).concat(e.href);return t(t({"@context":"https://schema.org/","@type":"Product",name:e.product.name,description:null===(i=e.product.metaData)||void 0===i?void 0:i.description,image:e.selectedVariant.images.map((function(t){return t.src})),productId:e.selectedVariant.id,sku:e.selectedVariant.sku,mpn:e.selectedVariant.barcodeList.length?e.selectedVariant.barcodeList[0]:"",brand:{"@type":"Brand",name:null===(r=e.product.brand)||void 0===r?void 0:r.name}},o&&{aggregateRating:{"@type":"AggregateRating",ratingValue:o.averageStar,reviewCount:o.totalReview}}),{offers:{"@type":"Offer",url:a,priceCurrency:e.selectedVariant.price.currency||"TRY",price:e.selectedVariant.price.finalPrice,priceValidUntil:"",itemCondition:"https://schema.org/NewCondition",availability:e.selectedVariant.stock>0?"https://schema.org/InStock":"https://schema.org/OutOfStock"}})}catch(t){}}(w,x?JSON.parse(x):null);a&&o.push(a)}if(w&&c===d.CATEGORY){var n=function(t){var e,o,i;try{return{"@context":"http://schema.org","@type":"CollectionPage",url:"https://".concat(p.domain).concat(t.href),name:null===(e=t.metaData)||void 0===e?void 0:e.pageTitle,description:null===(o=t.metaData)||void 0===o?void 0:o.description,image:null===(i=t.image)||void 0===i?void 0:i.src}}catch(t){}}(w),s=function(t){try{return{"@context":"http://schema.org","@type":"BreadcrumbList",itemListElement:t.path.length?e(e([],t.path.map((function(t,e){return{"@type":"ListItem",position:e+1,name:t.name,item:"https://"+p.domain+t.href}})),!0),[{"@type":"ListItem",position:t.path.length+1,name:t.name,item:"https://"+p.domain+t.href}],!1):[{"@type":"ListItem",position:1,name:t.name,item:"https://"+p.domain+t.href}]}}catch(t){}}(w);n&&o.push(n),s&&o.push(s)}return o}),[w,b]);return o.createElement(r,null,o.createElement("title",null,u||""),o.createElement("meta",{name:"description",content:f||""}),!!j&&S.map((function(t,e){return o.createElement("meta",{key:"".concat(t.content,"-").concat(e),property:t.property,content:t.content})})),!!h&&o.createElement("link",{rel:"canonical",href:"https://".concat(p.domain,"/").concat(h)}),!!V.length&&V.map((function(t,e){return o.createElement("script",{key:e,type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(t)}})})))}));export{c as IkasPageHead};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t}from'../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as i}from"mobx-react-lite";import{useRouter as r}from"next/router.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"mobx";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as a}from"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductDetail as s}from"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import{IkasThemeSettings as n}from"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{Analytics as m}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasPageDataInit as d}from"../../providers/page-data-init.js";import{ThemeComponent as p}from"./ThemeComponent.js";import{IkasPageHead as l}from"./head.js";import{IkasStorefrontConfig as u}from"../../storefront/index.js";import{initIkasEvents as c}from"../../analytics/events.js";var f=i((function(i){var p=i.propValuesStr,f=i.pageType,x=i.pageTitle,v=i.pageDescription,g=i.pageSpecificDataStr,h=i.
|
|
1
|
+
import{__awaiter as e,__generator as t}from'../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as i}from"mobx-react-lite";import{useRouter as r}from"next/router.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"mobx";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as a}from"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductDetail as s}from"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import{IkasThemeSettings as n}from"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{Analytics as m}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasPageDataInit as d}from"../../providers/page-data-init.js";import{ThemeComponent as p}from"./ThemeComponent.js";import{IkasPageHead as l}from"./head.js";import{IkasStorefrontConfig as u}from"../../storefront/index.js";import{initIkasEvents as c}from"../../analytics/events.js";var f=i((function(i){var p=i.propValuesStr,f=i.pageType,x=i.pageTitle,v=i.pageDescription,g=i.pageSpecificDataStr,h=i.canonicalUrl,S=i.settingsStr,w=i.merchantSettingsStr,y=i.configJson,b=i.reInitOnBrowser,C=i.addOgpMetas,E=i.components,O=i.productReviewSummary,T=r();u.initWithJson(y,T),u.currentPageComponents=E;var V=u.store;V.currentPageType=f;var D=o.useState(!1),P=D[0],J=D[1],R=o.useState(new n(JSON.parse(S)))[0],k=o.useMemo((function(){return d.setPageSpecificData(g,f,P),d.initPropValues(p,T,S,!0,P)}),[P,p,f,S,g]);o.useEffect((function(){b&&J("undefined"!=typeof window),V.cartStore.getCart(),V.checkLocalization(),c()}),[]),o.useEffect((function(){var e=function(){u.store.customerStore.routeChangeInit()};return T.events.on("routeChangeStart",e),function(){T.events.off("routeChangeStart",e)}}),[]),o.useEffect((function(){!function(o,i,r){e(this,void 0,void 0,(function(){var e,n,p,l,c;return t(this,(function(t){switch(t.label){case 0:m.pageView(o),t.label=1;case 1:return t.trys.push([1,4,,5]),o===a.PRODUCT&&(e=JSON.parse(i),n=new s(e.product,e.selectedVariantValues),"undefined"!=typeof window&&d._initProductDetailOnBrowser(n),m.productView(n),u.store.customerStore.onProductView(n.product.id,n.selectedVariant.id)),o===a.CATEGORY&&(p=JSON.parse(i),l=p.path.map((function(e){return e.name})).join(" > "),l=p.path.length>0?l+" > "+p.name:p.name,m.viewCategory(l,p)),o!==a.CART?[3,3]:[4,r.cartStore.waitUntilInitialized()];case 2:t.sent(),m.viewCart(r.cartStore.cart),t.label=3;case 3:return[3,5];case 4:return c=t.sent(),console.error(c),[3,5];case 5:return[2]}}))}))}(f,g,V)}),[f,g]);var M=o.useMemo((function(){var e=k.find((function(e){return e.component.isHeader})),t=k.find((function(e){return e.component.isFooter})),i=k.filter((function(e){return!e.component.isHeader&&!e.component.isFooter}))||[];return o.createElement("div",{style:{position:"relative",minHeight:"100vh",display:"flex",flexDirection:"column",justifyContent:"space-between"}},o.createElement("div",null,e&&j(e,R,-1),i.map((function(e,t){return j(e,R,t)}))),t&&j(t,R,-1))}),[k,R]);return o.createElement(o.Fragment,null,o.createElement(l,{pageType:f,pageTitle:x,pageDescription:v,pageSpecificDataStr:g,canonicalUrl:h,merchantSettingsStr:w,addOgpMetas:C,productReviewSummary:O}),M)})),j=function(e,t,i){return o.createElement(p,{key:e.pageComponent.id,index:i,pageComponentPropValue:e,settings:t})};export{f as IkasPage,j as renderComponent};
|