hey-pharmacist-ecommerce 1.1.28 → 1.1.29

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.
Files changed (60) hide show
  1. package/dist/index.d.mts +344 -640
  2. package/dist/index.d.ts +344 -640
  3. package/dist/index.js +1807 -838
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +1807 -840
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +1 -1
  8. package/src/components/AccountOrdersTab.tsx +1 -1
  9. package/src/components/AccountSettingsTab.tsx +88 -6
  10. package/src/components/CartItem.tsx +1 -1
  11. package/src/components/Header.tsx +8 -2
  12. package/src/components/OrderCard.tsx +4 -4
  13. package/src/components/ProductCard.tsx +59 -42
  14. package/src/components/QuickViewModal.tsx +13 -13
  15. package/src/hooks/useAddresses.ts +4 -1
  16. package/src/hooks/usePaymentMethods.ts +26 -31
  17. package/src/hooks/useProducts.ts +63 -64
  18. package/src/hooks/useWishlistProducts.ts +4 -5
  19. package/src/index.ts +2 -0
  20. package/src/lib/Apis/api.ts +0 -1
  21. package/src/lib/Apis/apis/auth-api.ts +18 -29
  22. package/src/lib/Apis/apis/products-api.ts +845 -405
  23. package/src/lib/Apis/models/category-populated.ts +0 -12
  24. package/src/lib/Apis/models/category-sub-category-populated.ts +2 -2
  25. package/src/lib/Apis/models/category.ts +0 -18
  26. package/src/lib/Apis/models/{table-cell-dto.ts → change-password-dto.ts} +6 -6
  27. package/src/lib/Apis/models/create-product-dto.ts +30 -23
  28. package/src/lib/Apis/models/create-sub-category-dto.ts +6 -0
  29. package/src/lib/Apis/models/create-variant-dto.ts +29 -29
  30. package/src/lib/Apis/models/index.ts +5 -7
  31. package/src/lib/Apis/models/paginated-products-dto.ts +6 -6
  32. package/src/lib/Apis/models/product-summary.ts +69 -0
  33. package/src/lib/Apis/models/product-variant.ts +34 -65
  34. package/src/lib/Apis/models/product.ts +138 -0
  35. package/src/lib/Apis/models/products-insights-dto.ts +12 -0
  36. package/src/lib/Apis/models/single-product-media.ts +0 -12
  37. package/src/lib/Apis/models/sub-category.ts +6 -12
  38. package/src/lib/Apis/models/update-product-dto.ts +30 -19
  39. package/src/lib/Apis/models/update-sub-category-dto.ts +6 -0
  40. package/src/lib/Apis/models/{update-product-variant-dto.ts → update-variant-dto.ts} +51 -45
  41. package/src/lib/Apis/models/{shallow-parent-category-dto.ts → variant-id-inventory-body.ts} +5 -11
  42. package/src/lib/api-adapter/config.ts +53 -0
  43. package/src/lib/validations/address.ts +1 -1
  44. package/src/providers/FavoritesProvider.tsx +5 -5
  45. package/src/providers/WishlistProvider.tsx +4 -4
  46. package/src/screens/CartScreen.tsx +1 -1
  47. package/src/screens/ChangePasswordScreen.tsx +2 -6
  48. package/src/screens/CheckoutScreen.tsx +40 -11
  49. package/src/screens/ForgotPasswordScreen.tsx +153 -0
  50. package/src/screens/ProductDetailScreen.tsx +51 -60
  51. package/src/screens/RegisterScreen.tsx +31 -31
  52. package/src/screens/ResetPasswordScreen.tsx +202 -0
  53. package/src/screens/SearchResultsScreen.tsx +264 -26
  54. package/src/screens/ShopScreen.tsx +42 -45
  55. package/src/screens/WishlistScreen.tsx +35 -31
  56. package/src/lib/Apis/apis/product-variants-api.ts +0 -552
  57. package/src/lib/Apis/models/create-single-variant-product-dto.ts +0 -154
  58. package/src/lib/Apis/models/extended-product-dto.ts +0 -206
  59. package/src/lib/Apis/models/frequently-bought-product-dto.ts +0 -71
  60. package/src/lib/Apis/models/table-dto.ts +0 -34
@@ -12,6 +12,7 @@ import {
12
12
  ShoppingBag,
13
13
  Sparkles,
14
14
  Trash2,
15
+ Trash
15
16
  } from 'lucide-react';
