@riosst100/pwa-marketplace 2.9.5 → 2.9.7

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.
@@ -1,318 +1,184 @@
1
+
1
2
  import React from 'react';
2
3
  import { arrayOf, number, shape, string } from 'prop-types';
3
- import { ChevronDown, ChevronUp } from 'react-feather';
4
4
  import { FormattedMessage, useIntl } from 'react-intl';
5
5
  import Price from '@magento/venia-ui/lib/components/Price';
6
- import { useOrderRow } from '@magento/peregrine/lib/talons/OrderHistoryPage/useOrderRow';
7
-
8
6
  import { useStyle } from '@magento/venia-ui/lib/classify';
9
- import Icon from '@magento/venia-ui/lib/components/Icon';
10
- import CollapsedImageGallery from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/OrderHistoryPage/collapsedImageGallery';
11
- import OrderDetails from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/OrderHistoryPage/OrderDetails';
12
- import defaultClasses from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/OrderHistoryPage/orderRow.module.css';
13
7
  import cn from 'classnames';
14
- import { Verify } from 'iconsax-react';
8
+ import { Shop } from 'iconsax-react';
15
9
  import PlaceholderImage from '@magento/venia-ui/lib/components/Image/placeholderImage';
16
10
  import { Link } from 'react-router-dom';
11
+ import defaultClasses from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/OrderHistoryPage/orderRow.module.css';
17
12
 
