hey-pharmacist-ecommerce 1.1.28 → 1.1.30

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 (91) hide show
  1. package/dist/index.d.mts +10552 -1370
  2. package/dist/index.d.ts +10552 -1370
  3. package/dist/index.js +4696 -1281
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +4640 -1283
  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/useStoreCapabilities.ts +87 -0
  19. package/src/hooks/useWishlistProducts.ts +4 -5
  20. package/src/index.ts +6 -0
  21. package/src/lib/Apis/api.ts +0 -1
  22. package/src/lib/Apis/apis/auth-api.ts +37 -36
  23. package/src/lib/Apis/apis/categories-api.ts +97 -0
  24. package/src/lib/Apis/apis/products-api.ts +942 -405
  25. package/src/lib/Apis/apis/shipping-api.ts +105 -0
  26. package/src/lib/Apis/apis/stores-api.ts +356 -0
  27. package/src/lib/Apis/apis/sub-categories-api.ts +97 -0
  28. package/src/lib/Apis/apis/users-api.ts +8 -8
  29. package/src/lib/Apis/models/address-created-request.ts +0 -12
  30. package/src/lib/Apis/models/address.ts +0 -12
  31. package/src/lib/Apis/models/api-key-info-dto.ts +49 -0
  32. package/src/lib/Apis/models/category-populated.ts +0 -12
  33. package/src/lib/Apis/models/category-sub-category-populated.ts +2 -2
  34. package/src/lib/Apis/models/category.ts +0 -18
  35. package/src/lib/Apis/models/{table-cell-dto.ts → change-password-dto.ts} +6 -6
  36. package/src/lib/Apis/models/create-address-dto.ts +0 -12
  37. package/src/lib/Apis/models/create-discount-dto.ts +0 -8
  38. package/src/lib/Apis/models/create-product-dto.ts +30 -23
  39. package/src/lib/Apis/models/create-store-address-dto.ts +0 -12
  40. package/src/lib/Apis/models/create-store-dto-settings.ts +51 -0
  41. package/src/lib/Apis/models/create-store-dto.ts +7 -0
  42. package/src/lib/Apis/models/create-sub-category-dto.ts +6 -0
  43. package/src/lib/Apis/models/create-variant-dto.ts +26 -32
  44. package/src/lib/Apis/models/discount.ts +0 -8
  45. package/src/lib/Apis/models/index.ts +16 -7
  46. package/src/lib/Apis/models/paginated-products-dto.ts +6 -6
  47. package/src/lib/Apis/models/populated-discount.ts +0 -8
  48. package/src/lib/Apis/models/product-summary.ts +69 -0
  49. package/src/lib/Apis/models/product-variant.ts +31 -68
  50. package/src/lib/Apis/models/product.ts +138 -0
  51. package/src/lib/Apis/models/products-insights-dto.ts +12 -0
  52. package/src/lib/Apis/models/reorder-categories-dto.ts +27 -0
  53. package/src/lib/Apis/models/reorder-products-dto.ts +49 -0
  54. package/src/lib/Apis/models/{table-dto.ts → reorder-products-success-response-dto.ts} +8 -9
  55. package/src/lib/Apis/models/reorder-subcategories-dto.ts +33 -0
  56. package/src/lib/Apis/models/{shallow-parent-category-dto.ts → reorder-success-response-dto.ts} +7 -7
  57. package/src/lib/Apis/models/shipment-with-order.ts +18 -0
  58. package/src/lib/Apis/models/shipment.ts +18 -0
  59. package/src/lib/Apis/models/single-product-media.ts +0 -12
  60. package/src/lib/Apis/models/store-api-keys-response-dto.ts +34 -0
  61. package/src/lib/Apis/models/store-capabilities-dto.ts +63 -0
  62. package/src/lib/Apis/models/store-entity.ts +7 -0
  63. package/src/lib/Apis/models/store.ts +7 -0
  64. package/src/lib/Apis/models/sub-category.ts +6 -12
  65. package/src/lib/Apis/models/update-address-dto.ts +0 -12
  66. package/src/lib/Apis/models/update-api-keys-dto.ts +39 -0
  67. package/src/lib/Apis/models/update-discount-dto.ts +0 -8
  68. package/src/lib/Apis/models/update-manual-shipment-status-dto.ts +47 -0
  69. package/src/lib/Apis/models/update-product-dto.ts +30 -19
  70. package/src/lib/Apis/models/update-store-dto.ts +7 -0
  71. package/src/lib/Apis/models/update-sub-category-dto.ts +6 -0
  72. package/src/lib/Apis/models/{update-product-variant-dto.ts → update-variant-dto.ts} +46 -46
  73. package/src/lib/Apis/models/variant-id-inventory-body.ts +27 -0
  74. package/src/lib/api-adapter/config.ts +53 -0
  75. package/src/lib/validations/address.ts +1 -1
  76. package/src/providers/FavoritesProvider.tsx +5 -5
  77. package/src/providers/WishlistProvider.tsx +4 -4
  78. package/src/screens/CartScreen.tsx +1 -1
  79. package/src/screens/ChangePasswordScreen.tsx +2 -6
  80. package/src/screens/CheckoutScreen.tsx +402 -288
  81. package/src/screens/ForgotPasswordScreen.tsx +153 -0
  82. package/src/screens/ProductDetailScreen.tsx +51 -60
  83. package/src/screens/RegisterScreen.tsx +31 -31
  84. package/src/screens/ResetPasswordScreen.tsx +208 -0
  85. package/src/screens/SearchResultsScreen.tsx +264 -26
  86. package/src/screens/ShopScreen.tsx +42 -45
  87. package/src/screens/WishlistScreen.tsx +35 -31
  88. package/src/lib/Apis/apis/product-variants-api.ts +0 -552
  89. package/src/lib/Apis/models/create-single-variant-product-dto.ts +0 -154
  90. package/src/lib/Apis/models/extended-product-dto.ts +0 -206
  91. package/src/lib/Apis/models/frequently-bought-product-dto.ts +0 -71
