Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add price component #4

Merged
merged 7 commits into from
Apr 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions react/Price.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { FormattedMessage, injectIntl, intlShape } from 'react-intl'

/**
* The Price component. Shows the prices information of the Product Summary.
*/
class Price extends Component {
static contextTypes = {
culture: PropTypes.object,
}

render() {
const {
sellingPrice,
listPrice,
installments,
installmentPrice,
showListPrice,
intl: { formatNumber },
} = this.props

const currencyOptions = {
style: 'currency',
currency: this.context.culture.currency,
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}

return (
<div className="tc b fabriga">
{showListPrice && (
<div className="pv1">
<div className="dib">
<FormattedMessage id="pricing.from" />
</div>
<div className="dib strike ph2">
{formatNumber(listPrice, currencyOptions)}
</div>
</div>
)}
<div className="pv1">
<div className="dib">
<FormattedMessage id="pricing.to" />
</div>
<div className="dib ph2">
{formatNumber(sellingPrice, currencyOptions)}
</div>
</div>
{installments &&
installmentPrice && (
<div>
<div className="dib">
<FormattedMessage
id="pricing.installment-display"
values={{
installments,
installmentPrice: formatNumber(
installmentPrice,
currencyOptions
),
}}
/>
</div>
</div>
)}
</div>
)
}
}

Price.propTypes = {
/** Product selling price */
sellingPrice: PropTypes.number.isRequired,
/** Product list price */
listPrice: PropTypes.number.isRequired,
/** Determines if the list price is shown or not */
showListPrice: PropTypes.bool,
/** Available number of installments */
installments: PropTypes.number,
/** Single installment price */
installmentPrice: PropTypes.number,
/** intl property to format data */
intl: intlShape.isRequired,
}

export default injectIntl(Price)
2 changes: 1 addition & 1 deletion react/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import {ExtensionPoint, Link, Helmet} from 'render'
import {FormattedMessage, FormattedHTMLMessage, injectIntl, intlShape} from 'react-intl'
import {FormattedMessage, injectIntl, intlShape} from 'react-intl'

class GettingStartedIndex extends Component {
static propTypes = {
Expand Down
3 changes: 3 additions & 0 deletions react/locales/en-US.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"pricing.installment-display": "or up to {installments}X of {installmentPrice}",
"pricing.from": "from:",
"pricing.to": "to:",
"getting-started.title": "VTEX Render - Getting started",
"getting-started.greeting": "Welcome to the first VTEX Render tutorial!",
"getting-started.description": "This is an interactive tutorial.The idea is for you to discover the Render features by editing an app.",
Expand Down
3 changes: 3 additions & 0 deletions react/locales/es-AR.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"pricing.installment-display": "o hasta {installments}X de {installmentPrice}",
"pricing.from": "de:",
"pricing.to": "por:",
"getting-started.title": "VTEX Render - Primeros pasos",
"getting-started.greeting": "Bienvenido al Primero Tutorial del VTEX Render!",
"getting-started.description": "Ese es un tutorial interactivo. La idea es descubrir las features del Render editando una app.",
Expand Down
3 changes: 3 additions & 0 deletions react/locales/pt-BR.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"pricing.installment-display": "ou até {installments}X de {installmentPrice}",
"pricing.from": "de:",
"pricing.to": "por:",
"getting-started.title": "VTEX Render - Primeiros passos",
"getting-started.greeting": "Bem-vindo ao Primeiro Tutorial do VTEX Render!",
"getting-started.description": "Esse é um tutorial interativo. A idéia é você descobrir as funcionalidades do Render editando uma app.",
Expand Down