18
- const OrderRow = props => {
19
- const { order } = props;
13
+ const RmaRow = props => {
14
+ const { rma } = props;
20
15
  const { formatMessage } = useIntl();
21
16
  const {
22
- invoices,
17
+ created_at,
18
+ increment_id,
19
+ order_increment_id,
23
20
  items,
24
- number: orderNumber,
25
- order_date: orderDate,
26
- shipments,
21
+ order,
22
+ rma_date,
23
+ rma_id,
24
+ seller,
27
25
  status,
28
- total
29
- } = order;
30
- const { grand_total: grandTotal } = total;
31
- const { currency, value: orderTotal } = grandTotal;
32
-
33
- // Convert date to ISO-8601 format so Safari can also parse it
34
- const isoFormattedDate = orderDate.replace(' ', 'T');
35
- const formattedDate = new Date(isoFormattedDate).toLocaleDateString(
26
+ status_label,
27
+ rmaDetailLoading,
28
+ rmaDetailError,
29
+ rmaDetailData
30
+ } = rma;
31
+ const classes = useStyle(defaultClasses, props.classes);
32
+ // Format date
33
+ const isoFormattedDate = created_at ? created_at.replace(' ', 'T') : '';
34
+ const formattedDate = isoFormattedDate ? new Date(isoFormattedDate).toLocaleDateString(
36
35
  undefined,
37
36
  {
38
37
  year: 'numeric',
39
38
  month: 'short',
40
39
  day: 'numeric'
41
40
  }
42
- );
43
-
44
- const hasInvoice = !!invoices.length;
45
- const hasShipment = !!shipments.length;
46
- let derivedStatus;
47
- if (status === 'Complete') {
48
- derivedStatus = formatMessage({
49
- id: 'Quotes.deliveredText',
50
- defaultMessage: 'Delivered'
51
- });
52
- } else if (hasShipment) {
53
- derivedStatus = formatMessage({
54
- id: 'Quotes.shippedText',
55
- defaultMessage: 'Shipped'
56
- });
57
- } else if (hasInvoice) {
58
- derivedStatus = formatMessage({
59
- id: 'Quotes.readyToShipText',
60
- defaultMessage: 'Ready to ship'
61
- });
62
- } else {
63
- derivedStatus = formatMessage({
64
- id: 'Quotes.new',
65
- defaultMessage: 'New'
66
- });
41
+ ) : '';
42
+
43
+ // Seller name: prefer from first item's seller_name, fallback to seller?.name
44
+ let sellerName = '-';
45
+ if (items && items.length > 0 && items[0].seller_name) {
46
+ sellerName = items[0].seller_name;
47
+ } else if (seller?.name) {
48
+ sellerName = seller.name;
67
49
  }
68
50
 
69
- const talonProps = useOrderRow({ items });
70
- const { loading, isOpen, imagesData } = talonProps;
71
-
72
- const classes = useStyle(defaultClasses, props.classes);
73
-
74
- const contentClass = isOpen ? classes.content : classes.content_collapsed;
75
-
76
- const contentToggleIconSrc = isOpen ? ChevronUp : ChevronDown;
77
-
78
- const contentToggleIcon = <Icon src={contentToggleIconSrc} size={24} />;
79
-
80
- const collapsedImageGalleryElement = isOpen ? null : (
81
- <CollapsedImageGallery items={imagesData} />
82
- );
83
-
84
- const orderDetails = loading ? null : (
85
- <OrderDetails orderData={order} imagesData={imagesData} />
86
- );
87
-
88
- const orderTotalPrice =
89
- currency && orderTotal !== null ? (
90
- <Price currencyCode={currency} value={orderTotal} />
91
- ) : (
92
- '-'
93
- );
94
51
 
95
52
  const badgeStatusStyle = () => {
96
- return 'bg-[#F1EFF6] text-blue-700 text-[14px] font-semibold rounded-full px-[30px] py-[5px] border-none';
53
+ return 'text-blue-700 text-[14px] font-medium py-[5px] border-none';
97
54
  }
98
55
 
99
- const thumbnailProps = {
100
- alt: items[0].product_name,
101
- classes: { root: classes.thumbnail },
102
- width: 50
103
- };
56
+ // Inject parent rma_id (atau increment_id) ke setiap item agar key unik
57
+ const itemsWithParentId = Array.isArray(items)
58
+ ? items.map(it => ({
59
+ ...it,
60
+ __rmaParentId: rma_id || increment_id || ''
61
+ }))
62
+ : [];
104
63
 
105
64
  return (
106
65
  <li className={classes.root}>
107
- <div className='flex flex-col md_flex-row justify-between mb-2.5'>
108
- <div className='flex flex-col'>
109
- <div className="flex gap-x-[15px] flex-row">
110
- <span className="text-[14px] text-colorDefault">{formattedDate}</span>
111
- <span className="text-gray-200 text-[14px]">{orderNumber}</span>
66
+ <div className='flex flex-col md_flex-row md_items-start justify-between mb-2.5'>
67
+ <div className='flex flex-col ml-[14px] mt-[5px]'>
68
+ <div className="flex gap-x-[15px] flex-col">
69
+ <div className='flex gap-x-[5px] items-center'>
70
+ <Shop size={17} className='text-blue-700' variant="Bold" />
71
+ <span className='text-[14px] font-medium text-blue-700'>
72
+ {sellerName}
73
+ </span>
74
+ <span>|</span>
75
+ <span className="text-blue-700 text-[14px]">#{increment_id}</span>
76
+ </div>
112
77
  </div>
113
78
  </div>
114
79
  <div className='flex flex-col'>
115
80
  <div className='flex w-full justify-start mt-2.5 md_mt-0 md_justify-end'>
116
81
  <span className={cn(classes.orderStatusBadge, badgeStatusStyle())}>
117
- {derivedStatus}
82
+ {status_label || status}
118
83
  </span>
119
84
  </div>
120
85
  </div>
121
86
  </div>
122
87
  <div className='flex flex-col md_flex-row justify-between mb-2.5'>
123
- <div className='flex flex-col'>
124
- <div className='flex gap-x-[5px] mb-2.5'>
125
- <Verify size={17} className='text-blue-700' variant="Bold" />
126
- <span className='text-xs font-medium text-[rgba(25, 34, 42, 0.7)]'>
127
- Gundam Info
128
- </span>
129
- </div>
88
+ <div className='flex flex-col ml-[14px]'>
130
89
  <div className='flex flex-row'>
131
- <div>
132
- <PlaceholderImage {...thumbnailProps} />
90
+ <div className={cn('mr-4 flex flex-col gap-8')}>
91
+ {itemsWithParentId.map((it, idx) => {
92
+ const thumbnailProps = {
93
+ alt: it.name,
94
+ classes: { root: classes.thumbnail },
95
+ width: 50
96
+ };
97
+ // Use unique key: parent id + item.id
98
+ return (
99
+ <div key={`${it.__rmaParentId}-${it.id || idx}`} className={classes.productImage}>
100
+ {it.image_url ? (
101
+ <img src={it.image_url} alt={it.name} width={70} className={classes.thumbnail} />
102
+ ) : (
103
+ <PlaceholderImage {...thumbnailProps} />
104
+ )}
105
+ </div>
106
+ );
107
+ })}
133
108
  </div>
134
- <div className='flex flex-col max-w-[260px] gap-2.5'>
135
- <div className={cn(classes.productName, 'text-[14] font-medium')}>
136
- <span>
137
- {items[0]?.product_name}
138
- </span>
139
- </div>
140
- <div className="text-[14] text-gray-200">
141
- <span>
142
- {`${items[0]?.quantity_ordered}X`}
143
- </span>
144
- {' '}
145
- <span>
146
- <Price currencyCode={items[0]?.product_sale_price?.currency} value={items[0]?.product_sale_price?.value} />
147
- </span>
148
- </div>
109
+ <div className='flex flex-col max-w-[375px] gap-8'>
110
+ {itemsWithParentId.map((it, idx) => {
111
+ const qty = Number.isFinite(it.qty_requested) ? it.qty_requested : '-';
112
+ return (
113
+ <div key={`${it.__rmaParentId}-${it.id || idx}`} className='flex flex-col gap-1 pb-2 last_pb-0'>
114
+ <div className={cn(classes.productName, 'text-[14] font-medium')}>
115
+ <span>{it.name}</span>
116
+ </div>
117
+ <div className="text-[14] text-gray-300">
118
+ <span>Qty Requested : {qty}</span>
119
+ <br />
120
+ <span>
121
+ Price : {it.price ? <Price currencyCode={it.price.currency} value={it.price.value} /> : '-'}
122
+ </span>
123
+ </div>
124
+ </div>
125
+ );
126
+ })}
149
127
  </div>
150
128
  </div>
151
129
  </div>
152
- <div className='flex flex-col'>
153
- <div className="md_px-10 py-3 md_border-l border-gray-100">
154
- <span className="text-[14] text-gray-200 text-left md_text-center block mb-2">
130
+ {/* Right column: bottom-aligned RMA Date + CTA */}
131
+ <div className='flex flex-col items-end gap-2 md_pl-10 md_self-end mr-4 mb-1'>
132
+ <Link
133
+ to={{
134
+ pathname: `/return/view/${rma_id}`,
135
+ state: { rma }
136
+ }}
137
+ >
138
+ <span className="bg-blue-700 hover:bg-white hover:text-blue-700 hover:border hover:border-blue-700 rounded-full px-[30px] py-[5px] text-[13px] font-medium text-white transition-all duration-300 ease-in-out">
155
139
  <FormattedMessage
156
- id={'orderRow.orderTotalText'}
157
- defaultMessage={'Order Total'}
140
+ id={'rmaRow.ViewTransactionDetail'}
141
+ defaultMessage={'View RMA Detail'}
158
142
  />
159
143
  </span>
160
- <div className="text-lg font-semibold text-left md_text-center block">{orderTotalPrice}</div>
161
- </div>
144
+ </Link>
162
145
  </div>
163
146
  </div>
164
- <div className='flex flex-row justify-end py-[5px]'>
165
- <Link to="/return/view/DEV123123123">
166
- <span className="text-[13px] font-medium text-blue-700 underline">
167
- <FormattedMessage
168
- id={'orderRow.ViewTransactionDetail'}
169
- defaultMessage={'View Transaction Detail'}
170
- />
171
- </span>
172
- </Link>
173
- </div>
174
-
175
- {/* <div className={classes.orderDateContainer}>
176
- <span className={classes.orderDateLabel}>
177
- <FormattedMessage
178
- id={'orderRow.orderDateText'}
179
- defaultMessage={'Order Date'}
180
- />
181
- </span>
182
- <span className={classes.orderDate}>{formattedDate}</span>
183
- </div> */}
184
- {/* <div className={classes.orderItemsContainer}>
185
- {collapsedImageGalleryElement}
186
- </div> */}
187
- {/* <div className={classes.orderStatusContainer}>
188
- <span className={classes.orderStatusBadge}>
189
- {derivedStatus}
190
- </span>
191
- <OrderProgressBar status={derivedStatus} />
192
- </div> */}
193
- <div className={cn(contentClass, '!py-4 mt-4')}>{orderDetails}</div>
194
147
  </li>
195
148
  );
196
149
  };
197
150
 
198
- export default OrderRow;
199
-
200
- OrderRow.propTypes = {
201
- classes: shape({
202
- root: string,
203
- cell: string,
204
- stackedCell: string,
205
- label: string,
206
- value: string,
207
- orderNumberContainer: string,
208
- orderDateContainer: string,
209
- orderTotalContainer: string,
210
- orderStatusContainer: string,
211
- orderItemsContainer: string,
212
- contentToggleContainer: string,
213
- orderNumberLabel: string,
214
- orderDateLabel: string,
215
- orderTotalLabel: string,
216
- orderNumber: string,
217
- orderDate: string,
218
- orderTotal: string,
219
- orderStatusBadge: string,
220
- content: string,
221
- content_collapsed: string
222
- }),
223
- order: shape({
224
- billing_address: shape({
225
- city: string,
226
- country_code: string,
227
- firstname: string,
228
- lastname: string,
229
- postcode: string,
230
- region_id: string,
231
- street: arrayOf(string)
232
- }),
151
+ RmaRow.propTypes = {
152
+ rma: shape({
153
+ created_at: string,
154
+ increment_id: string,
233
155
  items: arrayOf(
234
156
  shape({
235
157
  id: string,
236
- product_name: string,
237
- product_sale_price: shape({
158
+ name: string,
159
+ price: shape({
238
160
  currency: string,
239
161
  value: number
240
162
  }),
241
- product_sku: string,
242
- selected_options: arrayOf(
243
- shape({
244
- label: string,
245
- value: string
246
- })
247
- ),
248
- quantity_ordered: number
249
- })
250
- ),
251
- invoices: arrayOf(
252
- shape({
253
- id: string
163
+ qty_requested: number
254
164
  })
255
165
  ),
256
- number: string,
257
- order_date: string,
258
- payment_methods: arrayOf(
259
- shape({
260
- type: string,
261
- additional_data: arrayOf(
262
- shape({
263
- name: string,
264
- value: string
265
- })
266
- )
267
- })
268
- ),
269
- shipping_address: shape({
270
- city: string,
271
- country_code: string,
272
- firstname: string,
273
- lastname: string,
274
- postcode: string,
275
- region_id: string,
276
- street: arrayOf(string),
277
- telephone: string
166
+ order: shape({
167
+ id: string,
168
+ increment_id: string,
169
+ status: string,
170
+ status_label: string
171
+ }),
172
+ rma_date: string,
173
+ rma_id: string,
174
+ seller: shape({
175
+ id: string,
176
+ name: string,
177
+ url: string
278
178
  }),
279
- shipping_method: string,
280
- shipments: arrayOf(
281
- shape({
282
- id: string,
283
- tracking: arrayOf(
284
- shape({
285
- number: string
286
- })
287
- )
288
- })
289
- ),
290
179
  status: string,
291
- total: shape({
292
- discounts: arrayOf(
293
- shape({
294
- amount: shape({
295
- currency: string,
296
- value: number
297
- })
298
- })
299
- ),
300
- grand_total: shape({
301
- currency: string,
302
- value: number
303
- }),
304
- subtotal: shape({
305
- currency: string,
306
- value: number
307
- }),
308
- total_tax: shape({
309
- currency: string,
310
- value: number
311
- }),
312
- total_shipping: shape({
313
- currency: string,
314
- value: number
315
- })
316
- })
180
+ status_label: string
317
181
  })
318
182
  };
183
+
184
+ export default RmaRow;
@@ -5,19 +5,23 @@ const Select = (props) => {
5
5
  const {
6
6
  wrapperClassname,
7
7
  className,
8
- options = []
8
+ options = [],
9
+ value,
10
+ onChange
9
11
  } = props;
10
12
 
11
13
  return (
12
14
  <div className={cx('flex', wrapperClassname)}>
13
15
  <select
14
16
  className={cx('border rounded-md border-gray-100 p-2 focus-visible_outline-none', className)}
17
+ value={value}
18
+ onChange={onChange}
15
19
  >
16
20
  <option value=''>
17
21
  Choose Option
18
22
  </option>
19
23
  {options.map((item) => (
20
- <option value={item.value}>
24
+ <option key={item.value} value={item.value}>
21
25
  {item.label}
22
26
  </option>
23
27
  ))}
@@ -0,0 +1,45 @@
1
+ import { gql } from '@apollo/client';
2
+
3
+ export const GET_PAYMENT_METHODS = gql`
4
+ query getPaymentMethods($cartId: String!) {
5
+ cart(cart_id: $cartId) {
6
+ id
7
+ available_payment_methods {
8
+ code
9
+ title
10
+ }
11
+ selected_payment_method {
12
+ code
13
+ }
14
+ }
15
+ }
16
+ `;
17
+
18
+ export const SET_PAYMENT_METHOD_ON_CART = gql`
19
+ mutation setPaymentMethodOnCart(
20
+ $cartId: String!
21
+ $paymentMethod: PaymentMethodInput!
22
+ ) {
23
+ setPaymentMethodOnCart(
24
+ input: { cart_id: $cartId, payment_method: $paymentMethod }
25
+ ) {
26
+ cart {
27
+ id
28
+ payment_fees {
29
+ title
30
+ value
31
+ currency
32
+ }
33
+ selected_payment_method {
34
+ code
35
+ title
36
+ }
37
+ }
38
+ }
39
+ }
40
+ `;
41
+
42
+ export default {
43
+ getPaymentMethodsQuery: GET_PAYMENT_METHODS,
44
+ setPaymentMethodOnCartMutation: SET_PAYMENT_METHOD_ON_CART
45
+ };
@@ -20,6 +20,7 @@ const CustomerOrdersFragment = gql`
20
20
  }
21
21
  items {
22
22
  id
23
+ product_image_url
23
24
  product_name
24
25
  product_sale_price {
25
26
  currency
@@ -0,0 +1,46 @@
1
+ import { gql } from '@apollo/client';
2
+
3
+ // Align fields closely with core to ensure compatibility, while keeping extra image fields safe to use.
4
+ const GET_PRODUCT_THUMBNAILS = gql`
5
+ query getProductThumbnails($urlKeys: [String!]!) {
6
+ products(filter: { url_key: { in: $urlKeys } }) {
7
+ items {
8
+ uid
9
+ sku
10
+ name
11
+ url_key
12
+ thumbnail {
13
+ label
14
+ url
15
+ }
16
+ small_image { url }
17
+ media_gallery { url label }
18
+ ... on ConfigurableProduct {
19
+ variants {
20
+ product {
21
+ sku
22
+ uid
23
+ name
24
+ thumbnail { label url }
25
+ small_image { url }
26
+ }
27
+ }
28
+ }
29
+ }
30
+ }
31
+ }
32
+ `;
33
+
34
+ const GET_CONFIGURABLE_THUMBNAIL_SOURCE = gql`
35
+ query getConfigurableThumbnailSource {
36
+ storeConfig {
37
+ store_code
38
+ configurable_thumbnail_source
39
+ }
40
+ }
41
+ `;
42
+
43
+ export default {
44
+ getProductThumbnailsQuery: GET_PRODUCT_THUMBNAILS,
45
+ getConfigurableThumbnailSource: GET_CONFIGURABLE_THUMBNAIL_SOURCE
46
+ };