@storepecker/storefront-core 1.0.0 → 1.1.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/api/index.cjs +17 -17
- package/dist/api/index.d.cts +4 -5
- package/dist/api/index.d.ts +4 -5
- package/dist/api/index.js +1 -1
- package/dist/{booking-ClX-dhX7.d.ts → booking-Bo_tELLX.d.ts} +1 -1
- package/dist/{booking-Drl7-IL7.d.cts → booking-Dd877kxd.d.cts} +1 -1
- package/dist/{cart-DVrn8hD0.d.cts → cart-D8UXTY1g.d.cts} +51 -1
- package/dist/{cart-DVrn8hD0.d.ts → cart-D8UXTY1g.d.ts} +51 -1
- package/dist/checkout/index.d.cts +2 -3
- package/dist/checkout/index.d.ts +2 -3
- package/dist/{chunk-RCXQJ6XC.cjs → chunk-34KV265H.cjs} +2 -1
- package/dist/{chunk-7MQOVWLW.js → chunk-7DQIKSGY.js} +3 -3
- package/dist/{chunk-GH75WUO2.cjs → chunk-S3WIGYDS.cjs} +4 -4
- package/dist/{chunk-57ZBPAXU.js → chunk-Z7LHRD3V.js} +2 -1
- package/dist/hooks/index.cjs +86 -28
- package/dist/hooks/index.d.cts +21 -7
- package/dist/hooks/index.d.ts +21 -7
- package/dist/hooks/index.js +82 -24
- package/dist/models/index.d.cts +4 -5
- package/dist/models/index.d.ts +4 -5
- package/dist/{orders-CkUzv5Xh.d.ts → orders-DHJhJ3xz.d.cts} +1 -18
- package/dist/{orders-D0oC9ugD.d.cts → orders-DHJhJ3xz.d.ts} +1 -18
- package/dist/store/index.cjs +7 -7
- package/dist/store/index.d.cts +3 -3
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +3 -3
- package/dist/utils/index.d.cts +3 -3
- package/dist/utils/index.d.ts +3 -3
- package/dist/{wishlist-BzhnCAQD.d.ts → wishlist-BMWfB0Xe.d.ts} +1 -1
- package/dist/{wishlist-CBCZD66Y.d.cts → wishlist-C3SK9SS0.d.cts} +1 -1
- package/package.json +6 -1
- package/dist/coupons-C7iJ-1cy.d.cts +0 -37
- package/dist/coupons-CnfTKL1i.d.ts +0 -37
package/dist/api/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkKWKHHRRJ_cjs = require('../chunk-KWKHHRRJ.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunk34KV265H_cjs = require('../chunk-34KV265H.cjs');
|
|
5
5
|
require('../chunk-CFF632IQ.cjs');
|
|
6
6
|
var chunkA6IO3HIN_cjs = require('../chunk-A6IO3HIN.cjs');
|
|
7
7
|
var chunkJHGXIIBZ_cjs = require('../chunk-JHGXIIBZ.cjs');
|
|
@@ -143,67 +143,67 @@ Object.defineProperty(exports, "updateUserDetails", {
|
|
|
143
143
|
});
|
|
144
144
|
Object.defineProperty(exports, "addToCart", {
|
|
145
145
|
enumerable: true,
|
|
146
|
-
get: function () { return
|
|
146
|
+
get: function () { return chunk34KV265H_cjs.addToCart; }
|
|
147
147
|
});
|
|
148
148
|
Object.defineProperty(exports, "addWishlist", {
|
|
149
149
|
enumerable: true,
|
|
150
|
-
get: function () { return
|
|
150
|
+
get: function () { return chunk34KV265H_cjs.addWishlist; }
|
|
151
151
|
});
|
|
152
152
|
Object.defineProperty(exports, "getCart", {
|
|
153
153
|
enumerable: true,
|
|
154
|
-
get: function () { return
|
|
154
|
+
get: function () { return chunk34KV265H_cjs.getCart; }
|
|
155
155
|
});
|
|
156
156
|
Object.defineProperty(exports, "getCategories", {
|
|
157
157
|
enumerable: true,
|
|
158
|
-
get: function () { return
|
|
158
|
+
get: function () { return chunk34KV265H_cjs.getCategories; }
|
|
159
159
|
});
|
|
160
160
|
Object.defineProperty(exports, "getDigitalProductDownloadLink", {
|
|
161
161
|
enumerable: true,
|
|
162
|
-
get: function () { return
|
|
162
|
+
get: function () { return chunk34KV265H_cjs.getDigitalProductDownloadLink; }
|
|
163
163
|
});
|
|
164
164
|
Object.defineProperty(exports, "getProductCategories", {
|
|
165
165
|
enumerable: true,
|
|
166
|
-
get: function () { return
|
|
166
|
+
get: function () { return chunk34KV265H_cjs.getProductCategories; }
|
|
167
167
|
});
|
|
168
168
|
Object.defineProperty(exports, "getProductDetail", {
|
|
169
169
|
enumerable: true,
|
|
170
|
-
get: function () { return
|
|
170
|
+
get: function () { return chunk34KV265H_cjs.getProductDetail; }
|
|
171
171
|
});
|
|
172
172
|
Object.defineProperty(exports, "getProductDetailBySlug", {
|
|
173
173
|
enumerable: true,
|
|
174
|
-
get: function () { return
|
|
174
|
+
get: function () { return chunk34KV265H_cjs.getProductDetailBySlug; }
|
|
175
175
|
});
|
|
176
176
|
Object.defineProperty(exports, "getProductList", {
|
|
177
177
|
enumerable: true,
|
|
178
|
-
get: function () { return
|
|
178
|
+
get: function () { return chunk34KV265H_cjs.getProductList; }
|
|
179
179
|
});
|
|
180
180
|
Object.defineProperty(exports, "getProducts", {
|
|
181
181
|
enumerable: true,
|
|
182
|
-
get: function () { return
|
|
182
|
+
get: function () { return chunk34KV265H_cjs.getProducts; }
|
|
183
183
|
});
|
|
184
184
|
Object.defineProperty(exports, "getWishlist", {
|
|
185
185
|
enumerable: true,
|
|
186
|
-
get: function () { return
|
|
186
|
+
get: function () { return chunk34KV265H_cjs.getWishlist; }
|
|
187
187
|
});
|
|
188
188
|
Object.defineProperty(exports, "notifyProductStock", {
|
|
189
189
|
enumerable: true,
|
|
190
|
-
get: function () { return
|
|
190
|
+
get: function () { return chunk34KV265H_cjs.notifyProductStock; }
|
|
191
191
|
});
|
|
192
192
|
Object.defineProperty(exports, "removeFromCart", {
|
|
193
193
|
enumerable: true,
|
|
194
|
-
get: function () { return
|
|
194
|
+
get: function () { return chunk34KV265H_cjs.removeFromCart; }
|
|
195
195
|
});
|
|
196
196
|
Object.defineProperty(exports, "removeFromWishlist", {
|
|
197
197
|
enumerable: true,
|
|
198
|
-
get: function () { return
|
|
198
|
+
get: function () { return chunk34KV265H_cjs.removeFromWishlist; }
|
|
199
199
|
});
|
|
200
200
|
Object.defineProperty(exports, "updateCart", {
|
|
201
201
|
enumerable: true,
|
|
202
|
-
get: function () { return
|
|
202
|
+
get: function () { return chunk34KV265H_cjs.updateCart; }
|
|
203
203
|
});
|
|
204
204
|
Object.defineProperty(exports, "updateDigitalProductDownloadLinkCount", {
|
|
205
205
|
enumerable: true,
|
|
206
|
-
get: function () { return
|
|
206
|
+
get: function () { return chunk34KV265H_cjs.updateDigitalProductDownloadLinkCount; }
|
|
207
207
|
});
|
|
208
208
|
Object.defineProperty(exports, "applyCoupon", {
|
|
209
209
|
enumerable: true,
|
package/dist/api/index.d.cts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as axios from 'axios';
|
|
2
2
|
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
3
3
|
import { A as Address } from '../address-DQEZzyUG.cjs';
|
|
4
|
-
import { U as User, W as Wishlist } from '../wishlist-
|
|
5
|
-
import { C as Cart,
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { C as CollectionResponse, R as Review, A as Analytics, B as Booking } from '../booking-Drl7-IL7.cjs';
|
|
4
|
+
import { U as User, W as Wishlist } from '../wishlist-C3SK9SS0.cjs';
|
|
5
|
+
import { C as Cart, j as Product, f as CouponResponse, e as Coupon, d as Category, k as ProductDetail } from '../cart-D8UXTY1g.cjs';
|
|
6
|
+
import { O as Order } from '../orders-DHJhJ3xz.cjs';
|
|
7
|
+
import { C as CollectionResponse, R as Review, A as Analytics, B as Booking } from '../booking-Dd877kxd.cjs';
|
|
9
8
|
import 'react-toastify';
|
|
10
9
|
|
|
11
10
|
declare function getHttpService(): AxiosInstance;
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as axios from 'axios';
|
|
2
2
|
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
3
3
|
import { A as Address } from '../address-DQEZzyUG.js';
|
|
4
|
-
import { U as User, W as Wishlist } from '../wishlist-
|
|
5
|
-
import { C as Cart,
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { C as CollectionResponse, R as Review, A as Analytics, B as Booking } from '../booking-ClX-dhX7.js';
|
|
4
|
+
import { U as User, W as Wishlist } from '../wishlist-BMWfB0Xe.js';
|
|
5
|
+
import { C as Cart, j as Product, f as CouponResponse, e as Coupon, d as Category, k as ProductDetail } from '../cart-D8UXTY1g.js';
|
|
6
|
+
import { O as Order } from '../orders-DHJhJ3xz.js';
|
|
7
|
+
import { C as CollectionResponse, R as Review, A as Analytics, B as Booking } from '../booking-Bo_tELLX.js';
|
|
9
8
|
import 'react-toastify';
|
|
10
9
|
|
|
11
10
|
declare function getHttpService(): AxiosInstance;
|
package/dist/api/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getUserDetails, updateUserDetails } from '../chunk-7UH6REGV.js';
|
|
2
|
-
export { addToCart, addWishlist, getCart, getCategories, getDigitalProductDownloadLink, getProductCategories, getProductDetail, getProductDetailBySlug, getProductList, getProducts, getWishlist, notifyProductStock, removeFromCart, removeFromWishlist, updateCart, updateDigitalProductDownloadLinkCount } from '../chunk-
|
|
2
|
+
export { addToCart, addWishlist, getCart, getCategories, getDigitalProductDownloadLink, getProductCategories, getProductDetail, getProductDetailBySlug, getProductList, getProducts, getWishlist, notifyProductStock, removeFromCart, removeFromWishlist, updateCart, updateDigitalProductDownloadLinkCount } from '../chunk-Z7LHRD3V.js';
|
|
3
3
|
import '../chunk-E7WPE3PV.js';
|
|
4
4
|
export { applyCoupon, checkPhonepePaymentStatus, getAppliedCoupon, getCoupons, getOrderDetails, getOrderDetailsByNumber, getOrders, getPublicOrderDetailsByNumber, getStripePaymentStatus, getStripePaymentStatusPublic, makeCODOrder, phonepeOrderSuccess, phonepePublicOrderSuccess, placeOrder, publicMakeCODOrder, publicPlaceOrder, razorpayOrderFail, razorpayOrderSuccess, razorpayPublicOrderSuccess, removeCoupon, stripeOrderFail, stripeOrderSuccess, stripePublicOrderSuccess, updateOrder, updateOrderCustomization, uploadCustomizationImage, verifyTabbyPayment } from '../chunk-4MJMNIAB.js';
|
|
5
5
|
export { addAddress, deleteAddress, getAddresses, getCountries, getSubdivisions, updateAddress } from '../chunk-LBGIUNM6.js';
|
|
@@ -327,6 +327,55 @@ interface TimeSlot {
|
|
|
327
327
|
interface SpecialHours {
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
+
declare namespace Category {
|
|
331
|
+
interface Root {
|
|
332
|
+
id: number;
|
|
333
|
+
name: string;
|
|
334
|
+
photo: string;
|
|
335
|
+
slug: string;
|
|
336
|
+
description: string;
|
|
337
|
+
children?: Root[];
|
|
338
|
+
}
|
|
339
|
+
interface CategoriesState {
|
|
340
|
+
data: Root[];
|
|
341
|
+
status: SLICE_STATUS;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
type DiscountType = "discount";
|
|
346
|
+
type ValueType = "percentage" | "fixed";
|
|
347
|
+
type ApplicableTarget = "product_category" | "product_variant" | "product_bundle" | "customer";
|
|
348
|
+
type CouponStatus = "active" | "inactive" | "expired";
|
|
349
|
+
interface Coupon {
|
|
350
|
+
id: number;
|
|
351
|
+
coupon_code: string;
|
|
352
|
+
discount_type: DiscountType;
|
|
353
|
+
value: string;
|
|
354
|
+
value_type: ValueType;
|
|
355
|
+
min_order_amount: string;
|
|
356
|
+
max_discount_amount: string;
|
|
357
|
+
start_date: string;
|
|
358
|
+
end_date: string;
|
|
359
|
+
status: CouponStatus;
|
|
360
|
+
is_deleted: boolean;
|
|
361
|
+
usage_limit: number;
|
|
362
|
+
usage_count: number;
|
|
363
|
+
applicable_target: ApplicableTarget;
|
|
364
|
+
applicable_product_variants: any[];
|
|
365
|
+
applicable_product_bundles: any[];
|
|
366
|
+
applicable_product_categories: Category.Root[];
|
|
367
|
+
applicable_customers: any[];
|
|
368
|
+
auto_apply: boolean;
|
|
369
|
+
created_at: string;
|
|
370
|
+
updated_at: string;
|
|
371
|
+
is_cart_applicable: boolean;
|
|
372
|
+
coupon_message: string;
|
|
373
|
+
}
|
|
374
|
+
type Coupons = Coupon[];
|
|
375
|
+
interface CouponResponse {
|
|
376
|
+
coupon: Coupon;
|
|
377
|
+
}
|
|
378
|
+
|
|
330
379
|
interface CartState {
|
|
331
380
|
cart: Cart.Root | null;
|
|
332
381
|
status: SLICE_STATUS;
|
|
@@ -346,6 +395,7 @@ declare namespace Cart {
|
|
|
346
395
|
};
|
|
347
396
|
total_shipping: number;
|
|
348
397
|
total_tax_amount: number;
|
|
398
|
+
applied_coupon: Coupon | {};
|
|
349
399
|
}
|
|
350
400
|
interface CustomizationInput {
|
|
351
401
|
id: number;
|
|
@@ -364,4 +414,4 @@ declare namespace Cart {
|
|
|
364
414
|
}
|
|
365
415
|
}
|
|
366
416
|
|
|
367
|
-
export { type
|
|
417
|
+
export { type ApplicableTarget as A, type BookingService as B, Cart as C, type DiscountType as D, type OperatingHours as O, type Photos as P, type SpecialHours as S, type TimeSlot as T, USER_CART as U, type ValueType as V, type WishlistState as W, type Attributes as a, type BookingServiceDate as b, type CartState as c, Category as d, type Coupon as e, type CouponResponse as f, type CouponStatus as g, type Coupons as h, type CustomField as i, Product as j, ProductDetail as k, SLICE_STATUS as l, ADDRESS_FORM_SESSION_KEY as m, ALLOWED_COUNTRIES as n, DEFAULT_TOAST_CONFIG as o, PRODUCT_STATUSES as p, USER_CREDENTIALS as q, USER_CRED_REFRESH_TOKEN as r, USER_CRED_TOKEN as s, pathNameMap as t };
|
|
@@ -327,6 +327,55 @@ interface TimeSlot {
|
|
|
327
327
|
interface SpecialHours {
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
+
declare namespace Category {
|
|
331
|
+
interface Root {
|
|
332
|
+
id: number;
|
|
333
|
+
name: string;
|
|
334
|
+
photo: string;
|
|
335
|
+
slug: string;
|
|
336
|
+
description: string;
|
|
337
|
+
children?: Root[];
|
|
338
|
+
}
|
|
339
|
+
interface CategoriesState {
|
|
340
|
+
data: Root[];
|
|
341
|
+
status: SLICE_STATUS;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
type DiscountType = "discount";
|
|
346
|
+
type ValueType = "percentage" | "fixed";
|
|
347
|
+
type ApplicableTarget = "product_category" | "product_variant" | "product_bundle" | "customer";
|
|
348
|
+
type CouponStatus = "active" | "inactive" | "expired";
|
|
349
|
+
interface Coupon {
|
|
350
|
+
id: number;
|
|
351
|
+
coupon_code: string;
|
|
352
|
+
discount_type: DiscountType;
|
|
353
|
+
value: string;
|
|
354
|
+
value_type: ValueType;
|
|
355
|
+
min_order_amount: string;
|
|
356
|
+
max_discount_amount: string;
|
|
357
|
+
start_date: string;
|
|
358
|
+
end_date: string;
|
|
359
|
+
status: CouponStatus;
|
|
360
|
+
is_deleted: boolean;
|
|
361
|
+
usage_limit: number;
|
|
362
|
+
usage_count: number;
|
|
363
|
+
applicable_target: ApplicableTarget;
|
|
364
|
+
applicable_product_variants: any[];
|
|
365
|
+
applicable_product_bundles: any[];
|
|
366
|
+
applicable_product_categories: Category.Root[];
|
|
367
|
+
applicable_customers: any[];
|
|
368
|
+
auto_apply: boolean;
|
|
369
|
+
created_at: string;
|
|
370
|
+
updated_at: string;
|
|
371
|
+
is_cart_applicable: boolean;
|
|
372
|
+
coupon_message: string;
|
|
373
|
+
}
|
|
374
|
+
type Coupons = Coupon[];
|
|
375
|
+
interface CouponResponse {
|
|
376
|
+
coupon: Coupon;
|
|
377
|
+
}
|
|
378
|
+
|
|
330
379
|
interface CartState {
|
|
331
380
|
cart: Cart.Root | null;
|
|
332
381
|
status: SLICE_STATUS;
|
|
@@ -346,6 +395,7 @@ declare namespace Cart {
|
|
|
346
395
|
};
|
|
347
396
|
total_shipping: number;
|
|
348
397
|
total_tax_amount: number;
|
|
398
|
+
applied_coupon: Coupon | {};
|
|
349
399
|
}
|
|
350
400
|
interface CustomizationInput {
|
|
351
401
|
id: number;
|
|
@@ -364,4 +414,4 @@ declare namespace Cart {
|
|
|
364
414
|
}
|
|
365
415
|
}
|
|
366
416
|
|
|
367
|
-
export { type
|
|
417
|
+
export { type ApplicableTarget as A, type BookingService as B, Cart as C, type DiscountType as D, type OperatingHours as O, type Photos as P, type SpecialHours as S, type TimeSlot as T, USER_CART as U, type ValueType as V, type WishlistState as W, type Attributes as a, type BookingServiceDate as b, type CartState as c, Category as d, type Coupon as e, type CouponResponse as f, type CouponStatus as g, type Coupons as h, type CustomField as i, Product as j, ProductDetail as k, SLICE_STATUS as l, ADDRESS_FORM_SESSION_KEY as m, ALLOWED_COUNTRIES as n, DEFAULT_TOAST_CONFIG as o, PRODUCT_STATUSES as p, USER_CREDENTIALS as q, USER_CRED_REFRESH_TOKEN as r, USER_CRED_TOKEN as s, pathNameMap as t };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as Yup from 'yup';
|
|
2
|
-
import { C as Cart } from '../cart-
|
|
3
|
-
import {
|
|
4
|
-
import { O as Order } from '../orders-D0oC9ugD.cjs';
|
|
2
|
+
import { C as Cart, e as Coupon } from '../cart-D8UXTY1g.cjs';
|
|
3
|
+
import { O as Order } from '../orders-DHJhJ3xz.cjs';
|
|
5
4
|
import 'react-toastify';
|
|
6
5
|
|
|
7
6
|
/**
|
package/dist/checkout/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as Yup from 'yup';
|
|
2
|
-
import { C as Cart } from '../cart-
|
|
3
|
-
import {
|
|
4
|
-
import { O as Order } from '../orders-CkUzv5Xh.js';
|
|
2
|
+
import { C as Cart, e as Coupon } from '../cart-D8UXTY1g.js';
|
|
3
|
+
import { O as Order } from '../orders-DHJhJ3xz.js';
|
|
5
4
|
import 'react-toastify';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getCart } from './chunk-
|
|
1
|
+
import { getCart } from './chunk-Z7LHRD3V.js';
|
|
2
2
|
import { create } from 'zustand';
|
|
3
3
|
|
|
4
4
|
var initialState = {
|
|
@@ -13,10 +13,10 @@ var useCartStore = create((set) => ({
|
|
|
13
13
|
if (!state.cart) return state;
|
|
14
14
|
return { cart: { ...state.cart, total_quantity: 0 } };
|
|
15
15
|
}),
|
|
16
|
-
syncCart: async () => {
|
|
16
|
+
syncCart: async (addressId) => {
|
|
17
17
|
set({ status: "loading" /* LOADING */ });
|
|
18
18
|
try {
|
|
19
|
-
const response = await getCart("/customer/cart/");
|
|
19
|
+
const response = await getCart("/customer/cart/", addressId);
|
|
20
20
|
if (response) {
|
|
21
21
|
set({ cart: response, status: "idle" /* IDLE */ });
|
|
22
22
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk34KV265H_cjs = require('./chunk-34KV265H.cjs');
|
|
4
4
|
var zustand = require('zustand');
|
|
5
5
|
|
|
6
6
|
var initialState = {
|
|
@@ -15,10 +15,10 @@ var useCartStore = zustand.create((set) => ({
|
|
|
15
15
|
if (!state.cart) return state;
|
|
16
16
|
return { cart: { ...state.cart, total_quantity: 0 } };
|
|
17
17
|
}),
|
|
18
|
-
syncCart: async () => {
|
|
18
|
+
syncCart: async (addressId) => {
|
|
19
19
|
set({ status: "loading" /* LOADING */ });
|
|
20
20
|
try {
|
|
21
|
-
const response = await
|
|
21
|
+
const response = await chunk34KV265H_cjs.getCart("/customer/cart/", addressId);
|
|
22
22
|
if (response) {
|
|
23
23
|
set({ cart: response, status: "idle" /* IDLE */ });
|
|
24
24
|
}
|
|
@@ -29,7 +29,7 @@ var useCartStore = zustand.create((set) => ({
|
|
|
29
29
|
fetchCart: async (addressId) => {
|
|
30
30
|
set({ status: "loading" /* LOADING */ });
|
|
31
31
|
try {
|
|
32
|
-
const response = await
|
|
32
|
+
const response = await chunk34KV265H_cjs.getCart("/customer/cart/", addressId);
|
|
33
33
|
if (response) {
|
|
34
34
|
set({ cart: response, status: "idle" /* IDLE */ });
|
|
35
35
|
}
|
package/dist/hooks/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkKWKHHRRJ_cjs = require('../chunk-KWKHHRRJ.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunkS3WIGYDS_cjs = require('../chunk-S3WIGYDS.cjs');
|
|
5
|
+
var chunk34KV265H_cjs = require('../chunk-34KV265H.cjs');
|
|
6
6
|
require('../chunk-CFF632IQ.cjs');
|
|
7
7
|
var chunkLC5ZAUKL_cjs = require('../chunk-LC5ZAUKL.cjs');
|
|
8
8
|
var chunkA6IO3HIN_cjs = require('../chunk-A6IO3HIN.cjs');
|
|
@@ -49,7 +49,7 @@ var useCart = (addressId) => {
|
|
|
49
49
|
async (addrId) => {
|
|
50
50
|
try {
|
|
51
51
|
setIsLoading(true);
|
|
52
|
-
const result = await
|
|
52
|
+
const result = await chunk34KV265H_cjs.getCart("/customer/cart/", addrId ?? addressId);
|
|
53
53
|
setData(result);
|
|
54
54
|
setError(null);
|
|
55
55
|
} catch (err) {
|
|
@@ -94,36 +94,98 @@ var useOrders = (filters) => {
|
|
|
94
94
|
}, [fetchData]);
|
|
95
95
|
return { data, error, isLoading, mutate: fetchData };
|
|
96
96
|
};
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
);
|
|
97
|
+
function useGetProducts(initialFilter, options) {
|
|
98
|
+
const paginationMode = options?.paginationMode || "replace";
|
|
99
|
+
const endpoint = options?.endpoint || "/inventory/products/";
|
|
100
|
+
const [filters, setFiltersState] = react.useState(initialFilter);
|
|
101
|
+
const [data, setData] = react.useState(void 0);
|
|
102
|
+
const [products, setProducts] = react.useState([]);
|
|
101
103
|
const [isLoading, setIsLoading] = react.useState(true);
|
|
102
|
-
const
|
|
103
|
-
react.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
const isLoadMoreRef = react.useRef(false);
|
|
105
|
+
const modeRef = react.useRef(paginationMode);
|
|
106
|
+
modeRef.current = paginationMode;
|
|
107
|
+
const fetchProducts = react.useCallback(
|
|
108
|
+
async (currentFilters) => {
|
|
109
|
+
setIsLoading(true);
|
|
107
110
|
try {
|
|
108
|
-
|
|
109
|
-
const
|
|
111
|
+
const apiParams = {};
|
|
112
|
+
for (const [key, value] of Object.entries(currentFilters)) {
|
|
113
|
+
if (value === void 0 || value === "" || value === null) continue;
|
|
114
|
+
if (Array.isArray(value)) {
|
|
115
|
+
if (value.length > 0) apiParams[key] = value.join(",");
|
|
116
|
+
} else {
|
|
117
|
+
apiParams[key] = value;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const result = await chunk34KV265H_cjs.getProductList(endpoint, apiParams);
|
|
110
121
|
setData(result);
|
|
111
|
-
|
|
122
|
+
if (modeRef.current === "append" && isLoadMoreRef.current) {
|
|
123
|
+
setProducts((prev) => [...prev, ...result.results || []]);
|
|
124
|
+
} else {
|
|
125
|
+
setProducts(result.results || []);
|
|
126
|
+
}
|
|
127
|
+
isLoadMoreRef.current = false;
|
|
128
|
+
} catch {
|
|
129
|
+
isLoadMoreRef.current = false;
|
|
112
130
|
} finally {
|
|
113
131
|
setIsLoading(false);
|
|
114
132
|
}
|
|
115
|
-
}
|
|
116
|
-
|
|
133
|
+
},
|
|
134
|
+
[endpoint]
|
|
135
|
+
);
|
|
136
|
+
react.useEffect(() => {
|
|
137
|
+
fetchProducts(filters);
|
|
138
|
+
}, [filters, fetchProducts]);
|
|
139
|
+
const setFilters = react.useCallback((newFilters) => {
|
|
140
|
+
isLoadMoreRef.current = false;
|
|
141
|
+
setProducts([]);
|
|
142
|
+
setFiltersState({ ...newFilters, page: newFilters.page || 1 });
|
|
117
143
|
}, []);
|
|
118
|
-
|
|
119
|
-
|
|
144
|
+
const updateFilter = react.useCallback((key, value) => {
|
|
145
|
+
isLoadMoreRef.current = false;
|
|
146
|
+
setProducts([]);
|
|
147
|
+
setFiltersState((prev) => {
|
|
148
|
+
const next = { ...prev, page: 1 };
|
|
149
|
+
if (value === void 0 || value === "" || Array.isArray(value) && value.length === 0) {
|
|
150
|
+
delete next[key];
|
|
151
|
+
} else {
|
|
152
|
+
next[key] = value;
|
|
153
|
+
}
|
|
154
|
+
return next;
|
|
155
|
+
});
|
|
156
|
+
}, []);
|
|
157
|
+
const loadMore = react.useCallback(() => {
|
|
158
|
+
if (!data?.next) return;
|
|
159
|
+
isLoadMoreRef.current = true;
|
|
160
|
+
setFiltersState((prev) => ({ ...prev, page: (prev.page || 1) + 1 }));
|
|
161
|
+
}, [data?.next]);
|
|
162
|
+
const goToPage = react.useCallback((page) => {
|
|
163
|
+
isLoadMoreRef.current = false;
|
|
164
|
+
setProducts([]);
|
|
165
|
+
setFiltersState((prev) => ({ ...prev, page }));
|
|
166
|
+
}, []);
|
|
167
|
+
return {
|
|
168
|
+
data,
|
|
169
|
+
products,
|
|
170
|
+
loading: isLoading && products.length === 0,
|
|
171
|
+
isLoading,
|
|
172
|
+
hasMore: !!data?.next,
|
|
173
|
+
totalCount: data?.count || 0,
|
|
174
|
+
currentPage: filters.page || 1,
|
|
175
|
+
filters,
|
|
176
|
+
setFilters,
|
|
177
|
+
updateFilter,
|
|
178
|
+
loadMore,
|
|
179
|
+
goToPage
|
|
180
|
+
};
|
|
181
|
+
}
|
|
120
182
|
var useGetProductDetails = (slug) => {
|
|
121
183
|
const [data, setData] = react.useState(void 0);
|
|
122
184
|
const [isLoading, setIsLoading] = react.useState(true);
|
|
123
185
|
const fetchData = react.useCallback(async () => {
|
|
124
186
|
try {
|
|
125
187
|
setIsLoading(true);
|
|
126
|
-
const result = await
|
|
188
|
+
const result = await chunk34KV265H_cjs.getProductDetail("/inventory/products/", slug);
|
|
127
189
|
setData(result);
|
|
128
190
|
} catch (err) {
|
|
129
191
|
} finally {
|
|
@@ -146,7 +208,7 @@ var useGetProductCategories = () => {
|
|
|
146
208
|
const fetchData = async () => {
|
|
147
209
|
try {
|
|
148
210
|
setIsLoading(true);
|
|
149
|
-
const result = await
|
|
211
|
+
const result = await chunk34KV265H_cjs.getProductCategories("/store/categories");
|
|
150
212
|
setData(result || []);
|
|
151
213
|
} catch (err) {
|
|
152
214
|
setError(err);
|
|
@@ -191,7 +253,7 @@ var useWishlist = () => {
|
|
|
191
253
|
const fetchData = react.useCallback(async () => {
|
|
192
254
|
try {
|
|
193
255
|
setIsLoading(true);
|
|
194
|
-
const result = await
|
|
256
|
+
const result = await chunk34KV265H_cjs.getWishlist("/customer/wishlist/");
|
|
195
257
|
setData(result);
|
|
196
258
|
setError(null);
|
|
197
259
|
} catch (err) {
|
|
@@ -249,7 +311,7 @@ function useCheckoutPayment(options) {
|
|
|
249
311
|
const [isConfirmingPayment, setIsConfirmingPayment] = react.useState(false);
|
|
250
312
|
const [showSuccessModal, setShowSuccessModal] = react.useState(false);
|
|
251
313
|
const [showFailureModal, setShowFailureModal] = react.useState(false);
|
|
252
|
-
const resetCartCount =
|
|
314
|
+
const resetCartCount = chunkS3WIGYDS_cjs.useCartStore((s) => s.resetCartCount);
|
|
253
315
|
const callbacks = {
|
|
254
316
|
onSuccess: (order) => {
|
|
255
317
|
setOrderSummary(order);
|
|
@@ -311,12 +373,8 @@ function useCheckoutCoupon(options) {
|
|
|
311
373
|
const refreshCoupons = react.useCallback(async () => {
|
|
312
374
|
setIsLoading(true);
|
|
313
375
|
try {
|
|
314
|
-
const
|
|
315
|
-
chunkLC5ZAUKL_cjs.fetchAvailableCoupons(),
|
|
316
|
-
chunkLC5ZAUKL_cjs.fetchAppliedCoupon()
|
|
317
|
-
]);
|
|
376
|
+
const coupons = await chunkLC5ZAUKL_cjs.fetchAvailableCoupons();
|
|
318
377
|
setAvailableCoupons(coupons);
|
|
319
|
-
setAppliedCoupon(applied);
|
|
320
378
|
} catch {
|
|
321
379
|
} finally {
|
|
322
380
|
setIsLoading(false);
|
package/dist/hooks/index.d.cts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { A as Address } from '../address-DQEZzyUG.cjs';
|
|
2
|
-
import { C as Cart,
|
|
3
|
-
import { O as Order
|
|
4
|
-
import { U as User, W as Wishlist } from '../wishlist-
|
|
5
|
-
import { C as Coupon } from '../coupons-C7iJ-1cy.cjs';
|
|
2
|
+
import { C as Cart, j as Product, d as Category, e as Coupon } from '../cart-D8UXTY1g.cjs';
|
|
3
|
+
import { O as Order } from '../orders-DHJhJ3xz.cjs';
|
|
4
|
+
import { U as User, W as Wishlist } from '../wishlist-C3SK9SS0.cjs';
|
|
6
5
|
export { U as UseAddressFormOptions, a as UseAddressFormReturn, u as useAddressForm } from '../useAddressForm-DgkCP1nG.cjs';
|
|
7
6
|
import 'react-toastify';
|
|
8
7
|
import 'react';
|
|
@@ -30,11 +29,26 @@ declare const useOrders: (filters: any) => {
|
|
|
30
29
|
mutate: () => Promise<void>;
|
|
31
30
|
};
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
type PaginationMode = "append" | "replace";
|
|
33
|
+
interface UseGetProductsOptions {
|
|
34
|
+
paginationMode?: PaginationMode;
|
|
35
|
+
endpoint?: string;
|
|
36
|
+
}
|
|
37
|
+
interface UseGetProductsReturn {
|
|
34
38
|
data: Product.ProductResponse | undefined;
|
|
39
|
+
products: Product.ProductList[];
|
|
35
40
|
loading: boolean;
|
|
36
41
|
isLoading: boolean;
|
|
37
|
-
|
|
42
|
+
hasMore: boolean;
|
|
43
|
+
totalCount: number;
|
|
44
|
+
currentPage: number;
|
|
45
|
+
filters: Record<string, any>;
|
|
46
|
+
setFilters: (filters: Record<string, any>) => void;
|
|
47
|
+
updateFilter: (key: string, value: any) => void;
|
|
48
|
+
loadMore: () => void;
|
|
49
|
+
goToPage: (page: number) => void;
|
|
50
|
+
}
|
|
51
|
+
declare function useGetProducts(initialFilter: CustomObject, options?: UseGetProductsOptions): UseGetProductsReturn;
|
|
38
52
|
declare const useGetProductDetails: (slug: string) => {
|
|
39
53
|
data: any;
|
|
40
54
|
loading: boolean;
|
|
@@ -120,4 +134,4 @@ interface UseCheckoutCouponReturn {
|
|
|
120
134
|
*/
|
|
121
135
|
declare function useCheckoutCoupon(options: UseCheckoutCouponOptions): UseCheckoutCouponReturn;
|
|
122
136
|
|
|
123
|
-
export { type UseCheckoutCouponOptions, type UseCheckoutCouponReturn, type UseCheckoutPaymentOptions, type UseCheckoutPaymentReturn, useAddress, useCart, useCheckoutCoupon, useCheckoutPayment, useGetProductCategories, useGetProductDetails, useGetProducts, useOrders, useProductDetailModal, useServiceFormModal, useUserDetails, useWishlist };
|
|
137
|
+
export { type PaginationMode, type UseCheckoutCouponOptions, type UseCheckoutCouponReturn, type UseCheckoutPaymentOptions, type UseCheckoutPaymentReturn, type UseGetProductsOptions, type UseGetProductsReturn, useAddress, useCart, useCheckoutCoupon, useCheckoutPayment, useGetProductCategories, useGetProductDetails, useGetProducts, useOrders, useProductDetailModal, useServiceFormModal, useUserDetails, useWishlist };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { A as Address } from '../address-DQEZzyUG.js';
|
|
2
|
-
import { C as Cart,
|
|
3
|
-
import { O as Order
|
|
4
|
-
import { U as User, W as Wishlist } from '../wishlist-
|
|
5
|
-
import { C as Coupon } from '../coupons-CnfTKL1i.js';
|
|
2
|
+
import { C as Cart, j as Product, d as Category, e as Coupon } from '../cart-D8UXTY1g.js';
|
|
3
|
+
import { O as Order } from '../orders-DHJhJ3xz.js';
|
|
4
|
+
import { U as User, W as Wishlist } from '../wishlist-BMWfB0Xe.js';
|
|
6
5
|
export { U as UseAddressFormOptions, a as UseAddressFormReturn, u as useAddressForm } from '../useAddressForm-C-Uzug4d.js';
|
|
7
6
|
import 'react-toastify';
|
|
8
7
|
import 'react';
|
|
@@ -30,11 +29,26 @@ declare const useOrders: (filters: any) => {
|
|
|
30
29
|
mutate: () => Promise<void>;
|
|
31
30
|
};
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
type PaginationMode = "append" | "replace";
|
|
33
|
+
interface UseGetProductsOptions {
|
|
34
|
+
paginationMode?: PaginationMode;
|
|
35
|
+
endpoint?: string;
|
|
36
|
+
}
|
|
37
|
+
interface UseGetProductsReturn {
|
|
34
38
|
data: Product.ProductResponse | undefined;
|
|
39
|
+
products: Product.ProductList[];
|
|
35
40
|
loading: boolean;
|
|
36
41
|
isLoading: boolean;
|
|
37
|
-
|
|
42
|
+
hasMore: boolean;
|
|
43
|
+
totalCount: number;
|
|
44
|
+
currentPage: number;
|
|
45
|
+
filters: Record<string, any>;
|
|
46
|
+
setFilters: (filters: Record<string, any>) => void;
|
|
47
|
+
updateFilter: (key: string, value: any) => void;
|
|
48
|
+
loadMore: () => void;
|
|
49
|
+
goToPage: (page: number) => void;
|
|
50
|
+
}
|
|
51
|
+
declare function useGetProducts(initialFilter: CustomObject, options?: UseGetProductsOptions): UseGetProductsReturn;
|
|
38
52
|
declare const useGetProductDetails: (slug: string) => {
|
|
39
53
|
data: any;
|
|
40
54
|
loading: boolean;
|
|
@@ -120,4 +134,4 @@ interface UseCheckoutCouponReturn {
|
|
|
120
134
|
*/
|
|
121
135
|
declare function useCheckoutCoupon(options: UseCheckoutCouponOptions): UseCheckoutCouponReturn;
|
|
122
136
|
|
|
123
|
-
export { type UseCheckoutCouponOptions, type UseCheckoutCouponReturn, type UseCheckoutPaymentOptions, type UseCheckoutPaymentReturn, useAddress, useCart, useCheckoutCoupon, useCheckoutPayment, useGetProductCategories, useGetProductDetails, useGetProducts, useOrders, useProductDetailModal, useServiceFormModal, useUserDetails, useWishlist };
|
|
137
|
+
export { type PaginationMode, type UseCheckoutCouponOptions, type UseCheckoutCouponReturn, type UseCheckoutPaymentOptions, type UseCheckoutPaymentReturn, type UseGetProductsOptions, type UseGetProductsReturn, useAddress, useCart, useCheckoutCoupon, useCheckoutPayment, useGetProductCategories, useGetProductDetails, useGetProducts, useOrders, useProductDetailModal, useServiceFormModal, useUserDetails, useWishlist };
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getUserDetails } from '../chunk-7UH6REGV.js';
|
|
2
|
-
import { useCartStore } from '../chunk-
|
|
3
|
-
import { getCart, getProductDetail, getWishlist, getProductCategories
|
|
2
|
+
import { useCartStore } from '../chunk-7DQIKSGY.js';
|
|
3
|
+
import { getCart, getProductList, getProductDetail, getWishlist, getProductCategories } from '../chunk-Z7LHRD3V.js';
|
|
4
4
|
import '../chunk-E7WPE3PV.js';
|
|
5
|
-
import { processPayment, fetchAvailableCoupons,
|
|
5
|
+
import { processPayment, fetchAvailableCoupons, applyCheckoutCoupon, removeCheckoutCoupon } from '../chunk-QCQCFYYR.js';
|
|
6
6
|
import { getOrders, placeOrder } from '../chunk-4MJMNIAB.js';
|
|
7
7
|
import '../chunk-WFDKKOO7.js';
|
|
8
8
|
export { useAddressForm } from '../chunk-UM24VDYB.js';
|
|
@@ -92,29 +92,91 @@ var useOrders = (filters) => {
|
|
|
92
92
|
}, [fetchData]);
|
|
93
93
|
return { data, error, isLoading, mutate: fetchData };
|
|
94
94
|
};
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
);
|
|
95
|
+
function useGetProducts(initialFilter, options) {
|
|
96
|
+
const paginationMode = options?.paginationMode || "replace";
|
|
97
|
+
const endpoint = options?.endpoint || "/inventory/products/";
|
|
98
|
+
const [filters, setFiltersState] = useState(initialFilter);
|
|
99
|
+
const [data, setData] = useState(void 0);
|
|
100
|
+
const [products, setProducts] = useState([]);
|
|
99
101
|
const [isLoading, setIsLoading] = useState(true);
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
const isLoadMoreRef = useRef(false);
|
|
103
|
+
const modeRef = useRef(paginationMode);
|
|
104
|
+
modeRef.current = paginationMode;
|
|
105
|
+
const fetchProducts = useCallback(
|
|
106
|
+
async (currentFilters) => {
|
|
107
|
+
setIsLoading(true);
|
|
105
108
|
try {
|
|
106
|
-
|
|
107
|
-
const
|
|
109
|
+
const apiParams = {};
|
|
110
|
+
for (const [key, value] of Object.entries(currentFilters)) {
|
|
111
|
+
if (value === void 0 || value === "" || value === null) continue;
|
|
112
|
+
if (Array.isArray(value)) {
|
|
113
|
+
if (value.length > 0) apiParams[key] = value.join(",");
|
|
114
|
+
} else {
|
|
115
|
+
apiParams[key] = value;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const result = await getProductList(endpoint, apiParams);
|
|
108
119
|
setData(result);
|
|
109
|
-
|
|
120
|
+
if (modeRef.current === "append" && isLoadMoreRef.current) {
|
|
121
|
+
setProducts((prev) => [...prev, ...result.results || []]);
|
|
122
|
+
} else {
|
|
123
|
+
setProducts(result.results || []);
|
|
124
|
+
}
|
|
125
|
+
isLoadMoreRef.current = false;
|
|
126
|
+
} catch {
|
|
127
|
+
isLoadMoreRef.current = false;
|
|
110
128
|
} finally {
|
|
111
129
|
setIsLoading(false);
|
|
112
130
|
}
|
|
113
|
-
}
|
|
114
|
-
|
|
131
|
+
},
|
|
132
|
+
[endpoint]
|
|
133
|
+
);
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
fetchProducts(filters);
|
|
136
|
+
}, [filters, fetchProducts]);
|
|
137
|
+
const setFilters = useCallback((newFilters) => {
|
|
138
|
+
isLoadMoreRef.current = false;
|
|
139
|
+
setProducts([]);
|
|
140
|
+
setFiltersState({ ...newFilters, page: newFilters.page || 1 });
|
|
115
141
|
}, []);
|
|
116
|
-
|
|
117
|
-
|
|
142
|
+
const updateFilter = useCallback((key, value) => {
|
|
143
|
+
isLoadMoreRef.current = false;
|
|
144
|
+
setProducts([]);
|
|
145
|
+
setFiltersState((prev) => {
|
|
146
|
+
const next = { ...prev, page: 1 };
|
|
147
|
+
if (value === void 0 || value === "" || Array.isArray(value) && value.length === 0) {
|
|
148
|
+
delete next[key];
|
|
149
|
+
} else {
|
|
150
|
+
next[key] = value;
|
|
151
|
+
}
|
|
152
|
+
return next;
|
|
153
|
+
});
|
|
154
|
+
}, []);
|
|
155
|
+
const loadMore = useCallback(() => {
|
|
156
|
+
if (!data?.next) return;
|
|
157
|
+
isLoadMoreRef.current = true;
|
|
158
|
+
setFiltersState((prev) => ({ ...prev, page: (prev.page || 1) + 1 }));
|
|
159
|
+
}, [data?.next]);
|
|
160
|
+
const goToPage = useCallback((page) => {
|
|
161
|
+
isLoadMoreRef.current = false;
|
|
162
|
+
setProducts([]);
|
|
163
|
+
setFiltersState((prev) => ({ ...prev, page }));
|
|
164
|
+
}, []);
|
|
165
|
+
return {
|
|
166
|
+
data,
|
|
167
|
+
products,
|
|
168
|
+
loading: isLoading && products.length === 0,
|
|
169
|
+
isLoading,
|
|
170
|
+
hasMore: !!data?.next,
|
|
171
|
+
totalCount: data?.count || 0,
|
|
172
|
+
currentPage: filters.page || 1,
|
|
173
|
+
filters,
|
|
174
|
+
setFilters,
|
|
175
|
+
updateFilter,
|
|
176
|
+
loadMore,
|
|
177
|
+
goToPage
|
|
178
|
+
};
|
|
179
|
+
}
|
|
118
180
|
var useGetProductDetails = (slug) => {
|
|
119
181
|
const [data, setData] = useState(void 0);
|
|
120
182
|
const [isLoading, setIsLoading] = useState(true);
|
|
@@ -309,12 +371,8 @@ function useCheckoutCoupon(options) {
|
|
|
309
371
|
const refreshCoupons = useCallback(async () => {
|
|
310
372
|
setIsLoading(true);
|
|
311
373
|
try {
|
|
312
|
-
const
|
|
313
|
-
fetchAvailableCoupons(),
|
|
314
|
-
fetchAppliedCoupon()
|
|
315
|
-
]);
|
|
374
|
+
const coupons = await fetchAvailableCoupons();
|
|
316
375
|
setAvailableCoupons(coupons);
|
|
317
|
-
setAppliedCoupon(applied);
|
|
318
376
|
} catch {
|
|
319
377
|
} finally {
|
|
320
378
|
setIsLoading(false);
|
package/dist/models/index.d.cts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export { A as Address } from '../address-DQEZzyUG.cjs';
|
|
2
|
-
export { A as Analytics, B as Booking, a as BookingDetails, b as CollectionAttributes, C as CollectionResponse, c as CollectionVariant, R as Review, s as singleCollection } from '../booking-
|
|
3
|
-
export { A as Attributes, B as BookingService,
|
|
4
|
-
export {
|
|
5
|
-
export { A as ApplicableTarget, C as Coupon, a as CouponResponse, b as CouponStatus, c as Coupons, D as DiscountType, V as ValueType } from '../coupons-C7iJ-1cy.cjs';
|
|
2
|
+
export { A as Analytics, B as Booking, a as BookingDetails, b as CollectionAttributes, C as CollectionResponse, c as CollectionVariant, R as Review, s as singleCollection } from '../booking-Dd877kxd.cjs';
|
|
3
|
+
export { A as ApplicableTarget, a as Attributes, B as BookingService, b as BookingServiceDate, C as Cart, c as CartState, d as Category, e as Coupon, f as CouponResponse, g as CouponStatus, h as Coupons, i as CustomField, D as DiscountType, O as OperatingHours, P as Photos, j as Product, k as ProductDetail, S as SpecialHours, T as TimeSlot, V as ValueType, W as WishlistState } from '../cart-D8UXTY1g.cjs';
|
|
4
|
+
export { O as Order } from '../orders-DHJhJ3xz.cjs';
|
|
6
5
|
export { D as Data, P as PaymentInstrument, a as PhonePe } from '../phonepe-D7vn-9SR.cjs';
|
|
7
|
-
export { U as User, W as Wishlist } from '../wishlist-
|
|
6
|
+
export { U as User, W as Wishlist } from '../wishlist-C3SK9SS0.cjs';
|
|
8
7
|
import 'react-toastify';
|
|
9
8
|
|
|
10
9
|
declare namespace CountryModel {
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export { A as Address } from '../address-DQEZzyUG.js';
|
|
2
|
-
export { A as Analytics, B as Booking, a as BookingDetails, b as CollectionAttributes, C as CollectionResponse, c as CollectionVariant, R as Review, s as singleCollection } from '../booking-
|
|
3
|
-
export { A as Attributes, B as BookingService,
|
|
4
|
-
export {
|
|
5
|
-
export { A as ApplicableTarget, C as Coupon, a as CouponResponse, b as CouponStatus, c as Coupons, D as DiscountType, V as ValueType } from '../coupons-CnfTKL1i.js';
|
|
2
|
+
export { A as Analytics, B as Booking, a as BookingDetails, b as CollectionAttributes, C as CollectionResponse, c as CollectionVariant, R as Review, s as singleCollection } from '../booking-Bo_tELLX.js';
|
|
3
|
+
export { A as ApplicableTarget, a as Attributes, B as BookingService, b as BookingServiceDate, C as Cart, c as CartState, d as Category, e as Coupon, f as CouponResponse, g as CouponStatus, h as Coupons, i as CustomField, D as DiscountType, O as OperatingHours, P as Photos, j as Product, k as ProductDetail, S as SpecialHours, T as TimeSlot, V as ValueType, W as WishlistState } from '../cart-D8UXTY1g.js';
|
|
4
|
+
export { O as Order } from '../orders-DHJhJ3xz.js';
|
|
6
5
|
export { D as Data, P as PaymentInstrument, a as PhonePe } from '../phonepe-D7vn-9SR.js';
|
|
7
|
-
export { U as User, W as Wishlist } from '../wishlist-
|
|
6
|
+
export { U as User, W as Wishlist } from '../wishlist-BMWfB0Xe.js';
|
|
8
7
|
import 'react-toastify';
|
|
9
8
|
|
|
10
9
|
declare namespace CountryModel {
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
import { f as SLICE_STATUS } from './cart-DVrn8hD0.js';
|
|
2
|
-
|
|
3
|
-
declare namespace Category {
|
|
4
|
-
interface Root {
|
|
5
|
-
id: number;
|
|
6
|
-
name: string;
|
|
7
|
-
photo: string;
|
|
8
|
-
slug: string;
|
|
9
|
-
description: string;
|
|
10
|
-
children?: Root[];
|
|
11
|
-
}
|
|
12
|
-
interface CategoriesState {
|
|
13
|
-
data: Root[];
|
|
14
|
-
status: SLICE_STATUS;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
1
|
declare namespace Order {
|
|
19
2
|
interface Root {
|
|
20
3
|
id: number;
|
|
@@ -156,4 +139,4 @@ declare namespace Order {
|
|
|
156
139
|
}
|
|
157
140
|
}
|
|
158
141
|
|
|
159
|
-
export {
|
|
142
|
+
export { Order as O };
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
import { f as SLICE_STATUS } from './cart-DVrn8hD0.cjs';
|
|
2
|
-
|
|
3
|
-
declare namespace Category {
|
|
4
|
-
interface Root {
|
|
5
|
-
id: number;
|
|
6
|
-
name: string;
|
|
7
|
-
photo: string;
|
|
8
|
-
slug: string;
|
|
9
|
-
description: string;
|
|
10
|
-
children?: Root[];
|
|
11
|
-
}
|
|
12
|
-
interface CategoriesState {
|
|
13
|
-
data: Root[];
|
|
14
|
-
status: SLICE_STATUS;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
1
|
declare namespace Order {
|
|
19
2
|
interface Root {
|
|
20
3
|
id: number;
|
|
@@ -156,4 +139,4 @@ declare namespace Order {
|
|
|
156
139
|
}
|
|
157
140
|
}
|
|
158
141
|
|
|
159
|
-
export {
|
|
142
|
+
export { Order as O };
|
package/dist/store/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkS3WIGYDS_cjs = require('../chunk-S3WIGYDS.cjs');
|
|
4
|
+
var chunk34KV265H_cjs = require('../chunk-34KV265H.cjs');
|
|
5
5
|
var chunkCFF632IQ_cjs = require('../chunk-CFF632IQ.cjs');
|
|
6
6
|
require('../chunk-UXLUE3HW.cjs');
|
|
7
7
|
var chunkGQTO5ZE2_cjs = require('../chunk-GQTO5ZE2.cjs');
|
|
@@ -36,7 +36,7 @@ var useAuthStore = zustand.create((set, get) => ({
|
|
|
36
36
|
set({ user, status: "success" /* SUCCESS */, isAuthenticated: true });
|
|
37
37
|
const localCartItems = chunkCFF632IQ_cjs.cart_default.get();
|
|
38
38
|
if (localCartItems) {
|
|
39
|
-
const response = await
|
|
39
|
+
const response = await chunk34KV265H_cjs.addToCart(
|
|
40
40
|
Object.entries(localCartItems.products_quantity).map(
|
|
41
41
|
([key, value]) => ({
|
|
42
42
|
variant_id: parseInt(key),
|
|
@@ -46,7 +46,7 @@ var useAuthStore = zustand.create((set, get) => ({
|
|
|
46
46
|
);
|
|
47
47
|
if (response) {
|
|
48
48
|
chunkCFF632IQ_cjs.cart_default.clear();
|
|
49
|
-
|
|
49
|
+
chunkS3WIGYDS_cjs.useCartStore.getState().fetchCart();
|
|
50
50
|
setTimeout(() => {
|
|
51
51
|
if (!preventRefreshAfterLogin) {
|
|
52
52
|
if (redirect) {
|
|
@@ -93,7 +93,7 @@ var useWishlistStore = zustand.create((set) => ({
|
|
|
93
93
|
resetWishlist: () => set(initialState),
|
|
94
94
|
syncWishlist: async () => {
|
|
95
95
|
try {
|
|
96
|
-
const response = await
|
|
96
|
+
const response = await chunk34KV265H_cjs.getWishlist("/customer/wishlist/");
|
|
97
97
|
if (response) {
|
|
98
98
|
set({
|
|
99
99
|
wishlist_count: response.wishlist_count,
|
|
@@ -121,7 +121,7 @@ var useProductStore = zustand.create((set, get) => ({
|
|
|
121
121
|
data: filter.page === 1 ? [] : state.data
|
|
122
122
|
}));
|
|
123
123
|
try {
|
|
124
|
-
const response = await
|
|
124
|
+
const response = await chunk34KV265H_cjs.getProducts({ ...filter });
|
|
125
125
|
if (response.data) {
|
|
126
126
|
const { results, ...meta } = response.data;
|
|
127
127
|
set((state) => ({
|
|
@@ -141,7 +141,7 @@ var useProductStore = zustand.create((set, get) => ({
|
|
|
141
141
|
|
|
142
142
|
Object.defineProperty(exports, "useCartStore", {
|
|
143
143
|
enumerable: true,
|
|
144
|
-
get: function () { return
|
|
144
|
+
get: function () { return chunkS3WIGYDS_cjs.useCartStore; }
|
|
145
145
|
});
|
|
146
146
|
exports.loginUser = loginUser;
|
|
147
147
|
exports.useAuthStore = useAuthStore;
|
package/dist/store/index.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as zustand from 'zustand';
|
|
2
|
-
import {
|
|
3
|
-
import { U as User, W as Wishlist } from '../wishlist-
|
|
2
|
+
import { c as CartState, C as Cart, j as Product } from '../cart-D8UXTY1g.cjs';
|
|
3
|
+
import { U as User, W as Wishlist } from '../wishlist-C3SK9SS0.cjs';
|
|
4
4
|
import 'react-toastify';
|
|
5
5
|
|
|
6
6
|
interface CartStore extends CartState {
|
|
7
7
|
setCart: (cart: Cart.Root) => void;
|
|
8
8
|
resetCart: () => void;
|
|
9
9
|
resetCartCount: () => void;
|
|
10
|
-
syncCart: () => Promise<void>;
|
|
10
|
+
syncCart: (addressId?: number) => Promise<void>;
|
|
11
11
|
fetchCart: (addressId?: number) => Promise<void>;
|
|
12
12
|
}
|
|
13
13
|
declare const useCartStore: zustand.UseBoundStore<zustand.StoreApi<CartStore>>;
|
package/dist/store/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as zustand from 'zustand';
|
|
2
|
-
import {
|
|
3
|
-
import { U as User, W as Wishlist } from '../wishlist-
|
|
2
|
+
import { c as CartState, C as Cart, j as Product } from '../cart-D8UXTY1g.js';
|
|
3
|
+
import { U as User, W as Wishlist } from '../wishlist-BMWfB0Xe.js';
|
|
4
4
|
import 'react-toastify';
|
|
5
5
|
|
|
6
6
|
interface CartStore extends CartState {
|
|
7
7
|
setCart: (cart: Cart.Root) => void;
|
|
8
8
|
resetCart: () => void;
|
|
9
9
|
resetCartCount: () => void;
|
|
10
|
-
syncCart: () => Promise<void>;
|
|
10
|
+
syncCart: (addressId?: number) => Promise<void>;
|
|
11
11
|
fetchCart: (addressId?: number) => Promise<void>;
|
|
12
12
|
}
|
|
13
13
|
declare const useCartStore: zustand.UseBoundStore<zustand.StoreApi<CartStore>>;
|
package/dist/store/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useCartStore } from '../chunk-
|
|
2
|
-
export { useCartStore } from '../chunk-
|
|
3
|
-
import { addToCart, getWishlist, getProducts } from '../chunk-
|
|
1
|
+
import { useCartStore } from '../chunk-7DQIKSGY.js';
|
|
2
|
+
export { useCartStore } from '../chunk-7DQIKSGY.js';
|
|
3
|
+
import { addToCart, getWishlist, getProducts } from '../chunk-Z7LHRD3V.js';
|
|
4
4
|
import { cart_default } from '../chunk-E7WPE3PV.js';
|
|
5
5
|
import '../chunk-GB3HW6DM.js';
|
|
6
6
|
import { auth_default, USER_CRED_TOKEN, USER_CREDENTIALS } from '../chunk-FLBJKM6G.js';
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { C as Cart,
|
|
2
|
-
export {
|
|
1
|
+
import { C as Cart, k as ProductDetail, d as Category$1, j as Product, O as OperatingHours, T as TimeSlot } from '../cart-D8UXTY1g.cjs';
|
|
2
|
+
export { m as ADDRESS_FORM_SESSION_KEY, n as ALLOWED_COUNTRIES, o as DEFAULT_TOAST_CONFIG, p as PRODUCT_STATUSES, l as SLICE_STATUS, U as USER_CART, q as USER_CREDENTIALS, r as USER_CRED_REFRESH_TOKEN, s as USER_CRED_TOKEN, t as pathNameMap } from '../cart-D8UXTY1g.cjs';
|
|
3
3
|
export { S as SnapstoreConfig, g as getApiEndpoint, a as getCloudFront, b as getConfig, c as getPhonePeApiEndpoint, d as getPublicApiEndpoint, e as getSecretKey, f as getStoreId, i as initConfig } from '../index-DTyIuLuI.cjs';
|
|
4
|
-
import { C as Category$1, O as Order } from '../orders-D0oC9ugD.cjs';
|
|
5
4
|
import { AxiosResponse } from 'axios';
|
|
6
5
|
import { a as PhonePe } from '../phonepe-D7vn-9SR.cjs';
|
|
6
|
+
import { O as Order } from '../orders-DHJhJ3xz.cjs';
|
|
7
7
|
import 'react-toastify';
|
|
8
8
|
|
|
9
9
|
declare function setAuthTokenChangeCallback(callback: (token: string | undefined) => void): void;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { C as Cart,
|
|
2
|
-
export {
|
|
1
|
+
import { C as Cart, k as ProductDetail, d as Category$1, j as Product, O as OperatingHours, T as TimeSlot } from '../cart-D8UXTY1g.js';
|
|
2
|
+
export { m as ADDRESS_FORM_SESSION_KEY, n as ALLOWED_COUNTRIES, o as DEFAULT_TOAST_CONFIG, p as PRODUCT_STATUSES, l as SLICE_STATUS, U as USER_CART, q as USER_CREDENTIALS, r as USER_CRED_REFRESH_TOKEN, s as USER_CRED_TOKEN, t as pathNameMap } from '../cart-D8UXTY1g.js';
|
|
3
3
|
export { S as SnapstoreConfig, g as getApiEndpoint, a as getCloudFront, b as getConfig, c as getPhonePeApiEndpoint, d as getPublicApiEndpoint, e as getSecretKey, f as getStoreId, i as initConfig } from '../index-DTyIuLuI.js';
|
|
4
|
-
import { C as Category$1, O as Order } from '../orders-CkUzv5Xh.js';
|
|
5
4
|
import { AxiosResponse } from 'axios';
|
|
6
5
|
import { a as PhonePe } from '../phonepe-D7vn-9SR.js';
|
|
6
|
+
import { O as Order } from '../orders-DHJhJ3xz.js';
|
|
7
7
|
import 'react-toastify';
|
|
8
8
|
|
|
9
9
|
declare function setAuthTokenChangeCallback(callback: (token: string | undefined) => void): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storepecker/storefront-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Shared logic and utilities for Snapstore themes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -76,6 +76,8 @@
|
|
|
76
76
|
"scripts": {
|
|
77
77
|
"build": "tsup",
|
|
78
78
|
"dev": "tsup --watch",
|
|
79
|
+
"test": "vitest run",
|
|
80
|
+
"test:watch": "vitest",
|
|
79
81
|
"lint": "tsc --noEmit",
|
|
80
82
|
"prepublishOnly": "npm run build",
|
|
81
83
|
"release": "npm run build && npm publish --access public",
|
|
@@ -109,12 +111,14 @@
|
|
|
109
111
|
}
|
|
110
112
|
},
|
|
111
113
|
"devDependencies": {
|
|
114
|
+
"@testing-library/react": "^16.3.2",
|
|
112
115
|
"@types/node": "^25.3.3",
|
|
113
116
|
"@types/react": "^18.0.0",
|
|
114
117
|
"axios": "^1.7.0",
|
|
115
118
|
"clsx": "^2.1.1",
|
|
116
119
|
"esbuild-css-modules-plugin": "^3.1.5",
|
|
117
120
|
"formik": "^2.4.6",
|
|
121
|
+
"happy-dom": "^20.8.3",
|
|
118
122
|
"libphonenumber-js": "^1.11.0",
|
|
119
123
|
"react": "^18.3.1",
|
|
120
124
|
"react-dom": "^18.3.1",
|
|
@@ -124,6 +128,7 @@
|
|
|
124
128
|
"tsup": "^8.0.0",
|
|
125
129
|
"typescript": "^5.5.0",
|
|
126
130
|
"typescript-cookie": "^1.0.0",
|
|
131
|
+
"vitest": "^4.0.18",
|
|
127
132
|
"yup": "^1.4.0",
|
|
128
133
|
"zustand": "^5.0.11"
|
|
129
134
|
},
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { C as Category } from './orders-D0oC9ugD.cjs';
|
|
2
|
-
|
|
3
|
-
type DiscountType = "discount";
|
|
4
|
-
type ValueType = "percentage" | "fixed";
|
|
5
|
-
type ApplicableTarget = "product_category" | "product_variant" | "product_bundle" | "customer";
|
|
6
|
-
type CouponStatus = "active" | "inactive" | "expired";
|
|
7
|
-
interface Coupon {
|
|
8
|
-
id: number;
|
|
9
|
-
coupon_code: string;
|
|
10
|
-
discount_type: DiscountType;
|
|
11
|
-
value: string;
|
|
12
|
-
value_type: ValueType;
|
|
13
|
-
min_order_amount: string;
|
|
14
|
-
max_discount_amount: string;
|
|
15
|
-
start_date: string;
|
|
16
|
-
end_date: string;
|
|
17
|
-
status: CouponStatus;
|
|
18
|
-
is_deleted: boolean;
|
|
19
|
-
usage_limit: number;
|
|
20
|
-
usage_count: number;
|
|
21
|
-
applicable_target: ApplicableTarget;
|
|
22
|
-
applicable_product_variants: any[];
|
|
23
|
-
applicable_product_bundles: any[];
|
|
24
|
-
applicable_product_categories: Category.Root[];
|
|
25
|
-
applicable_customers: any[];
|
|
26
|
-
auto_apply: boolean;
|
|
27
|
-
created_at: string;
|
|
28
|
-
updated_at: string;
|
|
29
|
-
is_cart_applicable: boolean;
|
|
30
|
-
coupon_message: string;
|
|
31
|
-
}
|
|
32
|
-
type Coupons = Coupon[];
|
|
33
|
-
interface CouponResponse {
|
|
34
|
-
coupon: Coupon;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export type { ApplicableTarget as A, Coupon as C, DiscountType as D, ValueType as V, CouponResponse as a, CouponStatus as b, Coupons as c };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { C as Category } from './orders-CkUzv5Xh.js';
|
|
2
|
-
|
|
3
|
-
type DiscountType = "discount";
|
|
4
|
-
type ValueType = "percentage" | "fixed";
|
|
5
|
-
type ApplicableTarget = "product_category" | "product_variant" | "product_bundle" | "customer";
|
|
6
|
-
type CouponStatus = "active" | "inactive" | "expired";
|
|
7
|
-
interface Coupon {
|
|
8
|
-
id: number;
|
|
9
|
-
coupon_code: string;
|
|
10
|
-
discount_type: DiscountType;
|
|
11
|
-
value: string;
|
|
12
|
-
value_type: ValueType;
|
|
13
|
-
min_order_amount: string;
|
|
14
|
-
max_discount_amount: string;
|
|
15
|
-
start_date: string;
|
|
16
|
-
end_date: string;
|
|
17
|
-
status: CouponStatus;
|
|
18
|
-
is_deleted: boolean;
|
|
19
|
-
usage_limit: number;
|
|
20
|
-
usage_count: number;
|
|
21
|
-
applicable_target: ApplicableTarget;
|
|
22
|
-
applicable_product_variants: any[];
|
|
23
|
-
applicable_product_bundles: any[];
|
|
24
|
-
applicable_product_categories: Category.Root[];
|
|
25
|
-
applicable_customers: any[];
|
|
26
|
-
auto_apply: boolean;
|
|
27
|
-
created_at: string;
|
|
28
|
-
updated_at: string;
|
|
29
|
-
is_cart_applicable: boolean;
|
|
30
|
-
coupon_message: string;
|
|
31
|
-
}
|
|
32
|
-
type Coupons = Coupon[];
|
|
33
|
-
interface CouponResponse {
|
|
34
|
-
coupon: Coupon;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export type { ApplicableTarget as A, Coupon as C, DiscountType as D, ValueType as V, CouponResponse as a, CouponStatus as b, Coupons as c };
|