@salla.sa/twilight-components 2.14.385 → 2.14.386
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/{filepond-CH0EhqTR.js → filepond-Dz0w3b0-.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-DB_nSU5H.js → filepond-plugin-file-poster-Bc2hFAJm.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-DhmLgwAd.js → filepond-plugin-file-validate-size-D-ntIPdx.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-BP6pXR9l.js → filepond-plugin-file-validate-type-1TnSvBgD.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-H28z0oor.js → filepond-plugin-image-edit-DGi3QY5x.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-B3aPmsvW.js → filepond-plugin-image-exif-orientation-CzMQBbqX.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-2UoG7SNa.js → filepond-plugin-image-preview-D555a4un.js} +1 -1
- package/dist/cjs/{index-0Q56lC1x.js → index--a5myRaH.js} +1 -1
- package/dist/cjs/{index-C0Kew27I.js → index-Oy30xVAt.js} +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-accordion-body_3.cjs.entry.js +1 -1
- package/dist/cjs/salla-accordion_6.cjs.entry.js +1 -1
- package/dist/cjs/salla-add-product-button_4.cjs.entry.js +1 -1
- package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
- package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
- package/dist/cjs/salla-booking-field_7.cjs.entry.js +10 -10
- package/dist/cjs/salla-bullet-delivery.cjs.entry.js +248 -188
- package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-comment-form_8.cjs.entry.js +1 -1
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
- package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
- package/dist/cjs/salla-count-down_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters.cjs.entry.js +1 -1
- package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
- package/dist/cjs/salla-hook.cjs.entry.js +1 -1
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
- package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-program.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
- package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-menu.cjs.entry.js +1 -1
- package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-orders.cjs.entry.js +1 -1
- package/dist/cjs/salla-payments.cjs.entry.js +1 -1
- package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
- package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
- package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
- package/dist/cjs/salla-products-slider.cjs.entry.js +1 -1
- package/dist/cjs/salla-progress-bar.cjs.entry.js +1 -1
- package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
- package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
- package/dist/cjs/salla-search.cjs.entry.js +1 -1
- package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
- package/dist/cjs/salla-slider.cjs.entry.js +1 -1
- package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
- package/dist/cjs/salla-social.cjs.entry.js +1 -1
- package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
- package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
- package/dist/cjs/salla-verify.cjs.entry.js +1 -1
- package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
- package/dist/cjs/twilight.cjs.js +1 -1
- package/dist/cjs/{vanilla-picker-D_FRjdtf.js → vanilla-picker-BjBHEsil.js} +1 -1
- package/dist/collection/components/salla-bullet-delivery/helpers.js +4 -20
- package/dist/collection/components/salla-bullet-delivery/salla-bullet-delivery.js +244 -168
- package/dist/components/index.js +2 -2
- package/dist/components/salla-bullet-delivery.js +247 -187
- package/dist/esm/{filepond-C6DmvP0k.js → filepond-BXxeKj-9.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-aflPfdvq.js → filepond-plugin-file-poster-B5BTs5Ly.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-2ysTkym4.js → filepond-plugin-file-validate-size-_PyCg3tk.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-CvlSQE9k.js → filepond-plugin-file-validate-type-uSrSfAxF.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-CPNOb0bn.js → filepond-plugin-image-edit-Cke6iTN3.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-DSOEX9W9.js → filepond-plugin-image-exif-orientation-DKLDaeeL.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-ZVPoyaGu.js → filepond-plugin-image-preview-KfxXXS81.js} +1 -1
- package/dist/esm/{index-Dt1F_uJO.js → index-B2mHcqWp.js} +1 -1
- package/dist/esm/{index-DygKr0gG.js → index-D4I5TLtE.js} +2 -2
- package/dist/esm/loader.js +2 -2
- package/dist/esm/salla-accordion-body_3.entry.js +1 -1
- package/dist/esm/salla-accordion_6.entry.js +1 -1
- package/dist/esm/salla-add-product-button_4.entry.js +1 -1
- package/dist/esm/salla-advertisement.entry.js +1 -1
- package/dist/esm/salla-alert_2.entry.js +1 -1
- package/dist/esm/salla-app-install-alert.entry.js +1 -1
- package/dist/esm/salla-apps-icons.entry.js +1 -1
- package/dist/esm/salla-booking-field_7.entry.js +10 -10
- package/dist/esm/salla-bullet-delivery.entry.js +248 -188
- package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
- package/dist/esm/salla-comment-form_8.entry.js +1 -1
- package/dist/esm/salla-conditional-offer.entry.js +1 -1
- package/dist/esm/salla-contacts.entry.js +1 -1
- package/dist/esm/salla-cookies-bar.entry.js +1 -1
- package/dist/esm/salla-count-down_2.entry.js +1 -1
- package/dist/esm/salla-custom-fields.entry.js +1 -1
- package/dist/esm/salla-filters-widget.entry.js +1 -1
- package/dist/esm/salla-filters.entry.js +1 -1
- package/dist/esm/salla-gifting.entry.js +1 -1
- package/dist/esm/salla-hook.entry.js +1 -1
- package/dist/esm/salla-infinite-scroll.entry.js +1 -1
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-list-tile.entry.js +1 -1
- package/dist/esm/salla-localization-modal.entry.js +1 -1
- package/dist/esm/salla-login-modal.entry.js +1 -1
- package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
- package/dist/esm/salla-loyalty-program.entry.js +1 -1
- package/dist/esm/salla-loyalty.entry.js +1 -1
- package/dist/esm/salla-maintenance-alert.entry.js +1 -1
- package/dist/esm/salla-menu.entry.js +1 -1
- package/dist/esm/salla-metadata.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-notification-item.entry.js +1 -1
- package/dist/esm/salla-notifications.entry.js +1 -1
- package/dist/esm/salla-offer-modal.entry.js +1 -1
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-order-details-options.entry.js +1 -1
- package/dist/esm/salla-order-details.entry.js +1 -1
- package/dist/esm/salla-order-summary.entry.js +1 -1
- package/dist/esm/salla-order-totals-card.entry.js +1 -1
- package/dist/esm/salla-orders.entry.js +1 -1
- package/dist/esm/salla-payments.entry.js +1 -1
- package/dist/esm/salla-placeholder.entry.js +1 -1
- package/dist/esm/salla-price-range.entry.js +1 -1
- package/dist/esm/salla-product-size-guide.entry.js +1 -1
- package/dist/esm/salla-products-list.entry.js +1 -1
- package/dist/esm/salla-products-slider.entry.js +1 -1
- package/dist/esm/salla-progress-bar.entry.js +1 -1
- package/dist/esm/salla-quick-order.entry.js +1 -1
- package/dist/esm/salla-rating-modal.entry.js +1 -1
- package/dist/esm/salla-scopes.entry.js +1 -1
- package/dist/esm/salla-search.entry.js +1 -1
- package/dist/esm/salla-skeleton.entry.js +1 -1
- package/dist/esm/salla-slider.entry.js +1 -1
- package/dist/esm/salla-social-share.entry.js +1 -1
- package/dist/esm/salla-social.entry.js +1 -1
- package/dist/esm/salla-tab-content_3.entry.js +1 -1
- package/dist/esm/salla-tiered-offer.entry.js +1 -1
- package/dist/esm/salla-tooltip.entry.js +1 -1
- package/dist/esm/salla-trust-badges.entry.js +1 -1
- package/dist/esm/salla-user-menu.entry.js +1 -1
- package/dist/esm/salla-user-profile.entry.js +1 -1
- package/dist/esm/salla-user-settings.entry.js +1 -1
- package/dist/esm/salla-verify.entry.js +1 -1
- package/dist/esm/salla-wallet.entry.js +1 -1
- package/dist/esm/twilight.js +2 -2
- package/dist/esm/{vanilla-picker-vpLzwiOX.js → vanilla-picker-CM1O2U8w.js} +1 -1
- package/dist/twilight/{p-07aaf6fb.entry.js → p-0127cd6e.entry.js} +1 -1
- package/dist/twilight/{p-3306e240.entry.js → p-0476b736.entry.js} +1 -1
- package/dist/twilight/{p-c18afdd4.entry.js → p-0537ad3e.entry.js} +1 -1
- package/dist/twilight/{p-7ff1a66d.entry.js → p-06e10077.entry.js} +1 -1
- package/dist/twilight/{p-93fafdb9.entry.js → p-08c37adc.entry.js} +1 -1
- package/dist/twilight/{p-d46b9b12.entry.js → p-0e82b9cd.entry.js} +1 -1
- package/dist/twilight/{p-069a93a0.entry.js → p-12e9e619.entry.js} +1 -1
- package/dist/twilight/{p-ee30137a.entry.js → p-15732417.entry.js} +1 -1
- package/dist/twilight/{p-64aaf5d1.entry.js → p-15c7e73a.entry.js} +1 -1
- package/dist/twilight/{p-b900e4bf.entry.js → p-181da663.entry.js} +1 -1
- package/dist/twilight/{p-31feb28e.entry.js → p-283727c3.entry.js} +1 -1
- package/dist/twilight/{p-7725e637.entry.js → p-28665675.entry.js} +1 -1
- package/dist/twilight/{p-4f0da42e.entry.js → p-29da0820.entry.js} +1 -1
- package/dist/twilight/{p-f001a716.entry.js → p-2c5880fe.entry.js} +1 -1
- package/dist/twilight/{p-4329e96a.entry.js → p-30bdeebc.entry.js} +1 -1
- package/dist/twilight/{p-c1d5778e.entry.js → p-33727c81.entry.js} +1 -1
- package/dist/twilight/{p-8d40cb2a.entry.js → p-35bab511.entry.js} +1 -1
- package/dist/twilight/{p-64da3ca2.entry.js → p-37996e21.entry.js} +1 -1
- package/dist/twilight/{p-717f98a9.entry.js → p-3a67bf02.entry.js} +1 -1
- package/dist/twilight/{p-d7440521.entry.js → p-3cf6308d.entry.js} +1 -1
- package/dist/twilight/{p-e3725374.entry.js → p-408f439d.entry.js} +1 -1
- package/dist/twilight/{p-1570c69c.entry.js → p-48db8cc1.entry.js} +1 -1
- package/dist/twilight/{p-6a9c0acd.entry.js → p-4b34c403.entry.js} +1 -1
- package/dist/twilight/{p-bf5c3fb6.entry.js → p-4d80d014.entry.js} +1 -1
- package/dist/twilight/{p-d87a6578.entry.js → p-4ede0af7.entry.js} +1 -1
- package/dist/twilight/{p-a5a159b8.entry.js → p-4f5c85b6.entry.js} +1 -1
- package/dist/twilight/{p-d1c0eb72.entry.js → p-503a0362.entry.js} +1 -1
- package/dist/twilight/{p-e6909519.entry.js → p-5338f5de.entry.js} +1 -1
- package/dist/twilight/{p-97e204bf.entry.js → p-5bc80a29.entry.js} +1 -1
- package/dist/twilight/{p-0ac97966.entry.js → p-5bc914c3.entry.js} +1 -1
- package/dist/twilight/{p-7f5da469.entry.js → p-653b2dac.entry.js} +1 -1
- package/dist/twilight/{p-ba2754b0.entry.js → p-6a8ae21b.entry.js} +1 -1
- package/dist/twilight/{p-abda287b.entry.js → p-6b66894c.entry.js} +1 -1
- package/dist/twilight/{p-15ad8b57.entry.js → p-6c1eb2aa.entry.js} +1 -1
- package/dist/twilight/{p-ba9ea832.entry.js → p-70799a42.entry.js} +1 -1
- package/dist/twilight/{p-1dac71bd.entry.js → p-72ebeb8b.entry.js} +1 -1
- package/dist/twilight/{p-5609c0a2.entry.js → p-7424ba6e.entry.js} +1 -1
- package/dist/twilight/{p-61891d9d.entry.js → p-7a874935.entry.js} +1 -1
- package/dist/twilight/{p-fdd668a8.entry.js → p-7ac9fe96.entry.js} +1 -1
- package/dist/twilight/{p-28c10ffc.entry.js → p-7b18c9e0.entry.js} +1 -1
- package/dist/twilight/{p-16956de8.entry.js → p-89635370.entry.js} +1 -1
- package/dist/twilight/{p-7e6ac5b6.entry.js → p-90dc7be8.entry.js} +1 -1
- package/dist/twilight/{p-26dbba19.entry.js → p-91f1e6df.entry.js} +1 -1
- package/dist/twilight/{p-a265395a.entry.js → p-95afe7b9.entry.js} +1 -1
- package/dist/twilight/{p-3174a7da.entry.js → p-9ac3d8e7.entry.js} +1 -1
- package/dist/twilight/{p-9f92c538.entry.js → p-9b68f4f7.entry.js} +1 -1
- package/dist/twilight/{p-db8f128a.entry.js → p-9cf8788e.entry.js} +1 -1
- package/dist/twilight/{p-BqgMCU7i.js → p-BbjmfFRJ.js} +1 -1
- package/dist/twilight/{p-BlNhJOfK.js → p-BjbWnZaV.js} +1 -1
- package/dist/twilight/{p-CckfqYjO.js → p-Bm_ows1a.js} +1 -1
- package/dist/twilight/{p-DxwvrO7V.js → p-D339DoJY.js} +2 -2
- package/dist/twilight/{p-DygKr0gG.js → p-D4I5TLtE.js} +1 -1
- package/dist/twilight/p-D_Ov4zes.js +9 -0
- package/dist/twilight/{p-CU9SaqqL.js → p-Dr8Bgm1u.js} +1 -1
- package/dist/twilight/{p-DBSxANjD.js → p-OQFknQfe.js} +1 -1
- package/dist/twilight/{p-kltSiNjL.js → p-Q1_LG8_l.js} +1 -1
- package/dist/twilight/{p-CiQozo5Q.js → p-Ym28Ytut.js} +1 -1
- package/dist/twilight/{p-42a88fbe.entry.js → p-a2b440ae.entry.js} +1 -1
- package/dist/twilight/{p-b8f61fb6.entry.js → p-a32e417b.entry.js} +1 -1
- package/dist/twilight/{p-e8562b9e.entry.js → p-a348dd40.entry.js} +1 -1
- package/dist/twilight/{p-0e06763b.entry.js → p-a56efe37.entry.js} +1 -1
- package/dist/twilight/{p-01cd6efd.entry.js → p-a751f592.entry.js} +1 -1
- package/dist/twilight/{p-11d1af5a.entry.js → p-ba723c9d.entry.js} +1 -1
- package/dist/twilight/{p-b64af3e6.entry.js → p-bd3ed9f5.entry.js} +1 -1
- package/dist/twilight/{p-7c05380e.entry.js → p-c3c51233.entry.js} +1 -1
- package/dist/twilight/{p-b503ed92.entry.js → p-c52ad0b1.entry.js} +1 -1
- package/dist/twilight/{p-04b0d99d.entry.js → p-cfa77298.entry.js} +1 -1
- package/dist/twilight/{p-313de30b.entry.js → p-d0e38089.entry.js} +1 -1
- package/dist/twilight/{p-b17de694.entry.js → p-d4035f22.entry.js} +1 -1
- package/dist/twilight/{p-fa071bdf.entry.js → p-d6dccd1f.entry.js} +1 -1
- package/dist/twilight/{p-2f1dc423.entry.js → p-d8510bea.entry.js} +1 -1
- package/dist/twilight/p-dbb2069c.entry.js +4 -0
- package/dist/twilight/{p-e294f075.entry.js → p-e8601f3e.entry.js} +1 -1
- package/dist/twilight/{p-72dfb078.entry.js → p-e8b67cc3.entry.js} +1 -1
- package/dist/twilight/{p-b667c2d4.entry.js → p-ebc8b253.entry.js} +1 -1
- package/dist/twilight/{p-91c7b197.entry.js → p-f5004752.entry.js} +1 -1
- package/dist/twilight/{p-590aa84f.entry.js → p-f8693f42.entry.js} +1 -1
- package/dist/twilight/{p-4c8d6286.entry.js → p-fe2adfd8.entry.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-bullet-delivery/helpers.d.ts +1 -3
- package/dist/types/components/salla-bullet-delivery/salla-bullet-delivery.d.ts +19 -16
- package/package.json +5 -5
- package/dist/twilight/p-7e6cc902.entry.js +0 -4
- package/dist/twilight/p-PRDr-VhL.js +0 -9
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import { r as registerInstance, c as createEvent, h, H as Host } from './index-
|
|
4
|
+
import { r as registerInstance, c as createEvent, h, H as Host } from './index-D4I5TLtE.js';
|
|
5
5
|
import { S as Search } from './search-BscTeWDc.js';
|
|
6
6
|
import { L as Location } from './location-BO5AoBAP.js';
|
|
7
7
|
import { a as ArrowRightIcon, A as ArrowLeftIcon } from './keyboard_arrow_right-Vqpj4CWE.js';
|
|
@@ -189,25 +189,6 @@ const filterBranches = (branches, searchQuery) => {
|
|
|
189
189
|
const q = searchQuery.toLowerCase();
|
|
190
190
|
return branches.filter((b) => b.name.toLowerCase().includes(q) || b.city?.name?.toLowerCase().includes(q));
|
|
191
191
|
};
|
|
192
|
-
/** Match saved address to guest intent by city/district (and optional street). */
|
|
193
|
-
function findMatchingAddress(guestIntent, userAddresses) {
|
|
194
|
-
const cityId = getIntentCityId(guestIntent);
|
|
195
|
-
const districtId = getIntentDistrictId(guestIntent);
|
|
196
|
-
return userAddresses.find((addr) => {
|
|
197
|
-
const addrCity = addr.city?.id ?? addr.city_id;
|
|
198
|
-
const addrDistrict = addr.district?.id ?? addr.district_id;
|
|
199
|
-
if (cityId == null || addrCity !== cityId)
|
|
200
|
-
return false;
|
|
201
|
-
if (districtId != null) {
|
|
202
|
-
if (addrDistrict !== districtId)
|
|
203
|
-
return false;
|
|
204
|
-
if (guestIntent.street && addr.street)
|
|
205
|
-
return guestIntent.street.toLowerCase() === addr.street.toLowerCase();
|
|
206
|
-
return true;
|
|
207
|
-
}
|
|
208
|
-
return true;
|
|
209
|
-
}) ?? null;
|
|
210
|
-
}
|
|
211
192
|
const getIntentSubtitle = (intent, toAddress, fromBranch) => {
|
|
212
193
|
if (intent.type === 'branch') {
|
|
213
194
|
const loc = intent.branch_details?.city ?? intent.branch_details?.name;
|
|
@@ -236,7 +217,10 @@ const hasSessionAddressIntent = (intent) => {
|
|
|
236
217
|
const city = getIntentCityId(intent);
|
|
237
218
|
const d = getIntentDistrictId(intent);
|
|
238
219
|
const code = getIntentCountryCode(intent);
|
|
239
|
-
|
|
220
|
+
const hasDistrictId = d != null && Number(d) !== 0;
|
|
221
|
+
const hasDistrictName = Boolean(intent.address_details?.district?.name?.trim());
|
|
222
|
+
const districtOk = !isSaudiArabia(code) || hasDistrictId || hasDistrictName;
|
|
223
|
+
return !!(c && city && districtOk);
|
|
240
224
|
};
|
|
241
225
|
const requireRegionAndDistrictForSA = (countryCode, regionId, districtIdOrName) => !countryCode || !isSaudiArabia(countryCode)
|
|
242
226
|
? true
|
|
@@ -342,22 +326,33 @@ const SallaBulletDelivery = class {
|
|
|
342
326
|
this.addressCreated = createEvent(this, "addressCreated");
|
|
343
327
|
this.headerContextUpdate = createEvent(this, "headerContextUpdate");
|
|
344
328
|
this.confirming = false;
|
|
329
|
+
this.pendingCartSubmitResolver = null;
|
|
330
|
+
this.pendingCartSubmitPromise = null;
|
|
331
|
+
this.cartSubmitConfirmationPending = false;
|
|
345
332
|
this.branchSearchDebounceTimer = null;
|
|
346
333
|
this.componentReady = false;
|
|
347
334
|
this.pendingOpen = false;
|
|
348
335
|
this.tabChanging = false;
|
|
349
336
|
this.intentStorageKey = "bullet_delivery_intent";
|
|
350
|
-
this.sessionShownKey = "
|
|
337
|
+
this.sessionShownKey = "bullet_delivery_shown";
|
|
338
|
+
this.incompleteIntentPromptKey = "bullet_delivery_incomplete_intent_prompted";
|
|
351
339
|
this.cartItemAddedEvent = "cart::item.added";
|
|
352
340
|
this.cartItemAddedHandler = null;
|
|
341
|
+
this.cartSubmittingHandler = null;
|
|
353
342
|
this.useCartEventApi = false;
|
|
343
|
+
this.authLoggedInHandler = null;
|
|
344
|
+
this.authLoggedOutHandler = null;
|
|
345
|
+
this.loginClosedHandler = null;
|
|
346
|
+
this.hasExplicitPreselectedIdsForOpen = false;
|
|
354
347
|
this.bulletDeliveryOpenHandler = (eventData) => {
|
|
355
348
|
this.preselectedAddressId = eventData?.preselected_address_id;
|
|
356
349
|
this.preselectedBranchId = eventData?.preselected_branch_id;
|
|
350
|
+
this.hasExplicitPreselectedIdsForOpen =
|
|
351
|
+
eventData?.preselected_address_id != null ||
|
|
352
|
+
eventData?.preselected_branch_id != null;
|
|
357
353
|
this.open();
|
|
358
354
|
};
|
|
359
355
|
this.closeHandler = null;
|
|
360
|
-
this.guestLoginSyncHandler = null;
|
|
361
356
|
/** True after saved addresses have been loaded (lazy: only when address tab is shown). */
|
|
362
357
|
this.savedAddressesLoaded = false;
|
|
363
358
|
// Core state
|
|
@@ -466,17 +461,9 @@ const SallaBulletDelivery = class {
|
|
|
466
461
|
// Open modal immediately to show skeleton/loading state
|
|
467
462
|
this.modal.open();
|
|
468
463
|
try {
|
|
469
|
-
|
|
470
|
-
const
|
|
471
|
-
this.
|
|
472
|
-
const savedIntent = this.getStoredIntent();
|
|
473
|
-
// When opening from a stored intent, treat its IDs as preselected targets
|
|
474
|
-
if (savedIntent?.type === "address" && savedIntent.address_id) {
|
|
475
|
-
this.preselectedAddressId = savedIntent.address_id;
|
|
476
|
-
}
|
|
477
|
-
if (savedIntent?.type === "branch" && savedIntent.branch_id) {
|
|
478
|
-
this.preselectedBranchId = savedIntent.branch_id;
|
|
479
|
-
}
|
|
464
|
+
this.isLoggedIn = !this.isGuestUser();
|
|
465
|
+
const savedIntent = this.cleanStaleGuestAddressIdIfNeeded(this.getStoredIntent());
|
|
466
|
+
this.applyPreselectedIdsFromIntent(savedIntent);
|
|
480
467
|
const hasStoredAddressIds = !this.isLoggedIn &&
|
|
481
468
|
savedIntent?.type === "address" &&
|
|
482
469
|
getIntentCountryId(savedIntent) != null &&
|
|
@@ -536,12 +523,17 @@ const SallaBulletDelivery = class {
|
|
|
536
523
|
// Only hide loading after all data is loaded and UI is ready
|
|
537
524
|
this.loading = false;
|
|
538
525
|
this.modal?.stopLoading();
|
|
526
|
+
this.overrideScopeSwitchUI();
|
|
539
527
|
}
|
|
540
528
|
}
|
|
541
529
|
/**
|
|
542
530
|
* Closes the bullet delivery modal
|
|
543
531
|
*/
|
|
544
532
|
async close() {
|
|
533
|
+
// If submit flow is waiting and user dismissed the modal, release the pending gate.
|
|
534
|
+
if (this.cartSubmitConfirmationPending && !this.confirming) {
|
|
535
|
+
this.resolvePendingCartSubmit();
|
|
536
|
+
}
|
|
545
537
|
this.bulletDeliveryClosed.emit();
|
|
546
538
|
return this.modal?.close();
|
|
547
539
|
}
|
|
@@ -573,14 +565,87 @@ const SallaBulletDelivery = class {
|
|
|
573
565
|
const rememberLastSession = Boolean(Salla.config.get("store.settings.bullet_delivery.settings.remember_last_session"));
|
|
574
566
|
return Salla.storage[rememberLastSession ? "store" : "session"];
|
|
575
567
|
}
|
|
568
|
+
getShownStorage() {
|
|
569
|
+
// Always session-scoped. `remember_last_session` applies to intent persistence only.
|
|
570
|
+
return Salla.storage.session;
|
|
571
|
+
}
|
|
576
572
|
getStoredIntent() {
|
|
577
573
|
return this.getIntentStorage().get(this.intentStorageKey);
|
|
578
574
|
}
|
|
575
|
+
isGuestUser() {
|
|
576
|
+
return String(Salla.config.get("user.type") ?? "guest") === "guest";
|
|
577
|
+
}
|
|
578
|
+
cleanStaleGuestAddressIdIfNeeded(intent) {
|
|
579
|
+
if (!this.isGuestUser() || intent?.type !== "address" || !intent.address_id)
|
|
580
|
+
return intent;
|
|
581
|
+
const cleaned = {
|
|
582
|
+
...intent,
|
|
583
|
+
address_id: undefined,
|
|
584
|
+
};
|
|
585
|
+
this.setStoredIntent(cleaned);
|
|
586
|
+
return cleaned;
|
|
587
|
+
}
|
|
588
|
+
applyPreselectedIdsFromIntent(intent) {
|
|
589
|
+
if (this.hasExplicitPreselectedIdsForOpen) {
|
|
590
|
+
this.hasExplicitPreselectedIdsForOpen = false;
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
this.preselectedAddressId = undefined;
|
|
594
|
+
this.preselectedBranchId = undefined;
|
|
595
|
+
if (this.isGuestUser()) {
|
|
596
|
+
if (intent?.type === "branch" && intent.branch_id) {
|
|
597
|
+
this.preselectedBranchId = intent.branch_id;
|
|
598
|
+
}
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
if (intent?.type === "address" && intent.address_id) {
|
|
602
|
+
this.preselectedAddressId = intent.address_id;
|
|
603
|
+
}
|
|
604
|
+
else if (intent?.type === "branch" && intent.branch_id) {
|
|
605
|
+
this.preselectedBranchId = intent.branch_id;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
hasIncompleteUserAddressIntent() {
|
|
609
|
+
if (this.isGuestUser())
|
|
610
|
+
return false;
|
|
611
|
+
const intent = this.getStoredIntent();
|
|
612
|
+
if (!intent || intent.type !== "address" || intent.address_id || !intent.address_details)
|
|
613
|
+
return false;
|
|
614
|
+
// Intent is an address without address_id; consider it "incomplete"
|
|
615
|
+
// only when it represents a valid session-style address.
|
|
616
|
+
return hasSessionAddressIntent(intent);
|
|
617
|
+
}
|
|
618
|
+
hasCompleteIntentForLoggedInUser() {
|
|
619
|
+
if (this.isGuestUser())
|
|
620
|
+
return false;
|
|
621
|
+
const intent = this.getStoredIntent();
|
|
622
|
+
if (!intent)
|
|
623
|
+
return false;
|
|
624
|
+
if (intent.type === "address")
|
|
625
|
+
return !!intent.address_id;
|
|
626
|
+
if (intent.type === "branch")
|
|
627
|
+
return !!intent.branch_id;
|
|
628
|
+
return false;
|
|
629
|
+
}
|
|
630
|
+
shouldPromptIncompleteIntentThisSession() {
|
|
631
|
+
const storage = this.getShownStorage();
|
|
632
|
+
return (this.hasIncompleteUserAddressIntent() &&
|
|
633
|
+
storage.get(this.incompleteIntentPromptKey) !== true);
|
|
634
|
+
}
|
|
635
|
+
markIncompleteIntentPrompted() {
|
|
636
|
+
this.getShownStorage().set(this.incompleteIntentPromptKey, true);
|
|
637
|
+
}
|
|
579
638
|
setStoredIntent(intent) {
|
|
580
639
|
this.getIntentStorage().set(this.intentStorageKey, intent);
|
|
640
|
+
this.overrideScopeSwitchUI();
|
|
581
641
|
}
|
|
582
|
-
|
|
583
|
-
|
|
642
|
+
clearBulletDeliveryStoredData() {
|
|
643
|
+
// Clear all bullet-delivery keys from both scopes to avoid stale state across auth transitions.
|
|
644
|
+
Salla.storage.session.remove(this.intentStorageKey);
|
|
645
|
+
Salla.storage.store.remove(this.intentStorageKey);
|
|
646
|
+
Salla.storage.session.remove(this.sessionShownKey);
|
|
647
|
+
Salla.storage.session.remove(this.incompleteIntentPromptKey);
|
|
648
|
+
this.overrideScopeSwitchUI();
|
|
584
649
|
}
|
|
585
650
|
/**
|
|
586
651
|
* Single prefill flow: load geography from stored intent and set selected location + form.
|
|
@@ -638,17 +703,23 @@ const SallaBulletDelivery = class {
|
|
|
638
703
|
this.selectedDistrict = district;
|
|
639
704
|
}
|
|
640
705
|
}
|
|
706
|
+
// When district is captured as free text (or couldn't be matched), keep it in the text input state.
|
|
707
|
+
if (!this.selectedDistrict && districtName) {
|
|
708
|
+
this.districtName = districtName;
|
|
709
|
+
}
|
|
641
710
|
}
|
|
642
711
|
updateNewAddressForm(partial) {
|
|
643
712
|
this.newAddressForm = { ...this.newAddressForm, ...partial };
|
|
644
713
|
}
|
|
645
714
|
/** Whether allocation completed successfully this session (modal won't auto-open again). */
|
|
646
715
|
hasBeenShownThisSession() {
|
|
647
|
-
|
|
716
|
+
const storage = this.getShownStorage();
|
|
717
|
+
return storage.get(this.sessionShownKey) === true;
|
|
648
718
|
}
|
|
649
719
|
/** Mark allocation as completed this session (called only after allocateScope succeeds). */
|
|
650
720
|
markShownThisSession() {
|
|
651
|
-
|
|
721
|
+
const storage = this.getShownStorage();
|
|
722
|
+
storage.set(this.sessionShownKey, true);
|
|
652
723
|
}
|
|
653
724
|
async loadCountries(skipEagerSubFetch = false) {
|
|
654
725
|
const forBranch = this.activeTab === "branch";
|
|
@@ -845,110 +916,6 @@ const SallaBulletDelivery = class {
|
|
|
845
916
|
this.loadingRegions = false;
|
|
846
917
|
}
|
|
847
918
|
}
|
|
848
|
-
/**
|
|
849
|
-
* AC7: Guest-to-Registered Sync
|
|
850
|
-
* Syncs guest session location to user profile on login
|
|
851
|
-
*/
|
|
852
|
-
async handleGuestToRegisteredSync() {
|
|
853
|
-
try {
|
|
854
|
-
// Check if user is now logged in
|
|
855
|
-
const userId = Salla.config.get("user.id");
|
|
856
|
-
if (!userId)
|
|
857
|
-
return;
|
|
858
|
-
// Get the guest session location from session storage
|
|
859
|
-
const guestIntent = this.getStoredIntent();
|
|
860
|
-
if (!guestIntent || guestIntent.type !== "address") {
|
|
861
|
-
// No guest address intent to sync, or it's a branch intent
|
|
862
|
-
return;
|
|
863
|
-
}
|
|
864
|
-
// Get user's saved addresses
|
|
865
|
-
const userAddresses = await bulletDeliveryAPI.getSavedAddresses();
|
|
866
|
-
const matchingAddress = findMatchingAddress(guestIntent, userAddresses);
|
|
867
|
-
if (matchingAddress) {
|
|
868
|
-
await this.setAddressAsActive(matchingAddress.id);
|
|
869
|
-
const updatedIntent = {
|
|
870
|
-
...guestIntent,
|
|
871
|
-
address_id: matchingAddress.id,
|
|
872
|
-
address_details: this.buildIntentAddressFromSaved(matchingAddress),
|
|
873
|
-
};
|
|
874
|
-
this.setStoredIntent(updatedIntent);
|
|
875
|
-
}
|
|
876
|
-
else if (getIntentCityId(guestIntent)) {
|
|
877
|
-
// No match - create new address from guest session data
|
|
878
|
-
const newAddress = await this.createAddressFromGuestSession(guestIntent);
|
|
879
|
-
if (newAddress) {
|
|
880
|
-
const updatedIntent = {
|
|
881
|
-
...guestIntent,
|
|
882
|
-
address_id: newAddress.id,
|
|
883
|
-
address_details: this.buildIntentAddressFromSaved(newAddress),
|
|
884
|
-
};
|
|
885
|
-
this.setStoredIntent(updatedIntent);
|
|
886
|
-
this.addressCreated.emit({ address: newAddress });
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
// Emit event to notify that sync is complete
|
|
890
|
-
Salla.event.emit("bullet-delivery::guest-synced", {
|
|
891
|
-
guest_intent: guestIntent,
|
|
892
|
-
matched_address_id: matchingAddress?.id,
|
|
893
|
-
});
|
|
894
|
-
}
|
|
895
|
-
catch (error) {
|
|
896
|
-
console.error("SallaBulletDelivery: Error syncing guest session to user profile", error);
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
/**
|
|
900
|
-
* Set an address as active/last used
|
|
901
|
-
*/
|
|
902
|
-
async setAddressAsActive(addressId) {
|
|
903
|
-
try {
|
|
904
|
-
// Call API to mark address as default/active
|
|
905
|
-
await Salla.address?.api?.setDefault?.(addressId);
|
|
906
|
-
}
|
|
907
|
-
catch (error) {
|
|
908
|
-
// If setDefault API doesn't exist, just update local state
|
|
909
|
-
console.warn("SallaBulletDelivery: Could not set address as default", error);
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
/**
|
|
913
|
-
* Create a new address from guest session: only country, city and district IDs (no street, etc.).
|
|
914
|
-
* Uses address/location API; after fetch we return the newly created address from the list.
|
|
915
|
-
*/
|
|
916
|
-
async createAddressFromGuestSession(guestIntent) {
|
|
917
|
-
const countryId = getIntentCountryId(guestIntent);
|
|
918
|
-
const cityId = getIntentCityId(guestIntent);
|
|
919
|
-
if (!countryId || !cityId)
|
|
920
|
-
return null;
|
|
921
|
-
const isSA = isSaudiArabia(getIntentCountryCode(guestIntent));
|
|
922
|
-
const districtName = guestIntent.address_details?.district?.name ?? "";
|
|
923
|
-
const payload = {
|
|
924
|
-
country_id: countryId,
|
|
925
|
-
region_id: getIntentRegionId(guestIntent),
|
|
926
|
-
city_id: cityId,
|
|
927
|
-
district_id: getIntentDistrictId(guestIntent),
|
|
928
|
-
description: districtName,
|
|
929
|
-
};
|
|
930
|
-
if (isSA) {
|
|
931
|
-
payload.local = districtName;
|
|
932
|
-
}
|
|
933
|
-
try {
|
|
934
|
-
const { success, address } = await bulletDeliveryAPI.saveAddressLocation(payload);
|
|
935
|
-
if (!success)
|
|
936
|
-
return null;
|
|
937
|
-
if (address)
|
|
938
|
-
return address;
|
|
939
|
-
const addresses = await bulletDeliveryAPI.getSavedAddresses();
|
|
940
|
-
const districtId = getIntentDistrictId(guestIntent);
|
|
941
|
-
const newAddress = addresses.find((a) => (a.city_id ?? a.city?.id) === cityId &&
|
|
942
|
-
(a.district_id ?? a.district?.id) === districtId) ??
|
|
943
|
-
addresses[0] ??
|
|
944
|
-
null;
|
|
945
|
-
return newAddress;
|
|
946
|
-
}
|
|
947
|
-
catch (error) {
|
|
948
|
-
console.error("SallaBulletDelivery: Could not create address from guest session", error);
|
|
949
|
-
return null;
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
919
|
emitHeaderContextUpdate(result, address, branch) {
|
|
953
920
|
let locationText = "";
|
|
954
921
|
if (result.type === "address") {
|
|
@@ -1219,8 +1186,21 @@ const SallaBulletDelivery = class {
|
|
|
1219
1186
|
return false;
|
|
1220
1187
|
}
|
|
1221
1188
|
handleLogin() {
|
|
1189
|
+
// Keep bullet-delivery flow in-place and avoid full page reload after login.
|
|
1190
|
+
Salla.auth.setCanRedirect(false);
|
|
1222
1191
|
Salla.event.dispatch("bullet-delivery::close");
|
|
1223
|
-
Salla.event.dispatch("login::open")
|
|
1192
|
+
Salla.event.dispatch("login::open", Salla.url.is_page("cart")
|
|
1193
|
+
? { withoutReload: true, source: "cart-submit" }
|
|
1194
|
+
: { withoutReload: true, source: "bullet-delivery" });
|
|
1195
|
+
}
|
|
1196
|
+
resolvePendingCartSubmit() {
|
|
1197
|
+
if (!this.pendingCartSubmitResolver)
|
|
1198
|
+
return;
|
|
1199
|
+
const resolve = this.pendingCartSubmitResolver;
|
|
1200
|
+
this.pendingCartSubmitResolver = null;
|
|
1201
|
+
this.pendingCartSubmitPromise = null;
|
|
1202
|
+
this.cartSubmitConfirmationPending = false;
|
|
1203
|
+
resolve();
|
|
1224
1204
|
}
|
|
1225
1205
|
buildIntentAddress() {
|
|
1226
1206
|
if (this.activeTab !== "address" ||
|
|
@@ -1306,10 +1286,8 @@ const SallaBulletDelivery = class {
|
|
|
1306
1286
|
};
|
|
1307
1287
|
let selectedAddress;
|
|
1308
1288
|
let selectedBranchData;
|
|
1309
|
-
let usedSessionAddress = false;
|
|
1310
1289
|
if (this.activeTab === "address") {
|
|
1311
1290
|
if (this.isLoggedIn && this.selectedSessionAddress) {
|
|
1312
|
-
usedSessionAddress = true;
|
|
1313
1291
|
const savedAddress = await this.saveSessionAddressToProfile();
|
|
1314
1292
|
if (!savedAddress) {
|
|
1315
1293
|
Salla.notify?.error(Salla.lang.get("common.errors.error_occurred"));
|
|
@@ -1416,14 +1394,9 @@ const SallaBulletDelivery = class {
|
|
|
1416
1394
|
}
|
|
1417
1395
|
// After allocation success: mark session so we don't show modal again this session
|
|
1418
1396
|
this.markShownThisSession();
|
|
1419
|
-
// After allocation success:
|
|
1420
|
-
//
|
|
1421
|
-
|
|
1422
|
-
this.removeStoredIntent();
|
|
1423
|
-
}
|
|
1424
|
-
else {
|
|
1425
|
-
this.setStoredIntent(result);
|
|
1426
|
-
}
|
|
1397
|
+
// After allocation success: persist latest intent so switch UI can always reflect
|
|
1398
|
+
// the selected address/branch once confirmed.
|
|
1399
|
+
this.setStoredIntent(result);
|
|
1427
1400
|
if (allocatedScopeId) {
|
|
1428
1401
|
await bulletDeliveryAPI.setDeliveryScope(allocatedScopeId);
|
|
1429
1402
|
}
|
|
@@ -1439,6 +1412,10 @@ const SallaBulletDelivery = class {
|
|
|
1439
1412
|
this.confirmBtn?.stop();
|
|
1440
1413
|
this.close();
|
|
1441
1414
|
this.confirming = false;
|
|
1415
|
+
if (this.cartSubmitConfirmationPending) {
|
|
1416
|
+
this.resolvePendingCartSubmit();
|
|
1417
|
+
return;
|
|
1418
|
+
}
|
|
1442
1419
|
if (allocatedScopeId) {
|
|
1443
1420
|
const scope = Salla.storage.get("scope") || {};
|
|
1444
1421
|
let url = Salla.helpers.addParamToUrl("scope", allocatedScopeId);
|
|
@@ -1557,7 +1534,7 @@ const SallaBulletDelivery = class {
|
|
|
1557
1534
|
} }, h("option", { value: "", disabled: true, selected: !this.selectedCountry }, Salla.lang.get("pages.checkout.select_country")), this.countries.map((country) => (h("option", { key: country.id, value: country.id, selected: this.selectedCountry?.id === country.id }, country.name))))));
|
|
1558
1535
|
}
|
|
1559
1536
|
renderSelectLoader() {
|
|
1560
|
-
return (h("span", { class: "s-bullet-delivery-select-loader", "aria-hidden": "true" }, h("salla-
|
|
1537
|
+
return (h("span", { class: "s-bullet-delivery-select-loader", "aria-hidden": "true" }, h("salla-skeleton", { height: "16px", width: "16px" })));
|
|
1561
1538
|
}
|
|
1562
1539
|
renderLoadingLabel(label, htmlFor, isLoading = false, isRequired = true) {
|
|
1563
1540
|
return (h("label", { class: "s-bullet-delivery-label", htmlFor: htmlFor }, h("span", { class: "s-bullet-delivery-label-content" }, h("span", null, label, isRequired && h("span", { class: "text-red-500" }, " *")), isLoading && this.renderSelectLoader())));
|
|
@@ -1682,22 +1659,17 @@ const SallaBulletDelivery = class {
|
|
|
1682
1659
|
if (!this.isLoggedIn)
|
|
1683
1660
|
return null;
|
|
1684
1661
|
if (this.loadingSavedAddresses) {
|
|
1685
|
-
return (h("div",
|
|
1662
|
+
return (h("div", { class: "s-bullet-delivery-addresses-list s-scrollbar" }, [1, 2, 3].map((v) => (h("div", { key: v, class: "s-bullet-delivery-address-item s-bullet-delivery-address-item--skeleton" }, h("salla-skeleton", { class: "s-bullet-delivery-skel-radio", height: "18px", width: "18px" }), h("salla-skeleton", { class: "s-bullet-delivery-skel-map", height: "36px", width: "36px" }), h("div", { class: "s-bullet-delivery-address-content" }, h("div", { class: "s-bullet-delivery-address-lines" }, h("salla-skeleton", { height: "18px", width: "72%" }), h("salla-skeleton", { height: "16px", width: "56%" }))))))));
|
|
1686
1663
|
}
|
|
1687
1664
|
const intent = this.getStoredIntent();
|
|
1688
1665
|
const hasSessionAddress = hasSessionAddressIntent(intent);
|
|
1689
|
-
const
|
|
1690
|
-
? [
|
|
1691
|
-
intent.address_details.district?.name,
|
|
1692
|
-
intent.address_details.city.name,
|
|
1693
|
-
intent.address_details.country.name,
|
|
1694
|
-
]
|
|
1666
|
+
const sessionLine1 = hasSessionAddress && intent?.address_details
|
|
1667
|
+
? [intent.address_details.city?.name, intent.address_details.country?.name]
|
|
1695
1668
|
.filter(Boolean)
|
|
1696
|
-
.join("، ") ||
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
].join(", ")
|
|
1669
|
+
.join("، ") || ""
|
|
1670
|
+
: "";
|
|
1671
|
+
const sessionLine2 = hasSessionAddress && intent?.address_details
|
|
1672
|
+
? (intent.address_details.district?.name ?? "").trim()
|
|
1701
1673
|
: "";
|
|
1702
1674
|
if (this.savedAddresses.length === 0 && !hasSessionAddress) {
|
|
1703
1675
|
return this.renderSavedAddressesEmptyState();
|
|
@@ -1705,8 +1677,8 @@ const SallaBulletDelivery = class {
|
|
|
1705
1677
|
return (h("div", { class: "s-bullet-delivery-addresses-list s-scrollbar" }, hasSessionAddress &&
|
|
1706
1678
|
this.renderAddressRow({
|
|
1707
1679
|
key: "session-address",
|
|
1708
|
-
line1:
|
|
1709
|
-
line2:
|
|
1680
|
+
line1: sessionLine1,
|
|
1681
|
+
line2: sessionLine2,
|
|
1710
1682
|
selected: this.selectedSessionAddress,
|
|
1711
1683
|
onClick: () => this.handleSessionAddressSelect(),
|
|
1712
1684
|
}), this.savedAddresses.map((address) => {
|
|
@@ -1721,7 +1693,7 @@ const SallaBulletDelivery = class {
|
|
|
1721
1693
|
]
|
|
1722
1694
|
.filter(Boolean)
|
|
1723
1695
|
.join("، ");
|
|
1724
|
-
const line2 = (
|
|
1696
|
+
const line2 = (address.formatted?.address_two || builtLine2) ?? "";
|
|
1725
1697
|
const inCoverage = address.is_in_coverage !== false;
|
|
1726
1698
|
return this.renderAddressRow({
|
|
1727
1699
|
key: String(address.id),
|
|
@@ -1769,7 +1741,7 @@ const SallaBulletDelivery = class {
|
|
|
1769
1741
|
"s-bullet-delivery-location-btn": true,
|
|
1770
1742
|
"s-bullet-delivery-location-btn--full": true,
|
|
1771
1743
|
"s-bullet-delivery-location-btn--loading": this.loadingNearestBranch,
|
|
1772
|
-
}, onClick: () => this.handleFindNearestBranch(), disabled: this.loadingNearestBranch }, this.loadingNearestBranch ? (h("salla-
|
|
1744
|
+
}, onClick: () => this.handleFindNearestBranch(), disabled: this.loadingNearestBranch }, this.loadingNearestBranch ? (h("span", { class: "s-bullet-delivery-location-icon", "aria-hidden": "true" }, h("salla-skeleton", { height: "18px", width: "18px" }))) : (h("span", { class: "s-bullet-delivery-location-icon", innerHTML: GPS, "aria-hidden": "true" })), h("span", null, Salla.lang.get("pages.checkout.nearest_to_my_location")))), this.locationError && this.activeTab === "branch" && (h("span", { class: "s-bullet-delivery-error" }, this.locationError))));
|
|
1773
1745
|
}
|
|
1774
1746
|
renderBranchList() {
|
|
1775
1747
|
if (this.loadingBranches) {
|
|
@@ -1839,10 +1811,14 @@ const SallaBulletDelivery = class {
|
|
|
1839
1811
|
handleAfterAddToCart() {
|
|
1840
1812
|
if (this.openingType !== "after_add_to_cart")
|
|
1841
1813
|
return;
|
|
1842
|
-
|
|
1814
|
+
const canOpenForIncompleteIntent = this.shouldPromptIncompleteIntentThisSession();
|
|
1815
|
+
if (this.hasBeenShownThisSession() && !canOpenForIncompleteIntent)
|
|
1843
1816
|
return;
|
|
1844
1817
|
if (this.modal?.hasAttribute?.("visible"))
|
|
1845
1818
|
return;
|
|
1819
|
+
if (canOpenForIncompleteIntent) {
|
|
1820
|
+
this.markIncompleteIntentPrompted();
|
|
1821
|
+
}
|
|
1846
1822
|
this.open();
|
|
1847
1823
|
}
|
|
1848
1824
|
overrideScopeSwitchUI() {
|
|
@@ -1850,13 +1826,17 @@ const SallaBulletDelivery = class {
|
|
|
1850
1826
|
const btn = document.querySelector('[onclick*="scopes"]');
|
|
1851
1827
|
if (!btn)
|
|
1852
1828
|
return;
|
|
1829
|
+
const hasIntentWithType = !!intent && (intent.type === "address" || intent.type === "branch");
|
|
1830
|
+
if (!hasIntentWithType) {
|
|
1831
|
+
btn.style.display = "none";
|
|
1832
|
+
btn.onclick = () => this.open();
|
|
1833
|
+
return;
|
|
1834
|
+
}
|
|
1853
1835
|
const trunc = (s, max) => s && s.length > max ? `${s.slice(0, max)}...` : (s ?? "");
|
|
1854
|
-
const label =
|
|
1855
|
-
? Salla.lang.get("common.
|
|
1856
|
-
:
|
|
1857
|
-
|
|
1858
|
-
: `${Salla.lang.get("mobile_app.strings.delivery")} ${Salla.lang.get("common.elements.to")} ${trunc(intent.address_details?.city?.name, 10)}`;
|
|
1859
|
-
btn.style.display = intent ? "" : "none";
|
|
1836
|
+
const label = intent.type === "branch"
|
|
1837
|
+
? `${Salla.lang.get("mobile_app.strings.pickup")} ${Salla.lang.get("common.elements.from")} ${trunc(intent.branch_details?.name, 20)}`
|
|
1838
|
+
: `${Salla.lang.get("mobile_app.strings.delivery")} ${Salla.lang.get("common.elements.to")} ${trunc(intent.address_details?.city?.name, 10)}`;
|
|
1839
|
+
btn.style.display = "inline-flex";
|
|
1860
1840
|
btn.onclick = () => this.open();
|
|
1861
1841
|
const span = btn.querySelector('span:not([class*="sicon"]):not([class*="icon"])');
|
|
1862
1842
|
if (span) {
|
|
@@ -1872,6 +1852,31 @@ const SallaBulletDelivery = class {
|
|
|
1872
1852
|
await Salla.onReady();
|
|
1873
1853
|
try {
|
|
1874
1854
|
this.overrideScopeSwitchUI();
|
|
1855
|
+
this.cartSubmittingHandler = async () => {
|
|
1856
|
+
if (this.pendingCartSubmitPromise) {
|
|
1857
|
+
await this.pendingCartSubmitPromise;
|
|
1858
|
+
return;
|
|
1859
|
+
}
|
|
1860
|
+
// Logged-in users with a complete intent can continue checkout without re-prompting.
|
|
1861
|
+
if (this.hasCompleteIntentForLoggedInUser()) {
|
|
1862
|
+
return;
|
|
1863
|
+
}
|
|
1864
|
+
this.cartSubmitConfirmationPending = true;
|
|
1865
|
+
this.pendingCartSubmitPromise = new Promise((resolve) => {
|
|
1866
|
+
this.pendingCartSubmitResolver = resolve;
|
|
1867
|
+
if (this.isGuestUser()) {
|
|
1868
|
+
Salla.auth.setCanRedirect(false);
|
|
1869
|
+
Salla.event.dispatch("login::open", {
|
|
1870
|
+
withoutReload: true,
|
|
1871
|
+
source: "cart-submit",
|
|
1872
|
+
});
|
|
1873
|
+
return;
|
|
1874
|
+
}
|
|
1875
|
+
this.open();
|
|
1876
|
+
});
|
|
1877
|
+
await this.pendingCartSubmitPromise;
|
|
1878
|
+
};
|
|
1879
|
+
Salla.cart.event.onSubmitting(this.cartSubmittingHandler);
|
|
1875
1880
|
}
|
|
1876
1881
|
catch (e) {
|
|
1877
1882
|
console.warn("SallaBulletDelivery: overrideScopeSwitchUI failed", e);
|
|
@@ -1879,11 +1884,40 @@ const SallaBulletDelivery = class {
|
|
|
1879
1884
|
Salla.event.on("bullet-delivery::open", this.bulletDeliveryOpenHandler);
|
|
1880
1885
|
this.closeHandler = this.close.bind(this);
|
|
1881
1886
|
Salla.event.on("bullet-delivery::close", this.closeHandler);
|
|
1882
|
-
// Listen for successful login to sync guest session to user profile (AC7)
|
|
1883
|
-
this.guestLoginSyncHandler = this.handleGuestToRegisteredSync.bind(this);
|
|
1884
|
-
Salla.event.on("login::success", this.guestLoginSyncHandler);
|
|
1885
|
-
Salla.event.on("auth::logged-in", this.guestLoginSyncHandler);
|
|
1886
1887
|
this.isRTL = Salla.config.get("theme.is_rtl");
|
|
1888
|
+
this.authLoggedInHandler = () => {
|
|
1889
|
+
if (this.cartSubmitConfirmationPending) {
|
|
1890
|
+
Salla.event.dispatch("login::close");
|
|
1891
|
+
if (this.hasCompleteIntentForLoggedInUser()) {
|
|
1892
|
+
this.resolvePendingCartSubmit();
|
|
1893
|
+
return;
|
|
1894
|
+
}
|
|
1895
|
+
if (!this.modal?.hasAttribute?.("visible")) {
|
|
1896
|
+
this.open();
|
|
1897
|
+
}
|
|
1898
|
+
return;
|
|
1899
|
+
}
|
|
1900
|
+
// Always prompt after login when intent is incomplete, regardless of prior prompted flags.
|
|
1901
|
+
if (!this.hasIncompleteUserAddressIntent())
|
|
1902
|
+
return;
|
|
1903
|
+
if (this.modal?.hasAttribute?.("visible"))
|
|
1904
|
+
return;
|
|
1905
|
+
this.open();
|
|
1906
|
+
};
|
|
1907
|
+
Salla.event.on("auth::logged.in", this.authLoggedInHandler);
|
|
1908
|
+
this.authLoggedOutHandler = () => {
|
|
1909
|
+
this.clearBulletDeliveryStoredData();
|
|
1910
|
+
};
|
|
1911
|
+
Salla.event.on("auth::logged.out", this.authLoggedOutHandler);
|
|
1912
|
+
this.loginClosedHandler = () => {
|
|
1913
|
+
// Guest cart-submit flow opens login first; if login is dismissed, unblock submit gate.
|
|
1914
|
+
if (!this.cartSubmitConfirmationPending || !this.isGuestUser())
|
|
1915
|
+
return;
|
|
1916
|
+
if (this.hasCompleteIntentForLoggedInUser())
|
|
1917
|
+
return;
|
|
1918
|
+
this.resolvePendingCartSubmit();
|
|
1919
|
+
};
|
|
1920
|
+
Salla.event.on("salla-login::closed", this.loginClosedHandler);
|
|
1887
1921
|
// Listen for add-to-cart events for 'after_add_to_cart' opening strategy (after salla is ready)
|
|
1888
1922
|
this.cartItemAddedHandler = () => this.handleAfterAddToCart();
|
|
1889
1923
|
if (typeof Salla.cart?.event?.onItemAdded === "function") {
|
|
@@ -1895,7 +1929,7 @@ const SallaBulletDelivery = class {
|
|
|
1895
1929
|
}
|
|
1896
1930
|
}
|
|
1897
1931
|
render() {
|
|
1898
|
-
return (h(Host, { key: '
|
|
1932
|
+
return (h(Host, { key: '751566707c28202b5ccf4ecde28bfb09550ae886', class: "s-bullet-delivery" }, h("salla-modal", { key: '25a18755aa4aa85b55f08bb73829e30833ca5328', ref: (modal) => {
|
|
1899
1933
|
this.modal = modal;
|
|
1900
1934
|
}, isClosable: !this.isRequired, class: "s-bullet-delivery-modal", isLoading: this.loading, width: "sm" }, this.loading ? (this.renderSkeleton()) : (h("div", { class: "s-bullet-delivery-inner" }, this.viewMode === "main" && this.renderMainView(), this.viewMode === "add-address" && this.renderAddAddressForm())))));
|
|
1901
1935
|
}
|
|
@@ -1915,12 +1949,22 @@ const SallaBulletDelivery = class {
|
|
|
1915
1949
|
if (!this.hasBeenShownThisSession()) {
|
|
1916
1950
|
this.open();
|
|
1917
1951
|
}
|
|
1952
|
+
else if (this.shouldPromptIncompleteIntentThisSession()) {
|
|
1953
|
+
this.markIncompleteIntentPrompted();
|
|
1954
|
+
this.open();
|
|
1955
|
+
}
|
|
1918
1956
|
break;
|
|
1919
1957
|
case "on_cart_click":
|
|
1920
1958
|
// Open automatically when user is on the cart page
|
|
1921
1959
|
if (Salla.url.is_page("cart")) {
|
|
1922
|
-
|
|
1960
|
+
const shown = this.getShownStorage().get(this.sessionShownKey) === true;
|
|
1961
|
+
if (!shown) {
|
|
1923
1962
|
this.open();
|
|
1963
|
+
}
|
|
1964
|
+
else if (this.shouldPromptIncompleteIntentThisSession()) {
|
|
1965
|
+
this.markIncompleteIntentPrompted();
|
|
1966
|
+
this.open();
|
|
1967
|
+
}
|
|
1924
1968
|
}
|
|
1925
1969
|
break;
|
|
1926
1970
|
}
|
|
@@ -1939,11 +1983,6 @@ const SallaBulletDelivery = class {
|
|
|
1939
1983
|
Salla.event.off("bullet-delivery::close", this.closeHandler);
|
|
1940
1984
|
this.closeHandler = null;
|
|
1941
1985
|
}
|
|
1942
|
-
if (this.guestLoginSyncHandler) {
|
|
1943
|
-
Salla.event.off("login::success", this.guestLoginSyncHandler);
|
|
1944
|
-
Salla.event.off("auth::logged-in", this.guestLoginSyncHandler);
|
|
1945
|
-
this.guestLoginSyncHandler = null;
|
|
1946
|
-
}
|
|
1947
1986
|
if (this.cartItemAddedHandler) {
|
|
1948
1987
|
if (this.useCartEventApi && typeof Salla.cart?.event?.offItemAdded === "function") {
|
|
1949
1988
|
Salla.cart.event.offItemAdded(this.cartItemAddedHandler);
|
|
@@ -1953,6 +1992,27 @@ const SallaBulletDelivery = class {
|
|
|
1953
1992
|
}
|
|
1954
1993
|
this.cartItemAddedHandler = null;
|
|
1955
1994
|
}
|
|
1995
|
+
if (this.cartSubmittingHandler) {
|
|
1996
|
+
if (typeof Salla.cart?.event?.offSubmitting === "function") {
|
|
1997
|
+
Salla.cart.event.offSubmitting(this.cartSubmittingHandler);
|
|
1998
|
+
}
|
|
1999
|
+
else {
|
|
2000
|
+
Salla.event.off("cart::submitting", this.cartSubmittingHandler);
|
|
2001
|
+
}
|
|
2002
|
+
this.cartSubmittingHandler = null;
|
|
2003
|
+
}
|
|
2004
|
+
if (this.authLoggedInHandler) {
|
|
2005
|
+
Salla.event.off("auth::logged.in", this.authLoggedInHandler);
|
|
2006
|
+
this.authLoggedInHandler = null;
|
|
2007
|
+
}
|
|
2008
|
+
if (this.authLoggedOutHandler) {
|
|
2009
|
+
Salla.event.off("auth::logged.out", this.authLoggedOutHandler);
|
|
2010
|
+
this.authLoggedOutHandler = null;
|
|
2011
|
+
}
|
|
2012
|
+
if (this.loginClosedHandler) {
|
|
2013
|
+
Salla.event.off("salla-login::closed", this.loginClosedHandler);
|
|
2014
|
+
this.loginClosedHandler = null;
|
|
2015
|
+
}
|
|
1956
2016
|
}
|
|
1957
2017
|
};
|
|
1958
2018
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import { r as registerInstance, h, H as Host, a as getElement } from './index-
|
|
4
|
+
import { r as registerInstance, h, H as Host, a as getElement } from './index-D4I5TLtE.js';
|
|
5
5
|
import { S as SpecialDiscountIcon } from './special-discount-Ctkfc4K-.js';
|
|
6
6
|
import { l as loyaltyProgramIcon } from './gift-BChI23pG.js';
|
|
7
7
|
import { A as ArrowDown } from './keyboard_arrow_down-DCZbpt2a.js';
|