@storepecker/storefront-core 1.1.1 → 2.0.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 +76 -75
- package/dist/api/index.d.cts +4 -3
- package/dist/api/index.d.ts +4 -3
- package/dist/api/index.js +9 -8
- package/dist/{booking-B21s0inO.d.cts → booking-B39Ilxhg.d.ts} +1 -1
- package/dist/{booking-CegE1cje.d.ts → booking-Dk-BoHUB.d.cts} +1 -1
- package/dist/cart-BY8D8w-s.d.cts +90 -0
- package/dist/cart-GuhgeBBt.d.ts +90 -0
- package/dist/checkout/index.cjs +38 -37
- package/dist/checkout/index.d.cts +2 -1
- package/dist/checkout/index.d.ts +2 -1
- package/dist/checkout/index.js +6 -5
- package/dist/{chunk-34KV265H.cjs → chunk-26A3EBZI.cjs} +20 -20
- package/dist/chunk-2AHH3XBW.cjs +47 -0
- package/dist/{chunk-K5B62JZO.cjs → chunk-47XTPPII.cjs} +4 -4
- package/dist/chunk-4C4NTH6O.js +41 -0
- package/dist/{chunk-UM24VDYB.js → chunk-7R2V4C7Q.js} +2 -2
- package/dist/{chunk-CSISWBZZ.js → chunk-B7FOXIZN.js} +1 -1
- package/dist/chunk-BBRB475I.cjs +43 -0
- package/dist/chunk-BBRXE57K.cjs +50 -0
- package/dist/{chunk-QCQCFYYR.js → chunk-BHOXJGIE.js} +1 -1
- package/dist/chunk-BQ256JKN.js +39 -0
- package/dist/{chunk-7UH6REGV.js → chunk-C7ZJZEEN.js} +1 -1
- package/dist/{chunk-A6IO3HIN.cjs → chunk-FMHR5ABF.cjs} +28 -28
- package/dist/{chunk-JHGXIIBZ.cjs → chunk-G3R7ZVAG.cjs} +7 -7
- package/dist/{chunk-4MJMNIAB.js → chunk-GHABOHLA.js} +1 -1
- package/dist/chunk-GTV42PDK.cjs +46 -0
- package/dist/chunk-HEFA67WK.js +42 -0
- package/dist/chunk-HSF2D56O.js +40 -0
- package/dist/{chunk-GB3HW6DM.js → chunk-JWKDXFS4.js} +1 -1
- package/dist/{chunk-KWKHHRRJ.cjs → chunk-KKQKHG26.cjs} +3 -3
- package/dist/{chunk-QM73PI5L.cjs → chunk-N3ZCCKXV.cjs} +10 -10
- package/dist/{chunk-GQTO5ZE2.cjs → chunk-NE3ZHELZ.cjs} +0 -46
- package/dist/chunk-PWYWNRVO.cjs +150 -0
- package/dist/{chunk-E7WPE3PV.js → chunk-QAC72HKO.js} +1 -1
- package/dist/{chunk-CFF632IQ.cjs → chunk-SMHJRNCR.cjs} +4 -4
- package/dist/chunk-UOFTDL4D.js +146 -0
- package/dist/chunk-WEMNXIRS.js +47 -0
- package/dist/{chunk-LC5ZAUKL.cjs → chunk-XLQAALMU.cjs} +10 -10
- package/dist/{chunk-Z7LHRD3V.js → chunk-Y6NFUWTH.js} +3 -3
- package/dist/{chunk-LBGIUNM6.js → chunk-YY77CUWX.js} +1 -1
- package/dist/{chunk-UXLUE3HW.cjs → chunk-ZO2HREQL.cjs} +2 -2
- package/dist/components/index.cjs +126 -7
- package/dist/components/index.d.cts +35 -8
- package/dist/components/index.d.ts +35 -8
- package/dist/components/index.js +122 -7
- package/dist/hooks/index.cjs +368 -27
- package/dist/hooks/index.d.cts +83 -3
- package/dist/hooks/index.d.ts +83 -3
- package/dist/hooks/index.js +352 -14
- package/dist/middleware/index.cjs +47 -0
- package/dist/middleware/index.d.cts +8 -0
- package/dist/middleware/index.d.ts +8 -0
- package/dist/middleware/index.js +44 -0
- package/dist/models/index.d.cts +4 -3
- package/dist/models/index.d.ts +4 -3
- package/dist/{cart-VaCKkJ1C.d.cts → product-Dfi0ke-4.d.cts} +1 -88
- package/dist/{cart-VaCKkJ1C.d.ts → product-Dfi0ke-4.d.ts} +1 -88
- package/dist/store/index.cjs +17 -85
- package/dist/store/index.d.cts +22 -2
- package/dist/store/index.d.ts +22 -2
- package/dist/store/index.js +7 -82
- package/dist/utils/index.cjs +80 -65
- package/dist/utils/index.d.cts +54 -3
- package/dist/utils/index.d.ts +54 -3
- package/dist/utils/index.js +20 -43
- package/dist/{wishlist-FG8tgn76.d.ts → wishlist-DHOvXmJj.d.cts} +1 -1
- package/dist/{wishlist-CkAhLpbI.d.cts → wishlist-LfdFxddw.d.ts} +1 -1
- package/package.json +24 -5
- package/dist/chunk-7DQIKSGY.js +0 -40
- package/dist/chunk-FLBJKM6G.js +0 -83
- package/dist/chunk-S3WIGYDS.cjs +0 -42
package/dist/models/index.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
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 ApplicableTarget,
|
|
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-Dk-BoHUB.cjs';
|
|
3
|
+
export { A as ApplicableTarget, C as Cart, a as CartState, b as Category, c as Coupon, d as CouponResponse, e as CouponStatus, f as Coupons, D as DiscountType, V as ValueType } from '../cart-BY8D8w-s.cjs';
|
|
4
4
|
export { O as Order } from '../orders-DHJhJ3xz.cjs';
|
|
5
5
|
export { D as Data, P as PaymentInstrument, a as PhonePe } from '../phonepe-D7vn-9SR.cjs';
|
|
6
|
-
export {
|
|
6
|
+
export { A as Attributes, B as BookingService, a as BookingServiceDate, C as CustomField, O as OperatingHours, P as Photos, b as Product, c as ProductDetail, S as SpecialHours, T as TimeSlot, W as WishlistState } from '../product-Dfi0ke-4.cjs';
|
|
7
|
+
export { U as User, W as Wishlist } from '../wishlist-DHOvXmJj.cjs';
|
|
7
8
|
import 'react-toastify';
|
|
8
9
|
|
|
9
10
|
declare namespace CountryModel {
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
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 ApplicableTarget,
|
|
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-B39Ilxhg.js';
|
|
3
|
+
export { A as ApplicableTarget, C as Cart, a as CartState, b as Category, c as Coupon, d as CouponResponse, e as CouponStatus, f as Coupons, D as DiscountType, V as ValueType } from '../cart-GuhgeBBt.js';
|
|
4
4
|
export { O as Order } from '../orders-DHJhJ3xz.js';
|
|
5
5
|
export { D as Data, P as PaymentInstrument, a as PhonePe } from '../phonepe-D7vn-9SR.js';
|
|
6
|
-
export {
|
|
6
|
+
export { A as Attributes, B as BookingService, a as BookingServiceDate, C as CustomField, O as OperatingHours, P as Photos, b as Product, c as ProductDetail, S as SpecialHours, T as TimeSlot, W as WishlistState } from '../product-Dfi0ke-4.js';
|
|
7
|
+
export { U as User, W as Wishlist } from '../wishlist-LfdFxddw.js';
|
|
7
8
|
import 'react-toastify';
|
|
8
9
|
|
|
9
10
|
declare namespace CountryModel {
|
|
@@ -327,91 +327,4 @@ interface TimeSlot {
|
|
|
327
327
|
interface SpecialHours {
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
|
|
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
|
-
|
|
379
|
-
interface CartState {
|
|
380
|
-
cart: Cart.Root | null;
|
|
381
|
-
status: SLICE_STATUS;
|
|
382
|
-
}
|
|
383
|
-
declare namespace Cart {
|
|
384
|
-
interface Root {
|
|
385
|
-
product_variants: ProductDetail.Root[];
|
|
386
|
-
total_amount: number;
|
|
387
|
-
total_quantity: number;
|
|
388
|
-
products_quantity: ProductsQuantity;
|
|
389
|
-
cart_count: number;
|
|
390
|
-
missing_items: Array<any>;
|
|
391
|
-
customization_inputs: Array<CustomizationInput>;
|
|
392
|
-
total_coupon_discount: number;
|
|
393
|
-
variant_discounts: {
|
|
394
|
-
[key: number]: number;
|
|
395
|
-
};
|
|
396
|
-
total_shipping: number;
|
|
397
|
-
total_tax_amount: number;
|
|
398
|
-
applied_coupon: Coupon | {};
|
|
399
|
-
}
|
|
400
|
-
interface CustomizationInput {
|
|
401
|
-
id: number;
|
|
402
|
-
product_variant: number;
|
|
403
|
-
customization_option: number;
|
|
404
|
-
customer_wishlist: null;
|
|
405
|
-
customer_order: null;
|
|
406
|
-
customer_cart: number;
|
|
407
|
-
customer_input: string;
|
|
408
|
-
customization_option_name: string;
|
|
409
|
-
customization_option_type: string;
|
|
410
|
-
is_mandatory: boolean;
|
|
411
|
-
}
|
|
412
|
-
interface ProductsQuantity {
|
|
413
|
-
[key: number]: number;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
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 };
|
|
330
|
+
export { type Attributes as A, type BookingService as B, type CustomField as C, DEFAULT_TOAST_CONFIG as D, type OperatingHours as O, type Photos as P, type SpecialHours as S, type TimeSlot as T, USER_CART as U, type WishlistState as W, type BookingServiceDate as a, Product as b, ProductDetail as c, SLICE_STATUS as d, ADDRESS_FORM_SESSION_KEY as e, ALLOWED_COUNTRIES as f, PRODUCT_STATUSES as g, USER_CREDENTIALS as h, USER_CRED_REFRESH_TOKEN as i, USER_CRED_TOKEN as j, pathNameMap as p };
|
|
@@ -327,91 +327,4 @@ interface TimeSlot {
|
|
|
327
327
|
interface SpecialHours {
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
|
|
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
|
-
|
|
379
|
-
interface CartState {
|
|
380
|
-
cart: Cart.Root | null;
|
|
381
|
-
status: SLICE_STATUS;
|
|
382
|
-
}
|
|
383
|
-
declare namespace Cart {
|
|
384
|
-
interface Root {
|
|
385
|
-
product_variants: ProductDetail.Root[];
|
|
386
|
-
total_amount: number;
|
|
387
|
-
total_quantity: number;
|
|
388
|
-
products_quantity: ProductsQuantity;
|
|
389
|
-
cart_count: number;
|
|
390
|
-
missing_items: Array<any>;
|
|
391
|
-
customization_inputs: Array<CustomizationInput>;
|
|
392
|
-
total_coupon_discount: number;
|
|
393
|
-
variant_discounts: {
|
|
394
|
-
[key: number]: number;
|
|
395
|
-
};
|
|
396
|
-
total_shipping: number;
|
|
397
|
-
total_tax_amount: number;
|
|
398
|
-
applied_coupon: Coupon | {};
|
|
399
|
-
}
|
|
400
|
-
interface CustomizationInput {
|
|
401
|
-
id: number;
|
|
402
|
-
product_variant: number;
|
|
403
|
-
customization_option: number;
|
|
404
|
-
customer_wishlist: null;
|
|
405
|
-
customer_order: null;
|
|
406
|
-
customer_cart: number;
|
|
407
|
-
customer_input: string;
|
|
408
|
-
customization_option_name: string;
|
|
409
|
-
customization_option_type: string;
|
|
410
|
-
is_mandatory: boolean;
|
|
411
|
-
}
|
|
412
|
-
interface ProductsQuantity {
|
|
413
|
-
[key: number]: number;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
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 };
|
|
330
|
+
export { type Attributes as A, type BookingService as B, type CustomField as C, DEFAULT_TOAST_CONFIG as D, type OperatingHours as O, type Photos as P, type SpecialHours as S, type TimeSlot as T, USER_CART as U, type WishlistState as W, type BookingServiceDate as a, Product as b, ProductDetail as c, SLICE_STATUS as d, ADDRESS_FORM_SESSION_KEY as e, ALLOWED_COUNTRIES as f, PRODUCT_STATUSES as g, USER_CREDENTIALS as h, USER_CRED_REFRESH_TOKEN as i, USER_CRED_TOKEN as j, pathNameMap as p };
|
package/dist/store/index.cjs
CHANGED
|
@@ -1,88 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
require('../chunk-
|
|
7
|
-
|
|
3
|
+
var chunkPWYWNRVO_cjs = require('../chunk-PWYWNRVO.cjs');
|
|
4
|
+
var chunk26A3EBZI_cjs = require('../chunk-26A3EBZI.cjs');
|
|
5
|
+
require('../chunk-SMHJRNCR.cjs');
|
|
6
|
+
require('../chunk-ZO2HREQL.cjs');
|
|
7
|
+
require('../chunk-BBRXE57K.cjs');
|
|
8
|
+
require('../chunk-NE3ZHELZ.cjs');
|
|
8
9
|
require('../chunk-N3CTXRFT.cjs');
|
|
9
10
|
var zustand = require('zustand');
|
|
10
|
-
var typescriptCookie = require('typescript-cookie');
|
|
11
11
|
|
|
12
|
-
var getInitialState = () => ({
|
|
13
|
-
user: null,
|
|
14
|
-
status: "idle" /* IDLE */,
|
|
15
|
-
isAuthenticated: typeof window !== "undefined" ? !!typescriptCookie.getCookie(chunkGQTO5ZE2_cjs.USER_CRED_TOKEN) : false
|
|
16
|
-
});
|
|
17
|
-
var useAuthStore = zustand.create((set, get) => ({
|
|
18
|
-
...getInitialState(),
|
|
19
|
-
fetchUser: () => set({ status: "loading" /* LOADING */ }),
|
|
20
|
-
fetchUserSuccess: (user) => set({ user, status: "success" /* SUCCESS */, isAuthenticated: true }),
|
|
21
|
-
fetchUserFailure: (error) => set({ status: "failure" /* FAILURE */, isAuthenticated: false, error }),
|
|
22
|
-
setAuthenticated: () => set({ isAuthenticated: true }),
|
|
23
|
-
resetUser: () => set(getInitialState()),
|
|
24
|
-
logoutUser: () => {
|
|
25
|
-
try {
|
|
26
|
-
chunkGQTO5ZE2_cjs.auth_default.removeTokens();
|
|
27
|
-
set(getInitialState());
|
|
28
|
-
} catch {
|
|
29
|
-
set({ status: "failure" /* FAILURE */, isAuthenticated: false, error: "Something went wrong" });
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
loadCurrentUser: (user, referer, redirect = true, preventRefreshAfterLogin) => {
|
|
33
|
-
set({ status: "loading" /* LOADING */ });
|
|
34
|
-
setTimeout(async () => {
|
|
35
|
-
try {
|
|
36
|
-
set({ user, status: "success" /* SUCCESS */, isAuthenticated: true });
|
|
37
|
-
const localCartItems = chunkCFF632IQ_cjs.cart_default.get();
|
|
38
|
-
if (localCartItems) {
|
|
39
|
-
const response = await chunk34KV265H_cjs.addToCart(
|
|
40
|
-
Object.entries(localCartItems.products_quantity).map(
|
|
41
|
-
([key, value]) => ({
|
|
42
|
-
variant_id: parseInt(key),
|
|
43
|
-
quantity: value
|
|
44
|
-
})
|
|
45
|
-
)
|
|
46
|
-
);
|
|
47
|
-
if (response) {
|
|
48
|
-
chunkCFF632IQ_cjs.cart_default.clear();
|
|
49
|
-
chunkS3WIGYDS_cjs.useCartStore.getState().fetchCart();
|
|
50
|
-
setTimeout(() => {
|
|
51
|
-
if (!preventRefreshAfterLogin) {
|
|
52
|
-
if (redirect) {
|
|
53
|
-
window.location.href = referer;
|
|
54
|
-
} else {
|
|
55
|
-
window.location.reload();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}, 500);
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
if (!preventRefreshAfterLogin) {
|
|
62
|
-
if (redirect) {
|
|
63
|
-
window.location.href = referer;
|
|
64
|
-
} else {
|
|
65
|
-
window.location.reload();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
} catch {
|
|
70
|
-
localStorage.removeItem("userExists");
|
|
71
|
-
set({
|
|
72
|
-
status: "failure" /* FAILURE */,
|
|
73
|
-
isAuthenticated: false,
|
|
74
|
-
error: "Something went wrong while fetching user"
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}, 1e3);
|
|
78
|
-
}
|
|
79
|
-
}));
|
|
80
|
-
var loginUser = async (user) => {
|
|
81
|
-
const { access, refresh, ...userData } = user;
|
|
82
|
-
localStorage.setItem(chunkGQTO5ZE2_cjs.USER_CREDENTIALS, JSON.stringify(userData));
|
|
83
|
-
chunkGQTO5ZE2_cjs.auth_default.setAccessToken(access);
|
|
84
|
-
chunkGQTO5ZE2_cjs.auth_default.setRefreshToken(refresh);
|
|
85
|
-
};
|
|
86
12
|
var initialState = {
|
|
87
13
|
wishlist_count: 0,
|
|
88
14
|
product_variants: []
|
|
@@ -93,7 +19,7 @@ var useWishlistStore = zustand.create((set) => ({
|
|
|
93
19
|
resetWishlist: () => set(initialState),
|
|
94
20
|
syncWishlist: async () => {
|
|
95
21
|
try {
|
|
96
|
-
const response = await
|
|
22
|
+
const response = await chunk26A3EBZI_cjs.getWishlist("/customer/wishlist/");
|
|
97
23
|
if (response) {
|
|
98
24
|
set({
|
|
99
25
|
wishlist_count: response.wishlist_count,
|
|
@@ -121,7 +47,7 @@ var useProductStore = zustand.create((set, get) => ({
|
|
|
121
47
|
data: filter.page === 1 ? [] : state.data
|
|
122
48
|
}));
|
|
123
49
|
try {
|
|
124
|
-
const response = await
|
|
50
|
+
const response = await chunk26A3EBZI_cjs.getProducts({ ...filter });
|
|
125
51
|
if (response.data) {
|
|
126
52
|
const { results, ...meta } = response.data;
|
|
127
53
|
set((state) => ({
|
|
@@ -139,11 +65,17 @@ var useProductStore = zustand.create((set, get) => ({
|
|
|
139
65
|
setGatePasses: (products) => set({ data: products })
|
|
140
66
|
}));
|
|
141
67
|
|
|
68
|
+
Object.defineProperty(exports, "loginUser", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function () { return chunkPWYWNRVO_cjs.loginUser; }
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "useAuthStore", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () { return chunkPWYWNRVO_cjs.useAuthStore; }
|
|
75
|
+
});
|
|
142
76
|
Object.defineProperty(exports, "useCartStore", {
|
|
143
77
|
enumerable: true,
|
|
144
|
-
get: function () { return
|
|
78
|
+
get: function () { return chunkPWYWNRVO_cjs.useCartStore; }
|
|
145
79
|
});
|
|
146
|
-
exports.loginUser = loginUser;
|
|
147
|
-
exports.useAuthStore = useAuthStore;
|
|
148
80
|
exports.useProductStore = useProductStore;
|
|
149
81
|
exports.useWishlistStore = useWishlistStore;
|
package/dist/store/index.d.cts
CHANGED
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
import * as zustand from 'zustand';
|
|
2
|
-
import {
|
|
3
|
-
import { U as User, W as Wishlist } from '../wishlist-
|
|
2
|
+
import { a as CartState, C as Cart } from '../cart-BY8D8w-s.cjs';
|
|
3
|
+
import { U as User, W as Wishlist } from '../wishlist-DHOvXmJj.cjs';
|
|
4
|
+
import { b as Product } from '../product-Dfi0ke-4.cjs';
|
|
4
5
|
import 'react-toastify';
|
|
5
6
|
|
|
6
7
|
interface CartStore extends CartState {
|
|
7
8
|
setCart: (cart: Cart.Root) => void;
|
|
8
9
|
resetCart: () => void;
|
|
9
10
|
resetCartCount: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Fetch latest cart from backend (or local) and update state.
|
|
13
|
+
*/
|
|
10
14
|
syncCart: (addressId?: number) => Promise<void>;
|
|
11
15
|
fetchCart: (addressId?: number) => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Cart modification helpers that call the corresponding API and
|
|
18
|
+
* automatically synchronize the store afterwards.
|
|
19
|
+
*/
|
|
20
|
+
addToCart: (items: Array<{
|
|
21
|
+
variant_id: number;
|
|
22
|
+
quantity: number;
|
|
23
|
+
}>, customizationInputs?: any, addressId?: number) => Promise<void>;
|
|
24
|
+
removeFromCart: (items: Array<{
|
|
25
|
+
variant_id: number;
|
|
26
|
+
quantity: number;
|
|
27
|
+
}>, addressId?: number) => Promise<void>;
|
|
28
|
+
updateCart: (items: Array<{
|
|
29
|
+
variant_id: number;
|
|
30
|
+
quantity: number;
|
|
31
|
+
}>, addressId?: number) => Promise<void>;
|
|
12
32
|
}
|
|
13
33
|
declare const useCartStore: zustand.UseBoundStore<zustand.StoreApi<CartStore>>;
|
|
14
34
|
|
package/dist/store/index.d.ts
CHANGED
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
import * as zustand from 'zustand';
|
|
2
|
-
import {
|
|
3
|
-
import { U as User, W as Wishlist } from '../wishlist-
|
|
2
|
+
import { a as CartState, C as Cart } from '../cart-GuhgeBBt.js';
|
|
3
|
+
import { U as User, W as Wishlist } from '../wishlist-LfdFxddw.js';
|
|
4
|
+
import { b as Product } from '../product-Dfi0ke-4.js';
|
|
4
5
|
import 'react-toastify';
|
|
5
6
|
|
|
6
7
|
interface CartStore extends CartState {
|
|
7
8
|
setCart: (cart: Cart.Root) => void;
|
|
8
9
|
resetCart: () => void;
|
|
9
10
|
resetCartCount: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Fetch latest cart from backend (or local) and update state.
|
|
13
|
+
*/
|
|
10
14
|
syncCart: (addressId?: number) => Promise<void>;
|
|
11
15
|
fetchCart: (addressId?: number) => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Cart modification helpers that call the corresponding API and
|
|
18
|
+
* automatically synchronize the store afterwards.
|
|
19
|
+
*/
|
|
20
|
+
addToCart: (items: Array<{
|
|
21
|
+
variant_id: number;
|
|
22
|
+
quantity: number;
|
|
23
|
+
}>, customizationInputs?: any, addressId?: number) => Promise<void>;
|
|
24
|
+
removeFromCart: (items: Array<{
|
|
25
|
+
variant_id: number;
|
|
26
|
+
quantity: number;
|
|
27
|
+
}>, addressId?: number) => Promise<void>;
|
|
28
|
+
updateCart: (items: Array<{
|
|
29
|
+
variant_id: number;
|
|
30
|
+
quantity: number;
|
|
31
|
+
}>, addressId?: number) => Promise<void>;
|
|
12
32
|
}
|
|
13
33
|
declare const useCartStore: zustand.UseBoundStore<zustand.StoreApi<CartStore>>;
|
|
14
34
|
|
package/dist/store/index.js
CHANGED
|
@@ -1,87 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import '../chunk-
|
|
6
|
-
import
|
|
1
|
+
export { loginUser, useAuthStore, useCartStore } from '../chunk-UOFTDL4D.js';
|
|
2
|
+
import { getWishlist, getProducts } from '../chunk-Y6NFUWTH.js';
|
|
3
|
+
import '../chunk-QAC72HKO.js';
|
|
4
|
+
import '../chunk-JWKDXFS4.js';
|
|
5
|
+
import '../chunk-WEMNXIRS.js';
|
|
6
|
+
import '../chunk-BQ256JKN.js';
|
|
7
7
|
import '../chunk-JQMLHRWL.js';
|
|
8
8
|
import { create } from 'zustand';
|
|
9
|
-
import { getCookie } from 'typescript-cookie';
|
|
10
9
|
|
|
11
|
-
var getInitialState = () => ({
|
|
12
|
-
user: null,
|
|
13
|
-
status: "idle" /* IDLE */,
|
|
14
|
-
isAuthenticated: typeof window !== "undefined" ? !!getCookie(USER_CRED_TOKEN) : false
|
|
15
|
-
});
|
|
16
|
-
var useAuthStore = create((set, get) => ({
|
|
17
|
-
...getInitialState(),
|
|
18
|
-
fetchUser: () => set({ status: "loading" /* LOADING */ }),
|
|
19
|
-
fetchUserSuccess: (user) => set({ user, status: "success" /* SUCCESS */, isAuthenticated: true }),
|
|
20
|
-
fetchUserFailure: (error) => set({ status: "failure" /* FAILURE */, isAuthenticated: false, error }),
|
|
21
|
-
setAuthenticated: () => set({ isAuthenticated: true }),
|
|
22
|
-
resetUser: () => set(getInitialState()),
|
|
23
|
-
logoutUser: () => {
|
|
24
|
-
try {
|
|
25
|
-
auth_default.removeTokens();
|
|
26
|
-
set(getInitialState());
|
|
27
|
-
} catch {
|
|
28
|
-
set({ status: "failure" /* FAILURE */, isAuthenticated: false, error: "Something went wrong" });
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
loadCurrentUser: (user, referer, redirect = true, preventRefreshAfterLogin) => {
|
|
32
|
-
set({ status: "loading" /* LOADING */ });
|
|
33
|
-
setTimeout(async () => {
|
|
34
|
-
try {
|
|
35
|
-
set({ user, status: "success" /* SUCCESS */, isAuthenticated: true });
|
|
36
|
-
const localCartItems = cart_default.get();
|
|
37
|
-
if (localCartItems) {
|
|
38
|
-
const response = await addToCart(
|
|
39
|
-
Object.entries(localCartItems.products_quantity).map(
|
|
40
|
-
([key, value]) => ({
|
|
41
|
-
variant_id: parseInt(key),
|
|
42
|
-
quantity: value
|
|
43
|
-
})
|
|
44
|
-
)
|
|
45
|
-
);
|
|
46
|
-
if (response) {
|
|
47
|
-
cart_default.clear();
|
|
48
|
-
useCartStore.getState().fetchCart();
|
|
49
|
-
setTimeout(() => {
|
|
50
|
-
if (!preventRefreshAfterLogin) {
|
|
51
|
-
if (redirect) {
|
|
52
|
-
window.location.href = referer;
|
|
53
|
-
} else {
|
|
54
|
-
window.location.reload();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}, 500);
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
60
|
-
if (!preventRefreshAfterLogin) {
|
|
61
|
-
if (redirect) {
|
|
62
|
-
window.location.href = referer;
|
|
63
|
-
} else {
|
|
64
|
-
window.location.reload();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
} catch {
|
|
69
|
-
localStorage.removeItem("userExists");
|
|
70
|
-
set({
|
|
71
|
-
status: "failure" /* FAILURE */,
|
|
72
|
-
isAuthenticated: false,
|
|
73
|
-
error: "Something went wrong while fetching user"
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}, 1e3);
|
|
77
|
-
}
|
|
78
|
-
}));
|
|
79
|
-
var loginUser = async (user) => {
|
|
80
|
-
const { access, refresh, ...userData } = user;
|
|
81
|
-
localStorage.setItem(USER_CREDENTIALS, JSON.stringify(userData));
|
|
82
|
-
auth_default.setAccessToken(access);
|
|
83
|
-
auth_default.setRefreshToken(refresh);
|
|
84
|
-
};
|
|
85
10
|
var initialState = {
|
|
86
11
|
wishlist_count: 0,
|
|
87
12
|
product_variants: []
|
|
@@ -138,4 +63,4 @@ var useProductStore = create((set, get) => ({
|
|
|
138
63
|
setGatePasses: (products) => set({ data: products })
|
|
139
64
|
}));
|
|
140
65
|
|
|
141
|
-
export {
|
|
66
|
+
export { useProductStore, useWishlistStore };
|