hey-pharmacist-ecommerce 1.1.23 → 1.1.24
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/dist/index.js +79 -153
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -153
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/AccountSavedItemsTab.tsx +0 -1
- package/src/components/ProductCard.tsx +5 -3
- package/src/components/QuickViewModal.tsx +66 -67
- package/src/hooks/useOrders.ts +0 -1
- package/src/hooks/useProducts.ts +3 -3
- package/src/lib/Apis/apis/products-api.ts +0 -104
- package/src/providers/CartProvider.tsx +0 -6
- package/src/screens/NewAddressScreen.tsx +9 -10
- package/src/screens/ProductDetailScreen.tsx +9 -11
- package/src/screens/SearchResultsScreen.tsx +2 -3
- package/src/screens/ShopScreen.tsx +57 -62
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hey-pharmacist-ecommerce",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.24",
|
|
4
4
|
"description": "Production-ready, multi-tenant e‑commerce UI + API adapter for Next.js with auth, carts, checkout, orders, theming, and pharmacist-focused UX.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -260,9 +260,11 @@ export function ProductCard({
|
|
|
260
260
|
</p>
|
|
261
261
|
</div>
|
|
262
262
|
|
|
263
|
-
<
|
|
264
|
-
|
|
265
|
-
|
|
263
|
+
<div className="h-[40px] mb-3">
|
|
264
|
+
<h3 className="text-sm font-['Poppins',sans-serif] font-semibold text-[#2B4B7C] line-clamp-2">
|
|
265
|
+
{displayName}
|
|
266
|
+
</h3>
|
|
267
|
+
</div>
|
|
266
268
|
{/* Rating */}
|
|
267
269
|
<div className="flex items-center gap-1.5 mb-2">
|
|
268
270
|
<div className="flex items-center gap-0.5">
|
|
@@ -5,6 +5,7 @@ import { useCart } from '@/providers/CartProvider';
|
|
|
5
5
|
import Image from 'next/image';
|
|
6
6
|
import { ProductVariantInventoryStatusEnum } from '@/lib/Apis';
|
|
7
7
|
import { useNotification } from '@/providers/NotificationProvider';
|
|
8
|
+
import Link from 'next/link';
|
|
8
9
|
|
|
9
10
|
interface QuickViewModalProps {
|
|
10
11
|
product: ExtendedProductDTO;
|
|
@@ -40,7 +41,6 @@ export function QuickViewModal({ product, onClose, onNavigateToProduct }: QuickV
|
|
|
40
41
|
|
|
41
42
|
setIsAddingToCart(true);
|
|
42
43
|
try {
|
|
43
|
-
console.log(selectedVariant)
|
|
44
44
|
await addToCart(
|
|
45
45
|
product.id,
|
|
46
46
|
quantity,
|
|
@@ -62,11 +62,11 @@ export function QuickViewModal({ product, onClose, onNavigateToProduct }: QuickV
|
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
return (
|
|
65
|
-
<div
|
|
65
|
+
<div
|
|
66
66
|
className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-xs"
|
|
67
67
|
onClick={onClose}
|
|
68
68
|
>
|
|
69
|
-
<div
|
|
69
|
+
<div
|
|
70
70
|
className="bg-white rounded-[32px] max-w-5xl w-full max-h-[90vh] overflow-y-auto"
|
|
71
71
|
onClick={(e) => e.stopPropagation()}
|
|
72
72
|
>
|
|
@@ -75,28 +75,27 @@ export function QuickViewModal({ product, onClose, onNavigateToProduct }: QuickV
|
|
|
75
75
|
<div className="flex items-start justify-between mb-6">
|
|
76
76
|
<div>
|
|
77
77
|
<p className="font-['Poppins',sans-serif] text-[11px] text-primary uppercase tracking-wide font-medium mb-2">
|
|
78
|
-
{product.brand} • {product.parentCategories[0]
|
|
78
|
+
{product.brand} • {product.parentCategories?.[0]?.name || 'Uncategorized'}
|
|
79
79
|
</p>
|
|
80
80
|
<h2 className="font-['Poppins',sans-serif] font-semibold text-secondary tracking-[-1px]">
|
|
81
81
|
{displayName}
|
|
82
82
|
</h2>
|
|
83
|
-
|
|
83
|
+
|
|
84
84
|
{/* Rating */}
|
|
85
85
|
<div className="flex items-center gap-2 mt-2">
|
|
86
86
|
<div className="flex items-center gap-0.5">
|
|
87
87
|
{[...Array(5)].map((_, i) => (
|
|
88
88
|
<Star
|
|
89
89
|
key={i}
|
|
90
|
-
className={`size-4 ${
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}`}
|
|
90
|
+
className={`size-4 ${i < Math.floor(product.rating ? product.rating : 0)
|
|
91
|
+
? 'text-accent fill-accent'
|
|
92
|
+
: 'text-gray-300'
|
|
93
|
+
}`}
|
|
95
94
|
/>
|
|
96
95
|
))}
|
|
97
96
|
</div>
|
|
98
97
|
<span className="font-['Poppins',sans-serif] text-[13px] text-muted">
|
|
99
|
-
{product.rating} ({product.reviews? product.reviews.length : 0} reviews)
|
|
98
|
+
{product.rating} ({product.reviews ? product.reviews.length : 0} reviews)
|
|
100
99
|
</span>
|
|
101
100
|
</div>
|
|
102
101
|
</div>
|
|
@@ -115,7 +114,7 @@ export function QuickViewModal({ product, onClose, onNavigateToProduct }: QuickV
|
|
|
115
114
|
<img
|
|
116
115
|
src={selectedVariant.productMedia[selectedImageIndex]?.file || selectedVariant.productMedia[0]?.file}
|
|
117
116
|
alt={product.name}
|
|
118
|
-
className="w-full h-full object-
|
|
117
|
+
className="w-full h-full object-contain"
|
|
119
118
|
/>
|
|
120
119
|
{/* Badges */}
|
|
121
120
|
<div className="absolute top-4 left-4 flex flex-col gap-2">
|
|
@@ -140,15 +139,15 @@ export function QuickViewModal({ product, onClose, onNavigateToProduct }: QuickV
|
|
|
140
139
|
{selectedVariant.productMedia.length > 1 && (
|
|
141
140
|
<div className="grid grid-cols-4 gap-3">
|
|
142
141
|
{selectedVariant.productMedia.map((image: any, index: any) => (
|
|
143
|
-
<div
|
|
144
|
-
key={index}
|
|
142
|
+
<div
|
|
143
|
+
key={index}
|
|
145
144
|
className={`aspect-square rounded-xl overflow-hidden cursor-pointer transition-opacity ${selectedImageIndex === index ? 'ring-2 ring-primary' : 'bg-gray-50 hover:opacity-75'}`}
|
|
146
145
|
onClick={() => setSelectedImageIndex(index)}
|
|
147
146
|
>
|
|
148
|
-
<img
|
|
149
|
-
src={image.file}
|
|
150
|
-
alt={`${product.name} ${index + 1}`}
|
|
151
|
-
className="w-full h-full object-
|
|
147
|
+
<img
|
|
148
|
+
src={image.file}
|
|
149
|
+
alt={`${product.name} ${index + 1}`}
|
|
150
|
+
className="w-full h-full object-contain"
|
|
152
151
|
/>
|
|
153
152
|
</div>
|
|
154
153
|
))}
|
|
@@ -190,9 +189,10 @@ export function QuickViewModal({ product, onClose, onNavigateToProduct }: QuickV
|
|
|
190
189
|
</div>
|
|
191
190
|
|
|
192
191
|
{/* Description */}
|
|
193
|
-
<
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
<div
|
|
193
|
+
className="font-['Poppins',sans-serif] text-[14px] text-muted leading-[1.7] mb-6 max-w-full overflow-hidden break-words"
|
|
194
|
+
dangerouslySetInnerHTML={{ __html: product.description }}
|
|
195
|
+
/>
|
|
196
196
|
|
|
197
197
|
{/* Color Selection */}
|
|
198
198
|
<div className="mb-6">
|
|
@@ -208,21 +208,20 @@ export function QuickViewModal({ product, onClose, onNavigateToProduct }: QuickV
|
|
|
208
208
|
setSelectedSizeIndex(0);
|
|
209
209
|
setSelectedImageIndex(0); // Reset selected image index when variant changes
|
|
210
210
|
}}
|
|
211
|
-
className={`size-10 rounded-full border-2 transition-all ${
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}`}
|
|
211
|
+
className={`size-10 rounded-full border-2 transition-all ${selectedVariantIndex === index
|
|
212
|
+
? 'border-primary scale-110'
|
|
213
|
+
: 'border-gray-200 hover:border-primary/50'
|
|
214
|
+
}`}
|
|
216
215
|
style={{ backgroundColor: variant.colorHex }}
|
|
217
216
|
title={variant.color}
|
|
218
217
|
>
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
218
|
+
<Image
|
|
219
|
+
src={variant.productMedia?.[0]?.file || ''}
|
|
220
|
+
alt={variant.color || `Variant ${index + 1}`}
|
|
221
|
+
className="object-cover"
|
|
222
|
+
height={32}
|
|
223
|
+
width={32}
|
|
224
|
+
/>
|
|
226
225
|
</button>
|
|
227
226
|
))}
|
|
228
227
|
</div>
|
|
@@ -270,44 +269,44 @@ export function QuickViewModal({ product, onClose, onNavigateToProduct }: QuickV
|
|
|
270
269
|
<button
|
|
271
270
|
onClick={handleAddToCart}
|
|
272
271
|
disabled={addedToCart || selectedVariant.inventoryCount === 0}
|
|
273
|
-
className={`w-full font-['Poppins',sans-serif] font-medium text-[14px] px-6 py-4 rounded-full transition-all duration-300 flex items-center justify-center gap-3 ${
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}`}
|
|
272
|
+
className={`w-full font-['Poppins',sans-serif] font-medium text-[14px] px-6 py-4 rounded-full transition-all duration-300 flex items-center justify-center gap-3 ${addedToCart
|
|
273
|
+
? 'bg-green-500 text-white'
|
|
274
|
+
: 'bg-accent text-white hover:bg-[#d66f45] hover:shadow-lg disabled:opacity-50 disabled:cursor-not-allowed'
|
|
275
|
+
}`}
|
|
278
276
|
>
|
|
279
277
|
{isAddingToCart ? (
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
</>
|
|
297
|
-
)
|
|
298
|
-
}
|
|
299
|
-
</button>
|
|
278
|
+
<>
|
|
279
|
+
<svg className="animate-spin h-5 w-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" aria-hidden="true">
|
|
280
|
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
|
|
281
|
+
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
282
|
+
</svg>
|
|
283
|
+
Loading...
|
|
284
|
+
</>
|
|
285
|
+
) : (
|
|
286
|
+
<>
|
|
287
|
+
<ShoppingCart className="h-4 w-4" />
|
|
288
|
+
{!selectedVariant
|
|
289
|
+
? 'Select a variant'
|
|
290
|
+
: selectedVariant.inventoryStatus === ProductVariantInventoryStatusEnum.OUTOFSTOCK
|
|
291
|
+
? 'Out of Stock'
|
|
292
|
+
: 'Add to Cart'}
|
|
300
293
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
onNavigateToProduct?.(product.id);
|
|
305
|
-
}}
|
|
306
|
-
className="w-full font-['Poppins',sans-serif] font-medium text-[13px] px-6 py-3 rounded-full bg-white text-secondary border-2 border-primary hover:bg-gray-50 transition-all flex items-center justify-center gap-2"
|
|
307
|
-
>
|
|
308
|
-
View Full Details
|
|
309
|
-
<ExternalLink className="size-4" />
|
|
294
|
+
</>
|
|
295
|
+
)
|
|
296
|
+
}
|
|
310
297
|
</button>
|
|
298
|
+
<Link href={`/products/${product._id}`}>
|
|
299
|
+
<button
|
|
300
|
+
onClick={() => {
|
|
301
|
+
onClose();
|
|
302
|
+
// onNavigateToProduct?.(product._id || product.id);
|
|
303
|
+
}}
|
|
304
|
+
className="w-full font-['Poppins',sans-serif] font-medium text-[13px] px-6 py-3 rounded-full bg-white text-secondary border-2 border-primary hover:bg-gray-50 transition-all flex items-center justify-center gap-2"
|
|
305
|
+
>
|
|
306
|
+
View Full Details
|
|
307
|
+
<ExternalLink className="size-4" />
|
|
308
|
+
</button>
|
|
309
|
+
</Link>
|
|
311
310
|
</div>
|
|
312
311
|
</div>
|
|
313
312
|
</div>
|
package/src/hooks/useOrders.ts
CHANGED
package/src/hooks/useProducts.ts
CHANGED
|
@@ -49,12 +49,12 @@ export function useProducts(filters?: ProductFilters, page: number = 1, limit: n
|
|
|
49
49
|
page
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
|
-
setProducts(response.data.data
|
|
52
|
+
setProducts(response.data.data);
|
|
53
53
|
setPagination({
|
|
54
54
|
page: response.data.currentPage || page,
|
|
55
55
|
limit: response.data.limit || limit,
|
|
56
|
-
total:
|
|
57
|
-
totalPages:
|
|
56
|
+
total: products.length, // Use filtered count
|
|
57
|
+
totalPages: Math.ceil(products.length / limit),
|
|
58
58
|
});
|
|
59
59
|
} catch (err) {
|
|
60
60
|
setError(err as Error);
|
|
@@ -874,72 +874,6 @@ export const ProductsApiAxiosParamCreator = function (configuration?: Configurat
|
|
|
874
874
|
options: localVarRequestOptions,
|
|
875
875
|
};
|
|
876
876
|
},
|
|
877
|
-
/**
|
|
878
|
-
*
|
|
879
|
-
* @summary Set or unset a product as featured for home screen
|
|
880
|
-
* @param {string} id Product ID
|
|
881
|
-
* @param {boolean} featured Whether to set the product as featured
|
|
882
|
-
* @param {*} [options] Override http request option.
|
|
883
|
-
* @throws {RequiredError}
|
|
884
|
-
*/
|
|
885
|
-
setFeaturedProduct: async (id: string, featured: boolean, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
|
886
|
-
// verify required parameter 'id' is not null or undefined
|
|
887
|
-
if (id === null || id === undefined) {
|
|
888
|
-
throw new RequiredError('id','Required parameter id was null or undefined when calling setFeaturedProduct.');
|
|
889
|
-
}
|
|
890
|
-
// verify required parameter 'featured' is not null or undefined
|
|
891
|
-
if (featured === null || featured === undefined) {
|
|
892
|
-
throw new RequiredError('featured','Required parameter featured was null or undefined when calling setFeaturedProduct.');
|
|
893
|
-
}
|
|
894
|
-
const localVarPath = `/products/{id}/featured`
|
|
895
|
-
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
|
|
896
|
-
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
897
|
-
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
|
|
898
|
-
let baseOptions;
|
|
899
|
-
if (configuration) {
|
|
900
|
-
baseOptions = configuration.baseOptions;
|
|
901
|
-
}
|
|
902
|
-
const localVarRequestOptions :AxiosRequestConfig = { method: 'PATCH', ...baseOptions, ...options};
|
|
903
|
-
const localVarHeaderParameter = {} as any;
|
|
904
|
-
const localVarQueryParameter = {} as any;
|
|
905
|
-
|
|
906
|
-
// authentication bearer required
|
|
907
|
-
// http bearer authentication required
|
|
908
|
-
if (configuration && configuration.accessToken) {
|
|
909
|
-
const accessToken = typeof configuration.accessToken === 'function'
|
|
910
|
-
? await configuration.accessToken()
|
|
911
|
-
: await configuration.accessToken;
|
|
912
|
-
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
// authentication x-store-key required
|
|
916
|
-
if (configuration && configuration.apiKey) {
|
|
917
|
-
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
|
918
|
-
? await configuration.apiKey("x-store-key")
|
|
919
|
-
: await configuration.apiKey;
|
|
920
|
-
localVarHeaderParameter["x-store-key"] = localVarApiKeyValue;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
if (featured !== undefined) {
|
|
924
|
-
localVarQueryParameter['featured'] = featured;
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
const query = new URLSearchParams(localVarUrlObj.search);
|
|
928
|
-
for (const key in localVarQueryParameter) {
|
|
929
|
-
query.set(key, localVarQueryParameter[key]);
|
|
930
|
-
}
|
|
931
|
-
for (const key in options.params) {
|
|
932
|
-
query.set(key, options.params[key]);
|
|
933
|
-
}
|
|
934
|
-
localVarUrlObj.search = (new URLSearchParams(query)).toString();
|
|
935
|
-
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
936
|
-
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
|
937
|
-
|
|
938
|
-
return {
|
|
939
|
-
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
|
|
940
|
-
options: localVarRequestOptions,
|
|
941
|
-
};
|
|
942
|
-
},
|
|
943
877
|
/**
|
|
944
878
|
*
|
|
945
879
|
* @summary Update a product
|
|
@@ -1215,21 +1149,6 @@ export const ProductsApiFp = function(configuration?: Configuration) {
|
|
|
1215
1149
|
return axios.request(axiosRequestArgs);
|
|
1216
1150
|
};
|
|
1217
1151
|
},
|
|
1218
|
-
/**
|
|
1219
|
-
*
|
|
1220
|
-
* @summary Set or unset a product as featured for home screen
|
|
1221
|
-
* @param {string} id Product ID
|
|
1222
|
-
* @param {boolean} featured Whether to set the product as featured
|
|
1223
|
-
* @param {*} [options] Override http request option.
|
|
1224
|
-
* @throws {RequiredError}
|
|
1225
|
-
*/
|
|
1226
|
-
async setFeaturedProduct(id: string, featured: boolean, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<ExtendedProductDTO>>> {
|
|
1227
|
-
const localVarAxiosArgs = await ProductsApiAxiosParamCreator(configuration).setFeaturedProduct(id, featured, options);
|
|
1228
|
-
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
|
1229
|
-
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
|
1230
|
-
return axios.request(axiosRequestArgs);
|
|
1231
|
-
};
|
|
1232
|
-
},
|
|
1233
1152
|
/**
|
|
1234
1153
|
*
|
|
1235
1154
|
* @summary Update a product
|
|
@@ -1406,17 +1325,6 @@ export const ProductsApiFactory = function (configuration?: Configuration, baseP
|
|
|
1406
1325
|
async getTopSellingProducts(limit?: number, page?: number, isActive?: boolean, includeNoVariantProducts?: boolean, options?: AxiosRequestConfig): Promise<AxiosResponse<PaginatedProductsDto>> {
|
|
1407
1326
|
return ProductsApiFp(configuration).getTopSellingProducts(limit, page, isActive, includeNoVariantProducts, options).then((request) => request(axios, basePath));
|
|
1408
1327
|
},
|
|
1409
|
-
/**
|
|
1410
|
-
*
|
|
1411
|
-
* @summary Set or unset a product as featured for home screen
|
|
1412
|
-
* @param {string} id Product ID
|
|
1413
|
-
* @param {boolean} featured Whether to set the product as featured
|
|
1414
|
-
* @param {*} [options] Override http request option.
|
|
1415
|
-
* @throws {RequiredError}
|
|
1416
|
-
*/
|
|
1417
|
-
async setFeaturedProduct(id: string, featured: boolean, options?: AxiosRequestConfig): Promise<AxiosResponse<ExtendedProductDTO>> {
|
|
1418
|
-
return ProductsApiFp(configuration).setFeaturedProduct(id, featured, options).then((request) => request(axios, basePath));
|
|
1419
|
-
},
|
|
1420
1328
|
/**
|
|
1421
1329
|
*
|
|
1422
1330
|
* @summary Update a product
|
|
@@ -1602,18 +1510,6 @@ export class ProductsApi extends BaseAPI {
|
|
|
1602
1510
|
public async getTopSellingProducts(limit?: number, page?: number, isActive?: boolean, includeNoVariantProducts?: boolean, options?: AxiosRequestConfig) : Promise<AxiosResponse<PaginatedProductsDto>> {
|
|
1603
1511
|
return ProductsApiFp(this.configuration).getTopSellingProducts(limit, page, isActive, includeNoVariantProducts, options).then((request) => request(this.axios, this.basePath));
|
|
1604
1512
|
}
|
|
1605
|
-
/**
|
|
1606
|
-
*
|
|
1607
|
-
* @summary Set or unset a product as featured for home screen
|
|
1608
|
-
* @param {string} id Product ID
|
|
1609
|
-
* @param {boolean} featured Whether to set the product as featured
|
|
1610
|
-
* @param {*} [options] Override http request option.
|
|
1611
|
-
* @throws {RequiredError}
|
|
1612
|
-
* @memberof ProductsApi
|
|
1613
|
-
*/
|
|
1614
|
-
public async setFeaturedProduct(id: string, featured: boolean, options?: AxiosRequestConfig) : Promise<AxiosResponse<ExtendedProductDTO>> {
|
|
1615
|
-
return ProductsApiFp(this.configuration).setFeaturedProduct(id, featured, options).then((request) => request(this.axios, this.basePath));
|
|
1616
|
-
}
|
|
1617
1513
|
/**
|
|
1618
1514
|
*
|
|
1619
1515
|
* @summary Update a product
|
|
@@ -148,7 +148,6 @@ export function CartProvider({ children }: CartProviderProps) {
|
|
|
148
148
|
_id: oldCart.cartBody._id,
|
|
149
149
|
items: simplifiedItems
|
|
150
150
|
};
|
|
151
|
-
console.log("payload", payload);
|
|
152
151
|
const response = await new CartApi(getApiConfiguration()).handleUserCart(payload as any);
|
|
153
152
|
|
|
154
153
|
if (response.data) {
|
|
@@ -185,9 +184,7 @@ export function CartProvider({ children }: CartProviderProps) {
|
|
|
185
184
|
});
|
|
186
185
|
|
|
187
186
|
try {
|
|
188
|
-
console.log('Removing item with productVariantId:', productId);
|
|
189
187
|
const itemsToKeep = currentCart.cartBody.items.filter(item => String(item.productVariantId) !== String(productId));
|
|
190
|
-
console.log('Items to keep count:', itemsToKeep.length);
|
|
191
188
|
|
|
192
189
|
const simplifiedItems = itemsToKeep.map(item => ({
|
|
193
190
|
_id: item._id,
|
|
@@ -196,7 +193,6 @@ export function CartProvider({ children }: CartProviderProps) {
|
|
|
196
193
|
}));
|
|
197
194
|
|
|
198
195
|
if (simplifiedItems.length === 0) {
|
|
199
|
-
console.log('Cart will be empty, calling clearCart');
|
|
200
196
|
await new CartApi(getApiConfiguration()).clearCart();
|
|
201
197
|
setCart(null);
|
|
202
198
|
} else {
|
|
@@ -204,9 +200,7 @@ export function CartProvider({ children }: CartProviderProps) {
|
|
|
204
200
|
_id: currentCart.cartBody._id,
|
|
205
201
|
items: simplifiedItems
|
|
206
202
|
};
|
|
207
|
-
console.log("Remove from cart payload:", JSON.stringify(payload, null, 2));
|
|
208
203
|
const response = await new CartApi(getApiConfiguration()).handleUserCart(payload as any);
|
|
209
|
-
console.log("Remove from cart response:", response.status, response.data);
|
|
210
204
|
if (response.data) {
|
|
211
205
|
setCart(response.data);
|
|
212
206
|
}
|
|
@@ -15,7 +15,7 @@ import { useNotification } from '@/providers/NotificationProvider';
|
|
|
15
15
|
export default function NewAddressPage() {
|
|
16
16
|
const router = useRouter();
|
|
17
17
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
18
|
-
|
|
18
|
+
const notification = useNotification();
|
|
19
19
|
|
|
20
20
|
const {
|
|
21
21
|
register,
|
|
@@ -31,7 +31,6 @@ export default function NewAddressPage() {
|
|
|
31
31
|
const onSubmit = async (data: AddressFormData) => {
|
|
32
32
|
setIsSubmitting(true);
|
|
33
33
|
try {
|
|
34
|
-
console.log('Submitting address data:', data);
|
|
35
34
|
const api = new AddressesApi(AXIOS_CONFIG);
|
|
36
35
|
const response = await api.createAddressForUser({
|
|
37
36
|
name: data.name,
|
|
@@ -45,8 +44,8 @@ export default function NewAddressPage() {
|
|
|
45
44
|
});
|
|
46
45
|
|
|
47
46
|
notification.success(
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
'Address added',
|
|
48
|
+
'Your new address has been saved to your account.'
|
|
50
49
|
);
|
|
51
50
|
router.back();
|
|
52
51
|
|
|
@@ -71,17 +70,17 @@ export default function NewAddressPage() {
|
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
notification.error(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
'Unable to save address',
|
|
74
|
+
errorMessage,
|
|
75
|
+
5000
|
|
77
76
|
);
|
|
78
77
|
|
|
79
78
|
// Show additional guidance for certain error types
|
|
80
79
|
if (error.response?.status === 422) {
|
|
81
80
|
notification.info(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
'Address validation failed',
|
|
82
|
+
'Make sure your address is complete and formatted correctly.',
|
|
83
|
+
6000
|
|
85
84
|
);
|
|
86
85
|
}
|
|
87
86
|
} finally {
|
|
@@ -78,9 +78,6 @@ export function ProductDetailScreen({ productId }: ProductDetailScreenProps) {
|
|
|
78
78
|
}, [selectedVariant]);
|
|
79
79
|
|
|
80
80
|
const product = useMemo(() => {
|
|
81
|
-
console.log('productData', productData);
|
|
82
|
-
console.log('selectedVariant', selectedVariant);
|
|
83
|
-
console.log('initialProductData', initialProductData);
|
|
84
81
|
if (initialProductData && !productData) {
|
|
85
82
|
return initialProductData;
|
|
86
83
|
}
|
|
@@ -450,7 +447,7 @@ export function ProductDetailScreen({ productId }: ProductDetailScreenProps) {
|
|
|
450
447
|
{/* Category Path */}
|
|
451
448
|
<div className="mb-4">
|
|
452
449
|
<p className="font-['Poppins',sans-serif] text-[12px] text-primary uppercase tracking-wide font-medium mb-2">
|
|
453
|
-
{product.brand} • {product.parentCategories?.[0]
|
|
450
|
+
{product.brand} • {product.parentCategories?.[0]?.name || 'Uncategorized'}
|
|
454
451
|
</p>
|
|
455
452
|
<h1 className="text-3xl font-['Poppins',sans-serif] font-semibold text-secondary tracking-[-1.5px] mb-3">
|
|
456
453
|
{selectedVariant?.name || product.name}
|
|
@@ -528,9 +525,10 @@ export function ProductDetailScreen({ productId }: ProductDetailScreenProps) {
|
|
|
528
525
|
|
|
529
526
|
{/* Description */}
|
|
530
527
|
{product.description && (
|
|
531
|
-
<
|
|
532
|
-
|
|
533
|
-
|
|
528
|
+
<div
|
|
529
|
+
className="font-['Poppins',sans-serif] text-[14px] text-muted leading-[1.7] mb-8 max-w-full overflow-hidden break-words"
|
|
530
|
+
dangerouslySetInnerHTML={{ __html: product.description }}
|
|
531
|
+
/>
|
|
534
532
|
)}
|
|
535
533
|
|
|
536
534
|
{/* Variant Selector with Images */}
|
|
@@ -738,10 +736,10 @@ export function ProductDetailScreen({ productId }: ProductDetailScreenProps) {
|
|
|
738
736
|
<h3 className="font-['Poppins',sans-serif] font-semibold text-secondary mb-4">
|
|
739
737
|
Product Description
|
|
740
738
|
</h3>
|
|
741
|
-
<
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
739
|
+
<div
|
|
740
|
+
className="font-['Poppins',sans-serif] text-[14px] text-muted leading-[1.8] mb-4 max-w-full overflow-hidden break-words"
|
|
741
|
+
dangerouslySetInnerHTML={{ __html: product.description }}
|
|
742
|
+
/>
|
|
745
743
|
|
|
746
744
|
<div className="mt-6">
|
|
747
745
|
<h4 className="font-['Poppins',sans-serif] font-semibold text-[13px] text-secondary mb-3">
|
|
@@ -15,8 +15,8 @@ import { useRouter } from 'next/navigation';
|
|
|
15
15
|
import { useBasePath } from '@/providers/BasePathProvider';
|
|
16
16
|
|
|
17
17
|
export default function SearchPage() {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const router = useRouter();
|
|
19
|
+
const { buildPath } = useBasePath();
|
|
20
20
|
const searchParams = useSearchParams();
|
|
21
21
|
const searchQuery = searchParams.get('q') || '';
|
|
22
22
|
const [products, setProducts] = useState<ExtendedProductDTO[]>([]);
|
|
@@ -35,7 +35,6 @@ export default function SearchPage() {
|
|
|
35
35
|
|
|
36
36
|
try {
|
|
37
37
|
setIsLoading(true);
|
|
38
|
-
console.log(searchQuery);
|
|
39
38
|
const api = new ProductsApi(AXIOS_CONFIG);
|
|
40
39
|
const response = await api.getAllProductsForStore(
|
|
41
40
|
searchQuery,
|