@@ -11,9 +11,8 @@
11
11
  * https://github.com/swagger-api/swagger-codegen.git
12
12
  * Do not edit the class manually.
13
13
  */
14
- import { Category } from './category';
14
+ import { CreateVariantDto } from './create-variant-dto';
15
15
  import { SingleProductMedia } from './single-product-media';
16
- import { SubCategory } from './sub-category';
17
16
  /**
18
17
  *
19
18
  * @export
@@ -35,40 +34,52 @@ export interface UpdateProductDto {
35
34
  description?: string;
36
35
  /**
37
36
  *
38
- * @type {Array<string>}
37
+ * @type {string}
39
38
  * @memberof UpdateProductDto
40
39
  */
41
- tags?: Array<string>;
40
+ brand?: string;
42
41
  /**
43
42
  *
44
43
  * @type {string}
45
44
  * @memberof UpdateProductDto
46
45
  */
47
- brand?: string;
46
+ sku?: string;
48
47
  /**
49
48
  *
50
49
  * @type {string}
51
50
  * @memberof UpdateProductDto
52
51
  */
53
- sku?: string;
52
+ upc?: string;
54
53
  /**
55
54
  *
56
- * @type {boolean}
55
+ * @type {Array<SingleProductMedia>}
57
56
  * @memberof UpdateProductDto
58
57
  */
59
- showStock?: boolean;
58
+ media?: Array<SingleProductMedia>;
60
59
  /**
61
60
  *
62
61
  * @type {Array<string>}
63
62
  * @memberof UpdateProductDto
64
63
  */
65
- reviews?: Array<string>;
64
+ tags?: Array<string>;
65
+ /**
66
+ * Category IDs
67
+ * @type {Array<string>}
68
+ * @memberof UpdateProductDto
69
+ */
70
+ categoryIds?: Array<string>;
71
+ /**
72
+ * SubCategory IDs
73
+ * @type {Array<string>}
74
+ * @memberof UpdateProductDto
75
+ */
76
+ subCategoryIds?: Array<string>;
66
77
  /**
67
78
  *
68
- * @type {string}
79
+ * @type {boolean}
69
80
  * @memberof UpdateProductDto
70
81
  */
71
- upc?: string;
82
+ showStock?: boolean;
72
83
  /**
73
84
  *
74
85
  * @type {boolean}
@@ -76,27 +87,27 @@ export interface UpdateProductDto {
76
87
  */
77
88
  homeScreenFeatured?: boolean;
78
89
  /**
79
- *
80
- * @type {Array<SingleProductMedia>}
90
+ * IDs of frequently bought together products
91
+ * @type {Array<string>}
81
92
  * @memberof UpdateProductDto
82
93
  */
83
- productMedia?: Array<SingleProductMedia>;
94
+ frequentlyBoughtWith?: Array<string>;
84
95
  /**
85
- *
96
+ * IDs of frequently bought together products (alias)
86
97
  * @type {Array<string>}
87
98
  * @memberof UpdateProductDto
88
99
  */
89
100
  frequentlyBoughtProducts?: Array<string>;
