hey-pharmacist-ecommerce 1.1.29 → 1.1.31

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 (104) hide show
  1. package/dist/index.d.mts +10957 -1331
  2. package/dist/index.d.ts +10957 -1331
  3. package/dist/index.js +12364 -5144
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +9353 -2205
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +4 -3
  8. package/src/components/AccountReviewsTab.tsx +97 -0
  9. package/src/components/CouponCodeInput.tsx +190 -0
  10. package/src/components/Header.tsx +5 -1
  11. package/src/components/Notification.tsx +1 -1
  12. package/src/components/NotificationBell.tsx +33 -0
  13. package/src/components/NotificationCard.tsx +211 -0
  14. package/src/components/NotificationDrawer.tsx +195 -0
  15. package/src/components/OrderCard.tsx +164 -99
  16. package/src/components/ProductReviewsSection.tsx +30 -0
  17. package/src/components/RatingDistribution.tsx +86 -0
  18. package/src/components/ReviewCard.tsx +59 -0
  19. package/src/components/ReviewForm.tsx +207 -0
  20. package/src/components/ReviewPromptBanner.tsx +98 -0
  21. package/src/components/ReviewsList.tsx +151 -0
  22. package/src/components/StarRating.tsx +98 -0
  23. package/src/hooks/useDiscounts.ts +7 -0
  24. package/src/hooks/useOrders.ts +15 -0
  25. package/src/hooks/useReviews.ts +230 -0
  26. package/src/hooks/useStoreCapabilities.ts +87 -0
  27. package/src/index.ts +29 -0
  28. package/src/lib/Apis/apis/auth-api.ts +19 -7
  29. package/src/lib/Apis/apis/categories-api.ts +97 -0
  30. package/src/lib/Apis/apis/discounts-api.ts +23 -72
  31. package/src/lib/Apis/apis/notifications-api.ts +196 -231
  32. package/src/lib/Apis/apis/products-api.ts +181 -0
  33. package/src/lib/Apis/apis/review-api.ts +283 -4
  34. package/src/lib/Apis/apis/shipping-api.ts +105 -0
  35. package/src/lib/Apis/apis/stores-api.ts +536 -0
  36. package/src/lib/Apis/apis/sub-categories-api.ts +97 -0
  37. package/src/lib/Apis/apis/users-api.ts +8 -8
  38. package/src/lib/Apis/models/address-created-request.ts +0 -12
  39. package/src/lib/Apis/models/address.ts +0 -12
  40. package/src/lib/Apis/models/api-key-info-dto.ts +49 -0
  41. package/src/lib/Apis/models/bulk-channel-toggle-dto.ts +52 -0
  42. package/src/lib/Apis/models/cart-body-populated.ts +3 -3
  43. package/src/lib/Apis/models/channel-settings-dto.ts +39 -0
  44. package/src/lib/Apis/models/{discount-paginated-response.ts → completed-order-dto.ts} +21 -16
  45. package/src/lib/Apis/models/create-address-dto.ts +0 -12
  46. package/src/lib/Apis/models/create-discount-dto.ts +31 -100
  47. package/src/lib/Apis/models/create-review-dto.ts +4 -4
  48. package/src/lib/Apis/models/create-shippo-account-dto.ts +45 -0
  49. package/src/lib/Apis/models/create-store-address-dto.ts +0 -12
  50. package/src/lib/Apis/models/create-store-dto-settings.ts +51 -0
  51. package/src/lib/Apis/models/create-store-dto.ts +13 -0
  52. package/src/lib/Apis/models/create-variant-dto.ts +0 -6
  53. package/src/lib/Apis/models/discount.ts +37 -106
  54. package/src/lib/Apis/models/discounts-insights-dto.ts +12 -0
  55. package/src/lib/Apis/models/index.ts +24 -7
  56. package/src/lib/Apis/models/{manual-discount.ts → manual-discount-dto.ts} +10 -10
  57. package/src/lib/Apis/models/manual-order-dto.ts +3 -3
  58. package/src/lib/Apis/models/populated-discount.ts +41 -109
  59. package/src/lib/Apis/models/preference-update-item.ts +59 -0
  60. package/src/lib/Apis/models/product-light-dto.ts +40 -0
  61. package/src/lib/Apis/models/product-variant.ts +0 -6
  62. package/src/lib/Apis/models/reorder-categories-dto.ts +27 -0
  63. package/src/lib/Apis/models/reorder-products-dto.ts +49 -0
  64. package/src/lib/Apis/models/{check-notifications-response-dto.ts → reorder-products-success-response-dto.ts} +7 -7
  65. package/src/lib/Apis/models/reorder-subcategories-dto.ts +33 -0
  66. package/src/lib/Apis/models/reorder-success-response-dto.ts +33 -0
  67. package/src/lib/Apis/models/review-status-dto.ts +34 -0
  68. package/src/lib/Apis/models/review.ts +9 -3
  69. package/src/lib/Apis/models/reviewable-order-dto.ts +58 -0
  70. package/src/lib/Apis/models/reviewable-product-dto.ts +81 -0
  71. package/src/lib/Apis/models/shipment-with-order.ts +18 -0
  72. package/src/lib/Apis/models/shipment.ts +18 -0
  73. package/src/lib/Apis/models/shippo-account-response-dto.ts +51 -0
  74. package/src/lib/Apis/models/store-api-keys-response-dto.ts +34 -0
  75. package/src/lib/Apis/models/store-capabilities-dto.ts +63 -0
  76. package/src/lib/Apis/models/store-entity.ts +13 -0
  77. package/src/lib/Apis/models/store.ts +13 -0
  78. package/src/lib/Apis/models/update-address-dto.ts +0 -12
  79. package/src/lib/Apis/models/update-api-keys-dto.ts +39 -0
  80. package/src/lib/Apis/models/update-discount-dto.ts +31 -100
  81. package/src/lib/Apis/models/update-manual-shipment-status-dto.ts +47 -0
  82. package/src/lib/Apis/models/update-notification-settings-dto.ts +28 -0
  83. package/src/lib/Apis/models/update-review-dto.ts +4 -4
  84. package/src/lib/Apis/models/update-store-dto.ts +13 -0
  85. package/src/lib/Apis/models/update-variant-dto.ts +0 -6
  86. package/src/lib/Apis/models/{pick-type-class.ts → variant-light-dto.ts} +20 -14
  87. package/src/lib/utils/discount.ts +155 -0
  88. package/src/lib/validations/discount.ts +11 -0
  89. package/src/providers/CartProvider.tsx +2 -2
  90. package/src/providers/DiscountProvider.tsx +97 -0
  91. package/src/providers/EcommerceProvider.tsx +13 -5
  92. package/src/providers/NotificationCenterProvider.tsx +436 -0
  93. package/src/screens/CartScreen.tsx +1 -1
  94. package/src/screens/CheckoutScreen.tsx +402 -290
  95. package/src/screens/NotificationSettingsScreen.tsx +413 -0
  96. package/src/screens/OrderDetailScreen.tsx +283 -0
  97. package/src/screens/OrderReviewsScreen.tsx +308 -0
  98. package/src/screens/OrdersScreen.tsx +31 -7
  99. package/src/screens/ProductDetailScreen.tsx +24 -11
  100. package/src/screens/ProfileScreen.tsx +5 -0
  101. package/src/screens/ResetPasswordScreen.tsx +10 -4
  102. package/src/lib/Apis/models/create-notification-dto.ts +0 -75
  103. package/src/lib/Apis/models/notification.ts +0 -93
  104. package/src/lib/Apis/models/single-notification-dto.ts +0 -99