16
17
  import { useRouter } from 'next/navigation';
17
18
  import { ProductCard } from '@/components/ProductCard';
@@ -21,7 +22,7 @@ import { useAuth } from '@/providers/AuthProvider';
21
22
  import { useWishlistProducts } from '@/hooks/useWishlistProducts';
22
23
  import Image from 'next/image';
23
24
  import { formatPrice } from '@/lib/utils/format';
24
- import { ExtendedProductDTO } from '@/lib/Apis';
25
+ import { Product } from '@/lib/Apis';
25
26
  import { useBasePath } from '@/providers/BasePathProvider';
26
27
  import { useNotification } from '@/providers/NotificationProvider';
27
28
 
@@ -95,23 +96,26 @@ export default function WishlistScreen() {
95
96
  };
96
97
 
97
98
  const totalValue = useMemo(
98
- () => wishlistProducts.reduce((sum, product) => sum + (product.finalPrice ?? 0), 0),
99
+ () => wishlistProducts.reduce((sum, product) => sum + (product.summary?.minPrice ?? 0), 0),
99
100
  [wishlistProducts]
100
101
  );
101
102
 
102
103
  const totalSavings = useMemo(
103
104
  () =>
104
105
  wishlistProducts.reduce((sum, product) => {
105
- const before = product.priceBeforeDiscount ?? product.finalPrice ?? 0;
106
- const after = product.finalPrice ?? 0;
107
- const savings = Math.max(before - after, 0);
108
- return sum + savings;
106
+ // Calculate savings if product has discount
107
+ if (product.summary?.hasDiscount) {
108
+ const maxPrice = product.summary?.maxPrice ?? 0;
109
+ const minPrice = product.summary?.minPrice ?? 0;
110
+ return sum + (maxPrice - minPrice);
111
+ }
112
+ return sum;
109
113
  }, 0),
110
114
  [wishlistProducts]
111
115
  );
112
116
 
113
117
  const inStockCount = useMemo(
114
- () => wishlistProducts.filter((product) => (product.inventoryCount ?? 0) > 0).length,
118
+ () => wishlistProducts.filter((product) => (product.summary?.totalInventory ?? 0) > 0).length,
115
119
  [wishlistProducts]
116
120
  );
117
121
 
