From bac277b3ed4e1a97fe3e52374c1d102e03c5c5d7 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Fri, 2 Feb 2024 12:59:24 +0530 Subject: [PATCH 01/15] PWA-3178::Order statuses are decoupled from the back-end --- .../PriceSummary/priceSummaryFragments.gql.js | 4 --- packages/venia-ui/i18n/en_US.json | 3 +- .../OrderHistoryPage/orderProgressBar.js | 12 +++++-- .../components/OrderHistoryPage/orderRow.js | 32 +++---------------- 4 files changed, 16 insertions(+), 35 deletions(-) diff --git a/packages/peregrine/lib/talons/CartPage/PriceSummary/priceSummaryFragments.gql.js b/packages/peregrine/lib/talons/CartPage/PriceSummary/priceSummaryFragments.gql.js index f04d949562..06c7b091b1 100644 --- a/packages/peregrine/lib/talons/CartPage/PriceSummary/priceSummaryFragments.gql.js +++ b/packages/peregrine/lib/talons/CartPage/PriceSummary/priceSummaryFragments.gql.js @@ -37,12 +37,8 @@ export const PriceSummaryFragment = gql` value } } - ...GiftCardSummaryFragment - ...GiftOptionsSummaryFragment } ${DiscountSummaryFragment} - ${GiftCardSummaryFragment} - ${GiftOptionsSummaryFragment} ${GrandTotalFragment} ${ShippingSummaryFragment} ${TaxSummaryFragment} diff --git a/packages/venia-ui/i18n/en_US.json b/packages/venia-ui/i18n/en_US.json index d4bdea399e..b222396c1b 100644 --- a/packages/venia-ui/i18n/en_US.json +++ b/packages/venia-ui/i18n/en_US.json @@ -314,10 +314,11 @@ "orderHistoryPage.search": "Search by Order Number", "orderItems.itemsHeading": "Items", "orderProgressBar.deliveredText": "Delivered", - "orderProgressBar.processingText": "Processing", + "orderProgressBar.processingText": "Pending", "orderProgressBar.readyToShipText": "Ready to ship", "orderProgressBar.shippedText": "Shipped", "orderRow.deliveredText": "Delivered", + "orderProgressBar.closedText": "Closed", "orderRow.orderDateText": "Order Date", "orderRow.orderNumberText": "Order #", "orderRow.orderTotalText": "Order Total", diff --git a/packages/venia-ui/lib/components/OrderHistoryPage/orderProgressBar.js b/packages/venia-ui/lib/components/OrderHistoryPage/orderProgressBar.js index c3efbc610d..1a53a4b1b7 100644 --- a/packages/venia-ui/lib/components/OrderHistoryPage/orderProgressBar.js +++ b/packages/venia-ui/lib/components/OrderHistoryPage/orderProgressBar.js @@ -10,6 +10,7 @@ const TOTAL_STEPS = 4; const OrderProgressBar = props => { const { status } = props; const { formatMessage } = useIntl(); + console.log(status); const statusStepMap = new Map([ [ formatMessage({ @@ -38,10 +39,17 @@ const OrderProgressBar = props => { defaultMessage: 'Delivered' }), 4 - ] + ], + [ + formatMessage({ + id: 'orderProgressBar.closedText', + defaultMessage: 'Closed' + }), + 0 + ], ]); const currentStep = statusStepMap.get(status); - +console.log(currentStep); const classes = useStyle(defaultClasses, props.classes); const stepElements = useMemo(() => { diff --git a/packages/venia-ui/lib/components/OrderHistoryPage/orderRow.js b/packages/venia-ui/lib/components/OrderHistoryPage/orderRow.js index 93df587f34..0c513b3531 100644 --- a/packages/venia-ui/lib/components/OrderHistoryPage/orderRow.js +++ b/packages/venia-ui/lib/components/OrderHistoryPage/orderRow.js @@ -40,29 +40,7 @@ const OrderRow = props => { const hasInvoice = !!invoices.length; const hasShipment = !!shipments.length; - let derivedStatus; - if (status === 'Complete') { - derivedStatus = formatMessage({ - id: 'orderRow.deliveredText', - defaultMessage: 'Delivered' - }); - } else if (hasShipment) { - derivedStatus = formatMessage({ - id: 'orderRow.shippedText', - defaultMessage: 'Shipped' - }); - } else if (hasInvoice) { - derivedStatus = formatMessage({ - id: 'orderRow.readyToShipText', - defaultMessage: 'Ready to ship' - }); - } else { - derivedStatus = formatMessage({ - id: 'orderRow.processingText', - defaultMessage: 'Processing' - }); - } - + const talonProps = useOrderRow({ items }); const { loading, isOpen, handleContentToggle, imagesData } = talonProps; @@ -88,8 +66,7 @@ const OrderRow = props => { ) : ( '-' ); - - return ( +return (
  • @@ -123,9 +100,9 @@ const OrderRow = props => {
    - {derivedStatus} + {status} - +
  • `; +exports[`it renders closed status 1`] = ` +
  • +
    + +
    + + + 000000005 + +
    +
    + +
    + + + May 26, 2020 + +
    +
    + +
    + +
    + + $ + + + 1 + + + , + + + 434 + + + . + + + 00 + +
    +
    +
    +
    +
    +
    + + Shipped + +
    +
    + +
    +
    +
    +
  • +`; + exports[`it renders collapsed order row 1`] = `
  • { expect(orderProgressProps.status).toBe('Delivered'); }); +test('it renders processing status', () => { + useOrderRow.mockReturnValue({ + loading: false, + imagesData, + isOpen: false, + handleContentToggle: jest.fn() + }); + + const closedOrder = { + ...mockOrder, + status: 'Processing', + invoices: [1] + }; + const tree = createTestInstance(); + const { root } = tree; + const orderProgressProps = root.findByProps({ + componentName: 'OrderProgressBar' + }).props; + expect(tree.toJSON()).toMatchSnapshot(); +}); + test('it renders with missing order information', () => { useOrderRow.mockReturnValue({ loading: false, From fe10aa36ebadb36fec8ad1bfe633f6ed3d28cc99 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Mon, 5 Feb 2024 17:38:50 +0530 Subject: [PATCH 08/15] PWA-3178::Order statuses are decoupled from the back-end --- .../__snapshots__/orderRow.spec.js.snap | 322 ------------------ .../__tests__/orderRow.spec.js | 96 +----- 2 files changed, 5 insertions(+), 413 deletions(-) diff --git a/packages/venia-ui/lib/components/OrderHistoryPage/__tests__/__snapshots__/orderRow.spec.js.snap b/packages/venia-ui/lib/components/OrderHistoryPage/__tests__/__snapshots__/orderRow.spec.js.snap index 0f7606cf61..fb504180ff 100644 --- a/packages/venia-ui/lib/components/OrderHistoryPage/__tests__/__snapshots__/orderRow.spec.js.snap +++ b/packages/venia-ui/lib/components/OrderHistoryPage/__tests__/__snapshots__/orderRow.spec.js.snap @@ -159,328 +159,6 @@ exports[`it does not render order details if loading is true 1`] = `
  • `; -exports[`it renders closed status 1`] = ` -
  • -
    - -
    - - - 000000005 - -
    -
    - -
    - - - May 26, 2020 - -
    -
    - -
    - -
    - - $ - - - 1 - - - , - - - 434 - - - . - - - 00 - -
    -
    -
    -
    -
    -
    - - Shipped - -
    -
    - -
    -
    -
    -
  • -`; - exports[`it renders collapsed order row 1`] = `
  • { }); const orderWithInvoice = { - ...mockOrder, - invoices: [1] + ...mockOrder }; + const tree = createTestInstance(); const { root } = tree; const orderProgressProps = root.findByProps({ @@ -364,15 +278,15 @@ test('it renders processing status', () => { const closedOrder = { ...mockOrder, - status: 'Processing', - invoices: [1] + status: 'Pending', + shipments: [] }; const tree = createTestInstance(); const { root } = tree; const orderProgressProps = root.findByProps({ componentName: 'OrderProgressBar' }).props; - expect(tree.toJSON()).toMatchSnapshot(); + expect(orderProgressProps.status).toBe('Step2'); }); test('it renders with missing order information', () => { From 55b393d4649053d8f6f7c7239c9cebcdd69f8e9a Mon Sep 17 00:00:00 2001 From: glo82145 Date: Mon, 5 Feb 2024 17:51:18 +0530 Subject: [PATCH 09/15] PWA-3178::Order statuses are decoupled from the back-end --- .../__tests__/orderRow.spec.js | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/venia-ui/lib/components/OrderHistoryPage/__tests__/orderRow.spec.js b/packages/venia-ui/lib/components/OrderHistoryPage/__tests__/orderRow.spec.js index a1cde16d97..5dd685a5cb 100644 --- a/packages/venia-ui/lib/components/OrderHistoryPage/__tests__/orderRow.spec.js +++ b/packages/venia-ui/lib/components/OrderHistoryPage/__tests__/orderRow.spec.js @@ -268,7 +268,7 @@ test('it renders delivered status', () => { expect(orderProgressProps.status).toBe('Delivered'); }); -test('it renders processing status', () => { +test('it renders step2 status', () => { useOrderRow.mockReturnValue({ loading: false, imagesData, @@ -289,6 +289,28 @@ test('it renders processing status', () => { expect(orderProgressProps.status).toBe('Step2'); }); +test('it renders processing status', () => { + useOrderRow.mockReturnValue({ + loading: false, + imagesData, + isOpen: false, + handleContentToggle: jest.fn() + }); + + const closedOrder = { + ...mockOrder, + status: 'Pending', + shipments: [], + invoices: [] + }; + const tree = createTestInstance(); + const { root } = tree; + const orderProgressProps = root.findByProps({ + componentName: 'OrderProgressBar' + }).props; + expect(orderProgressProps.status).toBe('Step1'); +}); + test('it renders with missing order information', () => { useOrderRow.mockReturnValue({ loading: false, From fa7d552b7dcb25fab173a494d9feb05dd28fc3fe Mon Sep 17 00:00:00 2001 From: glo82145 Date: Mon, 5 Feb 2024 18:30:01 +0530 Subject: [PATCH 10/15] PWA-3178::Order statuses are decoupled from the back-end --- .../__tests__/useCustomerWishlistSkus.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/peregrine/lib/hooks/useCustomerWishlistSkus/__tests__/useCustomerWishlistSkus.spec.js b/packages/peregrine/lib/hooks/useCustomerWishlistSkus/__tests__/useCustomerWishlistSkus.spec.js index 5b08e766d1..e899c19d04 100644 --- a/packages/peregrine/lib/hooks/useCustomerWishlistSkus/__tests__/useCustomerWishlistSkus.spec.js +++ b/packages/peregrine/lib/hooks/useCustomerWishlistSkus/__tests__/useCustomerWishlistSkus.spec.js @@ -48,8 +48,7 @@ test('pre-caches wishlist items', async () => { expect(preCacheData).toMatchInlineSnapshot(` Object { "customerWishlistProducts": Array [ - "Dress", - "Shirt", + "Dress" ], } `); From 897f5fd28afbc1f56fad2407f8866aa0eec6f240 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Mon, 5 Feb 2024 18:44:54 +0530 Subject: [PATCH 11/15] PWA-3178::Order statuses are decoupled from the back-end --- .../__tests__/useCustomerWishlistSkus.spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/peregrine/lib/hooks/useCustomerWishlistSkus/__tests__/useCustomerWishlistSkus.spec.js b/packages/peregrine/lib/hooks/useCustomerWishlistSkus/__tests__/useCustomerWishlistSkus.spec.js index e899c19d04..5b08e766d1 100644 --- a/packages/peregrine/lib/hooks/useCustomerWishlistSkus/__tests__/useCustomerWishlistSkus.spec.js +++ b/packages/peregrine/lib/hooks/useCustomerWishlistSkus/__tests__/useCustomerWishlistSkus.spec.js @@ -48,7 +48,8 @@ test('pre-caches wishlist items', async () => { expect(preCacheData).toMatchInlineSnapshot(` Object { "customerWishlistProducts": Array [ - "Dress" + "Dress", + "Shirt", ], } `); From 556ed408a1ea4050529e7e168d9e4ac293946c66 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Fri, 15 Mar 2024 11:23:15 +0530 Subject: [PATCH 12/15] PWA-3178::Order statuses are decoupled from the back-end --- .../OrderHistoryPage/orderHistoryPage.gql.js | 1 + packages/venia-ui/i18n/en_US.json | 11 +++--- .../OrderHistoryPage/orderProgressBar.js | 37 ++++++++----------- .../components/OrderHistoryPage/orderRow.js | 36 ++---------------- 4 files changed, 26 insertions(+), 59 deletions(-) diff --git a/packages/peregrine/lib/talons/OrderHistoryPage/orderHistoryPage.gql.js b/packages/peregrine/lib/talons/OrderHistoryPage/orderHistoryPage.gql.js index 39b551e968..026a53c68d 100644 --- a/packages/peregrine/lib/talons/OrderHistoryPage/orderHistoryPage.gql.js +++ b/packages/peregrine/lib/talons/OrderHistoryPage/orderHistoryPage.gql.js @@ -60,6 +60,7 @@ const CustomerOrdersFragment = gql` } shipping_method status + state total { discounts { amount { diff --git a/packages/venia-ui/i18n/en_US.json b/packages/venia-ui/i18n/en_US.json index 33037482f2..a11aff2969 100644 --- a/packages/venia-ui/i18n/en_US.json +++ b/packages/venia-ui/i18n/en_US.json @@ -313,13 +313,14 @@ "orderHistoryPage.ordersCount": "You have {count} orders in your history", "orderHistoryPage.search": "Search by Order Number", "orderItems.itemsHeading": "Items", - "orderProgressBar.deliveredText": "Delivered", - "orderProgressBar.processingText": "Processing", - "orderProgressBar.step2Text": "Processing", - "orderProgressBar.step1Text": "Processing", + "orderProgressBar.deliveredText": "complete", + "orderProgressBar.processingText": "processing", + "orderProgressBar.newText": "new", + "orderProgressBar.pendingPaymentText": "Pending Payment", + "orderProgressBar.paymentReviewText": "Payment Review", "orderProgressBar.readyToShipText": "Ready to ship", "orderProgressBar.shippedText": "Shipped", - "orderRow.deliveredText": "Delivered", + "orderRow.deliveredText": "complete", "orderProgressBar.closedText": "Closed", "orderRow.orderDateText": "Order Date", "orderRow.orderNumberText": "Order #", diff --git a/packages/venia-ui/lib/components/OrderHistoryPage/orderProgressBar.js b/packages/venia-ui/lib/components/OrderHistoryPage/orderProgressBar.js index 3144f54a73..ce5f1d978c 100644 --- a/packages/venia-ui/lib/components/OrderHistoryPage/orderProgressBar.js +++ b/packages/venia-ui/lib/components/OrderHistoryPage/orderProgressBar.js @@ -13,29 +13,36 @@ const OrderProgressBar = props => { const statusStepMap = new Map([ [ formatMessage({ - id: 'orderProgressBar.processingText', - defaultMessage: 'Processing' + id: 'orderProgressBar.newText', + defaultMessage: 'new' }), 1 ], [ formatMessage({ - id: 'orderProgressBar.readyToShipText', - defaultMessage: 'Ready to ship' + id: 'orderProgressBar.processingText', + defaultMessage: 'Progressing' }), 2 ], [ formatMessage({ - id: 'orderProgressBar.shippedText', - defaultMessage: 'Shipped' + id: 'orderProgressBar.pendingPaymentText', + defaultMessage: 'pending_payment' + }), + 3 + ], + [ + formatMessage({ + id: 'orderProgressBar.paymentReviewText', + defaultMessage: 'payment_review' }), 3 ], [ formatMessage({ id: 'orderProgressBar.deliveredText', - defaultMessage: 'Delivered' + defaultMessage: 'complete' }), 4 ], @@ -45,24 +52,10 @@ const OrderProgressBar = props => { defaultMessage: 'Closed' }), 0 - ], - [ - formatMessage({ - id: 'orderProgressBar.step2Text', - defaultMessage: 'Step2' - }), - 2 - ], - [ - formatMessage({ - id: 'orderProgressBar.step1Text', - defaultMessage: 'Step1' - }), - 1 ] ]); - const currentStep = statusStepMap.get(status); + const currentStep = statusStepMap.get(status); const classes = useStyle(defaultClasses, props.classes); const stepElements = useMemo(() => { diff --git a/packages/venia-ui/lib/components/OrderHistoryPage/orderRow.js b/packages/venia-ui/lib/components/OrderHistoryPage/orderRow.js index cec57fc0c7..ef9f98a0a9 100644 --- a/packages/venia-ui/lib/components/OrderHistoryPage/orderRow.js +++ b/packages/venia-ui/lib/components/OrderHistoryPage/orderRow.js @@ -15,12 +15,11 @@ import defaultClasses from './orderRow.module.css'; const OrderRow = props => { const { order } = props; const { - invoices, items, number: orderNumber, order_date: orderDate, - shipments, status, + state, total } = order; const { grand_total: grandTotal } = total; @@ -38,36 +37,9 @@ const OrderRow = props => { day: 'numeric' } ); - const hasInvoice = !!invoices.length; - const hasShipment = !!shipments.length; - - if (status === 'Complete') { - derivedStatus = formatMessage({ - id: 'orderRow.deliveredText', - defaultMessage: 'Delivered' - }); - derivedProgress = 'Delivered'; - } else if (hasShipment) { - derivedStatus = formatMessage({ - id: 'orderRow.shippedText', - defaultMessage: 'Shipped' - }); - derivedProgress = 'Shipped'; - } else if ( - (status !== 'Closed' && (hasInvoice && !hasShipment)) || - (!hasInvoice && hasShipment) - ) { - derivedProgress = 'Step2'; - } else if (status === 'Pending') { - derivedStatus = formatMessage({ - id: 'orderRow.processingText', - defaultMessage: 'Processing' - }); - derivedProgress = 'Step1'; - } else { - derivedStatus = status; - derivedProgress = status; - } + + derivedStatus = status; + derivedProgress = state; const talonProps = useOrderRow({ items }); const { loading, isOpen, handleContentToggle, imagesData } = talonProps; From d7e95362c1241e4c087ae9fa63ddc50e0d185638 Mon Sep 17 00:00:00 2001 From: glo82145 Date: Mon, 1 Apr 2024 17:23:02 +0530 Subject: [PATCH 13/15] Resolved issue --- .../__snapshots__/orderRow.spec.js.snap | 12 ++-- .../__tests__/orderRow.spec.js | 63 ------------------- .../OrderHistoryPage/orderProgressBar.js | 2 +- .../components/OrderHistoryPage/orderRow.js | 8 +-- 4 files changed, 8 insertions(+), 77 deletions(-) diff --git a/packages/venia-ui/lib/components/OrderHistoryPage/__tests__/__snapshots__/orderRow.spec.js.snap b/packages/venia-ui/lib/components/OrderHistoryPage/__tests__/__snapshots__/orderRow.spec.js.snap index fb504180ff..49c8bf7e28 100644 --- a/packages/venia-ui/lib/components/OrderHistoryPage/__tests__/__snapshots__/orderRow.spec.js.snap +++ b/packages/venia-ui/lib/components/OrderHistoryPage/__tests__/__snapshots__/orderRow.spec.js.snap @@ -119,11 +119,10 @@ exports[`it does not render order details if loading is true 1`] = ` - Delivered + Complete