Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kieckhafer
Copy link
Member

@kieckhafer kieckhafer commented Feb 12, 2019

Resolves #4579
Impact: minor
Type: feature

Issue

While we had ordersByAccountId outlined in our GraphQL schema, we had not yet built out the query to use this.

Solution

Add the needed query to be able to use ordersByAccountId

Testing

  1. Create orders from multiple accounts
  2. Add the following into the Shops collection, if you'd like to see translations of order statuses
"orderStatusLabels": {
    "new" : [ 
        {
            "language" : "en",
            "label" : "Order received"
        }, 
        {
            "language" : "es",
            "label" : "Recibido"
        }
    ],
    "coreOrderWorkflow/processing" : [ 
        {
            "language" : "en",
            "label" : "Order received"
        }, 
        {
            "language" : "es",
            "label" : "Recibido"
        }
    ],
    "coreOrderWorkflow/completed" : [ 
        {
            "language" : "en",
            "label" : "Shipped"
        }, 
        {
            "language" : "es",
            "label" : "Enviado"
        }
    ],
    "coreOrderWorkflow/canceled" : [ 
        {
            "language" : "en",
            "label" : "Canceled"
        }, 
        {
            "language" : "es",
            "label" : "Cancelado"
        }
    ]
}
  1. Use the following query, and make sure you only get back orders from the correct supplied accountId
{
  ordersByAccountId(accountId: "PUT_ACCOUNT_ID_HERE") {
    edges {
      node {
        _id
        status(language: "es") {
	  label
          status
        }
        ...anyOtherFieldsYouWantToTest
      }
    }
  }
}
{
  ordersByAccountId(accountId: "PUT_ACCOUNT_ID_HERE", shopIds: ["PUT_SHOP_ID(s)_HERE]) {
    edges {
      node {
        _id
        status(language: "es") {
	  label
          status
        }
        ...anyOtherFieldsYouWantToTest
      }
    }
  }
}
  1. Remove translations and make sure query still works and returns raw status data if translations are not available at all (not in collection), or for the requested language (request fr)
  2. If you'd like to see this in the UI, you can test against this starterkit branch: (feat): New Profile Orders page example-storefront#393 - however that one isn't quite ready so any UI errors please ignore, only use it to visualize the API as well as it can do for now

@kieckhafer kieckhafer changed the base branch from master to develop February 12, 2019 02:34
@kieckhafer kieckhafer changed the title [WIP] feat: add ordersByAccountId query feat: add ordersByAccountId query Feb 19, 2019
@kieckhafer
Copy link
Member Author

@aldeed addressed all comments made in this PR (they were just answers to questions I had, nothing has been reviewed officially yet), and this is ready for an actual review.

Translations are living on the Shops collection, on the orderStatusLabels object for now. I have a DR open to further investigate this, and they can be easily moved. I've made a ticket to build out the UI for this, but for the sake of getting this pulled into forks that need it, I would prefer to get this base merged prior to that buildout: https://github.com/reactioncommerce/reaction/issues/5000

In other scenarios (Surcharges), we decided that if a language was not provided for translations, we would show nothing. In this case, I've made the decision to show the raw order status (i.e. coreOrderWorkflow/processing) if there is no translation available. What are your thoughts on that? Can easily be changed to show nothing if no label is present.

aldeed
aldeed previously requested changes Feb 25, 2019
Copy link
Contributor

@aldeed aldeed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kieckhafer See a few comments. Returning the raw status when there isn't a translation seems fine to me.

* @param {Object} context - an object containing the per-request state
* @param {Object} params - request parameters
* @param {String} params.accountId - Account ID to search orders for
* @param {String} params.orderStatus - Workflow status to limit search results
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be more useful and not much extra work to do orderStatuses array rather than just one. Return orders with any of the statuses in the array. (So in UI the filter could be check boxes rather than a single status select.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. How do we want to go about the All selection then? Just have all the statuses checked by default?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rymorgan See above. What are your thoughts on using a multi-select instead of a single dropdown for the Order Status filter?

I don't think it looks that great, might get confusing for the user too.

I think @aldeed's idea of passing an array is best for the server side, but on the client maybe we have pre-set arrays that we pass (at least in our starterkit, other people can do what we want), and continue to use the single select. Thoughts?

account_profile___reaction

Copy link
Contributor

@rymorgan rymorgan Feb 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed @kieckhafer that a multi-select would likely be confusing to a user. I think it adds an extra bit of complexity to the user experience for not a huge benefit to the user. And actually a detriment to the user if they are confused by the UI. I don't remember seeing this type of behavior on brands that I visit which makes me think we'd be designing something almost all storefronts would eliminate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, too. I was thinking more of future operator UI needs.

@kieckhafer kieckhafer requested a review from aldeed February 26, 2019 01:28
@kieckhafer kieckhafer dismissed aldeed’s stale review February 26, 2019 01:29

@aldeed updated with all changes. Made a comment here regarding multi-select, but that's a discussion for the starterkit anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants