hey-pharmacist-ecommerce 1.1.30 → 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.
- package/dist/index.d.mts +1451 -1303
- package/dist/index.d.ts +1451 -1303
- package/dist/index.js +10502 -5728
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7817 -3059
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
- package/src/components/AccountReviewsTab.tsx +97 -0
- package/src/components/CouponCodeInput.tsx +190 -0
- package/src/components/Header.tsx +5 -1
- package/src/components/Notification.tsx +1 -1
- package/src/components/NotificationBell.tsx +33 -0
- package/src/components/NotificationCard.tsx +211 -0
- package/src/components/NotificationDrawer.tsx +195 -0
- package/src/components/OrderCard.tsx +164 -99
- package/src/components/ProductReviewsSection.tsx +30 -0
- package/src/components/RatingDistribution.tsx +86 -0
- package/src/components/ReviewCard.tsx +59 -0
- package/src/components/ReviewForm.tsx +207 -0
- package/src/components/ReviewPromptBanner.tsx +98 -0
- package/src/components/ReviewsList.tsx +151 -0
- package/src/components/StarRating.tsx +98 -0
- package/src/hooks/useDiscounts.ts +7 -0
- package/src/hooks/useOrders.ts +15 -0
- package/src/hooks/useReviews.ts +230 -0
- package/src/index.ts +25 -0
- package/src/lib/Apis/apis/discounts-api.ts +23 -72
- package/src/lib/Apis/apis/notifications-api.ts +196 -231
- package/src/lib/Apis/apis/products-api.ts +84 -0
- package/src/lib/Apis/apis/review-api.ts +283 -4
- package/src/lib/Apis/apis/stores-api.ts +180 -0
- package/src/lib/Apis/models/bulk-channel-toggle-dto.ts +52 -0
- package/src/lib/Apis/models/cart-body-populated.ts +3 -3
- package/src/lib/Apis/models/channel-settings-dto.ts +39 -0
- package/src/lib/Apis/models/{discount-paginated-response.ts → completed-order-dto.ts} +21 -16
- package/src/lib/Apis/models/create-discount-dto.ts +31 -92
- package/src/lib/Apis/models/create-review-dto.ts +4 -4
- package/src/lib/Apis/models/create-shippo-account-dto.ts +45 -0
- package/src/lib/Apis/models/create-store-dto.ts +6 -0
- package/src/lib/Apis/models/discount.ts +37 -98
- package/src/lib/Apis/models/discounts-insights-dto.ts +12 -0
- package/src/lib/Apis/models/index.ts +13 -7
- package/src/lib/Apis/models/{manual-discount.ts → manual-discount-dto.ts} +10 -10
- package/src/lib/Apis/models/manual-order-dto.ts +3 -3
- package/src/lib/Apis/models/populated-discount.ts +41 -101
- package/src/lib/Apis/models/preference-update-item.ts +59 -0
- package/src/lib/Apis/models/product-light-dto.ts +40 -0
- package/src/lib/Apis/models/{check-notifications-response-dto.ts → review-status-dto.ts} +8 -7
- package/src/lib/Apis/models/review.ts +9 -3
- package/src/lib/Apis/models/reviewable-order-dto.ts +58 -0
- package/src/lib/Apis/models/reviewable-product-dto.ts +81 -0
- package/src/lib/Apis/models/shippo-account-response-dto.ts +51 -0
- package/src/lib/Apis/models/store-entity.ts +6 -0
- package/src/lib/Apis/models/store.ts +6 -0
- package/src/lib/Apis/models/update-discount-dto.ts +31 -92
- package/src/lib/Apis/models/update-notification-settings-dto.ts +28 -0
- package/src/lib/Apis/models/update-review-dto.ts +4 -4
- package/src/lib/Apis/models/update-store-dto.ts +6 -0
- package/src/lib/Apis/models/{pick-type-class.ts → variant-light-dto.ts} +20 -14
- package/src/lib/utils/discount.ts +155 -0
- package/src/lib/validations/discount.ts +11 -0
- package/src/providers/CartProvider.tsx +2 -2
- package/src/providers/DiscountProvider.tsx +97 -0
- package/src/providers/EcommerceProvider.tsx +13 -5
- package/src/providers/NotificationCenterProvider.tsx +436 -0
- package/src/screens/CartScreen.tsx +1 -1
- package/src/screens/CheckoutScreen.tsx +39 -12
- package/src/screens/NotificationSettingsScreen.tsx +413 -0
- package/src/screens/OrderDetailScreen.tsx +283 -0
- package/src/screens/OrderReviewsScreen.tsx +308 -0
- package/src/screens/OrdersScreen.tsx +31 -7
- package/src/screens/ProductDetailScreen.tsx +24 -11
- package/src/screens/ProfileScreen.tsx +5 -0
- package/src/lib/Apis/models/create-notification-dto.ts +0 -75
- package/src/lib/Apis/models/notification.ts +0 -93
- 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(
|
|
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
|
-
{
|
|
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
|
-
<
|
|
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':
|
|
@@ -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
|
-
}
|