@salla.sa/twilight-components 2.14.4 → 2.14.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{app-globals-49848a86.js → app-globals-29d166ce.js} +2 -2
- package/dist/cjs/app-globals-29d166ce.js.map +1 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-add-product-button_48.cjs.entry.js.map +1 -1
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-conditional-offer.cjs.entry.js.map +1 -1
- package/dist/cjs/salla-orders.cjs.entry.js +4 -3
- package/dist/cjs/salla-orders.cjs.entry.js.map +1 -1
- package/dist/cjs/twilight.cjs.js +1 -1
- package/dist/collection/components/salla-conditional-offer/salla-conditional-offer.js +1 -1
- package/dist/collection/components/salla-conditional-offer/salla-conditional-offer.js.map +1 -1
- package/dist/collection/components/salla-orders/salla-orders.js +4 -3
- package/dist/collection/components/salla-orders/salla-orders.js.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/salla-conditional-offer.js +1 -1
- package/dist/components/salla-conditional-offer.js.map +1 -1
- package/dist/components/salla-orders.js +4 -3
- package/dist/components/salla-orders.js.map +1 -1
- package/dist/components/salla-quick-buy2.js.map +1 -1
- package/dist/esm/{app-globals-c97fe1b6.js → app-globals-f51db284.js} +2 -2
- package/dist/esm/app-globals-f51db284.js.map +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-add-product-button_48.entry.js.map +1 -1
- package/dist/esm/salla-conditional-offer.entry.js +1 -1
- package/dist/esm/salla-conditional-offer.entry.js.map +1 -1
- package/dist/esm/salla-orders.entry.js +4 -3
- package/dist/esm/salla-orders.entry.js.map +1 -1
- package/dist/esm/twilight.js +1 -1
- package/dist/esm-es5/{app-globals-c97fe1b6.js → app-globals-f51db284.js} +2 -2
- package/dist/esm-es5/app-globals-f51db284.js.map +1 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/salla-add-product-button_48.entry.js.map +1 -1
- package/dist/esm-es5/salla-conditional-offer.entry.js +1 -1
- package/dist/esm-es5/salla-conditional-offer.entry.js.map +1 -1
- package/dist/esm-es5/salla-orders.entry.js +1 -1
- package/dist/esm-es5/salla-orders.entry.js.map +1 -1
- package/dist/esm-es5/twilight.js +1 -1
- package/dist/twilight/p-0e195bd3.entry.js.map +1 -1
- package/dist/twilight/p-118d894f.system.entry.js.map +1 -1
- package/dist/twilight/{p-dc903b0a.js → p-1d0fd8b5.js} +4 -4
- package/dist/twilight/p-1d0fd8b5.js.map +1 -0
- package/dist/twilight/{p-4e549790.system.js → p-3d786e9f.system.js} +2 -2
- package/dist/twilight/p-85437cd8.system.js +25 -0
- package/dist/twilight/p-85437cd8.system.js.map +1 -0
- package/dist/twilight/{p-28c345ee.system.entry.js → p-a2c96f96.system.entry.js} +3 -3
- package/dist/twilight/p-a2c96f96.system.entry.js.map +1 -0
- package/dist/twilight/p-a34a0020.entry.js +5 -0
- package/dist/twilight/p-a34a0020.entry.js.map +1 -0
- package/dist/twilight/{p-72278eea.entry.js → p-c2505b70.entry.js} +2 -2
- package/dist/twilight/p-c2505b70.entry.js.map +1 -0
- package/dist/twilight/p-ccf8851a.system.entry.js +5 -0
- package/dist/twilight/p-ccf8851a.system.entry.js.map +1 -0
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/twilight/twilight.js +1 -1
- package/dist/types/components/salla-orders/salla-orders.d.ts +1 -1
- package/dist/types/global.d.ts +20 -0
- package/package.json +5 -5
- package/dist/cjs/app-globals-49848a86.js.map +0 -1
- package/dist/esm/app-globals-c97fe1b6.js.map +0 -1
- package/dist/esm-es5/app-globals-c97fe1b6.js.map +0 -1
- package/dist/twilight/p-28c345ee.system.entry.js.map +0 -1
- package/dist/twilight/p-34661205.entry.js +0 -5
- package/dist/twilight/p-34661205.entry.js.map +0 -1
- package/dist/twilight/p-3e67a023.system.entry.js +0 -5
- package/dist/twilight/p-3e67a023.system.entry.js.map +0 -1
- package/dist/twilight/p-72278eea.entry.js.map +0 -1
- package/dist/twilight/p-7af2c98d.system.js +0 -25
- package/dist/twilight/p-7af2c98d.system.js.map +0 -1
- package/dist/twilight/p-dc903b0a.js.map +0 -1
- /package/dist/twilight/{p-4e549790.system.js.map → p-3d786e9f.system.js.map} +0 -0
|
@@ -46,7 +46,7 @@ const SallaConditionalOffer$1 = /*@__PURE__*/ proxyCustomElement(class SallaCond
|
|
|
46
46
|
}).then(() => this.getProducts()).then(() => salla.event.on("cart::updated", (updatedCart) => this.updateOfferValues(updatedCart)))
|
|
47
47
|
.catch(error => {
|
|
48
48
|
this.canRender = false;
|
|
49
|
-
salla.logger.
|
|
49
|
+
salla.logger.warn('salla-conditional-offer:: ', error);
|
|
50
50
|
}).finally(() => {
|
|
51
51
|
this.isLoading = false;
|
|
52
52
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"salla-conditional-offer.js","mappings":";;;;;;AAEA,IAAY,YAIX;AAJD,WAAY,YAAY;EACpB,yCAAyB,CAAA;EACzB,+BAAe,CAAA;EACf,6CAA6B,CAAA;AACjC,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;EACjB,6CAAgC,CAAA;EAChC,8CAAiC,CAAA;AACrC,CAAC,EAHW,SAAS,KAAT,SAAS;;ACRrB,MAAM,wBAAwB,GAAG,sBAAsB;;MCc1CA,uBAAqB;;;;iBAEN,IAAI;oBACwC,EAAE;qBACjD,IAAI;qBACJ,IAAI;;EAEzB,iBAAiB;IACb,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;;MACjB,IAAI,EAAC,MAAA,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,0CAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAA,KAAK,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI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C,iBAAiB,CAAC,QAAQ,EAAE,KAAK,CAAC,CACtC,CACT,CAAC,CACA,CACH,CAAA;GACV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SallaConditionalOffer"],"sources":["src/components/salla-conditional-offer/interfaces.ts","src/components/salla-conditional-offer/salla-conditional-offer.scss?tag=salla-conditional-offer","src/components/salla-conditional-offer/salla-conditional-offer.tsx"],"sourcesContent":["import type { Product } from \"@salla.sa/twilight/types/common\";\n\nexport enum DiscountType {\n PERCENTAGE = \"percentage\",\n FIXED = \"fixed\",\n FREE_PRODUCT = \"free_product\",\n}\n\nexport enum OfferType {\n PRODUCT_COUNT = \"products_count\",\n PRODUCT_PURCHASE = \"order_amount\",\n}\n\nexport interface Discount {\n type?: DiscountType;\n value?: number;\n min_spend?: number;\n max_discount?: number;\n}\n\nexport interface OfferDetails {\n based_on?: OfferType;\n ends_at?: number;\n start_value?: number;\n end_value?: number;\n current_value?: number;\n discounts?: Discount[];\n}\n\nexport interface Offer {\n id?: number;\n type?: string;\n title?: string;\n description?: string;\n details?: OfferDetails | null;\n}\n\n\nexport interface ProductDetail {\n id?: number;\n sku?: string;\n name?: string;\n description?: string;\n url?: string;\n promotion_title?: null;\n subtitle?: null;\n type?: string;\n status?: string;\n price?: number;\n base_currency_price?: BaseCurrencyPrice;\n sale_price?: number;\n regular_price?: number;\n starting_price?: null;\n quantity?: null;\n max_quantity?: number;\n discount_ends?: null;\n is_taxable?: boolean;\n has_read_more?: boolean;\n can_add_note?: boolean;\n can_show_remained_quantity?: boolean;\n can_upload_file?: boolean;\n has_custom_form?: boolean;\n has_metadata?: boolean;\n is_on_sale?: boolean;\n is_hidden_quantity?: boolean;\n is_available?: boolean;\n is_out_of_stock?: boolean;\n is_require_shipping?: boolean;\n weight?: null;\n calories?: null;\n image?: Image;\n currency?: string;\n}\n\nexport interface BaseCurrencyPrice {\n currency?: string;\n amount?: number;\n}\n\nexport interface Image {\n url?: string;\n alt?: string;\n}\n\nexport interface UpdatedCart {\n items: Array<Product>;\n total: number;\n}\n",":host {\n display: block;\n}","import { Component, Host, State, h } from \"@stencil/core\";\nimport {\n type Discount,\n DiscountType,\n type Offer,\n OfferType,\n type UpdatedCart,\n} from \"./interfaces\";\nimport type { Product } from \"@salla.sa/twilight/types/common\";\n\n@Component({\n tag: \"salla-conditional-offer\",\n styleUrl: \"salla-conditional-offer.scss\",\n})\nexport class SallaConditionalOffer {\n\n @State() offer: Offer = null;\n @State() products: Record<string, Pick<Product, 'image' | 'url'>> = {}\n @State() isLoading = true\n @State() canRender = true\n\n componentWillLoad() {\n salla.onReady().then(() => {\n if (!salla.config.get('store.features')?.includes('conditional-offer') || (salla.storage.get(\"cart\") !== '' && !salla.storage.get(\"cart\")?.summary?.count)) {\n throw new Error('feature or cart object does not existed');\n }\n })\n .then(() => salla.api.cart.offers())\n .then(({ data }: { data: Offer[] }) => {\n //it's okay if there is an exception here, all thens will be skipped, and will catch the error,\n this.offer = data.find(offer => offer.type === \"conditional\")\n\n if (!this.offer) {\n throw new Error('No conditional offer has been activated in the merchant dashboard');\n }\n\n this.offer.details.discounts.unshift(({ value: 0, min_spend: 0 }))\n return this.updateInitialOfferValue()\n }).then(() => this.getProducts()).then(() => salla.event.on(\"cart::updated\", (updatedCart: UpdatedCart) => this.updateOfferValues(updatedCart)))\n .catch(error => {\n this.canRender = false\n salla.logger.error('salla-conditional-offer:: Error', error)\n }).finally(() => {\n this.isLoading = false\n })\n\n }\n\n private getProducts() {\n const freeProductIDs = this.offer.details.discounts.filter(({ type }) => type === DiscountType.FREE_PRODUCT).map(({ value }) => value)\n if (freeProductIDs.length > 0) {\n return salla.product.fetch({ source: 'selected', source_value: freeProductIDs }).then(({ data }: { data: Array<Product> }) => {\n data.forEach(({ id, url, image }) => {\n this.products[id] = { url, image }\n })\n })\n }\n }\n\n private updateInitialOfferValue() {\n return salla.api.cart.details().then(({ data: { cart } }: { data: { cart: UpdatedCart } }) => this.updateOfferValues(cart))\n }\n\n private updateOfferValues({ items, total }: UpdatedCart) {\n const current_value = this.offer.details.based_on === OfferType.PRODUCT_COUNT ? items.reduce((count: number, { quantity }) => count + quantity, 0,) : total\n //we need to assign the offer object a new reference to trigger re-rendering\n this.offer = {\n ...this.offer, details: {\n ...this.offer?.details, current_value,\n }\n }\n return this.offer\n }\n\n private getCheckpointContent(discount: Discount) {\n\n if (discount.type === DiscountType.PERCENTAGE) return `${discount.value}%`\n\n if (discount.type === DiscountType.FIXED) return salla.money(discount.value)\n\n if (discount.type !== DiscountType.FREE_PRODUCT) {\n salla.logger.error(`salla-conditional-offer:: unexpected type (${discount.type})!`);\n return \"\";\n }\n\n const productItem = this.products[discount.value]\n\n if (!productItem) {\n salla.logger.error(`salla-conditional-offer:: there is no product with id (${discount.value})!`);\n return \"\";\n }\n\n return <a class=\"s-conditional-offer-product-link\" href={productItem.url} >\n <img\n class=\"s-conditional-offer-checkpoint-image-content\"\n loading=\"lazy\"\n decoding=\"async\"\n alt={productItem?.image?.alt || \"\"}\n src={productItem?.image?.url} />\n </a>\n }\n\n private getOfferType(discount: Discount): string {\n const basedOn = this.offer.details?.based_on;\n if (basedOn === OfferType.PRODUCT_COUNT) return salla.lang.choice(\"blocks.header.products_count\", discount.min_spend);\n if (basedOn === OfferType.PRODUCT_PURCHASE) return salla.money(discount.min_spend);\n\n salla.logger.warn(`salla-conditional-offer:: Unexpected offer detail's based_on value: ${basedOn}`);\n return `${discount.min_spend}`;\n }\n\n private clamp(value: number, min: number, max: number) {\n return Math.max(min, Math.min(value, max));\n }\n\n private mapValueRanges(value: number, initialMinRange: number, initialMaxRange: number, newMinRange: number, newMaxRange: number) {\n\n const newRange = ((value - initialMinRange) * (newMaxRange - newMinRange)) / (initialMaxRange - initialMinRange) + newMinRange;\n\n if (newRange === Number.POSITIVE_INFINITY) return 100\n\n if (newRange === Number.NEGATIVE_INFINITY) return 0\n\n return this.clamp(newRange, 0, 100)\n }\n\n private getCheckPointView(discount: Discount, index: number) {\n const checkpointIndex = this.offer.details.discounts.findIndex(({ min_spend }) => min_spend === discount.min_spend);\n const previousCheckpointValue = this.offer.details.discounts[checkpointIndex - 1]?.min_spend ?? 0;\n const progressPercentage = this.mapValueRanges(this.offer.details.current_value, previousCheckpointValue, discount.min_spend, 0, 100);\n const isActive = discount.min_spend <= this.offer.details.current_value;\n\n return (\n <div class=\"s-conditional-offer-checkpoint-container\">\n {index > 0 ? [\n <div key=\"progress-line\" class=\"s-conditional-offer-progress-line-container\">\n <div class=\"s-conditional-offer-progress-line-inactive\" />\n <div class=\"s-conditional-offer-progress-line-active\" style={{ width: `${progressPercentage}%` }} />\n </div>,\n <div key=\"checkpoint\" class={`s-conditional-offer-checkpoint ${isActive ? \"s-conditional-offer-active-checkpoint\" : \"\"}`} >\n <div class={`s-conditional-offer-item-avatar-content ${isActive ? \"active\" : \"\"}`} >\n {this.products && this.getCheckpointContent(discount)}\n </div>\n <div class={`s-conditional-offer-checkpoint-label ${isActive ? \"active\" : \"\"}`} innerHTML={this.getOfferType(discount)} />\n\n </div>\n ] :\n <div key=\"label\" class={{ \"s-conditional-offer-checkpoint-label\": true, \"first-checkpoint\": index === 0, active: isActive }} innerHTML={this.getOfferType(discount)} />\n }\n </div>\n );\n }\n\n private getLoadingSkeletonView() {\n return <Host class=\"s-conditional-offer-container\" >\n <div class=\"s-conditional-offer-skeleton-inner-container\">\n <div class=\"s-conditional-offer-skeleton-subtitle\">\n <salla-skeleton height=\"16px\" width=\"30%\" />\n </div>\n\n <div class=\"s-conditional-offer-skeleton-subtitle\">\n <salla-skeleton height=\"16px\" width=\"35%\" />\n </div>\n <div class=\"s-conditional-offer-skeleton-checkpoints-wrapper\">\n {Array(3).fill(null).map(() => (\n [<salla-skeleton key=\"checkpoint-line\" height=\"8px\" />,\n <div key=\"checkpoint\">\n <salla-skeleton height=\"60px\" width=\"60px\" type=\"circle\" />\n </div>]\n ))}\n </div>\n\n </div>\n </Host>\n }\n\n render() {\n if (!this.canRender) return null\n if (this.isLoading) return this.getLoadingSkeletonView()\n\n return <Host class=\"s-conditional-offer-container\">\n <div class=\"s-conditional-offer-title-wrapper\">\n <div class=\"s-conditional-offer-title\">{this.offer.title}</div>\n {this.offer.description ? <div class=\"s-conditional-offer-subtitle\">\n {this.offer.description} <i class=\"sicon-information\" />\n </div> : null}\n </div>\n <div class=\"s-conditional-offer-progress-container\">\n {this.offer.details.discounts.map((discount, index) => (\n <div class={{ \"flex-1\": index > 0 }} key={discount.min_spend}>\n {this.getCheckPointView(discount, index)}\n </div>\n ))}\n </div>\n </Host>\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"salla-conditional-offer.js","mappings":";;;;;;AAEA,IAAY,YAIX;AAJD,WAAY,YAAY;EACpB,yCAAyB,CAAA;EACzB,+BAAe,CAAA;EACf,6CAA6B,CAAA;AACjC,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;EACjB,6CAAgC,CAAA;EAChC,8CAAiC,CAAA;AACrC,CAAC,EAHW,SAAS,KAAT,SAAS;;ACRrB,MAAM,wBAAwB,GAAG,sBAAsB;;MCc1CA,uBAAqB;;;;iBAEN,IAAI;oBACwC,EAAE;qBACjD,IAAI;qBACJ,IAAI;;EAEzB,iBAAiB;IACb,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;;MACjB,IAAI,EAAC,MAAA,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,0CAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAA,KAAK,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAC,MAAA,MAAA,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,0CAAE,OAAO,0CAAE,KAAK,CAAA,CAAC,EAAE;QACxJ,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;OAC9D;KACJ,CAAC;OACG,IAAI,CAAC,MAAM,KAAK,CAAC,GAAG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C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,OACrB,CAAC,sBAAgB,GAAG,EAAC,iBAAiB,EAAC,MAAM,EAAC,KAAK,GAAG,EACtD,WAAK,GAAG,EAAC,YAAY,IACjB,sBAAgB,MAAM,EAAC,MAAM,EAAC,KAAK,EAAC,MAAM,EAAC,IAAI,EAAC,QAAQ,GAAG,CACzD,CAAC,CACV,CAAC,CACA,CAEJ,CACH,CAAA;GACV;EAED,MAAM;IACF,IAAI,CAAC,IAAI,CAAC,SAAS;MAAE,OAAO,IAAI,CAAA;IAChC,IAAI,IAAI,CAAC,SAAS;MAAE,OAAO,IAAI,CAAC,sBAAsB,EAAE,CAAA;IAExD,OAAO,EAAC,IAAI,IAAC,KAAK,EAAC,+BAA+B,IAC9C,WAAK,KAAK,EAAC,mCAAmC,IAC1C,WAAK,KAAK,EAAC,2BAA2B,IAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAO,EAC9D,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,WAAK,KAAK,EAAC,8BAA8B,IAC9D,IAAI,CAAC,KAAK,CAAC,WAAW,OAAE,SAAG,KAAK,EAAC,mBAAmB,GAAG,CACtD,GAAG,IAAI,CACX,EACN,WAAK,KAAK,EAAC,wCAAwC,IAC9C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,MAC9C,WAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,QAAQ,CAAC,SAAS,IACvD,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,KAAK,CAAC,CACtC,CACT,CAAC,CACA,CACH,CAAA;GACV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SallaConditionalOffer"],"sources":["src/components/salla-conditional-offer/interfaces.ts","src/components/salla-conditional-offer/salla-conditional-offer.scss?tag=salla-conditional-offer","src/components/salla-conditional-offer/salla-conditional-offer.tsx"],"sourcesContent":["import type { Product } from \"@salla.sa/twilight/types/common\";\n\nexport enum DiscountType {\n PERCENTAGE = \"percentage\",\n FIXED = \"fixed\",\n FREE_PRODUCT = \"free_product\",\n}\n\nexport enum OfferType {\n PRODUCT_COUNT = \"products_count\",\n PRODUCT_PURCHASE = \"order_amount\",\n}\n\nexport interface Discount {\n type?: DiscountType;\n value?: number;\n min_spend?: number;\n max_discount?: number;\n}\n\nexport interface OfferDetails {\n based_on?: OfferType;\n ends_at?: number;\n start_value?: number;\n end_value?: number;\n current_value?: number;\n discounts?: Discount[];\n}\n\nexport interface Offer {\n id?: number;\n type?: string;\n title?: string;\n description?: string;\n details?: OfferDetails | null;\n}\n\n\nexport interface ProductDetail {\n id?: number;\n sku?: string;\n name?: string;\n description?: string;\n url?: string;\n promotion_title?: null;\n subtitle?: null;\n type?: string;\n status?: string;\n price?: number;\n base_currency_price?: BaseCurrencyPrice;\n sale_price?: number;\n regular_price?: number;\n starting_price?: null;\n quantity?: null;\n max_quantity?: number;\n discount_ends?: null;\n is_taxable?: boolean;\n has_read_more?: boolean;\n can_add_note?: boolean;\n can_show_remained_quantity?: boolean;\n can_upload_file?: boolean;\n has_custom_form?: boolean;\n has_metadata?: boolean;\n is_on_sale?: boolean;\n is_hidden_quantity?: boolean;\n is_available?: boolean;\n is_out_of_stock?: boolean;\n is_require_shipping?: boolean;\n weight?: null;\n calories?: null;\n image?: Image;\n currency?: string;\n}\n\nexport interface BaseCurrencyPrice {\n currency?: string;\n amount?: number;\n}\n\nexport interface Image {\n url?: string;\n alt?: string;\n}\n\nexport interface UpdatedCart {\n items: Array<Product>;\n total: number;\n}\n",":host {\n display: block;\n}","import { Component, Host, State, h } from \"@stencil/core\";\nimport {\n type Discount,\n DiscountType,\n type Offer,\n OfferType,\n type UpdatedCart,\n} from \"./interfaces\";\nimport type { Product } from \"@salla.sa/twilight/types/common\";\n\n@Component({\n tag: \"salla-conditional-offer\",\n styleUrl: \"salla-conditional-offer.scss\",\n})\nexport class SallaConditionalOffer {\n\n @State() offer: Offer = null;\n @State() products: Record<string, Pick<Product, 'image' | 'url'>> = {}\n @State() isLoading = true\n @State() canRender = true\n\n componentWillLoad() {\n salla.onReady().then(() => {\n if (!salla.config.get('store.features')?.includes('conditional-offer') || (salla.storage.get(\"cart\") !== '' && !salla.storage.get(\"cart\")?.summary?.count)) {\n throw new Error('feature or cart object does not existed');\n }\n })\n .then(() => salla.api.cart.offers())\n .then(({ data }: { data: Offer[] }) => {\n //it's okay if there is an exception here, all thens will be skipped, and will catch the error,\n this.offer = data.find(offer => offer.type === \"conditional\")\n\n if (!this.offer) {\n throw new Error('No conditional offer has been activated in the merchant dashboard');\n }\n\n this.offer.details.discounts.unshift(({ value: 0, min_spend: 0 }))\n return this.updateInitialOfferValue()\n }).then(() => this.getProducts()).then(() => salla.event.on(\"cart::updated\", (updatedCart: UpdatedCart) => this.updateOfferValues(updatedCart)))\n .catch(error => {\n this.canRender = false\n salla.logger.warn('salla-conditional-offer:: ', error)\n }).finally(() => {\n this.isLoading = false\n })\n\n }\n\n private getProducts() {\n const freeProductIDs = this.offer.details.discounts.filter(({ type }) => type === DiscountType.FREE_PRODUCT).map(({ value }) => value)\n if (freeProductIDs.length > 0) {\n return salla.product.fetch({ source: 'selected', source_value: freeProductIDs }).then(({ data }: { data: Array<Product> }) => {\n data.forEach(({ id, url, image }) => {\n this.products[id] = { url, image }\n })\n })\n }\n }\n\n private updateInitialOfferValue() {\n return salla.api.cart.details().then(({ data: { cart } }: { data: { cart: UpdatedCart } }) => this.updateOfferValues(cart))\n }\n\n private updateOfferValues({ items, total }: UpdatedCart) {\n const current_value = this.offer.details.based_on === OfferType.PRODUCT_COUNT ? items.reduce((count: number, { quantity }) => count + quantity, 0,) : total\n //we need to assign the offer object a new reference to trigger re-rendering\n this.offer = {\n ...this.offer, details: {\n ...this.offer?.details, current_value,\n }\n }\n return this.offer\n }\n\n private getCheckpointContent(discount: Discount) {\n\n if (discount.type === DiscountType.PERCENTAGE) return `${discount.value}%`\n\n if (discount.type === DiscountType.FIXED) return salla.money(discount.value)\n\n if (discount.type !== DiscountType.FREE_PRODUCT) {\n salla.logger.error(`salla-conditional-offer:: unexpected type (${discount.type})!`);\n return \"\";\n }\n\n const productItem = this.products[discount.value]\n\n if (!productItem) {\n salla.logger.error(`salla-conditional-offer:: there is no product with id (${discount.value})!`);\n return \"\";\n }\n\n return <a class=\"s-conditional-offer-product-link\" href={productItem.url} >\n <img\n class=\"s-conditional-offer-checkpoint-image-content\"\n loading=\"lazy\"\n decoding=\"async\"\n alt={productItem?.image?.alt || \"\"}\n src={productItem?.image?.url} />\n </a>\n }\n\n private getOfferType(discount: Discount): string {\n const basedOn = this.offer.details?.based_on;\n if (basedOn === OfferType.PRODUCT_COUNT) return salla.lang.choice(\"blocks.header.products_count\", discount.min_spend);\n if (basedOn === OfferType.PRODUCT_PURCHASE) return salla.money(discount.min_spend);\n\n salla.logger.warn(`salla-conditional-offer:: Unexpected offer detail's based_on value: ${basedOn}`);\n return `${discount.min_spend}`;\n }\n\n private clamp(value: number, min: number, max: number) {\n return Math.max(min, Math.min(value, max));\n }\n\n private mapValueRanges(value: number, initialMinRange: number, initialMaxRange: number, newMinRange: number, newMaxRange: number) {\n\n const newRange = ((value - initialMinRange) * (newMaxRange - newMinRange)) / (initialMaxRange - initialMinRange) + newMinRange;\n\n if (newRange === Number.POSITIVE_INFINITY) return 100\n\n if (newRange === Number.NEGATIVE_INFINITY) return 0\n\n return this.clamp(newRange, 0, 100)\n }\n\n private getCheckPointView(discount: Discount, index: number) {\n const checkpointIndex = this.offer.details.discounts.findIndex(({ min_spend }) => min_spend === discount.min_spend);\n const previousCheckpointValue = this.offer.details.discounts[checkpointIndex - 1]?.min_spend ?? 0;\n const progressPercentage = this.mapValueRanges(this.offer.details.current_value, previousCheckpointValue, discount.min_spend, 0, 100);\n const isActive = discount.min_spend <= this.offer.details.current_value;\n\n return (\n <div class=\"s-conditional-offer-checkpoint-container\">\n {index > 0 ? [\n <div key=\"progress-line\" class=\"s-conditional-offer-progress-line-container\">\n <div class=\"s-conditional-offer-progress-line-inactive\" />\n <div class=\"s-conditional-offer-progress-line-active\" style={{ width: `${progressPercentage}%` }} />\n </div>,\n <div key=\"checkpoint\" class={`s-conditional-offer-checkpoint ${isActive ? \"s-conditional-offer-active-checkpoint\" : \"\"}`} >\n <div class={`s-conditional-offer-item-avatar-content ${isActive ? \"active\" : \"\"}`} >\n {this.products && this.getCheckpointContent(discount)}\n </div>\n <div class={`s-conditional-offer-checkpoint-label ${isActive ? \"active\" : \"\"}`} innerHTML={this.getOfferType(discount)} />\n\n </div>\n ] :\n <div key=\"label\" class={{ \"s-conditional-offer-checkpoint-label\": true, \"first-checkpoint\": index === 0, active: isActive }} innerHTML={this.getOfferType(discount)} />\n }\n </div>\n );\n }\n\n private getLoadingSkeletonView() {\n return <Host class=\"s-conditional-offer-container\" >\n <div class=\"s-conditional-offer-skeleton-inner-container\">\n <div class=\"s-conditional-offer-skeleton-subtitle\">\n <salla-skeleton height=\"16px\" width=\"30%\" />\n </div>\n\n <div class=\"s-conditional-offer-skeleton-subtitle\">\n <salla-skeleton height=\"16px\" width=\"35%\" />\n </div>\n <div class=\"s-conditional-offer-skeleton-checkpoints-wrapper\">\n {Array(3).fill(null).map(() => (\n [<salla-skeleton key=\"checkpoint-line\" height=\"8px\" />,\n <div key=\"checkpoint\">\n <salla-skeleton height=\"60px\" width=\"60px\" type=\"circle\" />\n </div>]\n ))}\n </div>\n\n </div>\n </Host>\n }\n\n render() {\n if (!this.canRender) return null\n if (this.isLoading) return this.getLoadingSkeletonView()\n\n return <Host class=\"s-conditional-offer-container\">\n <div class=\"s-conditional-offer-title-wrapper\">\n <div class=\"s-conditional-offer-title\">{this.offer.title}</div>\n {this.offer.description ? <div class=\"s-conditional-offer-subtitle\">\n {this.offer.description} <i class=\"sicon-information\" />\n </div> : null}\n </div>\n <div class=\"s-conditional-offer-progress-container\">\n {this.offer.details.discounts.map((discount, index) => (\n <div class={{ \"flex-1\": index > 0 }} key={discount.min_spend}>\n {this.getCheckPointView(discount, index)}\n </div>\n ))}\n </div>\n </Host>\n }\n}\n"],"version":3}
|
|
@@ -235,9 +235,10 @@ const SallaOrder = /*@__PURE__*/ proxyCustomElement(class SallaOrder extends HTM
|
|
|
235
235
|
}
|
|
236
236
|
return h("div", { class: "s-orders-wrapper" }, h("table", { class: "s-orders-table" }, h("thead", { class: "s-orders-table-head" }, h("tr", { class: "s-orders-table-head-tr" }, h("th", { class: "s-orders-table-head-tr-th", scope: "col" }, this.orderNumberText), h("th", { class: "s-orders-table-head-tr-th", scope: "col" }, this.totalOrderText), h("th", { class: "s-orders-table-head-tr-th", scope: "col" }, this.orderDateText), h("th", { class: "s-orders-table-head-tr-th", scope: "col" }, this.orderStatusText))), h("tbody", { class: "s-orders-table-tbody", ref: (el) => (this.wrapper = el) })), this.nextPage && (h("div", { class: "s-infinite-scroll-wrapper", ref: status => this.status = status }, h("button", { onClick: () => this.loadMore(), class: "s-infinite-scroll-btn s-button-btn s-button-primary" }, h("span", { class: "s-button-text s-infinite-scroll-btn-text" }, (_a = this.loadMoreText) !== null && _a !== void 0 ? _a : this.load_more_text_trans), h("span", { class: "s-button-loader s-button-loader-center s-infinite-scroll-btn-loader", ref: btnLoader => this.btnLoader = btnLoader, style: { "display": "none" } })))));
|
|
237
237
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
componentWillLoad() {
|
|
239
|
+
return salla.onReady()
|
|
240
|
+
.then(() => this.loadInitialData())
|
|
241
|
+
.then(() => this.initiateInfiniteScroll());
|
|
241
242
|
}
|
|
242
243
|
get host() { return this; }
|
|
243
244
|
static get style() { return sallaOrdersCss; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"salla-orders.js","mappings":";;;;;;;AAAA,MAAM,cAAc,GAAG,sBAAsB;;MCShC,UAAU;EAErB;;;;;2BAsBmC,KAAK,CAAC,IAAI,CA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AAE,CAAA;IAC5B,IAAI,CAAC,sBAAsB,EAAE,CAAC;GAC/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/salla-orders/salla-orders.scss?tag=salla-orders","src/components/salla-orders/salla-orders.tsx"],"sourcesContent":[":host {\n display: block;\n}\n","import { Component, State, h, Prop, Element } from '@stencil/core';\nimport { Order, OrderQueryParameters } from './interface'\nimport {Pagination} from \"../../interfaces\"\nimport Helper from '../../Helpers/Helper';\n\n@Component({\n tag: 'salla-orders',\n styleUrl: 'salla-orders.scss',\n})\nexport class SallaOrder {\n\n constructor() {\n salla.lang.onLoaded(() => {\n this.languageCode = salla.lang.locale\n this.orderNumberText = salla.lang.get('pages.thank_you.order_id');\n this.totalOrderText = salla.lang.get('pages.orders.total')\n this.orderDateText = salla.lang.get('pages.orders.date')\n this.orderStatusText = salla.lang.get('pages.orders.status')\n this.noOrderText = salla.lang.get('pages.orders.non_orders')\n this.load_more_text_trans = salla.lang.get('common.elements.load_more')\n })\n }\n\n /**\n * Query Parameter to send along with the fetch request\n */\n @Prop() params: OrderQueryParameters;\n\n /**\n * Load more text\n */\n @Prop() loadMoreText: string;\n\n @State() orderNumberText: string = salla.lang.get('pages.thank_you.order_id')\n @State() totalOrderText: string = salla.lang.get('pages.orders.total')\n @State() orderDateText: string = salla.lang.get('pages.orders.date')\n @State() orderStatusText: string = salla.lang.get('pages.orders.status')\n @State() noOrderText: string = salla.lang.get('pages.orders.non_orders')\n @State() load_more_text_trans = salla.lang.get('common.elements.load_more');\n @State() languageCode: string = salla.lang.locale\n\n @State() orders: Array<Order> = [];\n @State() pagination: Pagination;\n @State() hasInfiniteScroll: boolean;\n @State() total: number;\n @State() nextPage: string;\n @State() showPlaceholder: boolean;\n\n private status: any;\n private btnLoader: any;\n private infiniteScroll: any;\n private wrapper: HTMLElement;\n\n @Element() host: HTMLElement;\n\n // Show/hide loading\n private loading(isLoading = true) {\n let btnText = this.status?.querySelector('.s-button-text');\n if (btnText) {\n Helper.toggleElementClassIf(btnText, 's-button-hide', 's-button-show', () => isLoading);\n this.btnLoader.style.display = isLoading ? 'inherit' : 'none';\n }\n }\n\n private initiateInfiniteScroll() {\n if (!this.hasInfiniteScroll) {\n return;\n }\n\n if (!this.wrapper) {\n salla.logger.error('Wrapper is undefined. Cannot initiate infinite scroll.');\n return;\n }\n\n this.infiniteScroll = salla.infiniteScroll.initiate(this.wrapper, this.wrapper, {\n path: () => this.nextPage,\n history: false,\n nextPage: this.nextPage,\n scrollThreshold: false,\n }, true);\n\n this.infiniteScroll?.on('request', _response => {\n this.loading();\n });\n\n this.infiniteScroll?.on('load', response => {\n this.loading(false);\n this.pagination = response.pagination;\n this.nextPage = response.pagination?.links?.next || null;\n this.handleResponse(response.data).forEach(data => {\n this.wrapper.append(data)\n })\n let items = this.host.querySelectorAll('.s-orders-table-tbody-tr:not(.animated)');\n Helper.animateItems(items);\n });\n\n this.infiniteScroll?.on('error', (e) => {\n salla.logger.error('Error loading more comments:', e);\n });\n\n }\n\n // Get next page\n async loadMore() {\n this.infiniteScroll.loadNextPage();\n }\n\n private handleResponse(orderList: Array<Order>) {\n return orderList.map(order => this.getSingleOrderItem(order));\n }\n\n private async loadInitialData() {\n await salla.order.api.fetch({ ...this.params, types: [\"\"] }).then((resp) => {\n this.orders = resp.data\n this.hasInfiniteScroll = !!resp.pagination?.links.next;\n this.pagination = resp.pagination;\n this.total = resp.pagination?.total;\n this.nextPage = resp.pagination?.links?.next || null;\n if (!this.orders.length) {\n this.showPlaceholder = true;\n return this.loading(false);\n }\n setTimeout(() => {\n this.handleResponse(resp.data).forEach(data => {\n this.wrapper.append(data)\n })\n this.initiateInfiniteScroll();\n let items = this.wrapper.querySelectorAll('.s-orders-table-tbody-tr:not(.animated)');\n Helper.animateItems(items);\n }, 100)\n }).catch(error => {\n this.showPlaceholder = true;\n this.loading(false)\n salla.logger.error(error)\n })\n }\n\n private getSingleOrderItem(order: Order): HTMLTableRowElement {\n const tr = document.createElement('tr');\n tr.classList.add('s-orders-table-tbody-tr', 's-orders-table-tbody-tr-shadow'); \n \n const td1 = document.createElement('td');\n td1.classList.add('s-orders-table-tbody-tr-td');\n const div1 = document.createElement('div');\n div1.classList.add('s-orders-table-tbody-tr-td-content');\n const span1 = document.createElement('span');\n span1.classList.add('s-orders-mobile-title');\n span1.textContent = this.orderNumberText + ':';\n const span2 = document.createElement('span');\n span2.classList.add('s-orders-reference-id');\n span2.textContent = '#' + order.reference_id;\n div1.appendChild(span1);\n div1.appendChild(span2);\n if (order.source == 'buy_as_gift') {\n const giftIcon = document.createElement('i');\n giftIcon.classList.add('sicon-gift-sharing', 's-orders-buy-as-gift-icon');\n div1.appendChild(giftIcon);\n }\n const anchor1 = document.createElement('a');\n anchor1.href = order.url;\n div1.appendChild(anchor1);\n const div2 = document.createElement('div');\n div2.classList.add('s-orders-copy-to-clipboard-button');\n const sallaButton = document.createElement('salla-button');\n sallaButton.classList.add('relative');\n sallaButton.setAttribute('color', 'dark');\n sallaButton.setAttribute('shape', 'link');\n sallaButton.dataset.content = order.reference_id.toString();\n sallaButton.addEventListener('click', (event) => {\n Helper.copyToClipboard(event)\n Helper.toggleElementClassIf(sallaButton, 'copied', 'code-to-copy', () => true);\n setTimeout(() => {\n Helper.toggleElementClassIf(sallaButton, 'code-to-copy', 'copied', () => true)\n }, 1000);\n });\n const span3 = document.createElement('span');\n span3.textContent = '#' + order.reference_id;\n const copyIcon = document.createElement('i');\n copyIcon.classList.add('sicon-swap-stroke', 's-orders-copy-to-clipboard-button-icon');\n // Check the text direction\n let isRTL = salla.config.get('theme.is_rtl', true);\n if (isRTL) {\n // Append the icon and then the span\n sallaButton.appendChild(copyIcon);\n sallaButton.appendChild(span3);\n } else {\n // Append the span and then the icon\n sallaButton.appendChild(span3);\n sallaButton.appendChild(copyIcon);\n }\n\n div2.appendChild(sallaButton);\n div1.appendChild(div2);\n td1.appendChild(div1);\n tr.appendChild(td1);\n\n const td2 = document.createElement('td');\n td2.classList.add('s-orders-table-tbody-tr-td');\n const div3 = document.createElement('div');\n div3.classList.add('s-orders-table-tbody-tr-td-content');\n const span4 = document.createElement('span');\n span4.classList.add('s-orders-mobile-title');\n span4.textContent = this.totalOrderText + ':';\n const div4 = document.createElement('div');\n div4.textContent = salla.money(order.total);\n const anchor2 = document.createElement('a');\n anchor2.href = order.url;\n div3.appendChild(span4);\n div3.appendChild(div4);\n div3.appendChild(anchor2);\n td2.appendChild(div3);\n tr.appendChild(td2);\n\n const td3 = document.createElement('td');\n td3.classList.add('s-orders-table-tbody-tr-td');\n const div5 = document.createElement('div');\n div5.classList.add('s-orders-table-tbody-tr-td-content');\n const span5 = document.createElement('span');\n span5.classList.add('s-orders-mobile-title');\n span5.textContent = this.orderDateText + ':';\n const div6 = document.createElement('div');\n div6.textContent = Helper.formatDateFromString(order.created_at.date, salla.helpers.number, this.languageCode);\n const anchor3 = document.createElement('a');\n anchor3.href = order.url;\n div5.appendChild(span5);\n div5.appendChild(div6);\n div5.appendChild(anchor3);\n td3.appendChild(div5);\n tr.appendChild(td3);\n\n const td4 = document.createElement('td');\n td4.classList.add('s-orders-table-tbody-tr-td');\n const div7 = document.createElement('div');\n div7.classList.add('s-orders-table-tbody-tr-td-content');\n const span6 = document.createElement('span');\n span6.classList.add('s-orders-mobile-title');\n span6.textContent = this.orderStatusText + ':';\n const statusSpan = document.createElement('span');\n statusSpan.classList.add('s-orders-status-container');\n statusSpan.style.color = order.status.color;\n const statusIcon = document.createElement('i');\n statusIcon.classList.add(order.status.icon);\n const statusName = document.createElement('span');\n statusName.textContent = order.status.name;\n statusSpan.appendChild(statusIcon);\n statusSpan.appendChild(statusName);\n div7.appendChild(span6);\n div7.appendChild(statusSpan);\n const starIcon = document.createElement('i');\n starIcon.classList.add('sicon-star2', 's-orders-status-rated', order.is_rated ? 's-orders-rated-text' : 's-orders-unrated-text');\n div7.appendChild(starIcon);\n const anchor4 = document.createElement('a');\n anchor4.href = order.url;\n div7.appendChild(anchor4);\n td4.appendChild(div7);\n tr.appendChild(td4);\n\n return tr;\n }\n\n render() {\n if (this.showPlaceholder) {\n return <div class=\"s-orders-no-content\">\n <i class=\"sicon-packed-box icon\"></i>\n <p>{this.noOrderText}</p>\n </div>\n }\n return <div class=\"s-orders-wrapper\">\n <table class=\"s-orders-table\">\n <thead class=\"s-orders-table-head\">\n <tr class=\"s-orders-table-head-tr\">\n <th class=\"s-orders-table-head-tr-th\" scope=\"col\">\n {this.orderNumberText}\n </th>\n <th class=\"s-orders-table-head-tr-th\" scope=\"col\">\n {this.totalOrderText}\n </th>\n <th class=\"s-orders-table-head-tr-th\" scope=\"col\">\n {this.orderDateText}\n </th>\n <th class=\"s-orders-table-head-tr-th\" scope=\"col\">\n {this.orderStatusText}\n </th>\n </tr>\n </thead>\n <tbody class=\"s-orders-table-tbody\" ref={(el) => (this.wrapper = el)}>\n\n </tbody>\n </table>\n\n {this.nextPage && (\n <div class=\"s-infinite-scroll-wrapper\" ref={status => this.status = status}>\n <button onClick={() => this.loadMore()} class=\"s-infinite-scroll-btn s-button-btn s-button-primary\">\n <span class=\"s-button-text s-infinite-scroll-btn-text\">{this.loadMoreText ?? this.load_more_text_trans}</span>\n <span class=\"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader\" ref={btnLoader => this.btnLoader = btnLoader} style={{ \"display\": \"none\" }}></span>\n </button>\n </div>\n )}\n </div>\n }\n\n async componentWillLoad() {\n await this.loadInitialData()\n this.initiateInfiniteScroll();\n }\n\n}\n\n\n"],"version":3}
|
|
1
|
+
{"file":"salla-orders.js","mappings":";;;;;;;AAAA,MAAM,cAAc,GAAG,sBAAsB;;MCShC,UAAU;EAErB;;;;;2BAsBmC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,0BAA0B,CAAC;0BAC3C,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC;yBACrC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC;2BACjC,KAAK,CAAC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;;;;;;;","names":[],"sources":["src/components/salla-orders/salla-orders.scss?tag=salla-orders","src/components/salla-orders/salla-orders.tsx"],"sourcesContent":[":host {\n display: block;\n}\n","import { Component, State, h, Prop, Element } from '@stencil/core';\nimport { Order, OrderQueryParameters } from './interface'\nimport {Pagination} from \"../../interfaces\"\nimport Helper from '../../Helpers/Helper';\n\n@Component({\n tag: 'salla-orders',\n styleUrl: 'salla-orders.scss',\n})\nexport class SallaOrder {\n\n constructor() {\n salla.lang.onLoaded(() => {\n this.languageCode = salla.lang.locale\n this.orderNumberText = salla.lang.get('pages.thank_you.order_id');\n this.totalOrderText = salla.lang.get('pages.orders.total')\n this.orderDateText = salla.lang.get('pages.orders.date')\n this.orderStatusText = salla.lang.get('pages.orders.status')\n this.noOrderText = salla.lang.get('pages.orders.non_orders')\n this.load_more_text_trans = salla.lang.get('common.elements.load_more')\n })\n }\n\n /**\n * Query Parameter to send along with the fetch request\n */\n @Prop() params: OrderQueryParameters;\n\n /**\n * Load more text\n */\n @Prop() loadMoreText: string;\n\n @State() orderNumberText: string = salla.lang.get('pages.thank_you.order_id')\n @State() totalOrderText: string = salla.lang.get('pages.orders.total')\n @State() orderDateText: string = salla.lang.get('pages.orders.date')\n @State() orderStatusText: string = salla.lang.get('pages.orders.status')\n @State() noOrderText: string = salla.lang.get('pages.orders.non_orders')\n @State() load_more_text_trans = salla.lang.get('common.elements.load_more');\n @State() languageCode: string = salla.lang.locale\n\n @State() orders: Array<Order> = [];\n @State() pagination: Pagination;\n @State() hasInfiniteScroll: boolean;\n @State() total: number;\n @State() nextPage: string;\n @State() showPlaceholder: boolean;\n\n private status: any;\n private btnLoader: any;\n private infiniteScroll: any;\n private wrapper: HTMLElement;\n\n @Element() host: HTMLElement;\n\n // Show/hide loading\n private loading(isLoading = true) {\n let btnText = this.status?.querySelector('.s-button-text');\n if (btnText) {\n Helper.toggleElementClassIf(btnText, 's-button-hide', 's-button-show', () => isLoading);\n this.btnLoader.style.display = isLoading ? 'inherit' : 'none';\n }\n }\n\n private initiateInfiniteScroll() {\n if (!this.hasInfiniteScroll) {\n return;\n }\n\n if (!this.wrapper) {\n salla.logger.error('Wrapper is undefined. Cannot initiate infinite scroll.');\n return;\n }\n\n this.infiniteScroll = salla.infiniteScroll.initiate(this.wrapper, this.wrapper, {\n path: () => this.nextPage,\n history: false,\n nextPage: this.nextPage,\n scrollThreshold: false,\n }, true);\n\n this.infiniteScroll?.on('request', _response => {\n this.loading();\n });\n\n this.infiniteScroll?.on('load', response => {\n this.loading(false);\n this.pagination = response.pagination;\n this.nextPage = response.pagination?.links?.next || null;\n this.handleResponse(response.data).forEach(data => {\n this.wrapper.append(data)\n })\n let items = this.host.querySelectorAll('.s-orders-table-tbody-tr:not(.animated)');\n Helper.animateItems(items);\n });\n\n this.infiniteScroll?.on('error', (e) => {\n salla.logger.error('Error loading more comments:', e);\n });\n\n }\n\n // Get next page\n async loadMore() {\n this.infiniteScroll.loadNextPage();\n }\n\n private handleResponse(orderList: Array<Order>) {\n return orderList.map(order => this.getSingleOrderItem(order));\n }\n\n private async loadInitialData() {\n await salla.order.api.fetch({ ...this.params, types: [\"\"] }).then((resp) => {\n this.orders = resp.data\n this.hasInfiniteScroll = !!resp.pagination?.links.next;\n this.pagination = resp.pagination;\n this.total = resp.pagination?.total;\n this.nextPage = resp.pagination?.links?.next || null;\n if (!this.orders.length) {\n this.showPlaceholder = true;\n return this.loading(false);\n }\n setTimeout(() => {\n this.handleResponse(resp.data).forEach(data => {\n this.wrapper.append(data)\n })\n this.initiateInfiniteScroll();\n let items = this.wrapper.querySelectorAll('.s-orders-table-tbody-tr:not(.animated)');\n Helper.animateItems(items);\n }, 100)\n }).catch(error => {\n this.showPlaceholder = true;\n this.loading(false)\n salla.logger.error(error)\n })\n }\n\n private getSingleOrderItem(order: Order): HTMLTableRowElement {\n const tr = document.createElement('tr');\n tr.classList.add('s-orders-table-tbody-tr', 's-orders-table-tbody-tr-shadow'); \n \n const td1 = document.createElement('td');\n td1.classList.add('s-orders-table-tbody-tr-td');\n const div1 = document.createElement('div');\n div1.classList.add('s-orders-table-tbody-tr-td-content');\n const span1 = document.createElement('span');\n span1.classList.add('s-orders-mobile-title');\n span1.textContent = this.orderNumberText + ':';\n const span2 = document.createElement('span');\n span2.classList.add('s-orders-reference-id');\n span2.textContent = '#' + order.reference_id;\n div1.appendChild(span1);\n div1.appendChild(span2);\n if (order.source == 'buy_as_gift') {\n const giftIcon = document.createElement('i');\n giftIcon.classList.add('sicon-gift-sharing', 's-orders-buy-as-gift-icon');\n div1.appendChild(giftIcon);\n }\n const anchor1 = document.createElement('a');\n anchor1.href = order.url;\n div1.appendChild(anchor1);\n const div2 = document.createElement('div');\n div2.classList.add('s-orders-copy-to-clipboard-button');\n const sallaButton = document.createElement('salla-button');\n sallaButton.classList.add('relative');\n sallaButton.setAttribute('color', 'dark');\n sallaButton.setAttribute('shape', 'link');\n sallaButton.dataset.content = order.reference_id.toString();\n sallaButton.addEventListener('click', (event) => {\n Helper.copyToClipboard(event)\n Helper.toggleElementClassIf(sallaButton, 'copied', 'code-to-copy', () => true);\n setTimeout(() => {\n Helper.toggleElementClassIf(sallaButton, 'code-to-copy', 'copied', () => true)\n }, 1000);\n });\n const span3 = document.createElement('span');\n span3.textContent = '#' + order.reference_id;\n const copyIcon = document.createElement('i');\n copyIcon.classList.add('sicon-swap-stroke', 's-orders-copy-to-clipboard-button-icon');\n // Check the text direction\n let isRTL = salla.config.get('theme.is_rtl', true);\n if (isRTL) {\n // Append the icon and then the span\n sallaButton.appendChild(copyIcon);\n sallaButton.appendChild(span3);\n } else {\n // Append the span and then the icon\n sallaButton.appendChild(span3);\n sallaButton.appendChild(copyIcon);\n }\n\n div2.appendChild(sallaButton);\n div1.appendChild(div2);\n td1.appendChild(div1);\n tr.appendChild(td1);\n\n const td2 = document.createElement('td');\n td2.classList.add('s-orders-table-tbody-tr-td');\n const div3 = document.createElement('div');\n div3.classList.add('s-orders-table-tbody-tr-td-content');\n const span4 = document.createElement('span');\n span4.classList.add('s-orders-mobile-title');\n span4.textContent = this.totalOrderText + ':';\n const div4 = document.createElement('div');\n div4.textContent = salla.money(order.total);\n const anchor2 = document.createElement('a');\n anchor2.href = order.url;\n div3.appendChild(span4);\n div3.appendChild(div4);\n div3.appendChild(anchor2);\n td2.appendChild(div3);\n tr.appendChild(td2);\n\n const td3 = document.createElement('td');\n td3.classList.add('s-orders-table-tbody-tr-td');\n const div5 = document.createElement('div');\n div5.classList.add('s-orders-table-tbody-tr-td-content');\n const span5 = document.createElement('span');\n span5.classList.add('s-orders-mobile-title');\n span5.textContent = this.orderDateText + ':';\n const div6 = document.createElement('div');\n div6.textContent = Helper.formatDateFromString(order.created_at.date, salla.helpers.number, this.languageCode);\n const anchor3 = document.createElement('a');\n anchor3.href = order.url;\n div5.appendChild(span5);\n div5.appendChild(div6);\n div5.appendChild(anchor3);\n td3.appendChild(div5);\n tr.appendChild(td3);\n\n const td4 = document.createElement('td');\n td4.classList.add('s-orders-table-tbody-tr-td');\n const div7 = document.createElement('div');\n div7.classList.add('s-orders-table-tbody-tr-td-content');\n const span6 = document.createElement('span');\n span6.classList.add('s-orders-mobile-title');\n span6.textContent = this.orderStatusText + ':';\n const statusSpan = document.createElement('span');\n statusSpan.classList.add('s-orders-status-container');\n statusSpan.style.color = order.status.color;\n const statusIcon = document.createElement('i');\n statusIcon.classList.add(order.status.icon);\n const statusName = document.createElement('span');\n statusName.textContent = order.status.name;\n statusSpan.appendChild(statusIcon);\n statusSpan.appendChild(statusName);\n div7.appendChild(span6);\n div7.appendChild(statusSpan);\n const starIcon = document.createElement('i');\n starIcon.classList.add('sicon-star2', 's-orders-status-rated', order.is_rated ? 's-orders-rated-text' : 's-orders-unrated-text');\n div7.appendChild(starIcon);\n const anchor4 = document.createElement('a');\n anchor4.href = order.url;\n div7.appendChild(anchor4);\n td4.appendChild(div7);\n tr.appendChild(td4);\n\n return tr;\n }\n\n render() {\n if (this.showPlaceholder) {\n return <div class=\"s-orders-no-content\">\n <i class=\"sicon-packed-box icon\"></i>\n <p>{this.noOrderText}</p>\n </div>\n }\n return <div class=\"s-orders-wrapper\">\n <table class=\"s-orders-table\">\n <thead class=\"s-orders-table-head\">\n <tr class=\"s-orders-table-head-tr\">\n <th class=\"s-orders-table-head-tr-th\" scope=\"col\">\n {this.orderNumberText}\n </th>\n <th class=\"s-orders-table-head-tr-th\" scope=\"col\">\n {this.totalOrderText}\n </th>\n <th class=\"s-orders-table-head-tr-th\" scope=\"col\">\n {this.orderDateText}\n </th>\n <th class=\"s-orders-table-head-tr-th\" scope=\"col\">\n {this.orderStatusText}\n </th>\n </tr>\n </thead>\n <tbody class=\"s-orders-table-tbody\" ref={(el) => (this.wrapper = el)}>\n\n </tbody>\n </table>\n\n {this.nextPage && (\n <div class=\"s-infinite-scroll-wrapper\" ref={status => this.status = status}>\n <button onClick={() => this.loadMore()} class=\"s-infinite-scroll-btn s-button-btn s-button-primary\">\n <span class=\"s-button-text s-infinite-scroll-btn-text\">{this.loadMoreText ?? this.load_more_text_trans}</span>\n <span class=\"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader\" ref={btnLoader => this.btnLoader = btnLoader} style={{ \"display\": \"none\" }}></span>\n </button>\n </div>\n )}\n </div>\n }\n\n componentWillLoad() {\n return salla.onReady()\n .then(() => this.loadInitialData())\n .then( () => this.initiateInfiniteScroll())\n }\n}\n\n\n"],"version":3}
|