From 4848e5334e1f80c75940984af556b9dd44a0f640 Mon Sep 17 00:00:00 2001 From: Jefferson Date: Thu, 19 Sep 2019 16:05:13 -0300 Subject: [PATCH 1/2] Show TBA in case of undefined or null price --- CHANGELOG.md | 4 ++++ messages/context.json | 3 ++- messages/en.json | 3 ++- messages/es.json | 3 ++- messages/pt.json | 3 ++- react/FormattedPrice.tsx | 7 +++++++ 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfe5963..15dc0b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## Added + +- Show TBA in case of undefined or null price. + ## [0.1.0] - 2019-08-28 ## Added diff --git a/messages/context.json b/messages/context.json index 3c63954..b31e4ac 100644 --- a/messages/context.json +++ b/messages/context.json @@ -1,3 +1,4 @@ { - "store/price.Free": "FREE" + "store/price.Free": "FREE", + "store/price.TBA": "TBA" } diff --git a/messages/en.json b/messages/en.json index 3c63954..b31e4ac 100644 --- a/messages/en.json +++ b/messages/en.json @@ -1,3 +1,4 @@ { - "store/price.Free": "FREE" + "store/price.Free": "FREE", + "store/price.TBA": "TBA" } diff --git a/messages/es.json b/messages/es.json index de7e389..1f41c72 100644 --- a/messages/es.json +++ b/messages/es.json @@ -1,3 +1,4 @@ { - "store/price.Free": "GRATIS" + "store/price.Free": "GRATIS", + "store/price.TBA": "TBA" } diff --git a/messages/pt.json b/messages/pt.json index 2990376..a9ba287 100644 --- a/messages/pt.json +++ b/messages/pt.json @@ -1,3 +1,4 @@ { - "store/price.Free": "GRÁTIS" + "store/price.Free": "GRÁTIS", + "store/price.TBA": "TBA" } diff --git a/react/FormattedPrice.tsx b/react/FormattedPrice.tsx index 7d76bc3..fe7381f 100644 --- a/react/FormattedPrice.tsx +++ b/react/FormattedPrice.tsx @@ -12,6 +12,11 @@ defineMessages({ id: 'store/price.Free', defaultMessage: 'FREE', }, + + TBA: { + id: 'store/price.TBA', + defaultMessage: 'TBA', + }, }) const FormattedPrice: FC = ({ @@ -21,6 +26,8 @@ const FormattedPrice: FC = ({ {value === 0 ? ( + ) : value === null || value === undefined ? ( + ) : ( )} From 40d1ac36592d9758cd9e45b150b2e84f6fb1db3a Mon Sep 17 00:00:00 2001 From: Jefferson Date: Thu, 19 Sep 2019 18:27:55 -0300 Subject: [PATCH 2/2] Removes unnecessary defineMessages --- react/FormattedPrice.tsx | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/react/FormattedPrice.tsx b/react/FormattedPrice.tsx index fe7381f..0d23d34 100644 --- a/react/FormattedPrice.tsx +++ b/react/FormattedPrice.tsx @@ -1,24 +1,7 @@ import React, { FC, Fragment } from 'react' -import { - defineMessages, - injectIntl, - InjectedIntlProps, - FormattedMessage, -} from 'react-intl' +import { injectIntl, InjectedIntlProps, FormattedMessage } from 'react-intl' import { FormattedCurrency } from 'vtex.format-currency' -defineMessages({ - Free: { - id: 'store/price.Free', - defaultMessage: 'FREE', - }, - - TBA: { - id: 'store/price.TBA', - defaultMessage: 'TBA', - }, -}) - const FormattedPrice: FC = ({ value, }) => {