-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5236 from reactioncommerce/feat-kieckhafer-addHum…
…anReadableStatusForFulfillment feat: add resolver to get displayStatus from database
- Loading branch information
Showing
4 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ export default gql` | |
} | ||
} | ||
} | ||
displayStatus(language: $language) | ||
items { | ||
nodes { | ||
_id | ||
|
30 changes: 30 additions & 0 deletions
30
.../orders/server/no-meteor/resolvers/OrderFulfillmentGroup/fulfillmentGroupDisplayStatus.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* @name OrderFulfillmentGroup/fulfillmentGroupDisplayStatus | ||
* @method | ||
* @memberof Order/GraphQL | ||
* @summary Displays a human readable status of order fulfillment group state | ||
* @param {Object} context An object with request-specific state | ||
* @param {Object} fulfillmentGroup - Result of the parent resolver, which is a Fulfillment Group object in GraphQL schema format | ||
* @param {String} language Language to filter item content by | ||
* @return {String} A string of the order status | ||
*/ | ||
export default async function fulfillmentGroupDisplayStatus(context, fulfillmentGroup, language) { | ||
const { Shops } = context.collections; | ||
const shop = await Shops.findOne({ _id: fulfillmentGroup.shopId }); | ||
const orderStatusLabels = shop && shop.orderStatusLabels; | ||
const { workflow: { status } } = fulfillmentGroup; | ||
|
||
// If translations are available in the `Shops` collection, | ||
// and are available for this specific order status, get translations | ||
if (orderStatusLabels && orderStatusLabels[status]) { | ||
const orderStatusLabel = orderStatusLabels[status]; | ||
const translatedLabel = orderStatusLabel.find((label) => label.language === language); | ||
|
||
// If translations are available in desired language, return them. | ||
// Otherwise, return raw status | ||
return (translatedLabel && translatedLabel.label) || status; | ||
} | ||
|
||
// If no translations are available in the `Shops` collection, use raw status data | ||
return status; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters