@fayz-ai/storefront 0.17.0 → 0.18.0
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/{chunk-STL6MATQ.js → chunk-ORKXSAZ6.js} +22 -15
- package/dist/chunk-ORKXSAZ6.js.map +1 -0
- package/dist/components/checkout/DeliveryEstimator.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/render.js +1 -1
- package/dist/stores/delivery.store.d.ts +10 -0
- package/dist/stores/delivery.store.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/chunk-STL6MATQ.js.map +0 -1
|
@@ -231,6 +231,7 @@ function productOptionSelectionKey(selection) {
|
|
|
231
231
|
const entries = Object.entries(normalized);
|
|
232
232
|
return entries.length > 0 ? JSON.stringify(entries) : "";
|
|
233
233
|
}
|
|
234
|
+
var HINT_TIMEOUT_MS = 1200;
|
|
234
235
|
var EMPTY = {
|
|
235
236
|
postalCode: "",
|
|
236
237
|
address: null,
|
|
@@ -238,7 +239,8 @@ var EMPTY = {
|
|
|
238
239
|
selectedZoneId: null,
|
|
239
240
|
status: "idle",
|
|
240
241
|
error: null,
|
|
241
|
-
refusedZone: null
|
|
242
|
+
refusedZone: null,
|
|
243
|
+
reviewZone: null
|
|
242
244
|
};
|
|
243
245
|
var useDeliveryStore = create()(
|
|
244
246
|
persist(
|
|
@@ -252,10 +254,17 @@ var useDeliveryStore = create()(
|
|
|
252
254
|
}
|
|
253
255
|
set({ postalCode: code, status: "loading", error: null });
|
|
254
256
|
const shop = getShopProvider();
|
|
255
|
-
const
|
|
257
|
+
const addressPromise = lookupPostalCode(code).catch(() => null);
|
|
258
|
+
const hint = await Promise.race([
|
|
259
|
+
addressPromise.then((a) => a ? { district: a.district, city: a.city, state: a.state, cityCode: a.cityCode } : void 0),
|
|
260
|
+
new Promise((resolve) => {
|
|
261
|
+
setTimeout(() => resolve(void 0), HINT_TIMEOUT_MS);
|
|
262
|
+
})
|
|
263
|
+
]);
|
|
264
|
+
const checkPromise = shop.checkDelivery ? shop.checkDelivery(code, hint).catch(() => null) : Promise.resolve(null);
|
|
256
265
|
let options = [];
|
|
257
266
|
try {
|
|
258
|
-
options = await shop.quoteShipping?.(code, subtotal) ?? [];
|
|
267
|
+
options = await shop.quoteShipping?.(code, subtotal, hint) ?? [];
|
|
259
268
|
} catch {
|
|
260
269
|
set({
|
|
261
270
|
...EMPTY,
|
|
@@ -265,22 +274,19 @@ var useDeliveryStore = create()(
|
|
|
265
274
|
});
|
|
266
275
|
return;
|
|
267
276
|
}
|
|
268
|
-
const
|
|
277
|
+
const check = await checkPromise;
|
|
278
|
+
const refusedZone = check?.refused ? check.refusedZone || "Regi\xE3o n\xE3o atendida" : null;
|
|
279
|
+
const reviewZone = !refusedZone && check?.outcome === "review" ? check.zoneName || "Regi\xE3o a confirmar" : null;
|
|
269
280
|
if (refusedZone) options = [];
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
try {
|
|
273
|
-
address = await lookupPostalCode(code);
|
|
274
|
-
notFound = address === null;
|
|
275
|
-
} catch {
|
|
276
|
-
address = null;
|
|
277
|
-
}
|
|
281
|
+
const address = await addressPromise;
|
|
282
|
+
const notFound = address === null;
|
|
278
283
|
set({
|
|
279
284
|
postalCode: code,
|
|
280
285
|
address,
|
|
281
286
|
options,
|
|
282
287
|
selectedZoneId: options[0]?.zoneId ?? null,
|
|
283
288
|
refusedZone,
|
|
289
|
+
reviewZone,
|
|
284
290
|
// A store with no zones configured quotes nothing, and that must NOT
|
|
285
291
|
// read as "we don't deliver here" — it falls back to the store-wide
|
|
286
292
|
// flat rate, which the cart already knows how to show.
|
|
@@ -4201,7 +4207,8 @@ function DeliveryEstimator({ compact: compact2 = false }) {
|
|
|
4201
4207
|
}
|
|
4202
4208
|
) }, option.zoneId);
|
|
4203
4209
|
}) }),
|
|
4204
|
-
delivery.status === "unserved" && /* @__PURE__ */ jsx("p", { "data-testid": TID.deliveryUnserved, className: "mt-3 text-sm text-destructive", children: "Ainda n\xE3o entregamos nesse CEP." }),
|
|
4210
|
+
delivery.status === "unserved" && /* @__PURE__ */ jsx("p", { "data-testid": TID.deliveryUnserved, className: "mt-3 text-sm text-destructive", children: delivery.refusedZone ? "Esta loja n\xE3o entrega nesse endere\xE7o." : "Ainda n\xE3o entregamos nesse CEP." }),
|
|
4211
|
+
delivery.reviewZone && delivery.status === "served" && /* @__PURE__ */ jsx("p", { className: "mt-3 text-sm text-amber-600 dark:text-amber-500", children: "Entregamos nessa regi\xE3o, mas confirmamos com voc\xEA antes de sair." }),
|
|
4205
4212
|
delivery.postalCode && /* @__PURE__ */ jsx(
|
|
4206
4213
|
"button",
|
|
4207
4214
|
{
|
|
@@ -11661,5 +11668,5 @@ ${formatErrors(report.errors)}`;
|
|
|
11661
11668
|
}
|
|
11662
11669
|
|
|
11663
11670
|
export { BEFORE_PLACE_ORDER_VALVE, BLOCK_STRUCTURAL_KEYS, BenefitsRow, BlockDataError, CART_LINE_ANNOTATION_POINT, CATALOG_BODY_BLOCK, CHECKOUT_FIELD_POINT, CartDrawer, CatalogPage, CategoryShowcase, CheckoutPage, CollectionCta, CollectionHero, ContentPage, CountdownBand, EmailConfirmationRequiredError, EntityListBlock, FaqSection, FiltersPanel, FormBlock, HeroSection, ImageTiles, Link, ManifestoBlock, MediaCarousel, MotifStrip, MyPurchasesPage, NewsletterBand, ORDER_METADATA_POINT, OrderConfirmationPage, OrderTrackingTimeline, PAGE_DATA_SCRIPT_ID, PLACEHOLDER_ASPECTS, PRODUCT_BODY_BLOCK, PRODUCT_CARD_BADGE_POINT, PageDataScope, PaymentTerms, Price, ProductCard, ProductDetailPage, ProductEnquiryForm, ProductGallery, ProductGrid, ProductOptionSelector, ProductRail, ProductReviews, ProductSlider, ProductSpecs, ProductSpotlight, PromoBanner, QuantityInput, Reveal, STOREFRONT_COMPONENT_KEYS, STOREFRONT_PAGE_KINDS, STOREFRONT_SLOTS, STORE_BACKEND_PROVIDERS, STORE_COMMERCE_MODES, STORE_DOCUMENT_KIND, STORE_PAYMENT_METHOD_KINDS, STORE_PAYMENT_MODES, STORE_ROUTE_CHROMES, STORE_ROUTE_KINDS, STORE_SECTIONS, STORE_SECTION_NAMES, SealsBand, SearchOverlay, Slot, SmoothImage, StepsSection, StorefrontConfigHost, StorefrontConfigProvider, StorefrontFooter, StorefrontHeader, StorefrontPage, StorefrontRouterProvider, StorefrontShell, StorefrontThemeStyle, StoryQuote, THEME_SCALE_FIELDS, THEME_SCALE_VAR_PREFIX, TID, Testimonials, TierCards, applyStoreSettings, bannerPlaceholder, blockInstanceId, buildEnquiryFromForm, checkPageBlocks, collectDataNeeds, collectOrderMetadata, contentPagePath, createStorefront, createStorefrontApp, currentStaticRenderPass, defaultPageBlocks, entityListBlockMeta, establishCustomerSession, exportStore, formatMoney, formatProductOptionSelection, getCartLineAnnotations, getCheckoutFieldContributions, getCustomerAuthAdapter, getProductCardBadges, getProductOptionGroups, hydrateStoreDocument, hydratedEntriesFor, initStorefrontRuntime, isJsonValue, isKnownPath, isNestedBlockRef, isPublicPath, isRecord, listSlots, matchContentPage, matchPath, matchesFacets, mergeCollectionFacet, mergePageTheme, navigateTo, nextMilestone, normalizeProductOptionSelection, orderGalleryImages, overrideComponent, overrideProps, pageSeo, pageThemeSelector, pickProductCardImage, placeStorefrontOrder, prefersReducedMotion, primaryImageUrl, productCardComponentContract, productJsonLd, productOptionSelectionKey, productPlaceholder, productSeo, readHydratedPageData, registerStorefrontBlocks, registerStorefrontEntities, registerStorefrontExtensionPoints, registerStorefrontLoaders, resetPageDiagnostics, resetProductOptionsDeprecationWarnings, resetStorefrontExtensionPoints, resolveAuthAdapter, resolveConfig, resolveDataParams, resolveOverride, resolvePageData, resolvePageDataNeed, resolvePaymentTerms, resolveStorefrontProvider, resolveStorefrontRoute, resolveVariantForSelection, roundCents, routePathParams, runBeforePlaceOrderValve, sectionToJsonSchema, sectionsToBlocks, selectCount, selectDiscountTotal, selectRequiresShipping, selectShipping, selectSubtotal, selectTotal, selectionPrice, serializePageData, shellRouterAdapter, signInByEmail, signOutCustomer, signUpCustomer, slugifyStoreName, storefrontComponentContracts, storefrontPaths, themeToCss, toBlockNodes, toFacetMap, useBlockData, useCartStore, useCatalogStore, useCategories, useDeliveryStore, useDiscountValidator, useEnquiry, useHashPath, useInView, useLoader, useMyOrders, useNavigate, usePopOnChange, useProduct, useProducts, useRoutePath, useRouterAdapter, useScrollToTopOnNavigate, useScrolled, useSessionStore, useSlotContext, useStorefrontActions, useStorefrontConfig, useStorefrontConfigOptional, useStorefrontHead, useStorefrontPage, useStorefrontPageOptional, usedSlots, validateStore, withFacet, withStaticRenderPass };
|
|
11664
|
-
//# sourceMappingURL=chunk-
|
|
11665
|
-
//# sourceMappingURL=chunk-
|
|
11671
|
+
//# sourceMappingURL=chunk-ORKXSAZ6.js.map
|
|
11672
|
+
//# sourceMappingURL=chunk-ORKXSAZ6.js.map
|