@storepecker/storefront-core 1.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/address-DQEZzyUG.d.cts +19 -0
- package/dist/address-DQEZzyUG.d.ts +19 -0
- package/dist/api/index.cjs +367 -0
- package/dist/api/index.d.cts +127 -0
- package/dist/api/index.d.ts +127 -0
- package/dist/api/index.js +131 -0
- package/dist/booking-ClX-dhX7.d.ts +131 -0
- package/dist/booking-Drl7-IL7.d.cts +131 -0
- package/dist/cart-DVrn8hD0.d.cts +367 -0
- package/dist/cart-DVrn8hD0.d.ts +367 -0
- package/dist/checkout/index.cjs +228 -0
- package/dist/checkout/index.d.cts +251 -0
- package/dist/checkout/index.d.ts +251 -0
- package/dist/checkout/index.js +122 -0
- package/dist/chunk-4CVKE6CC.cjs +312 -0
- package/dist/chunk-4MJMNIAB.js +123 -0
- package/dist/chunk-57ZBPAXU.js +114 -0
- package/dist/chunk-7MQOVWLW.js +40 -0
- package/dist/chunk-7UH6REGV.js +12 -0
- package/dist/chunk-A6IO3HIN.cjs +151 -0
- package/dist/chunk-CFF632IQ.cjs +100 -0
- package/dist/chunk-CSISWBZZ.js +121 -0
- package/dist/chunk-E7WPE3PV.js +98 -0
- package/dist/chunk-FLBJKM6G.js +83 -0
- package/dist/chunk-GB3HW6DM.js +61 -0
- package/dist/chunk-GH75WUO2.cjs +42 -0
- package/dist/chunk-GQTO5ZE2.cjs +96 -0
- package/dist/chunk-JHGXIIBZ.cjs +37 -0
- package/dist/chunk-JQMLHRWL.js +21 -0
- package/dist/chunk-K44JZ5NL.cjs +212 -0
- package/dist/chunk-K5B62JZO.cjs +154 -0
- package/dist/chunk-KWKHHRRJ.cjs +15 -0
- package/dist/chunk-LBGIUNM6.js +30 -0
- package/dist/chunk-LC5ZAUKL.cjs +220 -0
- package/dist/chunk-N3CTXRFT.cjs +30 -0
- package/dist/chunk-QCQCFYYR.js +206 -0
- package/dist/chunk-QM73PI5L.cjs +218 -0
- package/dist/chunk-RCXQJ6XC.cjs +131 -0
- package/dist/chunk-UM24VDYB.js +216 -0
- package/dist/chunk-UXLUE3HW.cjs +69 -0
- package/dist/chunk-WFDKKOO7.js +210 -0
- package/dist/chunk-YUPBTD4M.js +289 -0
- package/dist/components/index.cjs +576 -0
- package/dist/components/index.css +329 -0
- package/dist/components/index.d.cts +58 -0
- package/dist/components/index.d.ts +58 -0
- package/dist/components/index.js +569 -0
- package/dist/coupons-C7iJ-1cy.d.cts +37 -0
- package/dist/coupons-CnfTKL1i.d.ts +37 -0
- package/dist/hooks/index.cjs +381 -0
- package/dist/hooks/index.d.cts +123 -0
- package/dist/hooks/index.d.ts +123 -0
- package/dist/hooks/index.js +364 -0
- package/dist/index-DTyIuLuI.d.cts +18 -0
- package/dist/index-DTyIuLuI.d.ts +18 -0
- package/dist/index.cjs +14 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/models/index.cjs +2 -0
- package/dist/models/index.d.cts +53 -0
- package/dist/models/index.d.ts +53 -0
- package/dist/models/index.js +1 -0
- package/dist/orders-CkUzv5Xh.d.ts +159 -0
- package/dist/orders-D0oC9ugD.d.cts +159 -0
- package/dist/phonepe-D7vn-9SR.d.cts +27 -0
- package/dist/phonepe-D7vn-9SR.d.ts +27 -0
- package/dist/store/index.cjs +149 -0
- package/dist/store/index.d.cts +46 -0
- package/dist/store/index.d.ts +46 -0
- package/dist/store/index.js +141 -0
- package/dist/useAddressForm-C-Uzug4d.d.ts +42 -0
- package/dist/useAddressForm-DgkCP1nG.d.cts +42 -0
- package/dist/utils/index.cjs +535 -0
- package/dist/utils/index.d.cts +507 -0
- package/dist/utils/index.d.ts +507 -0
- package/dist/utils/index.js +342 -0
- package/dist/wishlist-BzhnCAQD.d.ts +41 -0
- package/dist/wishlist-CBCZD66Y.d.cts +41 -0
- package/package.json +134 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/utils/cache.ts
|
|
4
|
+
var DEFAULT_EXPIRY_HOURS = 24;
|
|
5
|
+
var CacheManager = class _CacheManager {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
8
|
+
this.loadFromStorage();
|
|
9
|
+
}
|
|
10
|
+
static getInstance() {
|
|
11
|
+
if (!_CacheManager.instance) {
|
|
12
|
+
_CacheManager.instance = new _CacheManager();
|
|
13
|
+
}
|
|
14
|
+
return _CacheManager.instance;
|
|
15
|
+
}
|
|
16
|
+
loadFromStorage() {
|
|
17
|
+
if (typeof window === "undefined") return;
|
|
18
|
+
try {
|
|
19
|
+
const stored = localStorage.getItem("app_cache");
|
|
20
|
+
if (stored) {
|
|
21
|
+
const parsed = JSON.parse(stored);
|
|
22
|
+
this.cache = new Map(Object.entries(parsed));
|
|
23
|
+
this.cleanExpired();
|
|
24
|
+
}
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.warn("Failed to load cache from storage:", error);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
saveToStorage() {
|
|
30
|
+
if (typeof window === "undefined") return;
|
|
31
|
+
try {
|
|
32
|
+
const cacheObject = Object.fromEntries(this.cache);
|
|
33
|
+
localStorage.setItem("app_cache", JSON.stringify(cacheObject));
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.warn("Failed to save cache to storage:", error);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
cleanExpired() {
|
|
39
|
+
const now = Date.now();
|
|
40
|
+
const keysToDelete = [];
|
|
41
|
+
this.cache.forEach((item, key) => {
|
|
42
|
+
if (now > item.expiry) {
|
|
43
|
+
keysToDelete.push(key);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
keysToDelete.forEach((key) => {
|
|
47
|
+
this.cache.delete(key);
|
|
48
|
+
});
|
|
49
|
+
this.saveToStorage();
|
|
50
|
+
}
|
|
51
|
+
set(key, data, options = {}) {
|
|
52
|
+
const expiryHours = options.expiryHours || DEFAULT_EXPIRY_HOURS;
|
|
53
|
+
const now = Date.now();
|
|
54
|
+
const expiry = now + expiryHours * 60 * 60 * 1e3;
|
|
55
|
+
const cacheItem = {
|
|
56
|
+
data,
|
|
57
|
+
timestamp: now,
|
|
58
|
+
expiry
|
|
59
|
+
};
|
|
60
|
+
this.cache.set(key, cacheItem);
|
|
61
|
+
this.saveToStorage();
|
|
62
|
+
}
|
|
63
|
+
get(key) {
|
|
64
|
+
this.cleanExpired();
|
|
65
|
+
const item = this.cache.get(key);
|
|
66
|
+
if (!item) return null;
|
|
67
|
+
const now = Date.now();
|
|
68
|
+
if (now > item.expiry) {
|
|
69
|
+
this.cache.delete(key);
|
|
70
|
+
this.saveToStorage();
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return item.data;
|
|
74
|
+
}
|
|
75
|
+
has(key) {
|
|
76
|
+
this.cleanExpired();
|
|
77
|
+
return this.cache.has(key);
|
|
78
|
+
}
|
|
79
|
+
delete(key) {
|
|
80
|
+
this.cache.delete(key);
|
|
81
|
+
this.saveToStorage();
|
|
82
|
+
}
|
|
83
|
+
clear() {
|
|
84
|
+
this.cache.clear();
|
|
85
|
+
if (typeof window !== "undefined") {
|
|
86
|
+
localStorage.removeItem("app_cache");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
getCacheInfo() {
|
|
90
|
+
this.cleanExpired();
|
|
91
|
+
return {
|
|
92
|
+
size: this.cache.size,
|
|
93
|
+
keys: Array.from(this.cache.keys())
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
invalidateCache(pattern) {
|
|
97
|
+
this.cleanExpired();
|
|
98
|
+
if (!pattern) {
|
|
99
|
+
this.clear();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const keysToDelete = [];
|
|
103
|
+
this.cache.forEach((item, key) => {
|
|
104
|
+
if (key.includes(pattern)) {
|
|
105
|
+
keysToDelete.push(key);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
keysToDelete.forEach((key) => {
|
|
109
|
+
this.cache.delete(key);
|
|
110
|
+
});
|
|
111
|
+
this.saveToStorage();
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
var cache = CacheManager.getInstance();
|
|
115
|
+
function setCache(key, data, options = {}) {
|
|
116
|
+
cache.set(key, data, options);
|
|
117
|
+
}
|
|
118
|
+
function getCache(key) {
|
|
119
|
+
return cache.get(key);
|
|
120
|
+
}
|
|
121
|
+
function hasCache(key) {
|
|
122
|
+
return cache.has(key);
|
|
123
|
+
}
|
|
124
|
+
function deleteCache(key) {
|
|
125
|
+
cache.delete(key);
|
|
126
|
+
}
|
|
127
|
+
function clearCache() {
|
|
128
|
+
cache.clear();
|
|
129
|
+
}
|
|
130
|
+
function invalidateCache(pattern) {
|
|
131
|
+
cache.invalidateCache(pattern);
|
|
132
|
+
}
|
|
133
|
+
function generateCacheKey(endpoint, params) {
|
|
134
|
+
const baseKey = endpoint.replace(/[^a-zA-Z0-9]/g, "_");
|
|
135
|
+
if (!params) return baseKey;
|
|
136
|
+
const paramString = JSON.stringify(params);
|
|
137
|
+
const hash = btoa(paramString).replace(/[^a-zA-Z0-9]/g, "");
|
|
138
|
+
return `${baseKey}_${hash}`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// src/utils/misc.ts
|
|
142
|
+
function convertObjectToParams(params) {
|
|
143
|
+
const cleanedParams = Object.fromEntries(
|
|
144
|
+
Object.entries(params).filter(([_, value]) => value !== void 0)
|
|
145
|
+
);
|
|
146
|
+
const searchParams = new URLSearchParams(cleanedParams);
|
|
147
|
+
return searchParams.toString();
|
|
148
|
+
}
|
|
149
|
+
function getParamsFromURL() {
|
|
150
|
+
if (typeof window === "undefined") return {};
|
|
151
|
+
const queryParams = {};
|
|
152
|
+
const search = window.location.search;
|
|
153
|
+
const searchParams = new URLSearchParams(search);
|
|
154
|
+
searchParams.forEach((value, key) => {
|
|
155
|
+
if (value.includes(",")) {
|
|
156
|
+
queryParams[key] = value.split(",");
|
|
157
|
+
} else if (isNaN(Number(value))) {
|
|
158
|
+
queryParams[key] = value;
|
|
159
|
+
} else queryParams[key] = Number(value);
|
|
160
|
+
});
|
|
161
|
+
return queryParams;
|
|
162
|
+
}
|
|
163
|
+
function pushParamsToURL(params) {
|
|
164
|
+
const cleanedParams = Object.fromEntries(
|
|
165
|
+
Object.entries(params).filter(([_, value]) => {
|
|
166
|
+
return Array.isArray(value) ? value.length : !(value === void 0 || value === 0);
|
|
167
|
+
})
|
|
168
|
+
);
|
|
169
|
+
const searchParams = new URLSearchParams(cleanedParams);
|
|
170
|
+
return searchParams.toString();
|
|
171
|
+
}
|
|
172
|
+
function convertToCurrency(amount, fraction = 0, currency) {
|
|
173
|
+
return amount?.toLocaleString("en-IN", {
|
|
174
|
+
style: "currency",
|
|
175
|
+
currency: currency || (typeof window !== "undefined" ? window.currency_code : void 0) || "INR",
|
|
176
|
+
maximumFractionDigits: fraction
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
function formatDateTime(date) {
|
|
180
|
+
return new Date(date).toLocaleString("en-IN", {
|
|
181
|
+
dateStyle: "medium"
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
var getQueryParams = (params, filterKeys = []) => {
|
|
185
|
+
let filterParams = params;
|
|
186
|
+
Object.keys(filterParams).forEach((key) => {
|
|
187
|
+
const value = filterParams[key];
|
|
188
|
+
if (!value) {
|
|
189
|
+
delete filterParams[key];
|
|
190
|
+
}
|
|
191
|
+
if (filterKeys.includes(key)) {
|
|
192
|
+
if (value && !Array.isArray(value)) {
|
|
193
|
+
filterParams[key] = value.toString()?.split(",");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
return filterParams;
|
|
198
|
+
};
|
|
199
|
+
var shareLink = (shareData, title, url) => {
|
|
200
|
+
if (navigator.share) {
|
|
201
|
+
navigator.share({
|
|
202
|
+
title: "Storepecker",
|
|
203
|
+
text: shareData,
|
|
204
|
+
url: url || window.location.href
|
|
205
|
+
});
|
|
206
|
+
} else {
|
|
207
|
+
navigator.clipboard.writeText(window.location.href);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
function pluralize(strings, count, singular, plural) {
|
|
211
|
+
const word = count === 1 ? singular : plural;
|
|
212
|
+
return `${strings[0]}${count} ${word}${strings[1]}`;
|
|
213
|
+
}
|
|
214
|
+
async function digestMessage(message) {
|
|
215
|
+
const msgUint8 = new TextEncoder().encode(message);
|
|
216
|
+
const hashBuffer = await window.crypto.subtle.digest("SHA-256", msgUint8);
|
|
217
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
218
|
+
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
219
|
+
return hashHex;
|
|
220
|
+
}
|
|
221
|
+
var constructFilter = (filter) => {
|
|
222
|
+
if (filter) {
|
|
223
|
+
const filtersObj = {};
|
|
224
|
+
filter.forEach((filter2) => {
|
|
225
|
+
if (filtersObj[filter2.type]) {
|
|
226
|
+
if (Array.isArray(filter2.value)) {
|
|
227
|
+
filtersObj[filter2.type] = filtersObj[filter2.type] + "," + filter2.value.join(",");
|
|
228
|
+
} else {
|
|
229
|
+
filtersObj[filter2.type] = filtersObj[filter2.type] + "," + filter2.value;
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
filtersObj[filter2.type] = Array.isArray(filter2.value) ? filter2.value.join(",") : filter2.value;
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
return filtersObj;
|
|
236
|
+
}
|
|
237
|
+
return {};
|
|
238
|
+
};
|
|
239
|
+
var getDelayInMilliseconds = (value, unit) => {
|
|
240
|
+
switch (unit) {
|
|
241
|
+
case "seconds":
|
|
242
|
+
return value * 1e3;
|
|
243
|
+
case "minutes":
|
|
244
|
+
return value * 60 * 1e3;
|
|
245
|
+
case "hours":
|
|
246
|
+
return value * 60 * 60 * 1e3;
|
|
247
|
+
case "days":
|
|
248
|
+
return value * 24 * 60 * 60 * 1e3;
|
|
249
|
+
case "weeks":
|
|
250
|
+
return value * 7 * 24 * 60 * 60 * 1e3;
|
|
251
|
+
case "months":
|
|
252
|
+
return value * 30 * 24 * 60 * 60 * 1e3;
|
|
253
|
+
default:
|
|
254
|
+
return value * 1e3;
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
function formatPostalLabel(zipNameType) {
|
|
258
|
+
if (!zipNameType) return "";
|
|
259
|
+
const t = zipNameType.toLowerCase();
|
|
260
|
+
switch (t) {
|
|
261
|
+
case "zip":
|
|
262
|
+
return "ZIP Code";
|
|
263
|
+
case "pin":
|
|
264
|
+
return "PIN Code";
|
|
265
|
+
case "postal":
|
|
266
|
+
return "Postal Code";
|
|
267
|
+
case "post":
|
|
268
|
+
return "Postcode";
|
|
269
|
+
case "eir":
|
|
270
|
+
return "Eircode";
|
|
271
|
+
case "cep":
|
|
272
|
+
return "CEP";
|
|
273
|
+
case "cap":
|
|
274
|
+
return "CAP";
|
|
275
|
+
default:
|
|
276
|
+
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
async function getAddressMeta(countryCode) {
|
|
280
|
+
const res = await fetch(
|
|
281
|
+
`https://chromium-i18n.appspot.com/ssl-address/data/${countryCode}`
|
|
282
|
+
);
|
|
283
|
+
const data = await res.json();
|
|
284
|
+
return {
|
|
285
|
+
regionLabel: data.state_name_type || "State",
|
|
286
|
+
postalLabel: formatPostalLabel(data.zip_name_type) || "Postal Code",
|
|
287
|
+
hasPostal: !!data.zip_name_type
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
exports.CacheManager = CacheManager;
|
|
292
|
+
exports.cache = cache;
|
|
293
|
+
exports.clearCache = clearCache;
|
|
294
|
+
exports.constructFilter = constructFilter;
|
|
295
|
+
exports.convertObjectToParams = convertObjectToParams;
|
|
296
|
+
exports.convertToCurrency = convertToCurrency;
|
|
297
|
+
exports.deleteCache = deleteCache;
|
|
298
|
+
exports.digestMessage = digestMessage;
|
|
299
|
+
exports.formatDateTime = formatDateTime;
|
|
300
|
+
exports.formatPostalLabel = formatPostalLabel;
|
|
301
|
+
exports.generateCacheKey = generateCacheKey;
|
|
302
|
+
exports.getAddressMeta = getAddressMeta;
|
|
303
|
+
exports.getCache = getCache;
|
|
304
|
+
exports.getDelayInMilliseconds = getDelayInMilliseconds;
|
|
305
|
+
exports.getParamsFromURL = getParamsFromURL;
|
|
306
|
+
exports.getQueryParams = getQueryParams;
|
|
307
|
+
exports.hasCache = hasCache;
|
|
308
|
+
exports.invalidateCache = invalidateCache;
|
|
309
|
+
exports.pluralize = pluralize;
|
|
310
|
+
exports.pushParamsToURL = pushParamsToURL;
|
|
311
|
+
exports.setCache = setCache;
|
|
312
|
+
exports.shareLink = shareLink;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { http_service_default } from './chunk-GB3HW6DM.js';
|
|
2
|
+
|
|
3
|
+
// src/api/coupon.ts
|
|
4
|
+
async function getCoupons() {
|
|
5
|
+
return http_service_default.get("/coupon/available/");
|
|
6
|
+
}
|
|
7
|
+
async function applyCoupon(couponCode) {
|
|
8
|
+
return http_service_default.post("/coupon/use/", { coupon_code: couponCode });
|
|
9
|
+
}
|
|
10
|
+
async function getAppliedCoupon() {
|
|
11
|
+
return http_service_default.get("/coupon/use/");
|
|
12
|
+
}
|
|
13
|
+
async function removeCoupon(couponCode) {
|
|
14
|
+
return http_service_default.delete("/coupon/use/");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/api/orders.ts
|
|
18
|
+
async function getOrders(url) {
|
|
19
|
+
const response = await http_service_default.get(url);
|
|
20
|
+
return response.data;
|
|
21
|
+
}
|
|
22
|
+
async function getOrderDetails(orderId) {
|
|
23
|
+
return http_service_default.get("/customer/order/", {
|
|
24
|
+
params: { order_id: orderId }
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async function getOrderDetailsByNumber(orderNumber) {
|
|
28
|
+
return http_service_default.get("/customer/order/", {
|
|
29
|
+
params: { order_number: orderNumber }
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async function getPublicOrderDetailsByNumber(orderNumber) {
|
|
33
|
+
return http_service_default.get("/customer/public_order/", {
|
|
34
|
+
params: { order_number: orderNumber }
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async function placeOrder(address_id, redirect, isCod, stripeRedirect, tabbyRedirect) {
|
|
38
|
+
return http_service_default.post("/customer/order/", {
|
|
39
|
+
address_id,
|
|
40
|
+
phonepe_redirect_url: redirect,
|
|
41
|
+
is_cod: isCod,
|
|
42
|
+
stripe_redirect_url: stripeRedirect,
|
|
43
|
+
tabby_redirect_url: tabbyRedirect
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async function publicPlaceOrder(address, redirect, orderDetails, stripeRedirect, tabbyRedirect) {
|
|
47
|
+
return http_service_default.post("/customer/public_order/", {
|
|
48
|
+
address,
|
|
49
|
+
phonepe_redirect_url: redirect,
|
|
50
|
+
stripe_redirect_url: stripeRedirect,
|
|
51
|
+
tabby_redirect_url: tabbyRedirect,
|
|
52
|
+
...orderDetails
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async function updateOrder(orderDetails) {
|
|
56
|
+
return http_service_default.patch("/customer/order/", orderDetails);
|
|
57
|
+
}
|
|
58
|
+
async function razorpayPublicOrderSuccess(orderDetails) {
|
|
59
|
+
return http_service_default.post("/payment/public-razorpay-order-success/", orderDetails);
|
|
60
|
+
}
|
|
61
|
+
async function razorpayOrderSuccess(orderDetails) {
|
|
62
|
+
return http_service_default.post("/payment/razorpay-order-success/", orderDetails);
|
|
63
|
+
}
|
|
64
|
+
async function razorpayOrderFail(orderDetails) {
|
|
65
|
+
return http_service_default.post("/payment/razorpay-order-fail/", orderDetails);
|
|
66
|
+
}
|
|
67
|
+
async function phonepePublicOrderSuccess(orderDetails) {
|
|
68
|
+
return http_service_default.post("/payment/public-phonepe-order-success/", orderDetails);
|
|
69
|
+
}
|
|
70
|
+
async function phonepeOrderSuccess(orderDetails) {
|
|
71
|
+
return http_service_default.post("/payment/phonepe-order-success/", orderDetails);
|
|
72
|
+
}
|
|
73
|
+
async function checkPhonepePaymentStatus(transactionId) {
|
|
74
|
+
return http_service_default.get("/payment/phonepe-order-success/", {
|
|
75
|
+
params: { phonepe_transaction_id: transactionId }
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
async function getStripePaymentStatus(stripeCheckoutSessionId, order_number, payment_link_id) {
|
|
79
|
+
return http_service_default.get("/payment/stripe-payment-status/", {
|
|
80
|
+
params: {
|
|
81
|
+
checkout_session_id: stripeCheckoutSessionId,
|
|
82
|
+
order_number,
|
|
83
|
+
payment_link_id
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
async function getStripePaymentStatusPublic(stripeCheckoutSessionId, order_number, payment_link_id) {
|
|
88
|
+
return http_service_default.get("/payment/public-stripe-payment-status/", {
|
|
89
|
+
params: {
|
|
90
|
+
checkout_session_id: stripeCheckoutSessionId,
|
|
91
|
+
order_number,
|
|
92
|
+
payment_link_id
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async function stripePublicOrderSuccess(orderDetails) {
|
|
97
|
+
return http_service_default.post("/payment/public-stripe-order-success/", orderDetails);
|
|
98
|
+
}
|
|
99
|
+
async function stripeOrderSuccess(orderDetails) {
|
|
100
|
+
return http_service_default.post("/payment/stripe-order-success/", orderDetails);
|
|
101
|
+
}
|
|
102
|
+
async function stripeOrderFail(orderDetails) {
|
|
103
|
+
return http_service_default.post("/payment/stripe-order-fail/", orderDetails);
|
|
104
|
+
}
|
|
105
|
+
async function makeCODOrder(orderId) {
|
|
106
|
+
return http_service_default.post("/customer/order_cod/", { order_id: orderId });
|
|
107
|
+
}
|
|
108
|
+
async function publicMakeCODOrder(orderNumber) {
|
|
109
|
+
return http_service_default.post("/customer/public_order_cod/", { order_number: orderNumber });
|
|
110
|
+
}
|
|
111
|
+
async function updateOrderCustomization(customizationInput) {
|
|
112
|
+
return http_service_default.post("/customer/product_personalize/", customizationInput);
|
|
113
|
+
}
|
|
114
|
+
async function uploadCustomizationImage(uploadForm) {
|
|
115
|
+
return http_service_default.post("/utils/upload_image", uploadForm);
|
|
116
|
+
}
|
|
117
|
+
async function verifyTabbyPayment(orderNumber) {
|
|
118
|
+
return http_service_default.get("/payment/tabby-payment-status/", {
|
|
119
|
+
params: { order_number: orderNumber }
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
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 };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { cart_default } from './chunk-E7WPE3PV.js';
|
|
2
|
+
import { http_service_default } from './chunk-GB3HW6DM.js';
|
|
3
|
+
import { auth_default } from './chunk-FLBJKM6G.js';
|
|
4
|
+
|
|
5
|
+
// src/api/cart.ts
|
|
6
|
+
async function getCart(url, addressId) {
|
|
7
|
+
const localCart = cart_default.get();
|
|
8
|
+
return auth_default.getUserDetails() ? (await http_service_default.get(url, { params: { address_id: addressId } })).data : localCart || {
|
|
9
|
+
product_variants: [],
|
|
10
|
+
total_amount: 0,
|
|
11
|
+
total_quantity: 0,
|
|
12
|
+
products_quantity: {},
|
|
13
|
+
cart_count: 0,
|
|
14
|
+
missing_items: [],
|
|
15
|
+
customization_inputs: [],
|
|
16
|
+
total_coupon_discount: 0,
|
|
17
|
+
variant_discounts: {},
|
|
18
|
+
total_shipping: 0,
|
|
19
|
+
total_tax_amount: 0
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async function addToCart(product, customizationInputs) {
|
|
23
|
+
return http_service_default.post("/customer/cart/", {
|
|
24
|
+
action: "add",
|
|
25
|
+
cart_items: product,
|
|
26
|
+
customization_inputs: customizationInputs
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async function removeFromCart(product) {
|
|
30
|
+
return http_service_default.post("/customer/cart/", {
|
|
31
|
+
action: "remove",
|
|
32
|
+
cart_items: product
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
async function updateCart(product) {
|
|
36
|
+
return http_service_default.post("/customer/cart/", {
|
|
37
|
+
action: "update",
|
|
38
|
+
cart_items: product
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/api/product.ts
|
|
43
|
+
async function getProductList(url, filter) {
|
|
44
|
+
const response = await http_service_default.get(url, {
|
|
45
|
+
params: filter
|
|
46
|
+
});
|
|
47
|
+
return response.data;
|
|
48
|
+
}
|
|
49
|
+
async function getProducts(filter) {
|
|
50
|
+
return http_service_default.get("/inventory/products/", {
|
|
51
|
+
params: { ...filter }
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async function getProductDetail(url, slug) {
|
|
55
|
+
const response = await http_service_default.get(url, {
|
|
56
|
+
params: { variant_slug: slug }
|
|
57
|
+
});
|
|
58
|
+
return response.data;
|
|
59
|
+
}
|
|
60
|
+
async function getProductCategories(url) {
|
|
61
|
+
return await http_service_default.get(url);
|
|
62
|
+
}
|
|
63
|
+
async function getDigitalProductDownloadLink(variantId) {
|
|
64
|
+
return http_service_default.get("/inventory/digital_product/download/", {
|
|
65
|
+
params: { variant_id: variantId }
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async function updateDigitalProductDownloadLinkCount(variantId, downloadLink) {
|
|
69
|
+
return http_service_default.post("/inventory/digital_product/download/", {
|
|
70
|
+
variant_id: variantId,
|
|
71
|
+
download_link: downloadLink
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
async function getCategories(responseType = "flat") {
|
|
75
|
+
return await http_service_default.get("/inventory/categories/", {
|
|
76
|
+
params: { response_structure: responseType }
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async function getProductDetailBySlug(url, slug) {
|
|
80
|
+
const response = await http_service_default.get(url, {
|
|
81
|
+
params: { variant_slug: slug }
|
|
82
|
+
});
|
|
83
|
+
const product = response.data;
|
|
84
|
+
const variantAttributes = product.variants.map((variant) => ({
|
|
85
|
+
...variant.attributes,
|
|
86
|
+
slug: variant.slug
|
|
87
|
+
}));
|
|
88
|
+
variantAttributes.push({
|
|
89
|
+
...product.attributes,
|
|
90
|
+
slug: product.slug
|
|
91
|
+
});
|
|
92
|
+
product.variantAttributes = variantAttributes;
|
|
93
|
+
return product;
|
|
94
|
+
}
|
|
95
|
+
async function notifyProductStock(userDetails) {
|
|
96
|
+
return http_service_default.post("/utils/customer/notify-me/", userDetails);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/api/wishlist.ts
|
|
100
|
+
async function getWishlist(url) {
|
|
101
|
+
const response = await http_service_default.get(url);
|
|
102
|
+
return response.data;
|
|
103
|
+
}
|
|
104
|
+
async function addWishlist(productDetails) {
|
|
105
|
+
return http_service_default.post("/customer/wishlist/", productDetails);
|
|
106
|
+
}
|
|
107
|
+
async function removeFromWishlist(product_variants) {
|
|
108
|
+
return http_service_default.post("/customer/wishlist/", {
|
|
109
|
+
action: "remove",
|
|
110
|
+
product_variants
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export { addToCart, addWishlist, getCart, getCategories, getDigitalProductDownloadLink, getProductCategories, getProductDetail, getProductDetailBySlug, getProductList, getProducts, getWishlist, notifyProductStock, removeFromCart, removeFromWishlist, updateCart, updateDigitalProductDownloadLinkCount };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getCart } from './chunk-57ZBPAXU.js';
|
|
2
|
+
import { create } from 'zustand';
|
|
3
|
+
|
|
4
|
+
var initialState = {
|
|
5
|
+
cart: null,
|
|
6
|
+
status: "idle" /* IDLE */
|
|
7
|
+
};
|
|
8
|
+
var useCartStore = create((set) => ({
|
|
9
|
+
...initialState,
|
|
10
|
+
setCart: (cart) => set({ cart, status: "idle" /* IDLE */ }),
|
|
11
|
+
resetCart: () => set(initialState),
|
|
12
|
+
resetCartCount: () => set((state) => {
|
|
13
|
+
if (!state.cart) return state;
|
|
14
|
+
return { cart: { ...state.cart, total_quantity: 0 } };
|
|
15
|
+
}),
|
|
16
|
+
syncCart: async () => {
|
|
17
|
+
set({ status: "loading" /* LOADING */ });
|
|
18
|
+
try {
|
|
19
|
+
const response = await getCart("/customer/cart/");
|
|
20
|
+
if (response) {
|
|
21
|
+
set({ cart: response, status: "idle" /* IDLE */ });
|
|
22
|
+
}
|
|
23
|
+
} catch {
|
|
24
|
+
set({ status: "idle" /* IDLE */ });
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
fetchCart: async (addressId) => {
|
|
28
|
+
set({ status: "loading" /* LOADING */ });
|
|
29
|
+
try {
|
|
30
|
+
const response = await getCart("/customer/cart/", addressId);
|
|
31
|
+
if (response) {
|
|
32
|
+
set({ cart: response, status: "idle" /* IDLE */ });
|
|
33
|
+
}
|
|
34
|
+
} catch {
|
|
35
|
+
set({ status: "idle" /* IDLE */ });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
export { useCartStore };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { http_service_default } from './chunk-GB3HW6DM.js';
|
|
2
|
+
|
|
3
|
+
// src/api/user.ts
|
|
4
|
+
async function getUserDetails(url) {
|
|
5
|
+
const response = await http_service_default.get(url);
|
|
6
|
+
return response.data;
|
|
7
|
+
}
|
|
8
|
+
async function updateUserDetails(userDetails) {
|
|
9
|
+
return http_service_default.patch("/users/store/profile/", { ...userDetails });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { getUserDetails, updateUserDetails };
|