@riosst100/pwa-marketplace 3.0.0 → 3.0.3

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 (55) hide show
  1. package/i18n/en_US.json +1 -1
  2. package/i18n/id_ID.json +1 -1
  3. package/package.json +1 -1
  4. package/src/componentOverrideMapping.js +2 -0
  5. package/src/components/CheckoutHeader/checkoutHeader.js +162 -0
  6. package/src/components/CheckoutHeader/checkoutHeader.module.css +171 -0
  7. package/src/components/CheckoutHeader/index.js +1 -0
  8. package/src/components/FavoriteSeller/AddToListButton/addToListButton.module.css +2 -2
  9. package/src/components/FilterTop/FilterBlockList/filterTopItem.module.css +2 -0
  10. package/src/components/OrderDetail/components/itemsOrdered.js +6 -1
  11. package/src/components/RMAPage/components/productItem.css +15 -0
  12. package/src/components/RMAPage/components/productItem.js +43 -13
  13. package/src/components/RMAPage/components/productItem.module.css +15 -0
  14. package/src/components/SellerCoupon/index.js +1 -0
  15. package/src/components/SellerCoupon/sellerCoupon.js +84 -0
  16. package/src/components/SellerCoupon/sellerCoupon.module.css +110 -0
  17. package/src/components/SellerCoupon/sellerCouponCheckout.js +147 -0
  18. package/src/components/SellerCoupon/sellerCouponCheckout.module.css +85 -0
  19. package/src/components/SellerDetail/sellerDetail.js +10 -2
  20. package/src/components/SellerProducts/sellerProducts.js +4 -2
  21. package/src/overwrites/peregrine/lib/talons/CartPage/PriceSummary/usePriceSummary.js +10 -1
  22. package/src/overwrites/peregrine/lib/talons/CartPage/useCartPage.js +121 -0
  23. package/src/overwrites/peregrine/lib/talons/CheckoutPage/checkoutPage.extended.gql.js +17 -1
  24. package/src/overwrites/peregrine/lib/talons/Header/useCartTrigger.js +82 -0
  25. package/src/overwrites/peregrine/lib/talons/ProductFullDetail/useProductFullDetail.js +17 -1
  26. package/src/overwrites/venia-ui/lib/components/Breadcrumbs/breadcrumbs.js +11 -11
  27. package/src/overwrites/venia-ui/lib/components/CartPage/PriceSummary/priceSummary.js +24 -6
  28. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListing/productListing.js +6 -2
  29. package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/productListingBySeller.js +3 -1
  30. package/src/overwrites/venia-ui/lib/components/CartPage/cartPage.js +20 -4
  31. package/src/overwrites/venia-ui/lib/components/CheckoutPage/OrderSummary/orderSummary.js +1 -1
  32. package/src/overwrites/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.js +1 -1
  33. package/src/overwrites/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentMethods.js +1 -1
  34. package/src/overwrites/venia-ui/lib/components/CheckoutPage/PriceAdjustments/priceAdjustments.js +74 -6
  35. package/src/overwrites/venia-ui/lib/components/CheckoutPage/ShippingInformation/shippingInformation.js +3 -3
  36. package/src/overwrites/venia-ui/lib/components/CheckoutPage/checkoutPage.js +53 -2
  37. package/src/overwrites/venia-ui/lib/components/CheckoutPage/checkoutPage.module.css +1 -1
  38. package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterItemRadio.js +1 -2
  39. package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterItemRadioGroup.js +10 -27
  40. package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/subFilterItemRadioGroup.js +1 -1
  41. package/src/overwrites/venia-ui/lib/components/Footer/footer.js +14 -4
  42. package/src/overwrites/venia-ui/lib/components/Footer/footer.module.css +16 -4
  43. package/src/overwrites/venia-ui/lib/components/Gallery/item.js +9 -8
  44. package/src/overwrites/venia-ui/lib/components/Header/accountTrigger.js +3 -3
  45. package/src/overwrites/venia-ui/lib/components/Header/cartTrigger.js +9 -6
  46. package/src/overwrites/venia-ui/lib/components/Header/cartTrigger.module.css +1 -1
  47. package/src/overwrites/venia-ui/lib/components/Header/header.js +2 -0
  48. package/src/overwrites/venia-ui/lib/components/Header/wishlistTrigger.js +4 -4
  49. package/src/overwrites/venia-ui/lib/components/Main/main.js +9 -4
  50. package/src/overwrites/venia-ui/lib/components/Main/main.module.css +2 -2
  51. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/productFullDetail.js +100 -72
  52. package/src/overwrites/venia-ui/lib/components/ToastContainer/toast.module.css +3 -3
  53. package/src/talons/Header/useCartTrigger.js +82 -0
  54. package/src/talons/Seller/seller.gql.js +42 -1
  55. package/src/talons/Seller/useSeller.js +25 -2
