hey-pharmacist-ecommerce 1.1.27 → 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 (61) hide show
  1. package/dist/index.d.mts +344 -640
  2. package/dist/index.d.ts +344 -640
  3. package/dist/index.js +1814 -835
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +1814 -837
  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/EditProfileScreen.tsx +5 -1
  50. package/src/screens/ForgotPasswordScreen.tsx +153 -0
  51. package/src/screens/ProductDetailScreen.tsx +51 -60
  52. package/src/screens/RegisterScreen.tsx +31 -31
  53. package/src/screens/ResetPasswordScreen.tsx +202 -0
  54. package/src/screens/SearchResultsScreen.tsx +264 -26
  55. package/src/screens/ShopScreen.tsx +42 -45
  56. package/src/screens/WishlistScreen.tsx +35 -31
  57. package/src/lib/Apis/apis/product-variants-api.ts +0 -552
  58. package/src/lib/Apis/models/create-single-variant-product-dto.ts +0 -154
  59. package/src/lib/Apis/models/extended-product-dto.ts +0 -206
  60. package/src/lib/Apis/models/frequently-bought-product-dto.ts +0 -71
  61. package/src/lib/Apis/models/table-dto.ts +0 -34
@@ -1,79 +1,78 @@
1
- import { useState, useEffect, useCallback } from 'react';
1
+ import { useState, useEffect } from 'react';
2
2
  import { AXIOS_CONFIG } from '@/lib/Apis/wrapper';
3
- import { CategoriesApi, CategoryPopulated, ExtendedProductDTO, ProductsApi } from '@/lib/Apis';
3
+ import { CategoriesApi, CategoryPopulated, ProductsApi, Product } from '@/lib/Apis';
4
4
  import { ProductFilters } from '@/lib/types';
5
+ import { useQuery } from '@tanstack/react-query';
6
+
7
+ export enum SortOrder {
8
+ Asc = "asc",
9
+ Desc = "desc",
10
+ }
5
11
 
6
12
  export function useProducts(filters?: ProductFilters, page: number = 1, limit: number = 20) {
7
- const [products, setProducts] = useState<ExtendedProductDTO[]>([]);
8
- const [isLoading, setIsLoading] = useState(true);
9
- const [error, setError] = useState<Error | null>(null);
10
- const [pagination, setPagination] = useState({
11
- page: 1,
12
- limit: 20,
13
- total: 0,
14
- totalPages: 0,
15
- });
13
+ const { data, isLoading, error, refetch } = useQuery({
14
+ queryKey: [
15
+ "products",
16
+ filters?.search,
17
+ filters?.category,
18
+ filters?.subCategory,
19
+ filters?.maxPrice,
20
+ filters?.minPrice,
21
+ filters?.inStock,
22
+ page,
23
+ limit
24
+ ],
25
+ queryFn: async () => {
26
+ const response = await new ProductsApi(AXIOS_CONFIG).getAllProducts(
27
+ filters?.search ?? "", // searchTerm
28
+ filters?.maxPrice, // maxPrice
29
+ filters?.minPrice, // minPrice
30
+ undefined, // brandFilter
31
+ filters?.inStock !== undefined ? (filters.inStock ? 'in-stock' : 'out-of-stock') : undefined, // availability
32
+ "createdAt", // sort
33
+ filters?.subCategory, // subCategoryId
34
+ filters?.category, // categoryId
35
+ true, // isActive
36
+ limit, // limit
37
+ page // page
38
+ );
16
39
 
17
- const fetchProducts = useCallback(async () => {
18
- setIsLoading(true);
19
- setError(null);
20
- try {
21
- let response;
22
- if (filters?.subCategory) {
23
- response = await new ProductsApi(AXIOS_CONFIG).getAllProducts(
24
- filters.subCategory,
25
- filters?.search,
26
- filters?.maxPrice,
27
- filters?.minPrice,
28
- undefined, // brandFilter
29
- filters?.inStock !== undefined ? (filters.inStock ? 'in-stock' : 'out-of-stock') : undefined,
30
- undefined, // sort
31
- true, // includeNoVariantProducts
32
- true, // isActive
33
- limit,
34
- page
35
- );
36
- } else {
37
- response = await new ProductsApi(AXIOS_CONFIG).getAllProductsForStore(
38
- filters?.search,
39
- undefined, // productType
40
- filters?.category,
41
- filters?.maxPrice,
42
- filters?.minPrice,
43
- undefined, // brandFilter
44
- filters?.inStock !== undefined ? (filters.inStock ? 'in-stock' : 'out-of-stock') : undefined,
45
- undefined, // sort
46
- true, // includeNoVariantProducts
47
- true, // isActive
48
- limit,
49
- page
50
- );
51
- }
52
- setProducts(response.data.data);
53
- setPagination({
54
- page: response.data.currentPage || page,
55
- limit: response.data.limit || limit,
56
- total: products.length, // Use filtered count
57
- totalPages: Math.ceil(products.length / limit),
58
- });
59
- } catch (err) {
60
- setError(err as Error);
61
- }
62
- setIsLoading(false);
63
- }, [filters, page, limit]);
40
+ const res = response.data;
41
+ console.log("Products API response:", res);
64
42
 
65
- useEffect(() => {
66
- fetchProducts();
67
- }, [fetchProducts]);
43
+ return {
44
+ products: res.data || [],
45
+ pagination: {
46
+ page: res.currentPage || page,
47
+ limit: res.limit || limit,
48
+ total: res.totalItems || 0,
49
+ totalPages: res.totalPages || 0,
50
+ },
51
+ };
52
+ },
53
+ });
68
54
 
69
- return { products, isLoading, error, pagination };
55
+ console.log("useProducts data:", data);
56
+
57
+ return {
58
+ products: data?.products || [],
59
+ isLoading,
60
+ error: error as Error | null,
61
+ pagination: data?.pagination || {
62
+ page: 1,
63
+ limit: 20,
64
+ total: 0,
65
+ totalPages: 0,
66
+ },
67
+ refetch,
68
+ };
70
69
  }
