@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
|
@@ -194,25 +194,6 @@ const filterBranches = (branches, searchQuery) => {
|
|
|
194
194
|
const q = searchQuery.toLowerCase();
|
|
195
195
|
return branches.filter((b) => b.name.toLowerCase().includes(q) || b.city?.name?.toLowerCase().includes(q));
|
|
196
196
|
};
|
|
197
|
-
/** Match saved address to guest intent by city/district (and optional street). */
|
|
198
|
-
function findMatchingAddress(guestIntent, userAddresses) {
|
|
199
|
-
const cityId = getIntentCityId(guestIntent);
|
|
200
|
-
const districtId = getIntentDistrictId(guestIntent);
|
|
201
|
-
return userAddresses.find((addr) => {
|
|
202
|
-
const addrCity = addr.city?.id ?? addr.city_id;
|
|
203
|
-
const addrDistrict = addr.district?.id ?? addr.district_id;
|
|
204
|
-
if (cityId == null || addrCity !== cityId)
|
|
205
|
-
return false;
|
|
206
|
-
if (districtId != null) {
|
|
207
|
-
if (addrDistrict !== districtId)
|
|
208
|
-
return false;
|
|
209
|
-
if (guestIntent.street && addr.street)
|
|
210
|
-
return guestIntent.street.toLowerCase() === addr.street.toLowerCase();
|
|
211
|
-
return true;
|
|
212
|
-
}
|
|
213
|
-
return true;
|
|
214
|
-
}) ?? null;
|
|
215
|
-
}
|
|
216
197
|
const getIntentSubtitle = (intent, toAddress, fromBranch) => {
|
|
217
198
|
if (intent.type === 'branch') {
|
|
218
199
|
const loc = intent.branch_details?.city ?? intent.branch_details?.name;
|
|
@@ -241,7 +222,10 @@ const hasSessionAddressIntent = (intent) => {
|
|
|
241
222
|
const city = getIntentCityId(intent);
|
|
242
223
|
const d = getIntentDistrictId(intent);
|
|
243
224
|
const code = getIntentCountryCode(intent);
|
|
244
|
-
|
|
225
|
+
const hasDistrictId = d != null && Number(d) !== 0;
|
|
226
|
+
const hasDistrictName = Boolean(intent.address_details?.district?.name?.trim());
|
|
227
|
+
const districtOk = !isSaudiArabia(code) || hasDistrictId || hasDistrictName;
|
|
228
|
+
return !!(c && city && districtOk);
|
|
245
229
|
};
|
|
246
230
|
const requireRegionAndDistrictForSA = (countryCode, regionId, districtIdOrName) => !countryCode || !isSaudiArabia(countryCode)
|
|
247
231
|
? true
|
|
@@ -348,22 +332,33 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
348
332
|
this.addressCreated = createEvent(this, "addressCreated", 7);
|
|
349
333
|
this.headerContextUpdate = createEvent(this, "headerContextUpdate", 7);
|
|
350
334
|
this.confirming = false;
|
|
335
|
+
this.pendingCartSubmitResolver = null;
|
|
336
|
+
this.pendingCartSubmitPromise = null;
|
|
337
|
+
this.cartSubmitConfirmationPending = false;
|
|
351
338
|
this.branchSearchDebounceTimer = null;
|
|
352
339
|
this.componentReady = false;
|
|
353
340
|
this.pendingOpen = false;
|
|
354
341
|
this.tabChanging = false;
|
|
355
342
|
this.intentStorageKey = "bullet_delivery_intent";
|
|
356
|
-
this.sessionShownKey = "
|
|
343
|
+
this.sessionShownKey = "bullet_delivery_shown";
|
|
344
|
+
this.incompleteIntentPromptKey = "bullet_delivery_incomplete_intent_prompted";
|
|
357
345
|
this.cartItemAddedEvent = "cart::item.added";
|
|
358
346
|
this.cartItemAddedHandler = null;
|
|
347
|
+
this.cartSubmittingHandler = null;
|
|
359
348
|
this.useCartEventApi = false;
|
|
349
|
+
this.authLoggedInHandler = null;
|
|
350
|
+
this.authLoggedOutHandler = null;
|
|
351
|
+
this.loginClosedHandler = null;
|
|
352
|
+
this.hasExplicitPreselectedIdsForOpen = false;
|
|
360
353
|
this.bulletDeliveryOpenHandler = (eventData) => {
|
|
361
354
|
this.preselectedAddressId = eventData?.preselected_address_id;
|
|
362
355
|
this.preselectedBranchId = eventData?.preselected_branch_id;
|
|
356
|
+
this.hasExplicitPreselectedIdsForOpen =
|
|
357
|
+
eventData?.preselected_address_id != null ||
|
|
358
|
+
eventData?.preselected_branch_id != null;
|
|
363
359
|
this.open();
|
|
364
360
|
};
|
|
365
361
|
this.closeHandler = null;
|
|
366
|
-
this.guestLoginSyncHandler = null;
|
|
367
362
|
/** True after saved addresses have been loaded (lazy: only when address tab is shown). */
|
|
368
363
|
this.savedAddressesLoaded = false;
|
|
369
364
|
// Core state
|
|
@@ -472,17 +467,9 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
472
467
|
// Open modal immediately to show skeleton/loading state
|
|
473
468
|
this.modal.open();
|
|
474
469
|
try {
|
|
475
|
-
|
|
476
|
-
const
|
|
477
|
-
this.
|
|
478
|
-
const savedIntent = this.getStoredIntent();
|
|
479
|
-
// When opening from a stored intent, treat its IDs as preselected targets
|
|
480
|
-
if (savedIntent?.type === "address" && savedIntent.address_id) {
|
|
481
|
-
this.preselectedAddressId = savedIntent.address_id;
|
|
482
|
-
}
|
|
483
|
-
if (savedIntent?.type === "branch" && savedIntent.branch_id) {
|
|
484
|
-
this.preselectedBranchId = savedIntent.branch_id;
|
|
485
|
-
}
|
|
470
|
+
this.isLoggedIn = !this.isGuestUser();
|
|
471
|
+
const savedIntent = this.cleanStaleGuestAddressIdIfNeeded(this.getStoredIntent());
|
|
472
|
+
this.applyPreselectedIdsFromIntent(savedIntent);
|
|
486
473
|
const hasStoredAddressIds = !this.isLoggedIn &&
|
|
487
474
|
savedIntent?.type === "address" &&
|
|
488
475
|
getIntentCountryId(savedIntent) != null &&
|
|
@@ -542,12 +529,17 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
542
529
|
// Only hide loading after all data is loaded and UI is ready
|
|
543
530
|
this.loading = false;
|
|
544
531
|
this.modal?.stopLoading();
|
|
532
|
+
this.overrideScopeSwitchUI();
|
|
545
533
|
}
|
|
546
534
|
}
|
|
547
535
|
/**
|
|
548
536
|
* Closes the bullet delivery modal
|
|
549
537
|
*/
|
|
550
538
|
async close() {
|
|
539
|
+
// If submit flow is waiting and user dismissed the modal, release the pending gate.
|
|
540
|
+
if (this.cartSubmitConfirmationPending && !this.confirming) {
|
|
541
|
+
this.resolvePendingCartSubmit();
|
|
542
|
+
}
|
|
551
543
|
this.bulletDeliveryClosed.emit();
|
|
552
544
|
return this.modal?.close();
|
|
553
545
|
}
|
|
@@ -579,14 +571,87 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
579
571
|
const rememberLastSession = Boolean(Salla.config.get("store.settings.bullet_delivery.settings.remember_last_session"));
|
|
580
572
|
return Salla.storage[rememberLastSession ? "store" : "session"];
|
|
581
573
|
}
|
|
574
|
+
getShownStorage() {
|
|
575
|
+
// Always session-scoped. `remember_last_session` applies to intent persistence only.
|
|
576
|
+
return Salla.storage.session;
|
|
577
|
+
}
|
|
582
578
|
getStoredIntent() {
|
|
583
579
|
return this.getIntentStorage().get(this.intentStorageKey);
|
|
584
580
|
}
|
|
581
|
+
isGuestUser() {
|
|
582
|
+
return String(Salla.config.get("user.type") ?? "guest") === "guest";
|
|
583
|
+
}
|
|
584
|
+
cleanStaleGuestAddressIdIfNeeded(intent) {
|
|
585
|
+
if (!this.isGuestUser() || intent?.type !== "address" || !intent.address_id)
|
|
586
|
+
return intent;
|
|
587
|
+
const cleaned = {
|
|
588
|
+
...intent,
|
|
589
|
+
address_id: undefined,
|
|
590
|
+
};
|
|
591
|
+
this.setStoredIntent(cleaned);
|
|
592
|
+
return cleaned;
|
|
593
|
+
}
|
|
594
|
+
applyPreselectedIdsFromIntent(intent) {
|
|
595
|
+
if (this.hasExplicitPreselectedIdsForOpen) {
|
|
596
|
+
this.hasExplicitPreselectedIdsForOpen = false;
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
this.preselectedAddressId = undefined;
|
|
600
|
+
this.preselectedBranchId = undefined;
|
|
601
|
+
if (this.isGuestUser()) {
|
|
602
|
+
if (intent?.type === "branch" && intent.branch_id) {
|
|
603
|
+
this.preselectedBranchId = intent.branch_id;
|
|
604
|
+
}
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
if (intent?.type === "address" && intent.address_id) {
|
|
608
|
+
this.preselectedAddressId = intent.address_id;
|
|
609
|
+
}
|
|
610
|
+
else if (intent?.type === "branch" && intent.branch_id) {
|
|
611
|
+
this.preselectedBranchId = intent.branch_id;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
hasIncompleteUserAddressIntent() {
|
|
615
|
+
if (this.isGuestUser())
|
|
616
|
+
return false;
|
|
617
|
+
const intent = this.getStoredIntent();
|
|
618
|
+
if (!intent || intent.type !== "address" || intent.address_id || !intent.address_details)
|
|
619
|
+
return false;
|
|
620
|
+
// Intent is an address without address_id; consider it "incomplete"
|
|
621
|
+
// only when it represents a valid session-style address.
|
|
622
|
+
return hasSessionAddressIntent(intent);
|
|
623
|
+
}
|
|
624
|
+
hasCompleteIntentForLoggedInUser() {
|
|
625
|
+
if (this.isGuestUser())
|
|
626
|
+
return false;
|
|
627
|
+
const intent = this.getStoredIntent();
|
|
628
|
+
if (!intent)
|
|
629
|
+
return false;
|
|
630
|
+
if (intent.type === "address")
|
|
631
|
+
return !!intent.address_id;
|
|
632
|
+
if (intent.type === "branch")
|
|
633
|
+
return !!intent.branch_id;
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
636
|
+
shouldPromptIncompleteIntentThisSession() {
|
|
637
|
+
const storage = this.getShownStorage();
|
|
638
|
+
return (this.hasIncompleteUserAddressIntent() &&
|
|
639
|
+
storage.get(this.incompleteIntentPromptKey) !== true);
|
|
640
|
+
}
|
|
641
|
+
markIncompleteIntentPrompted() {
|
|
642
|
+
this.getShownStorage().set(this.incompleteIntentPromptKey, true);
|
|
643
|
+
}
|
|
585
644
|
setStoredIntent(intent) {
|
|
586
645
|
this.getIntentStorage().set(this.intentStorageKey, intent);
|
|
646
|
+
this.overrideScopeSwitchUI();
|
|
587
647
|
}
|
|
588
|
-
|
|
589
|
-
|
|
648
|
+
clearBulletDeliveryStoredData() {
|
|
649
|
+
// Clear all bullet-delivery keys from both scopes to avoid stale state across auth transitions.
|
|
650
|
+
Salla.storage.session.remove(this.intentStorageKey);
|
|
651
|
+
Salla.storage.store.remove(this.intentStorageKey);
|
|
652
|
+
Salla.storage.session.remove(this.sessionShownKey);
|
|
653
|
+
Salla.storage.session.remove(this.incompleteIntentPromptKey);
|
|
654
|
+
this.overrideScopeSwitchUI();
|
|
590
655
|
}
|
|
591
656
|
/**
|
|
592
657
|
* Single prefill flow: load geography from stored intent and set selected location + form.
|
|
@@ -644,17 +709,23 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
644
709
|
this.selectedDistrict = district;
|
|
645
710
|
}
|
|
646
711
|
}
|
|
712
|
+
// When district is captured as free text (or couldn't be matched), keep it in the text input state.
|
|
713
|
+
if (!this.selectedDistrict && districtName) {
|
|
714
|
+
this.districtName = districtName;
|
|
715
|
+
}
|
|
647
716
|
}
|
|
648
717
|
updateNewAddressForm(partial) {
|
|
649
718
|
this.newAddressForm = { ...this.newAddressForm, ...partial };
|
|
650
719
|
}
|
|
651
720
|
/** Whether allocation completed successfully this session (modal won't auto-open again). */
|
|
652
721
|
hasBeenShownThisSession() {
|
|
653
|
-
|
|
722
|
+
const storage = this.getShownStorage();
|
|
723
|
+
return storage.get(this.sessionShownKey) === true;
|
|
654
724
|
}
|
|
655
725
|
/** Mark allocation as completed this session (called only after allocateScope succeeds). */
|
|
656
726
|
markShownThisSession() {
|
|
657
|
-
|
|
727
|
+
const storage = this.getShownStorage();
|
|
728
|
+
storage.set(this.sessionShownKey, true);
|
|
658
729
|
}
|
|
659
730
|
async loadCountries(skipEagerSubFetch = false) {
|
|
660
731
|
const forBranch = this.activeTab === "branch";
|
|
@@ -851,110 +922,6 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
851
922
|
this.loadingRegions = false;
|
|
852
923
|
}
|
|
853
924
|
}
|
|
854
|
-
/**
|
|
855
|
-
* AC7: Guest-to-Registered Sync
|
|
856
|
-
* Syncs guest session location to user profile on login
|
|
857
|
-
*/
|
|
858
|
-
async handleGuestToRegisteredSync() {
|
|
859
|
-
try {
|
|
860
|
-
// Check if user is now logged in
|
|
861
|
-
const userId = Salla.config.get("user.id");
|
|
862
|
-
if (!userId)
|
|
863
|
-
return;
|
|
864
|
-
// Get the guest session location from session storage
|
|
865
|
-
const guestIntent = this.getStoredIntent();
|
|
866
|
-
if (!guestIntent || guestIntent.type !== "address") {
|
|
867
|
-
// No guest address intent to sync, or it's a branch intent
|
|
868
|
-
return;
|
|
869
|
-
}
|
|
870
|
-
// Get user's saved addresses
|
|
871
|
-
const userAddresses = await bulletDeliveryAPI.getSavedAddresses();
|
|
872
|
-
const matchingAddress = findMatchingAddress(guestIntent, userAddresses);
|
|
873
|
-
if (matchingAddress) {
|
|
874
|
-
await this.setAddressAsActive(matchingAddress.id);
|
|
875
|
-
const updatedIntent = {
|
|
876
|
-
...guestIntent,
|
|
877
|
-
address_id: matchingAddress.id,
|
|
878
|
-
address_details: this.buildIntentAddressFromSaved(matchingAddress),
|
|
879
|
-
};
|
|
880
|
-
this.setStoredIntent(updatedIntent);
|
|
881
|
-
}
|
|
882
|
-
else if (getIntentCityId(guestIntent)) {
|
|
883
|
-
// No match - create new address from guest session data
|
|
884
|
-
const newAddress = await this.createAddressFromGuestSession(guestIntent);
|
|
885
|
-
if (newAddress) {
|
|
886
|
-
const updatedIntent = {
|
|
887
|
-
...guestIntent,
|
|
888
|
-
address_id: newAddress.id,
|
|
889
|
-
address_details: this.buildIntentAddressFromSaved(newAddress),
|
|
890
|
-
};
|
|
891
|
-
this.setStoredIntent(updatedIntent);
|
|
892
|
-
this.addressCreated.emit({ address: newAddress });
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
// Emit event to notify that sync is complete
|
|
896
|
-
Salla.event.emit("bullet-delivery::guest-synced", {
|
|
897
|
-
guest_intent: guestIntent,
|
|
898
|
-
matched_address_id: matchingAddress?.id,
|
|
899
|
-
});
|
|
900
|
-
}
|
|
901
|
-
catch (error) {
|
|
902
|
-
console.error("SallaBulletDelivery: Error syncing guest session to user profile", error);
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
/**
|
|
906
|
-
* Set an address as active/last used
|
|
907
|
-
*/
|
|
908
|
-
async setAddressAsActive(addressId) {
|
|
909
|
-
try {
|
|
910
|
-
// Call API to mark address as default/active
|
|
911
|
-
await Salla.address?.api?.setDefault?.(addressId);
|
|
912
|
-
}
|
|
913
|
-
catch (error) {
|
|
914
|
-
// If setDefault API doesn't exist, just update local state
|
|
915
|
-
console.warn("SallaBulletDelivery: Could not set address as default", error);
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
/**
|
|
919
|
-
* Create a new address from guest session: only country, city and district IDs (no street, etc.).
|
|
920
|
-
* Uses address/location API; after fetch we return the newly created address from the list.
|
|
921
|
-
*/
|
|
922
|
-
async createAddressFromGuestSession(guestIntent) {
|
|
923
|
-
const countryId = getIntentCountryId(guestIntent);
|
|
924
|
-
const cityId = getIntentCityId(guestIntent);
|
|
925
|
-
if (!countryId || !cityId)
|
|
926
|
-
return null;
|
|
927
|
-
const isSA = isSaudiArabia(getIntentCountryCode(guestIntent));
|
|
928
|
-
const districtName = guestIntent.address_details?.district?.name ?? "";
|
|
929
|
-
const payload = {
|
|
930
|
-
country_id: countryId,
|
|
931
|
-
region_id: getIntentRegionId(guestIntent),
|
|
932
|
-
city_id: cityId,
|
|
933
|
-
district_id: getIntentDistrictId(guestIntent),
|
|
934
|
-
description: districtName,
|
|
935
|
-
};
|
|
936
|
-
if (isSA) {
|
|
937
|
-
payload.local = districtName;
|
|
938
|
-
}
|
|
939
|
-
try {
|
|
940
|
-
const { success, address } = await bulletDeliveryAPI.saveAddressLocation(payload);
|
|
941
|
-
if (!success)
|
|
942
|
-
return null;
|
|
943
|
-
if (address)
|
|
944
|
-
return address;
|
|
945
|
-
const addresses = await bulletDeliveryAPI.getSavedAddresses();
|
|
946
|
-
const districtId = getIntentDistrictId(guestIntent);
|
|
947
|
-
const newAddress = addresses.find((a) => (a.city_id ?? a.city?.id) === cityId &&
|
|
948
|
-
(a.district_id ?? a.district?.id) === districtId) ??
|
|
949
|
-
addresses[0] ??
|
|
950
|
-
null;
|
|
951
|
-
return newAddress;
|
|
952
|
-
}
|
|
953
|
-
catch (error) {
|
|
954
|
-
console.error("SallaBulletDelivery: Could not create address from guest session", error);
|
|
955
|
-
return null;
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
925
|
emitHeaderContextUpdate(result, address, branch) {
|
|
959
926
|
let locationText = "";
|
|
960
927
|
if (result.type === "address") {
|
|
@@ -1225,8 +1192,21 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
1225
1192
|
return false;
|
|
1226
1193
|
}
|
|
1227
1194
|
handleLogin() {
|
|
1195
|
+
// Keep bullet-delivery flow in-place and avoid full page reload after login.
|
|
1196
|
+
Salla.auth.setCanRedirect(false);
|
|
1228
1197
|
Salla.event.dispatch("bullet-delivery::close");
|
|
1229
|
-
Salla.event.dispatch("login::open")
|
|
1198
|
+
Salla.event.dispatch("login::open", Salla.url.is_page("cart")
|
|
1199
|
+
? { withoutReload: true, source: "cart-submit" }
|
|
1200
|
+
: { withoutReload: true, source: "bullet-delivery" });
|
|
1201
|
+
}
|
|
1202
|
+
resolvePendingCartSubmit() {
|
|
1203
|
+
if (!this.pendingCartSubmitResolver)
|
|
1204
|
+
return;
|
|
1205
|
+
const resolve = this.pendingCartSubmitResolver;
|
|
1206
|
+
this.pendingCartSubmitResolver = null;
|
|
1207
|
+
this.pendingCartSubmitPromise = null;
|
|
1208
|
+
this.cartSubmitConfirmationPending = false;
|
|
1209
|
+
resolve();
|
|
1230
1210
|
}
|
|
1231
1211
|
buildIntentAddress() {
|
|
1232
1212
|
if (this.activeTab !== "address" ||
|
|
@@ -1312,10 +1292,8 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
1312
1292
|
};
|
|
1313
1293
|
let selectedAddress;
|
|
1314
1294
|
let selectedBranchData;
|
|
1315
|
-
let usedSessionAddress = false;
|
|
1316
1295
|
if (this.activeTab === "address") {
|
|
1317
1296
|
if (this.isLoggedIn && this.selectedSessionAddress) {
|
|
1318
|
-
usedSessionAddress = true;
|
|
1319
1297
|
const savedAddress = await this.saveSessionAddressToProfile();
|
|
1320
1298
|
if (!savedAddress) {
|
|
1321
1299
|
Salla.notify?.error(Salla.lang.get("common.errors.error_occurred"));
|
|
@@ -1422,14 +1400,9 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
1422
1400
|
}
|
|
1423
1401
|
// After allocation success: mark session so we don't show modal again this session
|
|
1424
1402
|
this.markShownThisSession();
|
|
1425
|
-
// After allocation success:
|
|
1426
|
-
//
|
|
1427
|
-
|
|
1428
|
-
this.removeStoredIntent();
|
|
1429
|
-
}
|
|
1430
|
-
else {
|
|
1431
|
-
this.setStoredIntent(result);
|
|
1432
|
-
}
|
|
1403
|
+
// After allocation success: persist latest intent so switch UI can always reflect
|
|
1404
|
+
// the selected address/branch once confirmed.
|
|
1405
|
+
this.setStoredIntent(result);
|
|
1433
1406
|
if (allocatedScopeId) {
|
|
1434
1407
|
await bulletDeliveryAPI.setDeliveryScope(allocatedScopeId);
|
|
1435
1408
|
}
|
|
@@ -1445,6 +1418,10 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
1445
1418
|
this.confirmBtn?.stop();
|
|
1446
1419
|
this.close();
|
|
1447
1420
|
this.confirming = false;
|
|
1421
|
+
if (this.cartSubmitConfirmationPending) {
|
|
1422
|
+
this.resolvePendingCartSubmit();
|
|
1423
|
+
return;
|
|
1424
|
+
}
|
|
1448
1425
|
if (allocatedScopeId) {
|
|
1449
1426
|
const scope = Salla.storage.get("scope") || {};
|
|
1450
1427
|
let url = Salla.helpers.addParamToUrl("scope", allocatedScopeId);
|
|
@@ -1563,7 +1540,7 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
1563
1540
|
} }, 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))))));
|
|
1564
1541
|
}
|
|
1565
1542
|
renderSelectLoader() {
|
|
1566
|
-
return (h("span", { class: "s-bullet-delivery-select-loader", "aria-hidden": "true" }, h("salla-
|
|
1543
|
+
return (h("span", { class: "s-bullet-delivery-select-loader", "aria-hidden": "true" }, h("salla-skeleton", { height: "16px", width: "16px" })));
|
|
1567
1544
|
}
|
|
1568
1545
|
renderLoadingLabel(label, htmlFor, isLoading = false, isRequired = true) {
|
|
1569
1546
|
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())));
|
|
@@ -1688,22 +1665,17 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
1688
1665
|
if (!this.isLoggedIn)
|
|
1689
1666
|
return null;
|
|
1690
1667
|
if (this.loadingSavedAddresses) {
|
|
1691
|
-
return (h("div",
|
|
1668
|
+
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%" }))))))));
|
|
1692
1669
|
}
|
|
1693
1670
|
const intent = this.getStoredIntent();
|
|
1694
1671
|
const hasSessionAddress = hasSessionAddressIntent(intent);
|
|
1695
|
-
const
|
|
1696
|
-
? [
|
|
1697
|
-
intent.address_details.district?.name,
|
|
1698
|
-
intent.address_details.city.name,
|
|
1699
|
-
intent.address_details.country.name,
|
|
1700
|
-
]
|
|
1672
|
+
const sessionLine1 = hasSessionAddress && intent?.address_details
|
|
1673
|
+
? [intent.address_details.city?.name, intent.address_details.country?.name]
|
|
1701
1674
|
.filter(Boolean)
|
|
1702
|
-
.join("، ") ||
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
].join(", ")
|
|
1675
|
+
.join("، ") || ""
|
|
1676
|
+
: "";
|
|
1677
|
+
const sessionLine2 = hasSessionAddress && intent?.address_details
|
|
1678
|
+
? (intent.address_details.district?.name ?? "").trim()
|
|
1707
1679
|
: "";
|
|
1708
1680
|
if (this.savedAddresses.length === 0 && !hasSessionAddress) {
|
|
1709
1681
|
return this.renderSavedAddressesEmptyState();
|
|
@@ -1711,8 +1683,8 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
1711
1683
|
return (h("div", { class: "s-bullet-delivery-addresses-list s-scrollbar" }, hasSessionAddress &&
|
|
1712
1684
|
this.renderAddressRow({
|
|
1713
1685
|
key: "session-address",
|
|
1714
|
-
line1:
|
|
1715
|
-
line2:
|
|
1686
|
+
line1: sessionLine1,
|
|
1687
|
+
line2: sessionLine2,
|
|
1716
1688
|
selected: this.selectedSessionAddress,
|
|
1717
1689
|
onClick: () => this.handleSessionAddressSelect(),
|
|
1718
1690
|
}), this.savedAddresses.map((address) => {
|
|
@@ -1727,7 +1699,7 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
1727
1699
|
]
|
|
1728
1700
|
.filter(Boolean)
|
|
1729
1701
|
.join("، ");
|
|
1730
|
-
const line2 = (
|
|
1702
|
+
const line2 = (address.formatted?.address_two || builtLine2) ?? "";
|
|
1731
1703
|
const inCoverage = address.is_in_coverage !== false;
|
|
1732
1704
|
return this.renderAddressRow({
|
|
1733
1705
|
key: String(address.id),
|
|
@@ -1775,7 +1747,7 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
1775
1747
|
"s-bullet-delivery-location-btn": true,
|
|
1776
1748
|
"s-bullet-delivery-location-btn--full": true,
|
|
1777
1749
|
"s-bullet-delivery-location-btn--loading": this.loadingNearestBranch,
|
|
1778
|
-
}, onClick: () => this.handleFindNearestBranch(), disabled: this.loadingNearestBranch }, this.loadingNearestBranch ? (h("salla-
|
|
1750
|
+
}, 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))));
|
|
1779
1751
|
}
|
|
1780
1752
|
renderBranchList() {
|
|
1781
1753
|
if (this.loadingBranches) {
|
|
@@ -1845,10 +1817,14 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
1845
1817
|
handleAfterAddToCart() {
|
|
1846
1818
|
if (this.openingType !== "after_add_to_cart")
|
|
1847
1819
|
return;
|
|
1848
|
-
|
|
1820
|
+
const canOpenForIncompleteIntent = this.shouldPromptIncompleteIntentThisSession();
|
|
1821
|
+
if (this.hasBeenShownThisSession() && !canOpenForIncompleteIntent)
|
|
1849
1822
|
return;
|
|
1850
1823
|
if (this.modal?.hasAttribute?.("visible"))
|
|
1851
1824
|
return;
|
|
1825
|
+
if (canOpenForIncompleteIntent) {
|
|
1826
|
+
this.markIncompleteIntentPrompted();
|
|
1827
|
+
}
|
|
1852
1828
|
this.open();
|
|
1853
1829
|
}
|
|
1854
1830
|
overrideScopeSwitchUI() {
|
|
@@ -1856,13 +1832,17 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
1856
1832
|
const btn = document.querySelector('[onclick*="scopes"]');
|
|
1857
1833
|
if (!btn)
|
|
1858
1834
|
return;
|
|
1835
|
+
const hasIntentWithType = !!intent && (intent.type === "address" || intent.type === "branch");
|
|
1836
|
+
if (!hasIntentWithType) {
|
|
1837
|
+
btn.style.display = "none";
|
|
1838
|
+
btn.onclick = () => this.open();
|
|
1839
|
+
return;
|
|
1840
|
+
}
|
|
1859
1841
|
const trunc = (s, max) => s && s.length > max ? `${s.slice(0, max)}...` : (s ?? "");
|
|
1860
|
-
const label =
|
|
1861
|
-
? Salla.lang.get("common.
|
|
1862
|
-
:
|
|
1863
|
-
|
|
1864
|
-
: `${Salla.lang.get("mobile_app.strings.delivery")} ${Salla.lang.get("common.elements.to")} ${trunc(intent.address_details?.city?.name, 10)}`;
|
|
1865
|
-
btn.style.display = intent ? "" : "none";
|
|
1842
|
+
const label = intent.type === "branch"
|
|
1843
|
+
? `${Salla.lang.get("mobile_app.strings.pickup")} ${Salla.lang.get("common.elements.from")} ${trunc(intent.branch_details?.name, 20)}`
|
|
1844
|
+
: `${Salla.lang.get("mobile_app.strings.delivery")} ${Salla.lang.get("common.elements.to")} ${trunc(intent.address_details?.city?.name, 10)}`;
|
|
1845
|
+
btn.style.display = "inline-flex";
|
|
1866
1846
|
btn.onclick = () => this.open();
|
|
1867
1847
|
const span = btn.querySelector('span:not([class*="sicon"]):not([class*="icon"])');
|
|
1868
1848
|
if (span) {
|
|
@@ -1878,6 +1858,31 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
1878
1858
|
await Salla.onReady();
|
|
1879
1859
|
try {
|
|
1880
1860
|
this.overrideScopeSwitchUI();
|
|
1861
|
+
this.cartSubmittingHandler = async () => {
|
|
1862
|
+
if (this.pendingCartSubmitPromise) {
|
|
1863
|
+
await this.pendingCartSubmitPromise;
|
|
1864
|
+
return;
|
|
1865
|
+
}
|
|
1866
|
+
// Logged-in users with a complete intent can continue checkout without re-prompting.
|
|
1867
|
+
if (this.hasCompleteIntentForLoggedInUser()) {
|
|
1868
|
+
return;
|
|
1869
|
+
}
|
|
1870
|
+
this.cartSubmitConfirmationPending = true;
|
|
1871
|
+
this.pendingCartSubmitPromise = new Promise((resolve) => {
|
|
1872
|
+
this.pendingCartSubmitResolver = resolve;
|
|
1873
|
+
if (this.isGuestUser()) {
|
|
1874
|
+
Salla.auth.setCanRedirect(false);
|
|
1875
|
+
Salla.event.dispatch("login::open", {
|
|
1876
|
+
withoutReload: true,
|
|
1877
|
+
source: "cart-submit",
|
|
1878
|
+
});
|
|
1879
|
+
return;
|
|
1880
|
+
}
|
|
1881
|
+
this.open();
|
|
1882
|
+
});
|
|
1883
|
+
await this.pendingCartSubmitPromise;
|
|
1884
|
+
};
|
|
1885
|
+
Salla.cart.event.onSubmitting(this.cartSubmittingHandler);
|
|
1881
1886
|
}
|
|
1882
1887
|
catch (e) {
|
|
1883
1888
|
console.warn("SallaBulletDelivery: overrideScopeSwitchUI failed", e);
|
|
@@ -1885,11 +1890,40 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
1885
1890
|
Salla.event.on("bullet-delivery::open", this.bulletDeliveryOpenHandler);
|
|
1886
1891
|
this.closeHandler = this.close.bind(this);
|
|
1887
1892
|
Salla.event.on("bullet-delivery::close", this.closeHandler);
|
|
1888
|
-
// Listen for successful login to sync guest session to user profile (AC7)
|
|
1889
|
-
this.guestLoginSyncHandler = this.handleGuestToRegisteredSync.bind(this);
|
|
1890
|
-
Salla.event.on("login::success", this.guestLoginSyncHandler);
|
|
1891
|
-
Salla.event.on("auth::logged-in", this.guestLoginSyncHandler);
|
|
1892
1893
|
this.isRTL = Salla.config.get("theme.is_rtl");
|
|
1894
|
+
this.authLoggedInHandler = () => {
|
|
1895
|
+
if (this.cartSubmitConfirmationPending) {
|
|
1896
|
+
Salla.event.dispatch("login::close");
|
|
1897
|
+
if (this.hasCompleteIntentForLoggedInUser()) {
|
|
1898
|
+
this.resolvePendingCartSubmit();
|
|
1899
|
+
return;
|
|
1900
|
+
}
|
|
1901
|
+
if (!this.modal?.hasAttribute?.("visible")) {
|
|
1902
|
+
this.open();
|
|
1903
|
+
}
|
|
1904
|
+
return;
|
|
1905
|
+
}
|
|
1906
|
+
// Always prompt after login when intent is incomplete, regardless of prior prompted flags.
|
|
1907
|
+
if (!this.hasIncompleteUserAddressIntent())
|
|
1908
|
+
return;
|
|
1909
|
+
if (this.modal?.hasAttribute?.("visible"))
|
|
1910
|
+
return;
|
|
1911
|
+
this.open();
|
|
1912
|
+
};
|
|
1913
|
+
Salla.event.on("auth::logged.in", this.authLoggedInHandler);
|
|
1914
|
+
this.authLoggedOutHandler = () => {
|
|
1915
|
+
this.clearBulletDeliveryStoredData();
|
|
1916
|
+
};
|
|
1917
|
+
Salla.event.on("auth::logged.out", this.authLoggedOutHandler);
|
|
1918
|
+
this.loginClosedHandler = () => {
|
|
1919
|
+
// Guest cart-submit flow opens login first; if login is dismissed, unblock submit gate.
|
|
1920
|
+
if (!this.cartSubmitConfirmationPending || !this.isGuestUser())
|
|
1921
|
+
return;
|
|
1922
|
+
if (this.hasCompleteIntentForLoggedInUser())
|
|
1923
|
+
return;
|
|
1924
|
+
this.resolvePendingCartSubmit();
|
|
1925
|
+
};
|
|
1926
|
+
Salla.event.on("salla-login::closed", this.loginClosedHandler);
|
|
1893
1927
|
// Listen for add-to-cart events for 'after_add_to_cart' opening strategy (after salla is ready)
|
|
1894
1928
|
this.cartItemAddedHandler = () => this.handleAfterAddToCart();
|
|
1895
1929
|
if (typeof Salla.cart?.event?.onItemAdded === "function") {
|
|
@@ -1901,7 +1935,7 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
1901
1935
|
}
|
|
1902
1936
|
}
|
|
1903
1937
|
render() {
|
|
1904
|
-
return (h(Host, { key: '
|
|
1938
|
+
return (h(Host, { key: '751566707c28202b5ccf4ecde28bfb09550ae886', class: "s-bullet-delivery" }, h("salla-modal", { key: '25a18755aa4aa85b55f08bb73829e30833ca5328', ref: (modal) => {
|
|
1905
1939
|
this.modal = modal;
|
|
1906
1940
|
}, 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())))));
|
|
1907
1941
|
}
|
|
@@ -1921,12 +1955,22 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
1921
1955
|
if (!this.hasBeenShownThisSession()) {
|
|
1922
1956
|
this.open();
|
|
1923
1957
|
}
|
|
1958
|
+
else if (this.shouldPromptIncompleteIntentThisSession()) {
|
|
1959
|
+
this.markIncompleteIntentPrompted();
|
|
1960
|
+
this.open();
|
|
1961
|
+
}
|
|
1924
1962
|
break;
|
|
1925
1963
|
case "on_cart_click":
|
|
1926
1964
|
// Open automatically when user is on the cart page
|
|
1927
1965
|
if (Salla.url.is_page("cart")) {
|
|
1928
|
-
|
|
1966
|
+
const shown = this.getShownStorage().get(this.sessionShownKey) === true;
|
|
1967
|
+
if (!shown) {
|
|
1929
1968
|
this.open();
|
|
1969
|
+
}
|
|
1970
|
+
else if (this.shouldPromptIncompleteIntentThisSession()) {
|
|
1971
|
+
this.markIncompleteIntentPrompted();
|
|
1972
|
+
this.open();
|
|
1973
|
+
}
|
|
1930
1974
|
}
|
|
1931
1975
|
break;
|
|
1932
1976
|
}
|
|
@@ -1945,11 +1989,6 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
1945
1989
|
Salla.event.off("bullet-delivery::close", this.closeHandler);
|
|
1946
1990
|
this.closeHandler = null;
|
|
1947
1991
|
}
|
|
1948
|
-
if (this.guestLoginSyncHandler) {
|
|
1949
|
-
Salla.event.off("login::success", this.guestLoginSyncHandler);
|
|
1950
|
-
Salla.event.off("auth::logged-in", this.guestLoginSyncHandler);
|
|
1951
|
-
this.guestLoginSyncHandler = null;
|
|
1952
|
-
}
|
|
1953
1992
|
if (this.cartItemAddedHandler) {
|
|
1954
1993
|
if (this.useCartEventApi && typeof Salla.cart?.event?.offItemAdded === "function") {
|
|
1955
1994
|
Salla.cart.event.offItemAdded(this.cartItemAddedHandler);
|
|
@@ -1959,6 +1998,27 @@ const SallaBulletDelivery$1 = /*@__PURE__*/ proxyCustomElement(class SallaBullet
|
|
|
1959
1998
|
}
|
|
1960
1999
|
this.cartItemAddedHandler = null;
|
|
1961
2000
|
}
|
|
2001
|
+
if (this.cartSubmittingHandler) {
|
|
2002
|
+
if (typeof Salla.cart?.event?.offSubmitting === "function") {
|
|
2003
|
+
Salla.cart.event.offSubmitting(this.cartSubmittingHandler);
|
|
2004
|
+
}
|
|
2005
|
+
else {
|
|
2006
|
+
Salla.event.off("cart::submitting", this.cartSubmittingHandler);
|
|
2007
|
+
}
|
|
2008
|
+
this.cartSubmittingHandler = null;
|
|
2009
|
+
}
|
|
2010
|
+
if (this.authLoggedInHandler) {
|
|
2011
|
+
Salla.event.off("auth::logged.in", this.authLoggedInHandler);
|
|
2012
|
+
this.authLoggedInHandler = null;
|
|
2013
|
+
}
|
|
2014
|
+
if (this.authLoggedOutHandler) {
|
|
2015
|
+
Salla.event.off("auth::logged.out", this.authLoggedOutHandler);
|
|
2016
|
+
this.authLoggedOutHandler = null;
|
|
2017
|
+
}
|
|
2018
|
+
if (this.loginClosedHandler) {
|
|
2019
|
+
Salla.event.off("salla-login::closed", this.loginClosedHandler);
|
|
2020
|
+
this.loginClosedHandler = null;
|
|
2021
|
+
}
|
|
1962
2022
|
}
|
|
1963
2023
|
static get style() { return sallaBulletDeliveryCss; }
|
|
1964
2024
|
}, [0, "salla-bullet-delivery", {
|