Skip to content

Commit

Permalink
Merge pull request #3 from vtex-apps/feature/tba-price
Browse files Browse the repository at this point in the history
Show TBA in case of undefined or null price
  • Loading branch information
jeffersontuc authored Sep 19, 2019
2 parents 16ec74e + 40d1ac3 commit 39e270f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion messages/context.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"store/price.Free": "FREE"
"store/price.Free": "FREE",
"store/price.TBA": "TBA"
}
3 changes: 2 additions & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"store/price.Free": "FREE"
"store/price.Free": "FREE",
"store/price.TBA": "TBA"
}
3 changes: 2 additions & 1 deletion messages/es.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"store/price.Free": "GRATIS"
"store/price.Free": "GRATIS",
"store/price.TBA": "TBA"
}
3 changes: 2 additions & 1 deletion messages/pt.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"store/price.Free": "GRÁTIS"
"store/price.Free": "GRÁTIS",
"store/price.TBA": "TBA"
}
16 changes: 3 additions & 13 deletions react/FormattedPrice.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
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',
},
})

const FormattedPrice: FC<FormattedPriceProps & InjectedIntlProps> = ({
value,
}) => {
return (
<Fragment>
{value === 0 ? (
<FormattedMessage id="store/price.Free" />
) : value === null || value === undefined ? (
<FormattedMessage id="store/price.TBA" />
) : (
<FormattedCurrency value={value} />
)}
Expand Down

0 comments on commit 39e270f

Please sign in to comment.