@behio/storefront-sdk 0.1.10 → 0.1.11

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.
@@ -418,6 +418,10 @@ var CatalogModule = class {
418
418
  async getProductPromotions(productSlug) {
419
419
  return this.client.request("GET", `/catalog/products/${productSlug}/promotions`);
420
420
  }
421
+ /** Check a gift card code — returns validity and remaining balance */
422
+ async checkGiftCard(code) {
423
+ return this.client.request("GET", `/catalog/gift-cards/${encodeURIComponent(code)}/check`);
424
+ }
421
425
  };
422
426
  var AuthModule = class {
423
427
  constructor(client) {
@@ -529,6 +533,20 @@ var CartModule = class {
529
533
  this.client.emit("cart:cleared");
530
534
  return result;
531
535
  }
536
+ /** Apply a gift card code to the cart. Balance is deducted at checkout. */
537
+ async applyGiftCard(code) {
538
+ const result = await this.client.request("POST", "/cart/gift-card", {
539
+ body: { code }
540
+ });
541
+ this.client.emit("cart:updated", result);
542
+ return result;
543
+ }
544
+ /** Remove a gift card from the cart */
545
+ async removeGiftCard() {
546
+ const result = await this.client.request("DELETE", "/cart/gift-card");
547
+ this.client.emit("cart:updated", result);
548
+ return result;
549
+ }
532
550
  /** Add a bundle to the cart (price is locked at the bundle's current price) */
533
551
  async addBundle(bundleId, quantity = 1) {
534
552
  const result = await this.client.request("POST", "/cart/bundles", {
@@ -418,6 +418,10 @@ var CatalogModule = class {
418
418
  async getProductPromotions(productSlug) {
419
419
  return this.client.request("GET", `/catalog/products/${productSlug}/promotions`);
420
420
  }
421
+ /** Check a gift card code — returns validity and remaining balance */
422
+ async checkGiftCard(code) {
423
+ return this.client.request("GET", `/catalog/gift-cards/${encodeURIComponent(code)}/check`);
424
+ }
421
425
  };
422
426
  var AuthModule = class {
423
427
  constructor(client) {
@@ -529,6 +533,20 @@ var CartModule = class {
529
533
  this.client.emit("cart:cleared");
530
534
  return result;
531
535
  }
536
+ /** Apply a gift card code to the cart. Balance is deducted at checkout. */
537
+ async applyGiftCard(code) {
538
+ const result = await this.client.request("POST", "/cart/gift-card", {
539
+ body: { code }
540
+ });
541
+ this.client.emit("cart:updated", result);
542
+ return result;
543
+ }
544
+ /** Remove a gift card from the cart */
545
+ async removeGiftCard() {
546
+ const result = await this.client.request("DELETE", "/cart/gift-card");
547
+ this.client.emit("cart:updated", result);
548
+ return result;
549
+ }
532
550
  /** Add a bundle to the cart (price is locked at the bundle's current price) */
533
551
  async addBundle(bundleId, quantity = 1) {
534
552
  const result = await this.client.request("POST", "/cart/bundles", {
package/dist/index.d.mts CHANGED
@@ -436,6 +436,11 @@ interface ActivePromotion {
436
436
  showCountdown: boolean;
437
437
  couponRequired: boolean;
438
438
  }
439
+ interface GiftCardBalance {
440
+ valid: boolean;
441
+ balance: number;
442
+ currency: string;
443
+ }
439
444
 
440
445
  declare class BehioStorefront {
441
446
  private baseUrl;
@@ -561,6 +566,8 @@ declare class CatalogModule {
561
566
  getProductPromotions(productSlug: string): Promise<{
562
567
  items: ActivePromotion[];
563
568
  }>;
569
+ /** Check a gift card code — returns validity and remaining balance */
570
+ checkGiftCard(code: string): Promise<GiftCardBalance>;
564
571
  }
565
572
  declare class AuthModule {
566
573
  private client;
@@ -597,6 +604,10 @@ declare class CartModule {
597
604
  removeItem(itemId: string): Promise<Cart>;
598
605
  /** Clear entire cart */
599
606
  clear(): Promise<void>;
607
+ /** Apply a gift card code to the cart. Balance is deducted at checkout. */
608
+ applyGiftCard(code: string): Promise<Cart>;
609
+ /** Remove a gift card from the cart */
610
+ removeGiftCard(): Promise<Cart>;
600
611
  /** Add a bundle to the cart (price is locked at the bundle's current price) */
601
612
  addBundle(bundleId: string, quantity?: number): Promise<Cart>;
602
613
  /** Update quantity of a bundle already in the cart */
@@ -662,4 +673,4 @@ declare class PagesModule {
662
673
  get(slug: string, locale?: string): Promise<PageDetail>;
663
674
  }
664
675
 
665
- export { type ActivePromotion, type AddToCartInput, type AddressType, AddressTypes, type AuthTokens, BehioApiError, type BehioErrorCode, type BehioEventHandler, type BehioEventType, BehioNetworkError, BehioStorefront, type BehioStorefrontConfig, type Bundle, type BundleItem, type Cart, type CartDiscount, type CartItem, type CartItemProduct, type Category, type CategoryDetail, type CheckoutAddress, type CheckoutInput, type CrossSellItem, type CustomerAddress, type CustomerProfile, type DataGroupFieldType, type FilterField, type FulfillmentStatus, FulfillmentStatuses, type LoginInput, type MessageResponse, type OrderDetail, type OrderItem, type OrderListItem, type OrderStatus, type OrderStatusHistory, OrderStatuses, type Page, type PageDetail, type PaginatedResponse, type PaymentStatus, PaymentStatuses, type ProductDetail, type ProductLabel, type ProductListItem, type ProductPrice, ProductSort, type ProductSortValue, type ProductVariant, type ProductVolumePrice, type ProductsQuery, type RegisterInput, type RequestInterceptor, type RequestInterceptorConfig, type ResponseInterceptor, type ResponseInterceptorData, type ShopInfo, type ShopSeo };
676
+ export { type ActivePromotion, type AddToCartInput, type AddressType, AddressTypes, type AuthTokens, BehioApiError, type BehioErrorCode, type BehioEventHandler, type BehioEventType, BehioNetworkError, BehioStorefront, type BehioStorefrontConfig, type Bundle, type BundleItem, type Cart, type CartDiscount, type CartItem, type CartItemProduct, type Category, type CategoryDetail, type CheckoutAddress, type CheckoutInput, type CrossSellItem, type CustomerAddress, type CustomerProfile, type DataGroupFieldType, type FilterField, type FulfillmentStatus, FulfillmentStatuses, type GiftCardBalance, type LoginInput, type MessageResponse, type OrderDetail, type OrderItem, type OrderListItem, type OrderStatus, type OrderStatusHistory, OrderStatuses, type Page, type PageDetail, type PaginatedResponse, type PaymentStatus, PaymentStatuses, type ProductDetail, type ProductLabel, type ProductListItem, type ProductPrice, ProductSort, type ProductSortValue, type ProductVariant, type ProductVolumePrice, type ProductsQuery, type RegisterInput, type RequestInterceptor, type RequestInterceptorConfig, type ResponseInterceptor, type ResponseInterceptorData, type ShopInfo, type ShopSeo };
package/dist/index.d.ts CHANGED
@@ -436,6 +436,11 @@ interface ActivePromotion {
436
436
  showCountdown: boolean;
437
437
  couponRequired: boolean;
438
438
  }
439
+ interface GiftCardBalance {
440
+ valid: boolean;
441
+ balance: number;
442
+ currency: string;
443
+ }
439
444
 
440
445
  declare class BehioStorefront {
441
446
  private baseUrl;
@@ -561,6 +566,8 @@ declare class CatalogModule {
561
566
  getProductPromotions(productSlug: string): Promise<{
562
567
  items: ActivePromotion[];
563
568
  }>;
569
+ /** Check a gift card code — returns validity and remaining balance */
570
+ checkGiftCard(code: string): Promise<GiftCardBalance>;
564
571
  }
565
572
  declare class AuthModule {
566
573
  private client;
@@ -597,6 +604,10 @@ declare class CartModule {
597
604
  removeItem(itemId: string): Promise<Cart>;
598
605
  /** Clear entire cart */
599
606
  clear(): Promise<void>;
607
+ /** Apply a gift card code to the cart. Balance is deducted at checkout. */
608
+ applyGiftCard(code: string): Promise<Cart>;
609
+ /** Remove a gift card from the cart */
610
+ removeGiftCard(): Promise<Cart>;
600
611
  /** Add a bundle to the cart (price is locked at the bundle's current price) */
601
612
  addBundle(bundleId: string, quantity?: number): Promise<Cart>;
602
613
  /** Update quantity of a bundle already in the cart */
@@ -662,4 +673,4 @@ declare class PagesModule {
662
673
  get(slug: string, locale?: string): Promise<PageDetail>;
663
674
  }
664
675
 
665
- export { type ActivePromotion, type AddToCartInput, type AddressType, AddressTypes, type AuthTokens, BehioApiError, type BehioErrorCode, type BehioEventHandler, type BehioEventType, BehioNetworkError, BehioStorefront, type BehioStorefrontConfig, type Bundle, type BundleItem, type Cart, type CartDiscount, type CartItem, type CartItemProduct, type Category, type CategoryDetail, type CheckoutAddress, type CheckoutInput, type CrossSellItem, type CustomerAddress, type CustomerProfile, type DataGroupFieldType, type FilterField, type FulfillmentStatus, FulfillmentStatuses, type LoginInput, type MessageResponse, type OrderDetail, type OrderItem, type OrderListItem, type OrderStatus, type OrderStatusHistory, OrderStatuses, type Page, type PageDetail, type PaginatedResponse, type PaymentStatus, PaymentStatuses, type ProductDetail, type ProductLabel, type ProductListItem, type ProductPrice, ProductSort, type ProductSortValue, type ProductVariant, type ProductVolumePrice, type ProductsQuery, type RegisterInput, type RequestInterceptor, type RequestInterceptorConfig, type ResponseInterceptor, type ResponseInterceptorData, type ShopInfo, type ShopSeo };
676
+ export { type ActivePromotion, type AddToCartInput, type AddressType, AddressTypes, type AuthTokens, BehioApiError, type BehioErrorCode, type BehioEventHandler, type BehioEventType, BehioNetworkError, BehioStorefront, type BehioStorefrontConfig, type Bundle, type BundleItem, type Cart, type CartDiscount, type CartItem, type CartItemProduct, type Category, type CategoryDetail, type CheckoutAddress, type CheckoutInput, type CrossSellItem, type CustomerAddress, type CustomerProfile, type DataGroupFieldType, type FilterField, type FulfillmentStatus, FulfillmentStatuses, type GiftCardBalance, type LoginInput, type MessageResponse, type OrderDetail, type OrderItem, type OrderListItem, type OrderStatus, type OrderStatusHistory, OrderStatuses, type Page, type PageDetail, type PaginatedResponse, type PaymentStatus, PaymentStatuses, type ProductDetail, type ProductLabel, type ProductListItem, type ProductPrice, ProductSort, type ProductSortValue, type ProductVariant, type ProductVolumePrice, type ProductsQuery, type RegisterInput, type RequestInterceptor, type RequestInterceptorConfig, type ResponseInterceptor, type ResponseInterceptorData, type ShopInfo, type ShopSeo };
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkQOEYSUF2js = require('./chunk-QOEYSUF2.js');
10
+ var _chunk33DUMF3Njs = require('./chunk-33DUMF3N.js');
11
11
 
12
12
 
13
13
 
@@ -17,4 +17,4 @@ var _chunkQOEYSUF2js = require('./chunk-QOEYSUF2.js');
17
17
 
18
18
 
19
19
 
20
- exports.AddressTypes = _chunkQOEYSUF2js.AddressTypes; exports.BehioApiError = _chunkQOEYSUF2js.BehioApiError; exports.BehioNetworkError = _chunkQOEYSUF2js.BehioNetworkError; exports.BehioStorefront = _chunkQOEYSUF2js.BehioStorefront; exports.FulfillmentStatuses = _chunkQOEYSUF2js.FulfillmentStatuses; exports.OrderStatuses = _chunkQOEYSUF2js.OrderStatuses; exports.PaymentStatuses = _chunkQOEYSUF2js.PaymentStatuses; exports.ProductSort = _chunkQOEYSUF2js.ProductSort;
20
+ exports.AddressTypes = _chunk33DUMF3Njs.AddressTypes; exports.BehioApiError = _chunk33DUMF3Njs.BehioApiError; exports.BehioNetworkError = _chunk33DUMF3Njs.BehioNetworkError; exports.BehioStorefront = _chunk33DUMF3Njs.BehioStorefront; exports.FulfillmentStatuses = _chunk33DUMF3Njs.FulfillmentStatuses; exports.OrderStatuses = _chunk33DUMF3Njs.OrderStatuses; exports.PaymentStatuses = _chunk33DUMF3Njs.PaymentStatuses; exports.ProductSort = _chunk33DUMF3Njs.ProductSort;
package/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  OrderStatuses,
8
8
  PaymentStatuses,
9
9
  ProductSort
10
- } from "./chunk-HYKJO2IB.mjs";
10
+ } from "./chunk-WMBSTKJR.mjs";
11
11
  export {
12
12
  AddressTypes,
13
13
  BehioApiError,
package/dist/react.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as _tanstack_react_query from '@tanstack/react-query';
3
3
  import { QueryClient } from '@tanstack/react-query';
4
- import { BehioStorefront, ProductsQuery, PaginatedResponse, ProductListItem, ProductDetail, Category, CategoryDetail, ProductLabel, FilterField, Cart, CustomerProfile, RegisterInput, CustomerAddress, OrderListItem, OrderDetail, CheckoutInput, PageDetail, Page, ShopInfo, ShopSeo, Bundle, CrossSellItem, ActivePromotion } from './index.mjs';
4
+ import { BehioStorefront, ProductsQuery, PaginatedResponse, ProductListItem, ProductDetail, Category, CategoryDetail, ProductLabel, FilterField, Cart, CustomerProfile, RegisterInput, CustomerAddress, OrderListItem, OrderDetail, CheckoutInput, PageDetail, Page, ShopInfo, ShopSeo, Bundle, CrossSellItem, ActivePromotion, GiftCardBalance } from './index.mjs';
5
5
  export { AddToCartInput, AuthTokens, BehioApiError, BundleItem, CartDiscount, CartItem, CheckoutAddress, FulfillmentStatus, LoginInput, MessageResponse, OrderItem, OrderStatus, PaymentStatus, ProductPrice, ProductVariant } from './index.mjs';
6
6
  import * as _tanstack_query_core from '@tanstack/query-core';
7
7
 
@@ -321,6 +321,19 @@ declare function useProductPromotions(productSlug: string | undefined, options?:
321
321
  items: ActivePromotion[];
322
322
  }, Error>;
323
323
 
324
+ /**
325
+ * Check a gift card code — validates the code against the eshop and
326
+ * returns remaining balance + currency. Use on the cart page to show
327
+ * "Gift card GC-XXXX: 350 CZK remaining" before checkout.
328
+ *
329
+ * The hook is intentionally disabled when code is empty/undefined so
330
+ * it doesn't fire unnecessary requests. Pass the code only after the
331
+ * user finishes typing (debounce recommended).
332
+ */
333
+ declare function useGiftCardBalance(code: string | undefined, options?: {
334
+ enabled?: boolean;
335
+ }): _tanstack_react_query.UseQueryResult<GiftCardBalance, Error>;
336
+
324
337
  /**
325
338
  * Returns the raw BehioStorefront client instance.
326
339
  *
@@ -339,4 +352,4 @@ declare function useBehioClient(): BehioStorefront;
339
352
  */
340
353
  declare function formatPrice(amount: number, currency: string, locale?: string): string;
341
354
 
342
- export { ActivePromotion, BehioProvider, type BehioProviderProps, Bundle, Cart, Category, CategoryDetail, CheckoutInput, CrossSellItem, CustomerAddress, CustomerProfile, FilterField, OrderDetail, OrderListItem, Page, PageDetail, PaginatedResponse, ProductDetail, ProductLabel, ProductListItem, ProductsQuery, RegisterInput, ShopInfo, ShopSeo, type StorageAdapter, type UseAddressesOptions, type UseCartCountOptions, type UseCartOptions, type UseCategoriesOptions, type UseCategoryOptions, type UseCustomerOptions, type UseFeaturedOptions, type UseFiltersOptions, type UseLabelsOptions, type UseOrderOptions, type UseOrdersOptions, type UsePageOptions, type UsePagesOptions, type UseProductOptions, type UseProductsOptions, type UseSearchOptions, type UseShopInfoOptions, type UseShopSeoOptions, cookieStorage, createMemoryStorage, detectStorage, formatPrice, localStorageAdapter, memoryStorage, useAddresses, useAuth, useBehio, useBehioClient, useBundle, useBundles, useCart, useCartCount, useCategories, useCategory, useCheckout, useCrossSell, useCustomer, useFeatured, useFilters, useLabels, useOrder, useOrders, usePage, usePages, useProduct, useProductPromotions, useProducts, useSearch, useShopInfo, useShopSeo };
355
+ export { ActivePromotion, BehioProvider, type BehioProviderProps, Bundle, Cart, Category, CategoryDetail, CheckoutInput, CrossSellItem, CustomerAddress, CustomerProfile, FilterField, GiftCardBalance, OrderDetail, OrderListItem, Page, PageDetail, PaginatedResponse, ProductDetail, ProductLabel, ProductListItem, ProductsQuery, RegisterInput, ShopInfo, ShopSeo, type StorageAdapter, type UseAddressesOptions, type UseCartCountOptions, type UseCartOptions, type UseCategoriesOptions, type UseCategoryOptions, type UseCustomerOptions, type UseFeaturedOptions, type UseFiltersOptions, type UseLabelsOptions, type UseOrderOptions, type UseOrdersOptions, type UsePageOptions, type UsePagesOptions, type UseProductOptions, type UseProductsOptions, type UseSearchOptions, type UseShopInfoOptions, type UseShopSeoOptions, cookieStorage, createMemoryStorage, detectStorage, formatPrice, localStorageAdapter, memoryStorage, useAddresses, useAuth, useBehio, useBehioClient, useBundle, useBundles, useCart, useCartCount, useCategories, useCategory, useCheckout, useCrossSell, useCustomer, useFeatured, useFilters, useGiftCardBalance, useLabels, useOrder, useOrders, usePage, usePages, useProduct, useProductPromotions, useProducts, useSearch, useShopInfo, useShopSeo };
package/dist/react.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as _tanstack_react_query from '@tanstack/react-query';
3
3
  import { QueryClient } from '@tanstack/react-query';
4
- import { BehioStorefront, ProductsQuery, PaginatedResponse, ProductListItem, ProductDetail, Category, CategoryDetail, ProductLabel, FilterField, Cart, CustomerProfile, RegisterInput, CustomerAddress, OrderListItem, OrderDetail, CheckoutInput, PageDetail, Page, ShopInfo, ShopSeo, Bundle, CrossSellItem, ActivePromotion } from './index.js';
4
+ import { BehioStorefront, ProductsQuery, PaginatedResponse, ProductListItem, ProductDetail, Category, CategoryDetail, ProductLabel, FilterField, Cart, CustomerProfile, RegisterInput, CustomerAddress, OrderListItem, OrderDetail, CheckoutInput, PageDetail, Page, ShopInfo, ShopSeo, Bundle, CrossSellItem, ActivePromotion, GiftCardBalance } from './index.js';
5
5
  export { AddToCartInput, AuthTokens, BehioApiError, BundleItem, CartDiscount, CartItem, CheckoutAddress, FulfillmentStatus, LoginInput, MessageResponse, OrderItem, OrderStatus, PaymentStatus, ProductPrice, ProductVariant } from './index.js';
6
6
  import * as _tanstack_query_core from '@tanstack/query-core';
7
7
 
@@ -321,6 +321,19 @@ declare function useProductPromotions(productSlug: string | undefined, options?:
321
321
  items: ActivePromotion[];
322
322
  }, Error>;
323
323
 
324
+ /**
325
+ * Check a gift card code — validates the code against the eshop and
326
+ * returns remaining balance + currency. Use on the cart page to show
327
+ * "Gift card GC-XXXX: 350 CZK remaining" before checkout.
328
+ *
329
+ * The hook is intentionally disabled when code is empty/undefined so
330
+ * it doesn't fire unnecessary requests. Pass the code only after the
331
+ * user finishes typing (debounce recommended).
332
+ */
333
+ declare function useGiftCardBalance(code: string | undefined, options?: {
334
+ enabled?: boolean;
335
+ }): _tanstack_react_query.UseQueryResult<GiftCardBalance, Error>;
336
+
324
337
  /**
325
338
  * Returns the raw BehioStorefront client instance.
326
339
  *
@@ -339,4 +352,4 @@ declare function useBehioClient(): BehioStorefront;
339
352
  */
340
353
  declare function formatPrice(amount: number, currency: string, locale?: string): string;
341
354
 
342
- export { ActivePromotion, BehioProvider, type BehioProviderProps, Bundle, Cart, Category, CategoryDetail, CheckoutInput, CrossSellItem, CustomerAddress, CustomerProfile, FilterField, OrderDetail, OrderListItem, Page, PageDetail, PaginatedResponse, ProductDetail, ProductLabel, ProductListItem, ProductsQuery, RegisterInput, ShopInfo, ShopSeo, type StorageAdapter, type UseAddressesOptions, type UseCartCountOptions, type UseCartOptions, type UseCategoriesOptions, type UseCategoryOptions, type UseCustomerOptions, type UseFeaturedOptions, type UseFiltersOptions, type UseLabelsOptions, type UseOrderOptions, type UseOrdersOptions, type UsePageOptions, type UsePagesOptions, type UseProductOptions, type UseProductsOptions, type UseSearchOptions, type UseShopInfoOptions, type UseShopSeoOptions, cookieStorage, createMemoryStorage, detectStorage, formatPrice, localStorageAdapter, memoryStorage, useAddresses, useAuth, useBehio, useBehioClient, useBundle, useBundles, useCart, useCartCount, useCategories, useCategory, useCheckout, useCrossSell, useCustomer, useFeatured, useFilters, useLabels, useOrder, useOrders, usePage, usePages, useProduct, useProductPromotions, useProducts, useSearch, useShopInfo, useShopSeo };
355
+ export { ActivePromotion, BehioProvider, type BehioProviderProps, Bundle, Cart, Category, CategoryDetail, CheckoutInput, CrossSellItem, CustomerAddress, CustomerProfile, FilterField, GiftCardBalance, OrderDetail, OrderListItem, Page, PageDetail, PaginatedResponse, ProductDetail, ProductLabel, ProductListItem, ProductsQuery, RegisterInput, ShopInfo, ShopSeo, type StorageAdapter, type UseAddressesOptions, type UseCartCountOptions, type UseCartOptions, type UseCategoriesOptions, type UseCategoryOptions, type UseCustomerOptions, type UseFeaturedOptions, type UseFiltersOptions, type UseLabelsOptions, type UseOrderOptions, type UseOrdersOptions, type UsePageOptions, type UsePagesOptions, type UseProductOptions, type UseProductsOptions, type UseSearchOptions, type UseShopInfoOptions, type UseShopSeoOptions, cookieStorage, createMemoryStorage, detectStorage, formatPrice, localStorageAdapter, memoryStorage, useAddresses, useAuth, useBehio, useBehioClient, useBundle, useBundles, useCart, useCartCount, useCategories, useCategory, useCheckout, useCrossSell, useCustomer, useFeatured, useFilters, useGiftCardBalance, useLabels, useOrder, useOrders, usePage, usePages, useProduct, useProductPromotions, useProducts, useSearch, useShopInfo, useShopSeo };
package/dist/react.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkQOEYSUF2js = require('./chunk-QOEYSUF2.js');
3
+ var _chunk33DUMF3Njs = require('./chunk-33DUMF3N.js');
4
4
 
5
5
  // src/react/provider.tsx
6
6
  var _react = require('react');
@@ -114,7 +114,7 @@ function BehioProvider({
114
114
  const storageAdapter = _react.useMemo.call(void 0, () => resolveStorage(storageOption), [storageOption]);
115
115
  const clientRef = _react.useRef.call(void 0, null);
116
116
  if (!clientRef.current) {
117
- clientRef.current = new (0, _chunkQOEYSUF2js.BehioStorefront)({
117
+ clientRef.current = new (0, _chunk33DUMF3Njs.BehioStorefront)({
118
118
  apiKey,
119
119
  baseUrl,
120
120
  locale,
@@ -930,6 +930,18 @@ function useProductPromotions(productSlug, options) {
930
930
  });
931
931
  }
932
932
 
933
+ // src/react/hooks/use-gift-card.ts
934
+
935
+ function useGiftCardBalance(code, options) {
936
+ const { client } = useBehio();
937
+ const trimmed = _optionalChain([code, 'optionalAccess', _68 => _68.trim, 'call', _69 => _69()]);
938
+ return _reactquery.useQuery.call(void 0, {
939
+ queryKey: ["behio", "gift-card-balance", trimmed],
940
+ queryFn: () => client.catalog.checkGiftCard(trimmed),
941
+ enabled: Boolean(trimmed && trimmed.length >= 6) && (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _70 => _70.enabled]), () => ( true)))
942
+ });
943
+ }
944
+
933
945
  // src/react/hooks/use-behio-client.ts
934
946
  function useBehioClient() {
935
947
  return useBehio().client;
@@ -983,4 +995,5 @@ function formatPrice(amount, currency, locale) {
983
995
 
984
996
 
985
997
 
986
- exports.BehioProvider = BehioProvider; exports.cookieStorage = cookieStorage; exports.createMemoryStorage = createMemoryStorage; exports.detectStorage = detectStorage; exports.formatPrice = formatPrice; exports.localStorageAdapter = localStorageAdapter; exports.memoryStorage = memoryStorage; exports.useAddresses = useAddresses; exports.useAuth = useAuth; exports.useBehio = useBehio; exports.useBehioClient = useBehioClient; exports.useBundle = useBundle; exports.useBundles = useBundles; exports.useCart = useCart; exports.useCartCount = useCartCount; exports.useCategories = useCategories; exports.useCategory = useCategory; exports.useCheckout = useCheckout; exports.useCrossSell = useCrossSell; exports.useCustomer = useCustomer; exports.useFeatured = useFeatured; exports.useFilters = useFilters; exports.useLabels = useLabels; exports.useOrder = useOrder; exports.useOrders = useOrders; exports.usePage = usePage; exports.usePages = usePages; exports.useProduct = useProduct; exports.useProductPromotions = useProductPromotions; exports.useProducts = useProducts; exports.useSearch = useSearch; exports.useShopInfo = useShopInfo; exports.useShopSeo = useShopSeo;
998
+
999
+ exports.BehioProvider = BehioProvider; exports.cookieStorage = cookieStorage; exports.createMemoryStorage = createMemoryStorage; exports.detectStorage = detectStorage; exports.formatPrice = formatPrice; exports.localStorageAdapter = localStorageAdapter; exports.memoryStorage = memoryStorage; exports.useAddresses = useAddresses; exports.useAuth = useAuth; exports.useBehio = useBehio; exports.useBehioClient = useBehioClient; exports.useBundle = useBundle; exports.useBundles = useBundles; exports.useCart = useCart; exports.useCartCount = useCartCount; exports.useCategories = useCategories; exports.useCategory = useCategory; exports.useCheckout = useCheckout; exports.useCrossSell = useCrossSell; exports.useCustomer = useCustomer; exports.useFeatured = useFeatured; exports.useFilters = useFilters; exports.useGiftCardBalance = useGiftCardBalance; exports.useLabels = useLabels; exports.useOrder = useOrder; exports.useOrders = useOrders; exports.usePage = usePage; exports.usePages = usePages; exports.useProduct = useProduct; exports.useProductPromotions = useProductPromotions; exports.useProducts = useProducts; exports.useSearch = useSearch; exports.useShopInfo = useShopInfo; exports.useShopSeo = useShopSeo;
package/dist/react.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BehioStorefront
3
- } from "./chunk-HYKJO2IB.mjs";
3
+ } from "./chunk-WMBSTKJR.mjs";
4
4
 
5
5
  // src/react/provider.tsx
6
6
  import { useRef, useEffect, useMemo } from "react";
@@ -930,6 +930,18 @@ function useProductPromotions(productSlug, options) {
930
930
  });
931
931
  }
932
932
 
933
+ // src/react/hooks/use-gift-card.ts
934
+ import { useQuery as useQuery19 } from "@tanstack/react-query";
935
+ function useGiftCardBalance(code, options) {
936
+ const { client } = useBehio();
937
+ const trimmed = code?.trim();
938
+ return useQuery19({
939
+ queryKey: ["behio", "gift-card-balance", trimmed],
940
+ queryFn: () => client.catalog.checkGiftCard(trimmed),
941
+ enabled: Boolean(trimmed && trimmed.length >= 6) && (options?.enabled ?? true)
942
+ });
943
+ }
944
+
933
945
  // src/react/hooks/use-behio-client.ts
934
946
  function useBehioClient() {
935
947
  return useBehio().client;
@@ -972,6 +984,7 @@ export {
972
984
  useCustomer,
973
985
  useFeatured,
974
986
  useFilters,
987
+ useGiftCardBalance,
975
988
  useLabels,
976
989
  useOrder,
977
990
  useOrders,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@behio/storefront-sdk",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "TypeScript SDK for Behio Headless E-Shop — core client + React hooks",
5
5
  "author": "Behio",
6
6
  "license": "MIT",