package/i18n/en_US.json CHANGED
@@ -63,7 +63,7 @@
63
63
  "checkoutPage.additionalText": "You will also receive an email with the details and we will let you know when your order has shipped.",
64
64
  "checkoutPage.billingAddressSame": "Billing address same as shipping address",
65
65
  "checkoutPage.checkout": "Checkout",
66
- "checkoutPage.couponCode": "Enter Coupon Code",
66
+ "checkoutPage.couponCode": "Apply Coupon Code",
67
67
  "checkoutPage.createAccount": "Create Account",
68
68
  "checkoutPage.editPaymentInformation": "Edit Payment Information",
69
69
  "checkoutPage.editShippingInfo": "Edit Shipping Information",
package/i18n/id_ID.json CHANGED
@@ -64,7 +64,7 @@
64
64
  "checkoutPage.additionalText": "You will also receive an email with the details and we will let you know when your order has shipped.",
65
65
  "checkoutPage.billingAddressSame": "Billing address same as shipping address",
66
66
  "checkoutPage.checkout": "Checkout",
67
- "checkoutPage.couponCode": "Enter Coupon Code",
67
+ "checkoutPage.couponCode": "Apply Coupon Code",
68
68
  "checkoutPage.createAccount": "Create Account",
69
69
  "checkoutPage.editPaymentInformation": "Edit Payment Information",
70
70
  "checkoutPage.editShippingInfo": "Edit Shipping Information",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@riosst100/pwa-marketplace",
3
3
  "author": "riosst100@gmail.com",
4
- "version": "3.0.0",
4
+ "version": "3.0.3",
5
5
  "main": "src/index.js",