90
101
  /**
91
102
  *
92
- * @type {Array<Category>}
103
+ * @type {boolean}
93
104
  * @memberof UpdateProductDto
94
105
  */
95
- parentCategories: Array<Category>;
106
+ isActive?: boolean;
96
107
  /**
97
108
  *
98
- * @type {Array<SubCategory>}
109
+ * @type {Array<CreateVariantDto>}
99
110
  * @memberof UpdateProductDto
100
111
  */
101
- parentSubCategories: Array<SubCategory>;
112
+ variants?: Array<CreateVariantDto>;
102
113
  }
@@ -11,6 +11,7 @@
11
11
  * https://github.com/swagger-api/swagger-codegen.git
12
12
  * Do not edit the class manually.
13
13
  */
14
+ import { CreateStoreDtoSettings } from './create-store-dto-settings';
14
15
  /**
15
16
  *
16
17
  * @export
@@ -102,4 +103,10 @@ export interface UpdateStoreDto {
102
103
  * @memberof UpdateStoreDto
103
104
  */
104
105
  storeBillingAddress?: string;
106
+ /**
107
+ *
108
+ * @type {CreateStoreDtoSettings}
109
+ * @memberof UpdateStoreDto
110
+ */
111
+ settings?: CreateStoreDtoSettings;
105
112
  }
@@ -42,4 +42,10 @@ export interface UpdateSubCategoryDto {
42
42
  * @memberof UpdateSubCategoryDto
43
43
  */
44
44
  isActive?: boolean;
45
+ /**
46
+ *
47
+ * @type {number}
48
+ * @memberof UpdateSubCategoryDto
49
+ */
50
+ order?: number;
45
51
  }
@@ -15,92 +15,92 @@ import { SingleProductMedia } from './single-product-media';
15
15
  /**
16
16
  *
17
17
  * @export
18
- * @interface UpdateProductVariantDto
18
+ * @interface UpdateVariantDto
19
19
  */
20
- export interface UpdateProductVariantDto {
20
+ export interface UpdateVariantDto {
21
21
  _id?: string;
22
22
  /**
23
23
  *
24
24
  * @type {string}
25
- * @memberof UpdateProductVariantDto
25
+ * @memberof UpdateVariantDto
26
26
  */
27
27
  name?: string;
28
28
  /**
29
29
  *
30
- * @type {Array<SingleProductMedia>}
31
- * @memberof UpdateProductVariantDto
30
+ * @type {string}
31
+ * @memberof UpdateVariantDto
32
32
  */
33
- productMedia?: Array<SingleProductMedia>;
33
+ description?: string;
34
34
  /**
35
35
  *
36
36
  * @type {string}
37
- * @memberof UpdateProductVariantDto
37
+ * @memberof UpdateVariantDto
38
38
  */
39
- description?: string;
39
+ sku?: string;
40
40
  /**
41
41
  *
42
- * @type {number}
43
- * @memberof UpdateProductVariantDto
42
+ * @type {string}
43
+ * @memberof UpdateVariantDto
44
44
  */
45
- inventory?: number;
45
+ brand?: string;
46
46
  /**
47
- * The width of the product variant in cm
48
- * @type {number}
49
- * @memberof UpdateProductVariantDto
47
+ *
48
+ * @type {Array<SingleProductMedia>}
49
+ * @memberof UpdateVariantDto
50
50
  */
51
- width?: number;
51
+ media?: Array<SingleProductMedia>;
52
52
  /**
53
- * The height of the product variant in cm
53
+ *
54
54
  * @type {number}
55
- * @memberof UpdateProductVariantDto
55
+ * @memberof UpdateVariantDto
56
56
  */
57
- height?: number;
57
+ retailPrice?: number;
58
58
  /**
59
- * The length of the product variant in cm
59
+ * Initial inventory count
60
60
  * @type {number}
61
- * @memberof UpdateProductVariantDto
61
+ * @memberof UpdateVariantDto
62
62
  */
63
- length?: number;
63
+ inventoryCount?: number;
64
64
  /**
65
- * The weight of the product variant in g
65
+ * Width in cm
66
66
  * @type {number}
67
- * @memberof UpdateProductVariantDto
67
+ * @memberof UpdateVariantDto
68
68
  */
69
- weight?: number;
69
+ width?: number;
70
70
  /**
71
- *
72
- * @type {string}
73
- * @memberof UpdateProductVariantDto
71
+ * Height in cm
72
+ * @type {number}
73
+ * @memberof UpdateVariantDto
74
74
  */
75
- brand?: string;
75
+ height?: number;
76
76
  /**
77
- *
78
- * @type {string}
79
- * @memberof UpdateProductVariantDto
77
+ * Length in cm
78
+ * @type {number}
79
+ * @memberof UpdateVariantDto
80
80
  */
81
- sku?: string;
81
+ length?: number;
82
82
  /**
83
- *
83
+ * Weight in grams
84
84
  * @type {number}
85
- * @memberof UpdateProductVariantDto
85
+ * @memberof UpdateVariantDto
86
86
  */
87
- retailPrice?: number;
87
+ weight?: number;
88
88
  /**
89
89
  *
90
- * @type {number}
91
- * @memberof UpdateProductVariantDto
90
+ * @type {boolean}
91
+ * @memberof UpdateVariantDto
92
92
  */
93
- costPrice?: number;
93
+ isActive?: boolean;
94
94
  /**
95
- *
96
- * @type {number}
97
- * @memberof UpdateProductVariantDto
95
+ * Custom attributes like color, size, etc.
96
+ * @type {any}
97
+ * @memberof UpdateVariantDto
98
98
  */
99
- totalSold?: number;
99
+ attributes?: any;
100
100
  /**
101
- *
102
- * @type {number}
103
- * @memberof UpdateProductVariantDto
101
+ * Variant ID to update
102
+ * @type {string}
103
+ * @memberof UpdateVariantDto
104
104
  */
105
- inventoryCount?: number;
105
+ id: string;
106
106
  }
@@ -0,0 +1,27 @@
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 VariantIdInventoryBody
18
+ */
19
+ export interface VariantIdInventoryBody {
20
+ _id?: string;
21
+ /**
22
+ *
23
+ * @type {number}
24
+ * @memberof VariantIdInventoryBody
25
+ */
26
+ quantityChange?: number;
27
+ }
@@ -83,3 +83,56 @@ export function clearAuthToken(): void {
83
83
  }
84
84
  }
85
85
 
86
+ /**
87
+ * Change user password
88
+ * Custom implementation to fix the auto-generated API which incorrectly sends passwords as headers
89
+ */
90
+ export async function changePassword(oldPassword: string, newPassword: string): Promise<void> {
91
+ if (!currentConfig) {
92
+ throw new Error('API adapter not initialized.');
93
+ }
94
+
95
+ const token = getAuthToken();
96
+ if (!token) {
97
+ throw new Error('User is not authenticated');
98
+ }
99
+
100
+ const url = `${currentConfig.apiBaseUrl}/auth/change-password`;
101
+
102
+ console.log('Change Password Request:', {
103
+ url,
104
+ storeId: currentConfig.storeId,
105
+ hasToken: !!token,
106
+ tokenPrefix: token.substring(0, 20) + '...',
107
+ });
108
+
109
+ const response = await fetch(url, {
110
+ method: 'POST',
111
+ headers: {
112
+ 'Content-Type': 'application/json',
113
+ 'X-Store-Key': currentConfig.storeId,
114
+ 'Authorization': `Bearer ${token}`,
115
+ },
116
+ body: JSON.stringify({
117
+ oldPassword,
118
+ newPassword,
119
+ }),
120
+ });
121
+
122
+ console.log('Change Password Response:', {
123
+ status: response.status,
124
+ statusText: response.statusText,
125
+ });
126
+
127
+ if (!response.ok) {
128
+ const errorData = await response.json().catch(() => ({}));
129
+ console.error('Change Password Error:', errorData);
130
+ throw {
131
+ response: {
132
+ data: errorData,
133
+ status: response.status,
134
+ },
135
+ };
136
+ }
137
+ }
138
+
@@ -8,7 +8,7 @@ export const addressSchema = z.object({
8
8
  state: z.string().min(2, 'State is required'),
9
9
  zip: z.string().min(4, 'ZIP code is required'),
10
10
  country: z.string().min(2, 'Country is required'),
11
- phone: z.string().min(10, 'Phone number is required'),
11
+ phone: z.string().min(10, 'Phone number must be at least 10 characters').optional().or(z.literal('')),
12
12
  });
13
13
 
14
14
  export type AddressFormData = z.infer<typeof addressSchema>;
@@ -1,14 +1,14 @@
1
1
  'use client';
2
2
 
3
- import { ExtendedProductDTO } from '@/lib/Apis';
3
+ import { Product } from '@/lib/Apis';
4
4
  import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react';
5
5
  import { useNotification } from './NotificationProvider';
6
6
 