@@ -119,25 +123,25 @@ export default function WishlistScreen() {
119
123
  let list = [...wishlistProducts];
120
124
 
121
125
  if (onlyInStock) {
122
- list = list.filter((product) => (product.inventoryCount ?? 0) > 0);
126
+ list = list.filter((product) => (product.summary?.totalInventory ?? 0) > 0);
123
127
  }
124
128
 
125
129
  switch (sortOption) {
126
130
  case 'price-low':
127
- list.sort((a, b) => (a.finalPrice ?? 0) - (b.finalPrice ?? 0));
131
+ list.sort((a, b) => (a.summary?.minPrice ?? 0) - (b.summary?.minPrice ?? 0));
128
132
  break;
129
133
  case 'price-high':
130
- list.sort((a, b) => (b.finalPrice ?? 0) - (a.finalPrice ?? 0));
134
+ list.sort((a, b) => (b.summary?.maxPrice ?? 0) - (a.summary?.maxPrice ?? 0));
131
135
  break;
132
136
  case 'name':
133
137
  list.sort((a, b) => (a.name || '').localeCompare(b.name || ''));
134
138
  break;
135
139
  case 'availability':
136
- list.sort((a, b) => (b.inventoryCount ?? 0) - (a.inventoryCount ?? 0));
140
+ list.sort((a, b) => (b.summary?.totalInventory ?? 0) - (a.summary?.totalInventory ?? 0));
137
141
  break;
138
142
  case 'featured':
139
143
  default:
140
- list.sort((a, b) => (b.totalSold ?? 0) - (a.totalSold ?? 0));
144
+ list.sort((a, b) => (b.summary?.totalSold ?? 0) - (a.summary?.totalSold ?? 0));
141
145
  break;
142
146
  }
143
147
 
@@ -318,9 +322,9 @@ export default function WishlistScreen() {
318
322
  transition={{ duration: 0.2 }}
319
323
  >
320
324
  <ProductCard
321
- product={product as ExtendedProductDTO}
322
- onClickProduct={(p) => router.push(buildPath(`/products/${p.id}`))}
323
- onFavorite={() => handleRemoveFromWishlist(product.id)}
325
+ product={product as Product}
326
+ onClickProduct={(p) => router.push(buildPath(`/products/${p._id}`))}
327
+ onFavorite={() => handleRemoveFromWishlist(product._id || product.id || '')}
324
328
  isFavorited
325
329
  />
326
330
  </motion.div>
@@ -343,7 +347,7 @@ export default function WishlistScreen() {
343
347
  <div className="relative h-28 w-full overflow-hidden rounded-2xl bg-white sm:w-40">
344
348
  <Image
345
349
  fill
346
- src={product.productMedia?.[0]?.file || '/placeholder-product.jpg'}
350
+ src={product.media?.[0]?.file || '/placeholder-product.jpg'}
347
351
  alt={product.name || 'Wishlist item'}
348
352
  className="h-full w-full object-cover"
349
353
  />
@@ -355,47 +359,47 @@ export default function WishlistScreen() {
355
359
  {product.name}
356
360
  </h3>
357
361
  <p className="text-sm text-muted">
358
- {product.parentCategories?.map((category) => category?.name).join(', ') || 'General wellness'}
362
+ General wellness
359
363
  </p>
360
364
  </div>
361
365
  <div className="text-right">
362
366
  <p className="text-lg font-bold text-primary">
363
- {formatPrice(product.finalPrice ?? 0)}
367
+ {formatPrice(product.summary?.minPrice ?? 0)}
364
368
  </p>
365
- {product.isDiscounted && (
369
+ {product.summary?.hasDiscount && (
366
370
  <p className="text-xs text-emerald-500">
367
- You save {formatPrice(Math.max((product.priceBeforeDiscount ?? 0) - (product.finalPrice ?? 0), 0))}
371
+ You save {formatPrice(Math.max((product.summary?.maxPrice ?? 0) - (product.summary?.minPrice ?? 0), 0))}
368
372
  </p>
369
373
  )}
370
374
  </div>
371
375
  </div>
372
376
  <div className="flex flex-wrap items-center gap-3 text-xs text-slate-500">
373
- <span className={`inline-flex items-center gap-1 rounded-full px-2.5 py-1 font-medium ${product.inventoryCount > 0 ? 'bg-emerald-100 text-emerald-700' : 'bg-rose-100 text-rose-700'}`}>
377
+ <span className={`inline-flex items-center gap-1 rounded-full px-2.5 py-1 font-medium ${(product.summary?.totalInventory ?? 0) > 0 ? 'bg-emerald-100 text-emerald-700' : 'bg-rose-100 text-rose-700'}`}>
374
378
  <Package className="h-3.5 w-3.5" />
375
- {product.inventoryCount > 0 ? 'In stock' : 'Backordered'}
379
+ {(product.summary?.totalInventory ?? 0) > 0 ? 'In stock' : 'Backordered'}
376
380
  </span>
377
- {product.totalSold > 0 && (
381
+ {(product.summary?.totalSold ?? 0) > 0 && (
378
382
  <span className="inline-flex items-center gap-1 rounded-full bg-slate-200 px-2.5 py-1 font-medium text-slate-700">
379
383
  <Sparkles className="h-3.5 w-3.5" />
380
- {product.totalSold}+ purchased
384
+ {product.summary?.totalSold}+ purchased
381
385
  </span>
382
386
  )}
383
387
  </div>
384
388
  <div className="flex flex-wrap gap-2">
385
389
  <Button
386
390
  size="sm"
387
- onClick={() => router.push(buildPath(`/products/${product.id}`))}
391
+ onClick={() => router.push(buildPath(`/products/${product._id}`))}
392
+ className='bg-primary/90 text-white hover:bg-primary/70'
388
393
  >
389
394
  View details
390
395
  </Button>
391
- <Button
392
- size="sm"
393
- variant="outline-solid"
394
- onClick={() => handleRemoveFromWishlist(product.id)}
395
- className="text-secondary"
396
+ <button
397
+ onClick={() => handleRemoveFromWishlist(product._id || product.id || '')}
398
+ className='text-red-500 hover:text-red-600 hover:bg-red-50 transition-colors cursor-pointer border border-red-500 rounded-full px-4 py-1 text-sm flex-row'
396
399
  >
400
+ {/* <Trash className="h-4 w-4" /> */}
397
401
  Remove
398
- </Button>
402
+ </button>
399
403
  </div>
400
404
  </div>
401
405
  </motion.div>