@riosst100/pwa-marketplace 3.2.9 → 3.3.1
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/package.json +1 -1
- package/src/components/AgeVerification/ageVerification.js +121 -0
- package/src/components/AgeVerification/index.js +1 -2
- package/src/components/AgeVerificationModal/ageVerificationModal.js +83 -0
- package/src/components/{AgeVerification → AgeVerificationModal}/ageVerificationModal.module.css +77 -10
- package/src/components/AgeVerificationModal/index.js +2 -0
- package/src/components/LiveChat/MessagesModal.js +3 -3
- package/src/components/Messages/messages.js +90 -117
- package/src/components/Messages/messages.module.css +15 -0
- package/src/components/RFQ/modalRfq.js +90 -18
- package/src/components/RFQPage/quoteDetail.js +47 -30
- package/src/components/ShowMore/showMore.js +8 -5
- package/src/intercept.js +9 -0
- package/src/overwrites/peregrine/lib/talons/RootComponents/Category/useCategory.js +0 -4
- package/src/overwrites/venia-ui/lib/RootComponents/Category/category.js +2 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +1 -1
- package/src/overwrites/venia-ui/lib/RootComponents/Product/product.js +2 -0
- package/src/overwrites/venia-ui/lib/components/Adapter/adapter.js +0 -23
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/productFullDetail.js +9 -4
- package/src/talons/AgeVerification/ageVerification.gql.js +31 -0
- package/src/talons/AgeVerification/useAgeVerification.js +126 -0
- package/src/talons/MessagesPage/messagesPage.gql.js +4 -0
- package/src/talons/RFQ/rfq.gql.js +8 -0
- package/src/talons/RFQ/useRFQ.js +31 -6
- package/src/talons/Seller/useSeller.js +4 -1
- package/src/components/AgeVerification/ageVerificationModal.js +0 -163
- package/src/components/AgeVerification/sellerCoupon.js +0 -119
- package/src/components/AgeVerification/sellerCouponCheckout.js +0 -164
- /package/src/components/{AgeVerification → AgeVerificationModal}/ageVerificationModal.shimmer.js +0 -0
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import listClasses from '@riosst100/pwa-marketplace/src/components/AgeVerification/sellerCoupon.module.css';
|
|
4
|
-
import modalClasses from '@riosst100/pwa-marketplace/src/components/AgeVerification/sellerCouponCheckout.module.css';
|
|
5
|
-
import { SellerCouponCheckoutShimmer } from '@riosst100/pwa-marketplace/src/components/SellerCoupon';
|
|
6
|
-
|
|
7
|
-
// Reuse day diff logic
|
|
8
|
-
const dayDiff = (toDate) => {
|
|
9
|
-
if (!toDate) return null;
|
|
10
|
-
const end = new Date(toDate);
|
|
11
|
-
if (Number.isNaN(end.getTime())) return null;
|
|
12
|
-
const now = new Date();
|
|
13
|
-
const diffMs = end.setHours(23, 59, 59, 999) - now.getTime();
|
|
14
|
-
const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24));
|
|
15
|
-
return diffDays;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// Simple portal root fallback
|
|
19
|
-
const getPortalRoot = () => {
|
|
20
|
-
let root = document.getElementById('seller-coupon-portal');
|
|
21
|
-
if (!root) {
|
|
22
|
-
root = document.createElement('div');
|
|
23
|
-
root.id = 'seller-coupon-portal';
|
|
24
|
-
document.body.appendChild(root);
|
|
25
|
-
}
|
|
26
|
-
return root;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const SellerCouponCheckout = ({
|
|
30
|
-
couponData,
|
|
31
|
-
couponError,
|
|
32
|
-
setCouponModalOpen,
|
|
33
|
-
couponModalOpen,
|
|
34
|
-
couponLoading,
|
|
35
|
-
isCopyAction,
|
|
36
|
-
triggerLabel = 'View Seller Coupons',
|
|
37
|
-
onSelectCoupon,
|
|
38
|
-
onTriggerRender, // optional custom trigger renderer
|
|
39
|
-
autoOpen = false, // auto open modal when mounted
|
|
40
|
-
closeOnClaim = true // close after claiming
|
|
41
|
-
}) => {
|
|
42
|
-
// const [open, setOpen] = useState(false);
|
|
43
|
-
const [copied, setCopied] = useState(null);
|
|
44
|
-
|
|
45
|
-
const items = couponData?.sellerCoupons?.items || [];
|
|
46
|
-
|
|
47
|
-
const handleOpen = () => setCouponModalOpen(true);
|
|
48
|
-
const handleClose = () => setCouponModalOpen(false);
|
|
49
|
-
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
if (!couponModalOpen) return;
|
|
52
|
-
const onKey = (e) => {
|
|
53
|
-
if (e.key === 'Escape') {
|
|
54
|
-
handleClose();
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
document.addEventListener('keydown', onKey);
|
|
58
|
-
return () => document.removeEventListener('keydown', onKey);
|
|
59
|
-
}, [couponModalOpen]);
|
|
60
|
-
|
|
61
|
-
const handleClaim = async (item) => {
|
|
62
|
-
try {
|
|
63
|
-
if (navigator?.clipboard?.writeText) {
|
|
64
|
-
await navigator.clipboard.writeText(item.code);
|
|
65
|
-
}
|
|
66
|
-
} catch (_) {
|
|
67
|
-
/* ignore */
|
|
68
|
-
}
|
|
69
|
-
console.log('item.code',item.code)
|
|
70
|
-
setCopied(item.code);
|
|
71
|
-
setTimeout(() => setCopied(null), 2000);
|
|
72
|
-
if (!isCopyAction) {
|
|
73
|
-
if (onSelectCoupon) onSelectCoupon(item);
|
|
74
|
-
if (closeOnClaim) handleClose();
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// Auto open behavior
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
if (autoOpen && !couponModalOpen) {
|
|
81
|
-
setCouponModalOpen(true);
|
|
82
|
-
}
|
|
83
|
-
}, [autoOpen, couponModalOpen]);
|
|
84
|
-
|
|
85
|
-
console.log('copied',copied)
|
|
86
|
-
|
|
87
|
-
const modal = couponModalOpen ? (
|
|
88
|
-
<div className={modalClasses.overlay} role="dialog" aria-modal="true" aria-label="Seller coupons list">
|
|
89
|
-
<div className={modalClasses.backdrop} onClick={handleClose} />
|
|
90
|
-
<div className={modalClasses.dialog}>
|
|
91
|
-
<div className={modalClasses.header}>
|
|
92
|
-
<h2 className={modalClasses.title}>{isCopyAction ? 'Store Coupons' : 'Apply Coupon'}</h2>
|
|
93
|
-
<button type="button" className={modalClasses.closeBtn} onClick={handleClose} aria-label="Close coupon modal">×</button>
|
|
94
|
-
</div>
|
|
95
|
-
<div className={modalClasses.body}>
|
|
96
|
-
{couponLoading && <SellerCouponCheckoutShimmer />}
|
|
97
|
-
{!couponLoading && couponError && <p className={listClasses.metaText}>Failed to load coupons.</p>}
|
|
98
|
-
{!couponLoading && !couponError && !items.length && <p className={listClasses.metaText}>No coupons available.</p>}
|
|
99
|
-
{!couponLoading && !couponError && items.length > 0 && (
|
|
100
|
-
<div className={modalClasses.stack}>
|
|
101
|
-
{items.map(item => {
|
|
102
|
-
const key = item.couponcode_id || item.coupon_id || item.code;
|
|
103
|
-
const daysLeft = dayDiff(item.to_date);
|
|
104
|
-
const expiryLabel = daysLeft === null
|
|
105
|
-
? 'No expiry'
|
|
106
|
-
: daysLeft <= 0
|
|
107
|
-
? 'Ends today'
|
|
108
|
-
: `Ends in ${daysLeft} day${daysLeft > 1 ? 's' : ''}`;
|
|
109
|
-
const title = item.description || item.name || `Discount ${item.discount_amount || ''}`;
|
|
110
|
-
return (
|
|
111
|
-
<div key={key} className={listClasses.card} role="group" aria-label={`Coupon ${item.code}`}>
|
|
112
|
-
<div className={listClasses.perf} aria-hidden="true" />
|
|
113
|
-
<div className={listClasses.content}>
|
|
114
|
-
<div className={listClasses.title}>{title}</div>
|
|
115
|
-
<div className={listClasses.subtext}>Code: <span className={listClasses.code}>{item.code}</span></div>
|
|
116
|
-
<div className={listClasses.expiry}>{expiryLabel}</div>
|
|
117
|
-
</div>
|
|
118
|
-
<div className={listClasses.divider} aria-hidden="true" />
|
|
119
|
-
<div className={listClasses.actions}>
|
|
120
|
-
{isCopyAction ? <button
|
|
121
|
-
type="button"
|
|
122
|
-
className={copied === item.code ? listClasses.claimedBtn : listClasses.claimBtn}
|
|
123
|
-
onClick={() => handleClaim(item)}
|
|
124
|
-
aria-label={`Claim coupon ${item.code}`}
|
|
125
|
-
>
|
|
126
|
-
{copied === item.code ? 'Copied' : 'Claim'}
|
|
127
|
-
</button> :
|
|
128
|
-
<button
|
|
129
|
-
type="button"
|
|
130
|
-
className={copied === item.code ? listClasses.claimedBtn : listClasses.claimBtn}
|
|
131
|
-
onClick={() => handleClaim(item)}
|
|
132
|
-
aria-label={`Apply coupon ${item.code}`}
|
|
133
|
-
>
|
|
134
|
-
{copied === item.code ? 'Applied' : 'Apply'}
|
|
135
|
-
</button>}
|
|
136
|
-
</div>
|
|
137
|
-
</div>
|
|
138
|
-
);
|
|
139
|
-
})}
|
|
140
|
-
</div>
|
|
141
|
-
)}
|
|
142
|
-
</div>
|
|
143
|
-
</div>
|
|
144
|
-
</div>
|
|
145
|
-
) : null;
|
|
146
|
-
|
|
147
|
-
const trigger = onTriggerRender
|
|
148
|
-
? onTriggerRender({ couponModalOpen, setCouponModalOpen, handleOpen })
|
|
149
|
-
: (
|
|
150
|
-
<button
|
|
151
|
-
type="button"
|
|
152
|
-
className={modalClasses.triggerBtn}
|
|
153
|
-
onClick={handleOpen}
|
|
154
|
-
aria-haspopup="dialog"
|
|
155
|
-
aria-expanded={couponModalOpen}
|
|
156
|
-
>
|
|
157
|
-
{triggerLabel}
|
|
158
|
-
</button>
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
return <>{onTriggerRender ? trigger : trigger}{couponModalOpen ? ReactDOM.createPortal(modal, getPortalRoot()) : null}</>;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
export default SellerCouponCheckout;
|
/package/src/components/{AgeVerification → AgeVerificationModal}/ageVerificationModal.shimmer.js
RENAMED
|
File without changes
|