6
6
  "pwa-studio": {
7
7
  "targets": {
@@ -1,4 +1,6 @@
1
1
  module.exports = componentOverrideMapping = {
2
+ ['@magento/peregrine/lib/talons/Header/useCartTrigger.js']: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/Header/useCartTrigger.js',
3
+ ['@magento/peregrine/lib/talons/CartPage/useCartPage.js']: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/CartPage/useCartPage.js',
2
4
  [`@magento/venia-ui/lib/components/CartPage/PriceSummary/priceSummary.js`]: '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/CartPage/PriceSummary/priceSummary.js',
3
5
  [`@magento/peregrine/lib/talons/CartPage/PriceSummary/priceSummaryFragments.gql.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/CartPage/PriceSummary/priceSummaryFragments.gql.js',
4
6
  [`@magento/venia-ui/lib/components/Adapter/adapter.js`]: '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/Adapter/adapter.js',
@@ -0,0 +1,162 @@
1
+ import React, { Fragment, Suspense } from 'react';
2
+ import { shape, string } from 'prop-types';
3
+ import { Link, Route } from 'react-router-dom';
4
+ import Icon from '@magento/venia-ui/lib/components/Icon';
5
+
6
+ import AccountTrigger from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/Header/accountTrigger';
7
+
8
+ import CartTrigger from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/Header/cartTrigger';
9
+ import { Lock } from 'react-feather';
10
+ import WishlistTrigger from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/Header/wishlistTrigger';
11
+ import NavTrigger from '@magento/venia-ui/lib/components/Header/navTrigger';
12
+ import SearchTrigger from '@magento/venia-ui/lib/components/Header/searchTrigger';
13
+ import OnlineIndicator from '@magento/venia-ui/lib/components/Header/onlineIndicator';
14
+ import { useHeader } from '@magento/peregrine/lib/talons/Header/useHeader';
15
+ import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
16
+
17
+ import { useStyle } from '@magento/venia-ui/lib/classify';
18
+ import defaultClasses from './checkoutHeader.module.css';
19
+ import StoreSwitcher from '@magento/venia-ui/lib/components/Header/storeSwitcher';
20
+ import WebsiteSwitcher from '@riosst100/pwa-marketplace/src/components/WebsiteSwitcher/websiteSwitcher';
21
+ // import CurrencySwitcher from '@magento/venia-ui/lib/components/Header/currencySwitcher';
22
+ import CurrencySwitcher from '@riosst100/pwa-marketplace/src/components/CurrencySwitcher';
23
+ import BecomeSellerLink from '@riosst100/pwa-marketplace/src/components/BecomeSellerLink/becomeSellerLink';
24
+ import MegaMenu from '@magento/venia-ui/lib/components/MegaMenu';
25
+ import PageLoadingIndicator from '@magento/venia-ui/lib/components/PageLoadingIndicator';
26
+ import { useIntl } from 'react-intl';
27
+ import cn from 'classnames';
28
+ // const SearchBar = React.lazy(() => import('@magento/venia-ui/lib/components/SearchBar'));
29
+ const SearchBar = React.lazy(() => import('@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/SearchBar'));
30
+ import { SearchNormal } from 'iconsax-react';
31
+
32
+ import { useLogo } from '@riosst100/pwa-marketplace/src/talons/Header/useLogo';
33
+ import Image from '@magento/venia-ui/lib/components/Image';
34
+
35
+ const CheckoutHeader = props => {
36
+ const {
37
+ handleSearchTriggerClick,
38
+ hasBeenOffline,
39
+ isOnline,
40
+ isSearchOpen,
41
+ searchRef,
42
+ searchTriggerRef
43
+ } = useHeader();
44
+
45
+ const talonPropsLogo = useLogo();
46
+ const { data } = talonPropsLogo
47
+ const baseUrl = data?.storeConfig?.base_media_url;
48
+ const imageSource = data?.storeConfig?.header_logo_src;
49
+ const LogoImageSource = `${baseUrl}/logo/${imageSource}`;
50
+ const IMAGE_HEIGHT = data?.storeConfig?.logo_width || 28;
51
+ const IMAGE_WIDTH = data?.storeConfig?.logo_height || 190;
52
+ const IMAGE_ALT = data?.storeConfig?.logo_alt || 'TCG Collective';
53
+
54
+ const classes = useStyle(defaultClasses, props.classes);
55
+ const rootClass = isSearchOpen ? classes.open : classes.closed;
56
+
57
+ const searchBarFallback = (
58
+ <div className={classes.searchFallback} ref={searchRef}>
59
+ <div className={classes.input}>
60
+ <div className={classes.loader}>
61
+ <div className={classes.loaderBefore} />
62
+ <div className={classes.loaderAfter} />
63
+ </div>
64
+ </div>
65
+ </div>
66
+ );
67
+ // const searchBar = isSearchOpen ? (
68
+ // <Suspense fallback={searchBarFallback}>
69
+ // <Route>
70
+ // <SearchBar isOpen={true} ref={searchRef} />
71
+ // </Route>
72
+ // </Suspense>
73
+ // ) : null;
74
+
75
+ const { formatMessage } = useIntl();
76
+ const title = formatMessage({ id: 'logo.title', defaultMessage: 'Venia' });
77
+
78
+ return (
79
+ <Fragment>
80
+ <PageLoadingIndicator absolute />
81
+ <header className={cn(rootClass, '!flex flex-col !px-0 border-gray-100 ')} data-cy="Header-root">
82
+ <div className={cn('middle-header border-b border-gray-100')}>
83
+ <div className={cn('w-full max-w-[1000px] px-[0px] py-[15px] mx-[auto] flex justify-between items-center')}>
84
+ <div className='flex items-center'>
85
+ <NavTrigger />
86
+
87
+ <Link
88
+ aria-label={title}
89
+ to={resourceUrl('/')}
90
+ className={''}
91
+ data-cy="Header-logoContainer"
92
+ >
93
+ {imageSource ? (
94
+ <Image
95
+ alt={IMAGE_ALT}
96
+ height={IMAGE_HEIGHT}
97
+ src={LogoImageSource}
98
+ width={IMAGE_WIDTH}
99
+ classes={{
100
+ container: 'logo-wrapper relative'
101
+ }}
102
+ />
103
+ ) : (
104
+ <>
105
+ <div className='text-[14px]'><b>TCG Collective</b></div>
106
+ <small>Bringing Collectors Together</small>
107
+ </>
108
+ )}
109
+
110
+ </Link>
111
+ </div>
112
+ <div className='flex flex-auto max-w-[700px]'>
113
+ <div className='flex w-full' style={{
114
+ "alignItems": "center",
115
+ "fontSize": "14px",
116
+ "fontWeight": "500",
117
+ "justifyContent": "center"
118
+ }}>
119
+ <Icon src={Lock} attrs={{ width: 16 }} /><span style={{
120
+ "paddingLeft": "5px"
121
+ }}>Secure Checkout</span>
122
+ </div>
123
+ </div>
124
+ <div className={cn(classes.secondaryActions, 'lg_gap-x-5 pl-5')}>
125
+ {/* <SearchTrigger
126
+ onClick={handleSearchTriggerClick}
127
+ ref={searchTriggerRef}
128
+ /> */}
129
+ <CartTrigger />
130
+ </div>
131
+ </div>
132
+ </div>
133
+ </header>
134
+ <OnlineIndicator
135
+ hasBeenOffline={hasBeenOffline}
136
+ isOnline={isOnline}
137
+ />
138
+ <style jsx="true">
139
+ {`
140
+ .logo-wrapper>img:first-child {
141
+ height: ${IMAGE_HEIGHT}px;
142
+ }
143
+ `}
144
+ </style>
145
+ </Fragment>
146
+ );
147
+ };
148
+
149
+ CheckoutHeader.propTypes = {
150
+ classes: shape({
151
+ closed: string,
152
+ logo: string,
153
+ open: string,
154
+ primaryActions: string,
155
+ secondaryActions: string,
156
+ toolbar: string,
157
+ switchers: string,
158
+ switchersContainer: string
159
+ })
160
+ };
161
+
162
+ export default CheckoutHeader;
@@ -0,0 +1,171 @@
1
+ .root {
2
+ composes: auto-cols-fr from global;
3
+ composes: bg-header from global;
4
+ composes: border-b from global;
5
+ composes: border-subtle from global;
6
+ composes: grid from global;
7
+ composes: h-auto from global;
8
+ composes: justify-center from global;
9
+ composes: px-4 from global;
10
+ composes: top-0 from global;
11
+ composes: sticky from global;
12
+ composes: w-full from global;
13
+ composes: z-header from global;
14
+
15
+ composes: lg_px-8 from global;
16
+ }
17
+
18
+ .switchers {
19
+ composes: auto-cols-max from global;
20
+ composes: grid from global;
21
+ composes: grid-flow-col from global;
22
+ composes: justify-end from global;
23
+ /* composes: max-w-site from global; */
24
+ composes: mx-auto from global;
25
+ composes: relative from global;
26
+ composes: w-full from global;
27
+ composes: z-menu from global;
28
+ }
29
+
30
+ .switchersContainer {
31
+ composes: bg-gray-100 from global;
32
+ composes: hidden from global;
33
+ composes: px-8 from global;
34
+ composes: w-full from global;
35
+ }
36
+
37
+ /* Large screen styles */
38
+ .switchersContainer {
39
+ composes: sm_block from global;
40
+ }
41
+
42
+ .open {
43
+ composes: root;
44
+ }
45
+
46
+ .closed {
47
+ composes: root;
48
+ }
49
+
50
+ .toolbar {
51
+ composes: border-0 from global;
52
+ composes: content-center from global;
53
+ composes: gap-x-4 from global;
54
+ composes: grid from global;
55
+ composes: grid-cols-3 from global;
56
+ composes: grid-rows-header from global;
57
+ composes: h-14 from global;
58
+ composes: items-center from global;
59
+ composes: justify-self-center from global;
60
+ composes: max-w-site from global;
61
+ composes: w-full from global;
62
+ composes: z-header from global;
63
+
64
+ composes: lg_h-20 from global;
65
+ composes: lg_gap-x-8 from global;
66
+ composes: lg_grid-cols-12 from global;
67
+ }
68
+
69
+ .logo {
70
+ height: var(--height);
71
+ width: var(--width);
72
+ }
73
+
74
+ .primaryActions {
75
+ composes: col-start-1 from global;
76
+ composes: grid from global;
77
+ composes: grid-flow-col from global;
78
+ composes: justify-self-start from global;
79
+ composes: row-start-1 from global;
80
+ composes: self-center from global;
81
+ }
82
+
83
+ .logoContainer {
84
+ composes: col-start-2 from global;
85
+ composes: justify-self-center from global;
86
+
87
+ composes: lg_col-end-3 from global;
88
+ composes: lg_col-start-1 from global;
89
+ composes: lg_justify-self-start from global;
90
+ composes: lg_mr-8 from global;
91
+ composes: lg_row-start-1 from global;
92
+ }
93
+
94
+ .secondaryActions {
95
+ composes: col-start-3 from global;
96
+ composes: grid from global;
97
+ composes: grid-flow-col from global;
98
+ composes: items-center from global;
99
+ composes: justify-items-end from global;
100
+ composes: justify-self-end from global;
101
+ composes: w-max from global;
102
+
103
+ composes: lg_col-end-13 from global;
104
+ composes: lg_col-start-10 from global;
105
+ composes: lg_gap-x-4 from global;
106
+ }
107
+
108
+ .searchFallback {
109
+ composes: flex from global;
110
+ composes: justify-center from global;
111
+ composes: mb-2 from global;
112
+ composes: px-4 from global;
113
+ }
114
+
115
+ .input {
116
+ @apply max-w-sm;
117
+ }
118
+
119
+ .loader,
120
+ .loaderBefore,
121
+ .loaderAfter {
122
+ --dot-size: 2em;
123
+ --dot-font-size: 6px;
124
+ --dot-shadow-offset: calc(-1 * var(--dot-size) + var(--dot-font-size));
125
+
126
+ composes: rounded-full from global;
127
+ width: var(--dot-size);
128
+ height: var(--dot-size);
129
+ animation: pulse 1.8s infinite ease-in-out;
130
+ animation-fill-mode: both;
131
+ }
132
+
133
+ .loader {
134
+ composes: mb-0 from global;
135
+ composes: mx-auto from global;
136
+ composes: relative from global;
137
+ composes: text-subtle from global;
138
+ font-size: var(--dot-font-size);
139
+ margin-top: var(--dot-shadow-offset);
140
+ transform: translateZ(0);
141
+ animation-delay: -0.16s;
142
+ }
143
+
144
+ .loaderBefore,
145
+ .loaderAfter {
146
+ composes: content-empty from global;
147
+ composes: absolute from global;
148
+ composes: top-0 from global;
149
+ }
150
+
151
+ .loaderBefore {
152
+ composes: left-[-3.5em] from global;
153
+ composes: text-gray-100 from global;
154
+ animation-delay: -0.32s;
155
+ }
156
+
157
+ .loaderAfter {
158
+ composes: left-[3.5em] from global;
159
+ composes: text-gray-600 from global;
160
+ }
161
+
162
+ @keyframes pulse {
163
+ 0%,
164
+ 80%,
165
+ 100% {
166
+ box-shadow: 0 var(--dot-size) 0 -1.3em;
167
+ }
168
+ 40% {
169
+ box-shadow: 0 var(--dot-size) 0 0;
170
+ }
171
+ }
@@ -0,0 +1 @@
1
+ export { default } from './checkoutHeader';
@@ -26,7 +26,7 @@
26
26
  }
27
27
  .root:hover svg {
28
28
  stroke: #fff !important;
29
- fill: #fff !important;
29
+ /* fill: #fff !important; */
30
30
  }
31
31
  .root:hover span {
32
32
  color: #fff !important;
@@ -37,7 +37,7 @@
37
37
  }
38
38
  .root_selected:hover svg {
39
39
  stroke: #fff !important;
40
- fill: #fff !important;
40
+ /* fill: #fff !important; */
41
41
  }
42
42
  .root_selected:hover span {
43
43
  color: #fff !important;
@@ -10,5 +10,7 @@
10
10
  composes: text-colorDefault from global;
11
11
  composes: bg-white from global;
12
12
  composes: border-gray-100 from global;
13
+ composes: hover_shadow-type-1 from global;
14
+ composes: cursor-pointer from global;
13
15
  border-radius: 5px;
14
16
  }
@@ -11,6 +11,11 @@ const ItemsOrdered = ({ order }) => {
11
11
  const tax = order?.total?.total_tax?.value || 0;
12
12
  const grandTotal = order?.total?.grand_total?.value || 0;
13
13
 
14
+ const itemLink = useMemo(
15
+ () => resourceUrl(`/${urlKey}${urlSuffix || ''}`),
16
+ [urlKey, urlSuffix]
17
+ );
18
+
14
19
  return (
15
20
  <>
16
21
  <div className='rounded-md border border-gray-100 pb-4'>
@@ -29,7 +34,7 @@ const ItemsOrdered = ({ order }) => {
29
34
  {items.map((item, idx) => (
30
35
  <tr key={item.id || idx} className='border-b border-gray-150'>
31
36
  <td className="col name text-left align-top py-3 px-2.5" data-th="Product Name">
32
- <strong className="product name product-item-name">{item.product_name}</strong>
37
+ <Link to={itemLink} className="product name product-item-name">{item.product_name}</Link>
33
38
  {item.selected_options && item.selected_options.length > 0 && (
34
39
  <dl className="item-options">
35
40
  {item.selected_options.map((opt, i) => (
@@ -0,0 +1,15 @@
1
+ .quantityLabel {
2
+ composes: font-medium from global;
3
+ composes: leading-normal from global;
4
+ composes: mb-sm from global;
5
+ composes: pt-xs from global;
6
+ composes: text-colorDefault from global;
7
+ }
8
+
9
+ .quantityRoot {
10
+ composes: root from '@magento/venia-ui/lib/components/QuantityStepper/quantityStepper.module.css';
11
+ grid-template-columns: auto 4rem auto;
12
+ composes: justify-start from global;
13
+ composes: px-xs from global;
14
+ composes: py-0 from global;
15
+ }
@@ -4,7 +4,9 @@ import { Link } from 'react-router-dom';
4
4
  import Select from '@riosst100/pwa-marketplace/src/components/commons/Select';
5
5
  import TextField from '@riosst100/pwa-marketplace/src/components/commons/Textfield';
6
6
  import Checkbox from '@riosst100/pwa-marketplace/src/components/commons/Checkbox';
7
-
7
+ import QuantityStepper from '@magento/venia-ui/lib/components/QuantityStepper';
8
+ import defaultClasses from './productItem.module.css';
9
+ import { useStyle } from '@magento/venia-ui/lib/classify';
8
10
 
9
11
  const productItem = (props) => {
10
12
  const {
@@ -41,6 +43,8 @@ const productItem = (props) => {
41
43
  // Input change handler with qty_requested validation
42
44
  const handleFieldChange = (field, value) => {
43
45
  if (field === 'qty_requested' && item && item.quantity_ordered) {
46
+ console.log('value',value)
47
+ console.log('item.quantity_ordered',item.quantity_ordered)
44
48
  if (value > item.quantity_ordered) {
45
49
  value = item.quantity_ordered;
46
50
  }
@@ -51,6 +55,8 @@ const productItem = (props) => {
51
55
  if (onItemChange) onItemChange(field, value);
52
56
  };
53
57
 
58
+ const classes = useStyle(defaultClasses, props.classes);
59
+
54
60
  return (
55
61
  <>
56
62
  <div className='item flex flex-col lg_flex-row justify-between border border-gray-100 rounded-md p-4'>
@@ -102,23 +108,47 @@ const productItem = (props) => {
102
108
  <p className='mb-1'>
103
109
  Qty Return
104
110
  </p>
105
- <TextField
111
+ <QuantityStepper
112
+ classes={{
113
+ root: classes.quantityRoot
114
+ }}
115
+ initialValue={item.quantity_ordered}
116
+ // itemId={item.id}
117
+ />
118
+ {/* <TextField
119
+ type="number"
106
120
  value={
107
- itemState.qty_requested > item.quantity_ordered
108
- ? item.quantity_ordered
109
- : itemState.qty_requested || ''
121
+ itemState.qty_requested !== undefined
122
+ ? String(itemState.qty_requested)
123
+ : ''
110
124
  }
111
- onChange={e => {
112
- let val = parseFloat(e.target.value);
113
- if (isNaN(val)) val = '';
125
+ min={1}
126
+ max={item.quantity_ordered}
127
+ onChange={(e) => {
128
+ let val = e.target.value;
129
+
130
+ // Jika kosong
131
+ if (val === '') {
132
+ handleFieldChange('qty_requested', '');
133
+ return;
134
+ }
135
+
136
+ val = parseFloat(val);
137
+
138
+ if (isNaN(val)) {
139
+ handleFieldChange('qty_requested', '');
140
+ return;
141
+ }
142
+
143
+ // batas maksimum
114
144
  if (val > item.quantity_ordered) val = item.quantity_ordered;
115
- if (val < 1 && val !== '') val = 1;
145
+
146
+ // batas minimum
147
+ if (val < 1) val = 1;
148
+
116
149
  handleFieldChange('qty_requested', val);
117
150
  }}
118
- type="number"
119
- min={1}
120
- max={item.quantity_ordered}
121
- />
151
+ /> */}
122
152
  </div>
123
153
  <div className='flex flex-col mb-2.5'>
124
154
  <p className='mb-1'>
@@ -0,0 +1,15 @@
1
+ .quantityLabel {
2
+ composes: font-medium from global;
3
+ composes: leading-normal from global;
4
+ composes: mb-sm from global;
5
+ composes: pt-xs from global;
6
+ composes: text-colorDefault from global;
7
+ }
8
+
9
+ .quantityRoot {
10
+ composes: root from '@magento/venia-ui/lib/components/QuantityStepper/quantityStepper.module.css';
11
+ grid-template-columns: auto 4rem auto;
12
+ composes: justify-start from global;
13
+ composes: px-xs from global;
14
+ composes: py-0 from global;
15
+ }
@@ -0,0 +1 @@
1
+ export { default } from './sellerCoupon';
@@ -0,0 +1,84 @@
1
+ import React, { useMemo, useState } from 'react';
2
+ import classes from './sellerCoupon.module.css';
3
+
4
+ const dayDiff = (toDate) => {
5
+ if (!toDate) return null;
6
+ const end = new Date(toDate);
7
+ if (Number.isNaN(end.getTime())) return null;
8
+ const now = new Date();
9
+ const diffMs = end.setHours(23, 59, 59, 999) - now.getTime();
10
+ const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24));
11
+ return diffDays;
12
+ };
13
+
14
+ const SellerCoupon = ({ couponData, couponError, couponLoading }) => {
15
+ if (couponLoading) {
16
+ return <div className={classes.container}><p className={classes.metaText}>Loading coupons...</p></div>;
17
+ }
18
+
19
+ if (couponError) {
20
+ return <div className={classes.container}><p className={classes.metaText}>Failed to load coupons.</p></div>;
21
+ }
22
+
23
+ const items = couponData?.sellerCoupons?.items || [];
24
+
25
+ if (!items.length) {
26
+ return <div className={classes.container}><p className={classes.metaText}>No coupons available.</p></div>;
27
+ }
28
+
29
+ const [copied, setCopied] = useState(null);
30
+
31
+ const handleClaim = async (code) => {
32
+ try {
33
+ if (navigator?.clipboard?.writeText) {
34
+ await navigator.clipboard.writeText(code);
35
+ }
36
+ } catch (_) {
37
+ // ignore clipboard issues
38
+ }
39
+ setCopied(code);
40
+ setTimeout(() => setCopied(null), 2000);
41
+ };
42
+
43
+ return (
44
+ <section className={classes.container} aria-label="Seller coupons">
45
+ <div className={classes.scroller}>
46
+ {items.map(item => {
47
+ const key = item.couponcode_id || item.coupon_id || item.code;
48
+ const daysLeft = dayDiff(item.to_date);
49
+ const expiryLabel = daysLeft === null
50
+ ? 'No expiry'
51
+ : daysLeft <= 0
52
+ ? 'Ends today'
53
+ : `Ends in ${daysLeft} day${daysLeft > 1 ? 's' : ''}`;
54
+
55
+ const title = item.description || item.name || `Discount ${item.discount_amount || ''}`;
56
+
57
+ return (
58
+ <div className={classes.card} key={key} role="group" aria-label={`Coupon ${item.code}`}>
59
+ <div className={classes.perf} aria-hidden="true" />
60
+ <div className={classes.content}>
61
+ <div className={classes.title}>{title}</div>
62
+ <div className={classes.subtext}>Code: <span className={classes.code}>{item.code}</span></div>
63
+ <div className={classes.expiry}>{expiryLabel}</div>
64
+ </div>
65
+ <div className={classes.divider} aria-hidden="true" />
66
+ <div className={classes.actions}>
67
+ <button
68
+ type="button"
69
+ className={classes.claimBtn}
70
+ onClick={() => handleClaim(item.code)}
71
+ aria-label={`Claim coupon ${item.code}`}
72
+ >
73
+ {copied === item.code ? 'Copied' : 'Claim'}
74
+ </button>
75
+ </div>
76
+ </div>
77
+ );
78
+ })}
79
+ </div>
80
+ </section>
81
+ );
82
+ };
83
+
84
+ export default SellerCoupon;