Skip to content

Commit

Permalink
Add default messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Cloud11PL committed Nov 26, 2021
1 parent 4611761 commit 0cdabf3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
8 changes: 8 additions & 0 deletions locale/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -6743,6 +6743,14 @@
"src_dot_products_dot_views_dot_ProductList_dot_44832327": {
"string": "We are currently exporting your requested CSV. As soon as it is available it will be sent to your email address"
},
"src_dot_products_dot_views_dot_ProductList_dot_giftCardLabel": {
"context": "label",
"string": "Gift Card"
},
"src_dot_products_dot_views_dot_ProductList_dot_normalLabel": {
"context": "label",
"string": "Normal"
},
"src_dot_products_dot_views_dot_ProductUpdate_dot_3423943948": {
"string": "Manage Products Channel Availability"
},
Expand Down
12 changes: 12 additions & 0 deletions src/products/views/ProductList/messages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineMessages } from "react-intl";

export const productKindMessages = defineMessages({
giftCardLabel: {
defaultMessage: "Gift Card",
description: "label"
},
normalLabel: {
defaultMessage: "Normal",
description: "label"
}
});
14 changes: 10 additions & 4 deletions src/products/views/ProductList/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { isInEnum } from "@saleor/misc";
import { ProductTypeKindEnum } from "@saleor/types/globalTypes";
import { useIntl } from "react-intl";

import { productKindMessages as messages } from "./messages";

interface ProductKindChoice {
label: string;
Expand All @@ -14,21 +17,24 @@ export const getAvailableProductKinds = (): ProductKindChoice[] =>

export const getProductKindOpts = (
availableProducts: ProductKindChoice[]
): ProductKindChoice[] =>
availableProducts.map(kind => {
): ProductKindChoice[] => {
const intl = useIntl();

return availableProducts.map(kind => {
switch (kind.value) {
case ProductTypeKindEnum.GIFT_CARD:
return {
...kind,
label: "Gift Card"
label: intl.formatMessage(messages.giftCardLabel)
};
case ProductTypeKindEnum.NORMAL:
return {
...kind,
label: "Normal"
label: intl.formatMessage(messages.normalLabel)
};
}
});
};

export const getProductGiftCardFilterParam = (productKind?: string) => {
if (
Expand Down

0 comments on commit 0cdabf3

Please sign in to comment.