7
7
  interface FavoritesContextType {
8
8
  favorites: string[];
9
9
  isFavorite: (productId: string) => boolean;
10
- toggleFavorite: (product: ExtendedProductDTO) => void;
11
- addToFavorites: (product: ExtendedProductDTO) => void;
10
+ toggleFavorite: (product: Product) => void;
11
+ addToFavorites: (product: Product) => void;
12
12
  removeFromFavorites: (productId: string) => void;
13
13
  }
14
14
 
@@ -53,7 +53,7 @@ export function FavoritesProvider({ children }: { children: ReactNode }) {
53
53
  return favorites.includes(productId);
54
54
  };
55
55
 
56
- const addToFavorites = (product: ExtendedProductDTO) => {
56
+ const addToFavorites = (product: Product) => {
57
57
  if (!favorites.includes(product.id)) {
58
58
  setFavorites(prev => [...prev, product.id]);
59
59
  notification.success(
@@ -71,7 +71,7 @@ export function FavoritesProvider({ children }: { children: ReactNode }) {
71
71
  );
72
72
  };
73
73
 
74
- const toggleFavorite = (product: ExtendedProductDTO) => {
74
+ const toggleFavorite = (product: Product) => {
75
75
  if (isFavorite(product.id)) {
76
76
  removeFromFavorites(product.id);
77
77
  } else {
@@ -5,12 +5,12 @@ import { WishlistApi } from '@/lib/Apis/apis/wishlist-api';
5
5
  import { AXIOS_CONFIG } from '@/lib/Apis/wrapper';
6
6
  import { useAuth } from './AuthProvider';
7
7
  import { useMemo } from 'react';
8
- import { ExtendedProductDTO, Wishlist } from '@/lib/Apis';
8
+ import { ProductsApi, Wishlist, Product } from '@/lib/Apis';
9
9
  import { useNotification } from './NotificationProvider';
10
10
 
11
11
 
12
12
  interface WishlistContextType extends Wishlist {
13
- addToWishlist: (product: ExtendedProductDTO) => Promise<void>;
13
+ addToWishlist: (product: Product) => Promise<void>;
14
14
  removeFromWishlist: (productId: string) => Promise<void>;
15
15
  isInWishlist: (productId: string) => boolean;
16
16
  getWishlistCount: () => number;
@@ -64,7 +64,7 @@ export function WishlistProvider({ children }: { children: ReactNode }) {
64
64
  error: error instanceof Error ? error.message : 'Failed to load wishlist',
65
65
  }));
66
66
  }
67
- // eslint-disable-next-line react-hooks/exhaustive-deps
67
+ // eslint-disable-next-line react-hooks/exhaustive-deps
68
68
  }, [isAuthenticated]);
69
69
 
70
70
 
@@ -72,7 +72,7 @@ export function WishlistProvider({ children }: { children: ReactNode }) {
72
72
  fetchWishlist();
73
73
  }, [fetchWishlist]);
74
74
 
75
- const addToWishlist = async (product: any) => {
75
+ const addToWishlist = async (product: Product) => {
76
76
  if (!isAuthenticated) {
77
77
  notification.error(
78
78
  'Sign-in required',
@@ -88,7 +88,7 @@ export function CartScreen() {
88
88
  );
89
89
  }
90
90
 
91
- const subtotal = cart.total;
91
+ const subtotal = cart.cartBody.items.reduce((total, item) => total + item.productVariantData.finalPrice * item.quantity, 0);
92
92
  const shipping = 0;
93
93
  const tax = 0;
94
94
  const total = subtotal + shipping + tax;
@@ -9,8 +9,7 @@ import { useRouter } from 'next/navigation';
9
9
  import { Lock, ShieldCheck } from 'lucide-react';
10
10
  import { Input } from '@/components/ui/Input';
11
11
  import { Button } from '@/components/ui/Button';
12
- import { AuthApi } from '@/lib/Apis/apis/auth-api';
13
- import { getApiConfiguration } from '@/lib/api-adapter/config';
12
+ import { changePassword } from '@/lib/api-adapter/config';
14
13
  import { useAuth } from '@/providers/AuthProvider';
15
14
  import { useBasePath } from '@/providers/BasePathProvider';
16
15
 
@@ -53,10 +52,7 @@ export function ChangePasswordScreen() {
53
52
  setIsSubmitting(true);
54
53
  setStatus(null);
55
54
  try {
56
- await new AuthApi(getApiConfiguration()).changePassword(
57
- data.currentPassword,
58
- data.newPassword
59
- );
55
+ await changePassword(data.currentPassword, data.newPassword);
60
56
  setStatus({ type: 'success', message: 'Password updated successfully' });
61
57
  setTimeout(() => router.push(buildPath('/account')), 600);
62
58
  } catch (error: any) {