71
70
 
72
71
  export function useProduct(id: string) {
73
- const [product, setProduct] = useState<ExtendedProductDTO | null>(null);
72
+ const [product, setProduct] = useState<Product | null>(null);
74
73
  const [isLoading, setIsLoading] = useState(true);
75
74
  const [error, setError] = useState<Error | null>(null);
76
-
75
+ console.log("product", product);
77
76
  useEffect(() => {
78
77
  const fetchProduct = async () => {
79
78
  setIsLoading(true);
@@ -1,12 +1,11 @@
1
1
  'use client';
2
2
 
3
3
  import { useCallback, useEffect, useMemo, useState } from 'react';
4
- import { ProductsApi } from '@/lib/Apis';
4
+ import { ProductsApi, Product } from '@/lib/Apis';
5
5
  import { AXIOS_CONFIG } from '@/lib/Apis/wrapper';
6
- import { ExtendedProductDTO } from '@/lib/Apis/models/extended-product-dto';
7
6
 
8
7
  interface UseWishlistProductsResult {
9
- products: ExtendedProductDTO[];
8
+ products: Product[];
10
9
  isLoading: boolean;
11
10
  error: Error | null;
12
11
  refetch: () => Promise<void>;
@@ -17,10 +16,10 @@ interface UseWishlistProductsResult {
17
16
  * Minimises duplicate requests by caching results during the component lifecycle.
18
17
  */
19
18
  export function useWishlistProducts(productIds: string[] = []): UseWishlistProductsResult {
20
- const [products, setProducts] = useState<ExtendedProductDTO[]>([]);
19
+ const [products, setProducts] = useState<Product[]>([]);
21
20
  const [isLoading, setIsLoading] = useState<boolean>(false);
22
21
  const [error, setError] = useState<Error | null>(null);
23
- const [cache] = useState<Map<string, ExtendedProductDTO>>(() => new Map());
22
+ const [cache] = useState<Map<string, Product>>(() => new Map());
24
23
 
25
24
  const uniqueIds = useMemo(
26
25
  () => Array.from(new Set((productIds || []).filter(Boolean))),
package/src/index.ts CHANGED
@@ -15,6 +15,8 @@ export { CartScreen } from './screens/CartScreen';
15
15
  export { CheckoutScreen } from './screens/CheckoutScreen';
16
16
  export { LoginScreen } from './screens/LoginScreen';
17
17
  export { RegisterScreen } from './screens/RegisterScreen';
18
+ export { ForgotPasswordScreen } from './screens/ForgotPasswordScreen';
19
+ export { ResetPasswordScreen } from './screens/ResetPasswordScreen';
18
20
  export { default as ProfileScreen } from './screens/ProfileScreen';
19
21
  export { OrdersScreen } from './screens/OrdersScreen';
20
22
  export { CurrentOrdersScreen } from './screens/CurrentOrdersScreen';
@@ -25,7 +25,6 @@ export * from './apis/marketing-api';
25
25
  export * from './apis/notifications-api';
26
26
  export * from './apis/orders-api';
27
27
  export * from './apis/payments-api';
28
- export * from './apis/product-variants-api';
29
28
  export * from './apis/products-api';
30
29
  export * from './apis/review-api';
31
30
  export * from './apis/shipping-api';
@@ -16,6 +16,7 @@ import { Configuration } from '../configuration';
16
16
  // Some imports not used depending on template conditions
17
17
  // @ts-ignore
18
18
  import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
19
+ import { ChangePasswordDto } from '../models';
19
20
  import { CreateUserDto } from '../models';
20
21
  import { ForgetPassword } from '../models';
21
22
  import { LoginDto } from '../models';
@@ -84,19 +85,14 @@ export const AuthApiAxiosParamCreator = function (configuration?: Configuration)
84
85
  /**
85
86
  *
86
87
  * @summary Change user password
87
- * @param {string} oldPassword
88
- * @param {string} newPassword
88
+ * @param {ChangePasswordDto} body
89
89
  * @param {*} [options] Override http request option.
90
90
  * @throws {RequiredError}
91
91
  */
92
- changePassword: async (oldPassword: string, newPassword: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
93
- // verify required parameter 'oldPassword' is not null or undefined
94
- if (oldPassword === null || oldPassword === undefined) {
95
- throw new RequiredError('oldPassword','Required parameter oldPassword was null or undefined when calling changePassword.');
96
- }
97
- // verify required parameter 'newPassword' is not null or undefined
98
- if (newPassword === null || newPassword === undefined) {
99
- throw new RequiredError('newPassword','Required parameter newPassword was null or undefined when calling changePassword.');
92
+ changePassword: async (body: ChangePasswordDto, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
93
+ // verify required parameter 'body' is not null or undefined
94
+ if (body === null || body === undefined) {
95
+ throw new RequiredError('body','Required parameter body was null or undefined when calling changePassword.');
100
96
  }
101
97
  const localVarPath = `/auth/change-password`;
102
98
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
@@ -117,13 +113,7 @@ export const AuthApiAxiosParamCreator = function (configuration?: Configuration)
117
113
  localVarHeaderParameter["x-store-key"] = localVarApiKeyValue;
118
114
  }
119
115
 
120
- if (oldPassword !== undefined && oldPassword !== null) {
121
- localVarHeaderParameter['oldPassword'] = String(oldPassword);
122
- }
123
-
124
- if (newPassword !== undefined && newPassword !== null) {
125
- localVarHeaderParameter['newPassword'] = String(newPassword);
126
- }
116
+ localVarHeaderParameter['Content-Type'] = 'application/json';
127
117
 
128
118
  const query = new URLSearchParams(localVarUrlObj.search);
129
119
  for (const key in localVarQueryParameter) {
@@ -135,6 +125,8 @@ export const AuthApiAxiosParamCreator = function (configuration?: Configuration)
135
125
  localVarUrlObj.search = (new URLSearchParams(query)).toString();
136
126
  let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
137
127
  localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
128
+ const needsSerialization = (typeof body !== "string") || (localVarRequestOptions.headers ||= {})['Content-Type'] === 'application/json';
129
+ localVarRequestOptions.data = needsSerialization ? JSON.stringify(body !== undefined ? body : {}) : (body || "");
138
130
 
139
131
  return {
140
132
  url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
@@ -584,13 +576,12 @@ export const AuthApiFp = function(configuration?: Configuration) {
584
576
  /**
585
577
  *
586
578
  * @summary Change user password
587
- * @param {string} oldPassword
588
- * @param {string} newPassword
579
+ * @param {ChangePasswordDto} body
589
580
  * @param {*} [options] Override http request option.
590
581
  * @throws {RequiredError}
591
582
  */
592
- async changePassword(oldPassword: string, newPassword: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<void>>> {
593
- const localVarAxiosArgs = await AuthApiAxiosParamCreator(configuration).changePassword(oldPassword, newPassword, options);
583
+ async changePassword(body: ChangePasswordDto, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<void>>> {
584
+ const localVarAxiosArgs = await AuthApiAxiosParamCreator(configuration).changePassword(body, options);
594
585
  return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
595
586
  const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
596
587
  return axios.request(axiosRequestArgs);
@@ -731,13 +722,12 @@ export const AuthApiFactory = function (configuration?: Configuration, basePath?
731
722
  /**
732
723
  *
733
724
  * @summary Change user password
734
- * @param {string} oldPassword
735
- * @param {string} newPassword
725
+ * @param {ChangePasswordDto} body
736
726
  * @param {*} [options] Override http request option.
737
727
  * @throws {RequiredError}
738
728
  */
739
- async changePassword(oldPassword: string, newPassword: string, options?: AxiosRequestConfig): Promise<AxiosResponse<void>> {
740
- return AuthApiFp(configuration).changePassword(oldPassword, newPassword, options).then((request) => request(axios, basePath));
729
+ async changePassword(body: ChangePasswordDto, options?: AxiosRequestConfig): Promise<AxiosResponse<void>> {
730
+ return AuthApiFp(configuration).changePassword(body, options).then((request) => request(axios, basePath));
741
731
  },
742
732
  /**
743
733
  *
@@ -844,14 +834,13 @@ export class AuthApi extends BaseAPI {
844
834
  /**
845
835
  *
846
836
  * @summary Change user password
847
- * @param {string} oldPassword
848
- * @param {string} newPassword
837
+ * @param {ChangePasswordDto} body
849
838
  * @param {*} [options] Override http request option.
850
839
  * @throws {RequiredError}
851
840
  * @memberof AuthApi
852
841
  */
853
- public async changePassword(oldPassword: string, newPassword: string, options?: AxiosRequestConfig) : Promise<AxiosResponse<void>> {
854
- return AuthApiFp(this.configuration).changePassword(oldPassword, newPassword, options).then((request) => request(this.axios, this.basePath));
842
+ public async changePassword(body: ChangePasswordDto, options?: AxiosRequestConfig) : Promise<AxiosResponse<void>> {
843
+ return AuthApiFp(this.configuration).changePassword(body, options).then((request) => request(this.axios, this.basePath));
855
844
  }
856
845
  /**
857
846
  *