@viu/emporix-sdk-react 2.2.0 → 2.4.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/CHANGELOG.md +39 -0
- package/dist/{chunk-P6QTUYBT.js → chunk-WXK2X7CM.js} +145 -3
- package/dist/chunk-WXK2X7CM.js.map +1 -0
- package/dist/hooks.cjs +157 -0
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +71 -2
- package/dist/hooks.d.ts +71 -2
- package/dist/hooks.js +1 -1
- package/dist/index.cjs +157 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-P6QTUYBT.js.map +0 -1
package/dist/hooks.cjs
CHANGED
|
@@ -364,6 +364,63 @@ function useProductsByCodes(codes, options = {}) {
|
|
|
364
364
|
staleTime: 3e4
|
|
365
365
|
});
|
|
366
366
|
}
|
|
367
|
+
var SHOPPING_LIST_STALE_TIME = 3e4;
|
|
368
|
+
var INVALIDATE_KEY = ["emporix", "shopping-lists"];
|
|
369
|
+
function useShoppingLists(opts = {}) {
|
|
370
|
+
const { client } = useEmporix();
|
|
371
|
+
const ctx = useCustomerOnlyCtx();
|
|
372
|
+
const { siteCode } = useReadSite();
|
|
373
|
+
return reactQuery.useQuery({
|
|
374
|
+
queryKey: emporixKey("shopping-lists", [opts.name ?? null], { tenant: client.tenant, authKind: ctx.kind, siteCode }),
|
|
375
|
+
queryFn: () => client.shoppingLists.list(ctx, opts),
|
|
376
|
+
staleTime: SHOPPING_LIST_STALE_TIME
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
function useCreateShoppingList() {
|
|
380
|
+
const { client } = useEmporix();
|
|
381
|
+
const ctx = useCustomerOnlyCtx();
|
|
382
|
+
const qc = reactQuery.useQueryClient();
|
|
383
|
+
return reactQuery.useMutation({
|
|
384
|
+
mutationFn: (draft) => client.shoppingLists.create(draft, ctx),
|
|
385
|
+
onSuccess: () => void qc.invalidateQueries({ queryKey: INVALIDATE_KEY })
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
function useDeleteShoppingList() {
|
|
389
|
+
const { client } = useEmporix();
|
|
390
|
+
const ctx = useCustomerOnlyCtx();
|
|
391
|
+
const qc = reactQuery.useQueryClient();
|
|
392
|
+
return reactQuery.useMutation({
|
|
393
|
+
mutationFn: ({ customerId, name }) => client.shoppingLists.delete(customerId, ctx, name !== void 0 ? { name } : {}),
|
|
394
|
+
onSuccess: () => void qc.invalidateQueries({ queryKey: INVALIDATE_KEY })
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
function useAddToShoppingList() {
|
|
398
|
+
const { client } = useEmporix();
|
|
399
|
+
const ctx = useCustomerOnlyCtx();
|
|
400
|
+
const qc = reactQuery.useQueryClient();
|
|
401
|
+
return reactQuery.useMutation({
|
|
402
|
+
mutationFn: ({ customerId, listName, item }) => client.shoppingLists.addItem(customerId, listName, item, ctx),
|
|
403
|
+
onSuccess: () => void qc.invalidateQueries({ queryKey: INVALIDATE_KEY })
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
function useRemoveFromShoppingList() {
|
|
407
|
+
const { client } = useEmporix();
|
|
408
|
+
const ctx = useCustomerOnlyCtx();
|
|
409
|
+
const qc = reactQuery.useQueryClient();
|
|
410
|
+
return reactQuery.useMutation({
|
|
411
|
+
mutationFn: ({ customerId, listName, productId }) => client.shoppingLists.removeItem(customerId, listName, productId, ctx),
|
|
412
|
+
onSuccess: () => void qc.invalidateQueries({ queryKey: INVALIDATE_KEY })
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
function useSetShoppingListItemQuantity() {
|
|
416
|
+
const { client } = useEmporix();
|
|
417
|
+
const ctx = useCustomerOnlyCtx();
|
|
418
|
+
const qc = reactQuery.useQueryClient();
|
|
419
|
+
return reactQuery.useMutation({
|
|
420
|
+
mutationFn: ({ customerId, listName, productId, quantity }) => client.shoppingLists.setItemQuantity(customerId, listName, productId, quantity, ctx),
|
|
421
|
+
onSuccess: () => void qc.invalidateQueries({ queryKey: INVALIDATE_KEY })
|
|
422
|
+
});
|
|
423
|
+
}
|
|
367
424
|
var VARIANT_CHILDREN_STALE_TIME = 6e4;
|
|
368
425
|
function useVariantChildren(parentVariantId, options = {}) {
|
|
369
426
|
const { client } = useEmporix();
|
|
@@ -1264,8 +1321,94 @@ function useAvailabilities(productIds, siteCode, options = {}) {
|
|
|
1264
1321
|
staleTime: AVAILABILITY_STALE_TIME2
|
|
1265
1322
|
});
|
|
1266
1323
|
}
|
|
1324
|
+
var INVALIDATE_KEY2 = ["emporix", "coupons"];
|
|
1325
|
+
function useValidateCoupon() {
|
|
1326
|
+
const { client } = useEmporix();
|
|
1327
|
+
const { ctx } = useReadAuth();
|
|
1328
|
+
return reactQuery.useMutation({
|
|
1329
|
+
mutationFn: ({ code, redemption }) => client.coupons.validateCoupon(code, redemption, ctx)
|
|
1330
|
+
});
|
|
1331
|
+
}
|
|
1332
|
+
function useRedeemCoupon() {
|
|
1333
|
+
const { client } = useEmporix();
|
|
1334
|
+
const { ctx } = useReadAuth();
|
|
1335
|
+
const qc = reactQuery.useQueryClient();
|
|
1336
|
+
return reactQuery.useMutation({
|
|
1337
|
+
mutationFn: ({ code, redemption }) => client.coupons.redeemCoupon(code, redemption, ctx),
|
|
1338
|
+
onSuccess: () => void qc.invalidateQueries({ queryKey: INVALIDATE_KEY2 })
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
var STALE = 3e4;
|
|
1342
|
+
var INVALIDATE_KEY3 = ["emporix", "reward-points"];
|
|
1343
|
+
function useMyRewardPoints() {
|
|
1344
|
+
const { client } = useEmporix();
|
|
1345
|
+
const ctx = useCustomerOnlyCtx();
|
|
1346
|
+
return reactQuery.useQuery({
|
|
1347
|
+
queryKey: emporixKey("reward-points", ["mine"], { tenant: client.tenant, authKind: ctx.kind }),
|
|
1348
|
+
queryFn: () => client.rewardPoints.getMyPoints(ctx),
|
|
1349
|
+
staleTime: STALE
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
function useMyRewardPointsSummary() {
|
|
1353
|
+
const { client } = useEmporix();
|
|
1354
|
+
const ctx = useCustomerOnlyCtx();
|
|
1355
|
+
return reactQuery.useQuery({
|
|
1356
|
+
queryKey: emporixKey("reward-points", ["mine", "summary"], { tenant: client.tenant, authKind: ctx.kind }),
|
|
1357
|
+
queryFn: () => client.rewardPoints.getMySummary(ctx),
|
|
1358
|
+
staleTime: STALE
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
function useRedeemOptions() {
|
|
1362
|
+
const { client } = useEmporix();
|
|
1363
|
+
const { ctx } = useReadAuth();
|
|
1364
|
+
return reactQuery.useQuery({
|
|
1365
|
+
queryKey: emporixKey("reward-points", ["redeem-options"], { tenant: client.tenant, authKind: ctx.kind }),
|
|
1366
|
+
queryFn: () => client.rewardPoints.listRedeemOptions(ctx),
|
|
1367
|
+
staleTime: STALE
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
function useRedeemRewardPoints() {
|
|
1371
|
+
const { client } = useEmporix();
|
|
1372
|
+
const ctx = useCustomerOnlyCtx();
|
|
1373
|
+
const qc = reactQuery.useQueryClient();
|
|
1374
|
+
return reactQuery.useMutation({
|
|
1375
|
+
mutationFn: (input) => client.rewardPoints.redeemMyPoints(input, ctx),
|
|
1376
|
+
onSuccess: () => void qc.invalidateQueries({ queryKey: INVALIDATE_KEY3 })
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
var STALE2 = 3e4;
|
|
1380
|
+
var INVALIDATE_KEY4 = ["emporix", "returns"];
|
|
1381
|
+
function useMyReturns(opts = {}) {
|
|
1382
|
+
const { client } = useEmporix();
|
|
1383
|
+
const ctx = useCustomerOnlyCtx();
|
|
1384
|
+
return reactQuery.useQuery({
|
|
1385
|
+
queryKey: emporixKey("returns", [opts.query ?? null], { tenant: client.tenant, authKind: ctx.kind }),
|
|
1386
|
+
queryFn: () => client.returns.listReturns(opts.query ?? {}, ctx),
|
|
1387
|
+
staleTime: STALE2
|
|
1388
|
+
});
|
|
1389
|
+
}
|
|
1390
|
+
function useReturn(returnId) {
|
|
1391
|
+
const { client } = useEmporix();
|
|
1392
|
+
const ctx = useCustomerOnlyCtx();
|
|
1393
|
+
return reactQuery.useQuery({
|
|
1394
|
+
queryKey: emporixKey("returns", [returnId ?? null], { tenant: client.tenant, authKind: ctx.kind }),
|
|
1395
|
+
queryFn: () => client.returns.getReturn(returnId, ctx),
|
|
1396
|
+
enabled: Boolean(returnId),
|
|
1397
|
+
staleTime: STALE2
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
function useCreateReturn() {
|
|
1401
|
+
const { client } = useEmporix();
|
|
1402
|
+
const ctx = useCustomerOnlyCtx();
|
|
1403
|
+
const qc = reactQuery.useQueryClient();
|
|
1404
|
+
return reactQuery.useMutation({
|
|
1405
|
+
mutationFn: (input) => client.returns.createReturn(input, ctx),
|
|
1406
|
+
onSuccess: () => void qc.invalidateQueries({ queryKey: INVALIDATE_KEY4 })
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1267
1409
|
|
|
1268
1410
|
exports.useActiveCart = useActiveCart;
|
|
1411
|
+
exports.useAddToShoppingList = useAddToShoppingList;
|
|
1269
1412
|
exports.useAddressMutations = useAddressMutations;
|
|
1270
1413
|
exports.useAssignContact = useAssignContact;
|
|
1271
1414
|
exports.useAvailabilities = useAvailabilities;
|
|
@@ -1287,16 +1430,22 @@ exports.useCompanySwitcher = useCompanySwitcher;
|
|
|
1287
1430
|
exports.useCreateCart = useCreateCart;
|
|
1288
1431
|
exports.useCreateCompany = useCreateCompany;
|
|
1289
1432
|
exports.useCreateLocation = useCreateLocation;
|
|
1433
|
+
exports.useCreateReturn = useCreateReturn;
|
|
1434
|
+
exports.useCreateShoppingList = useCreateShoppingList;
|
|
1290
1435
|
exports.useCustomerAddresses = useCustomerAddresses;
|
|
1291
1436
|
exports.useCustomerSession = useCustomerSession;
|
|
1292
1437
|
exports.useDefaultSite = useDefaultSite;
|
|
1293
1438
|
exports.useDeleteCompany = useDeleteCompany;
|
|
1294
1439
|
exports.useDeleteLocation = useDeleteLocation;
|
|
1440
|
+
exports.useDeleteShoppingList = useDeleteShoppingList;
|
|
1295
1441
|
exports.useMatchPrices = useMatchPrices;
|
|
1296
1442
|
exports.useMatchPricesChunked = useMatchPricesChunked;
|
|
1297
1443
|
exports.useMyCompanies = useMyCompanies;
|
|
1298
1444
|
exports.useMyOrders = useMyOrders;
|
|
1299
1445
|
exports.useMyOrdersInfinite = useMyOrdersInfinite;
|
|
1446
|
+
exports.useMyReturns = useMyReturns;
|
|
1447
|
+
exports.useMyRewardPoints = useMyRewardPoints;
|
|
1448
|
+
exports.useMyRewardPointsSummary = useMyRewardPointsSummary;
|
|
1300
1449
|
exports.useMySegmentCategories = useMySegmentCategories;
|
|
1301
1450
|
exports.useMySegmentCategoriesInfinite = useMySegmentCategoriesInfinite;
|
|
1302
1451
|
exports.useMySegmentCategoryTree = useMySegmentCategoryTree;
|
|
@@ -1317,8 +1466,15 @@ exports.useProductsByCodes = useProductsByCodes;
|
|
|
1317
1466
|
exports.useProductsInCategory = useProductsInCategory;
|
|
1318
1467
|
exports.useProductsInCategoryInfinite = useProductsInCategoryInfinite;
|
|
1319
1468
|
exports.useProductsInfinite = useProductsInfinite;
|
|
1469
|
+
exports.useRedeemCoupon = useRedeemCoupon;
|
|
1470
|
+
exports.useRedeemOptions = useRedeemOptions;
|
|
1471
|
+
exports.useRedeemRewardPoints = useRedeemRewardPoints;
|
|
1472
|
+
exports.useRemoveFromShoppingList = useRemoveFromShoppingList;
|
|
1320
1473
|
exports.useReorder = useReorder;
|
|
1474
|
+
exports.useReturn = useReturn;
|
|
1321
1475
|
exports.useSalesOrder = useSalesOrder;
|
|
1476
|
+
exports.useSetShoppingListItemQuantity = useSetShoppingListItemQuantity;
|
|
1477
|
+
exports.useShoppingLists = useShoppingLists;
|
|
1322
1478
|
exports.useSiteContext = useSiteContext;
|
|
1323
1479
|
exports.useSites = useSites;
|
|
1324
1480
|
exports.useUnassignContact = useUnassignContact;
|
|
@@ -1327,6 +1483,7 @@ exports.useUpdateContactAssignment = useUpdateContactAssignment;
|
|
|
1327
1483
|
exports.useUpdateCustomer = useUpdateCustomer;
|
|
1328
1484
|
exports.useUpdateLocation = useUpdateLocation;
|
|
1329
1485
|
exports.useUpdateSalesOrder = useUpdateSalesOrder;
|
|
1486
|
+
exports.useValidateCoupon = useValidateCoupon;
|
|
1330
1487
|
exports.useVariantChildren = useVariantChildren;
|
|
1331
1488
|
//# sourceMappingURL=hooks.cjs.map
|
|
1332
1489
|
//# sourceMappingURL=hooks.cjs.map
|