@@ -36,6 +36,8 @@ import { useWishlist } from '@/providers/WishlistProvider';
36
36
  import { ProductsApi, ProductVariant, ProductVariantInventoryStatusEnum } from '@/lib/Apis';
37
37
  import { useBasePath } from '@/providers/BasePathProvider';
38
38
  import { Category } from '@/lib/types';
39
+ import { useProductReviews } from '@/hooks/useReviews';
40
+ import { ProductReviewsSection } from '@/components/ProductReviewsSection';
39
41
 
40
42
  const safeFormatDate = (date?: Date | string, format: 'long' | 'short' = 'long'): string => {
41
43
  if (!date) return 'N/A';
@@ -60,6 +62,7 @@ export function ProductDetailScreen({ productId }: ProductDetailScreenProps) {
60
62
  const { addToCart } = useCart();
61
63
  const { isAuthenticated } = useAuth();
62
64
  const notification = useNotification();
65
+ const { reviews, isLoading: reviewsLoading } = useProductReviews(productId);
63
66
 
64
67
  // State declarations
65
68
  const [selectedVariant, setSelectedVariant] = useState<ProductVariant | null>(null);
@@ -97,6 +100,24 @@ export function ProductDetailScreen({ productId }: ProductDetailScreenProps) {
97
100
  return productData;
98
101
  }, [productData, selectedVariant, initialProductData]);
99
102
 
103
+ // Calculate average rating and review count from actual reviews
104
+ const reviewStats = useMemo(() => {
105
+ if (!reviews || reviews.length === 0) {
106
+ return {
107
+ averageRating: product?.rating || 0,
108
+ reviewCount: 0,
109
+ };
110
+ }
111
+
112
+ const totalRating = reviews.reduce((sum, review) => sum + (review.rating || 0), 0);
113
+ const averageRating = totalRating / reviews.length;
114
+
115
+ return {
116
+ averageRating: Math.round(averageRating * 10) / 10, // Round to 1 decimal place
117
+ reviewCount: reviews.length,
118
+ };
119
+ }, [reviews, product?.rating]);
120
+
100
121
  const getVariantImages = () => {
101
122
  if (selectedVariant?.media?.length) {
102
123
  return selectedVariant.media.map((media: any) => ({
@@ -450,7 +471,7 @@ export function ProductDetailScreen({ productId }: ProductDetailScreenProps) {
450
471
  {[...Array(5)].map((_, i) => (
451
472
  <Star
452
473
  key={i}
453
- className={`size-4 ${i < Math.floor(product.rating)
474
+ className={`size-4 ${i < Math.floor(reviewStats.averageRating)
454
475
  ? 'text-[#E67E50] fill-[#E67E50]'
455
476
  : 'text-gray-300'
456
477
  }`}
@@ -458,7 +479,7 @@ export function ProductDetailScreen({ productId }: ProductDetailScreenProps) {
458
479
  ))}
459
480
  </div>
460
481
  <span className="font-['Poppins',sans-serif] text-[14px] text-muted">
461
- {product.rating} ({product.reviewCount ? product.reviewCount : 0} reviews)
482
+ {reviewStats.averageRating} ({reviewStats.reviewCount} {reviewStats.reviewCount === 1 ? 'review' : 'reviews'})
462
483
  </span>
463
484
  </div>
464
485
  {selectedVariant && (
@@ -754,15 +775,7 @@ export function ProductDetailScreen({ productId }: ProductDetailScreenProps) {
754
775
  )}
755
776
 
756
777
  {activeTab === 'reviews' && (
757
- <div className="text-center py-8">
758
- <Star className="size-12 text-[#E67E50] mx-auto mb-4" />
759
- <h3 className="font-['Poppins',sans-serif] font-semibold text-secondary mb-2">
760
- {product.rating} out of 5 stars
761
- </h3>
762
- <p className="font-['Poppins',sans-serif] text-[14px] text-muted">
763
- Based on {product.reviewCount} customer reviews
764
- </p>
765
- </div>
778
+ <ProductReviewsSection productId={productId} />
766
779
  )}
767
780
  </div>
768
781
  </div>
@@ -11,6 +11,7 @@ import {
11
11
  Settings,
12
12
  LogOut,
13
13
  ChevronDown,
14
+ Star,
14
15
  } from 'lucide-react';
15
16
  import { useAuth } from '@/providers/AuthProvider';
16
17
  import { useBasePath } from '@/providers/BasePathProvider';
@@ -22,10 +23,12 @@ import { AccountSavedItemsTab } from '@/components/AccountSavedItemsTab';
22
23
  import { AccountPaymentTab } from '@/components/AccountPaymentTab';
23
24
  import { AccountAddressesTab } from '@/components/AccountAddressesTab';
24
25
  import { AccountSettingsTab } from '@/components/AccountSettingsTab';
26
+ import { AccountReviewsTab } from '@/components/AccountReviewsTab';
25
27
 
26
28
  const tabs = [
27
29
  { id: 'overview', label: 'Overview', icon: User },
28
30
  { id: 'orders', label: 'Orders', icon: Package },
31
+ { id: 'reviews', label: 'My Reviews', icon: Star },
29
32
  { id: 'saved-items', label: 'Saved Items', icon: Heart },
30
33
  // { id: 'payment', label: 'Payment', icon: CreditCard },
31
34
  { id: 'addresses', label: 'Addresses', icon: MapPin },
@@ -75,6 +78,8 @@ export default function AccountPage() {
75
78
  return <AccountOverviewTab />;
76
79
  case 'orders':
77
80
  return <AccountOrdersTab />;
81
+ case 'reviews':
82
+ return <AccountReviewsTab />;
78
83
  case 'saved-items':
79
84
  return <AccountSavedItemsTab />;
80
85
  // case 'payment':
@@ -69,7 +69,14 @@ export function ResetPasswordScreen() {
69
69
  setStatus(null);
70
70
  try {
71
71
  const authApi = new AuthApi(AXIOS_CONFIG);
72
- await authApi.resetPassword(data.newPassword, token);
72
+ if (!storeId) {
73
+ setStatus({
74
+ type: 'error',
75
+ message: 'Store ID is missing. Please use the link from your email.',
76
+ });
77
+ return;
78
+ }
79
+ await authApi.resetPassword(data.newPassword, token, storeId);
73
80
  setStatus({
74
81
  type: 'success',
75
82
  message: 'Password reset successfully! Redirecting to login...',
@@ -117,11 +124,10 @@ export function ResetPasswordScreen() {
117
124
  >
118
125
  {status && (
119
126
  <div
120
- className={`flex items-start gap-2 rounded-2xl border px-4 py-3 text-sm ${
121
- status.type === 'success'
127
+ className={`flex items-start gap-2 rounded-2xl border px-4 py-3 text-sm ${status.type === 'success'
122
128
  ? 'border-green-200 bg-green-50 text-green-800'
123
129
  : 'border-red-200 bg-red-50 text-red-700'
124
- }`}
130
+ }`}
125
131
  >
126
132
  <span className="mt-[2px] text-base">{status.type === 'success' ? '✔' : '!'}</span>
127
133
  <span>{status.message}</span>
@@ -1,75 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- /**
4
- * Hey Pharamcist API
5
- * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
6
- *
7
- * OpenAPI spec version: 1.0
8
- *
9
- *
10
- * NOTE: This class is auto generated by the swagger code generator program.
11
- * https://github.com/swagger-api/swagger-codegen.git
12
- * Do not edit the class manually.
13
- */
14
- /**
15
- *
16
- * @export
17
- * @interface CreateNotificationDto
18
- */
19
- export interface CreateNotificationDto {
20
- _id?: string;
21
- /**
22
- *
23
- * @type {string}
24
- * @memberof CreateNotificationDto
25
- */
26
- title: string;
27
- /**
28
- *
29
- * @type {string}
30
- * @memberof CreateNotificationDto
31
- */
32
- content: string;
33
- /**
34
- *
35
- * @type {string}
36
- * @memberof CreateNotificationDto
37
- */
38
- notificationType: string;
39
- /**
40
- *
41
- * @type {string}
42
- * @memberof CreateNotificationDto
43
- */
44
- notificationLink: string;
45
- /**
46
- *
47
- * @type {Array<string>}
48
- * @memberof CreateNotificationDto
49
- */
50
- sentTo: Array<string>;
51
- /**
52
- *
53
- * @type {Array<string>}
54
- * @memberof CreateNotificationDto
55
- */
56
- readBy: Array<string>;
57
- /**
58
- *
59
- * @type {Array<string>}
60
- * @memberof CreateNotificationDto
61
- */
62
- clearedBy: Array<string>;
63
- /**
64
- *
65
- * @type {boolean}
66
- * @memberof CreateNotificationDto
67
- */
68
- isAdminNotification: boolean;
69
- /**
70
- *
71
- * @type {string}
72
- * @memberof CreateNotificationDto
73
- */
74
- storeId: string;
75
- }
@@ -1,93 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- /**
4
- * Hey Pharamcist API
5
- * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
6
- *
7
- * OpenAPI spec version: 1.0
8
- *
9
- *
10
- * NOTE: This class is auto generated by the swagger code generator program.
11
- * https://github.com/swagger-api/swagger-codegen.git
12
- * Do not edit the class manually.
13
- */
14
- /**
15
- *
16
- * @export
17
- * @interface Notification
18
- */
19
- export interface Notification {
20
- _id?: string;
21
- /**
22
- *
23
- * @type {Date}
24
- * @memberof Notification
25
- */
26
- createdAt: Date;
27
- /**
28
- *
29
- * @type {Date}
30
- * @memberof Notification
31
- */
32
- updatedAt: Date;
33
- /**
34
- *
35
- * @type {string}
36
- * @memberof Notification
37
- */
38
- id: string;
39
- /**
40
- *
41
- * @type {string}
42
- * @memberof Notification
43
- */
44
- title: string;
45
- /**
46
- *
47
- * @type {string}
48
- * @memberof Notification
49
- */
50
- content: string;
51
- /**
52
- *
53
- * @type {string}
54
- * @memberof Notification
55
- */
56
- notificationType: string;
57
- /**
58
- *
59
- * @type {string}
60
- * @memberof Notification
61
- */
62
- notificationLink: string;
63
- /**
64
- *
65
- * @type {Array<string>}
66
- * @memberof Notification
67
- */
68
- sentTo: Array<string>;
69
- /**
70
- *
71
- * @type {Array<string>}
72
- * @memberof Notification
73
- */
74
- readBy: Array<string>;
75
- /**
76
- *
77
- * @type {Array<string>}
78
- * @memberof Notification
79
- */
80
- clearedBy: Array<string>;
81
- /**
82
- *
83
- * @type {boolean}
84
- * @memberof Notification
85
- */
86
- isAdminNotification: boolean;
87
- /**
88
- *
89
- * @type {string}
90
- * @memberof Notification
91
- */
92
- storeId: string;
93
- }
@@ -1,99 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- /**
4
- * Hey Pharamcist API
5
- * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
6
- *
7
- * OpenAPI spec version: 1.0
8
- *
9
- *
10
- * NOTE: This class is auto generated by the swagger code generator program.
11
- * https://github.com/swagger-api/swagger-codegen.git
12
- * Do not edit the class manually.
13
- */
14
- /**
15
- *
16
- * @export
17
- * @interface SingleNotificationDto
18
- */
19
- export interface SingleNotificationDto {
20
- _id?: string;
21
- /**
22
- *
23
- * @type {Date}
24
- * @memberof SingleNotificationDto
25
- */
26
- createdAt: Date;
27
- /**
28
- *
29
- * @type {Date}
30
- * @memberof SingleNotificationDto
31
- */
32
- updatedAt: Date;
33
- /**
34
- *
35
- * @type {string}
36
- * @memberof SingleNotificationDto
37
- */
38
- id: string;
39
- /**
40
- *
41
- * @type {string}
42
- * @memberof SingleNotificationDto
43
- */
44
- title: string;
45
- /**
46
- *
47
- * @type {string}
48
- * @memberof SingleNotificationDto
49
- */
50
- content: string;
51
- /**
52
- *
53
- * @type {string}
54
- * @memberof SingleNotificationDto
55
- */
56
- notificationType: string;
57
- /**
58
- *
59
- * @type {string}
60
- * @memberof SingleNotificationDto
61
- */
62
- notificationLink: string;
63
- /**
64
- *
65
- * @type {Array<string>}
66
- * @memberof SingleNotificationDto
67
- */
68
- sentTo: Array<string>;
69
- /**
70
- *
71
- * @type {Array<string>}
72
- * @memberof SingleNotificationDto
73
- */
74
- readBy: Array<string>;
75
- /**
76
- *
77
- * @type {Array<string>}
78
- * @memberof SingleNotificationDto
79
- */
80
- clearedBy: Array<string>;
81
- /**
82
- *
83
- * @type {boolean}
84
- * @memberof SingleNotificationDto
85
- */
86
- isAdminNotification: boolean;
87
- /**
88
- *
89
- * @type {string}
90
- * @memberof SingleNotificationDto
91
- */
92
- storeId: string;
93
- /**
94
- *
95
- * @type {boolean}
96
- * @memberof SingleNotificationDto
97
- */
98
- isRead: boolean;
99
- }