import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { ReviewIndicator } from './ReviewIndicator';
import FSI18n from '@brandingbrand/fsi18n';
const styles = StyleSheet.create({
    brand: {
        lineHeight: 25
    },
    title: {
        lineHeight: 25
    },
    priceContainer: {
        flexDirection: 'row'
    },
    reviewsContainer: {
        flexDirection: 'row',
        alignItems: 'center'
    },
    reviewCountContainer: {
        marginLeft: 5
    },
    reviewCount: {
        fontSize: 14
    },
    originalPrice: {
        lineHeight: 25,
        textDecorationLine: 'line-through',
        marginRight: 10
    },
    price: {
        lineHeight: 25
    },
    salePrice: {
        color: 'red'
    }
});
export class ProductMetadata extends Component {
    renderBrand() {
        return (<Text style={[styles.brand, this.props.brandStyle]}>{this.props.brand}</Text>);
    }
    renderTitle() {
        return (<Text style={[styles.title, this.props.titleStyle]}>{this.props.title}</Text>);
    }
    renderPrice() {
        const { originalPriceStyle, priceStyle, salePriceStyle, originalPrice, price } = this.props;
        const priceStyleGenerated = [
            styles.price,
            priceStyle || null,
            originalPrice && styles.salePrice || null,
            originalPrice && salePriceStyle || null
        ];
        return (<View style={styles.priceContainer}>
        {originalPrice && (<Text style={[styles.originalPrice, originalPriceStyle]}>
            {FSI18n.currency(originalPrice)}
          </Text>)}
        {price && (<View style={styles.priceContainer}>
            <Text style={priceStyleGenerated}>
              {FSI18n.currency(price)}
            </Text>
          </View>)}
      </View>);
    }
    renderReviews() {
        const { review, reviewCountStyle, reviewIndicatorProps } = this.props;
        const stats = review && review.statistics || {};
        const { averageRating, reviewCount } = stats;
        return (<View style={styles.reviewsContainer}>
        <ReviewIndicator value={averageRating} {...reviewIndicatorProps}/>
        {(typeof reviewCount !== 'undefined') && (<View style={styles.reviewCountContainer}>
            <Text style={[styles.reviewCount, reviewCountStyle]}>
              ({reviewCount})
            </Text>
          </View>)}
      </View>);
    }
    render() {
        return (<View style={this.props.style}>
        {this.props.brand && this.renderBrand()}
        {this.props.title && this.renderTitle()}
        {(this.props.originalPrice || this.props.price) && this.renderPrice()}
        {(typeof this.props.review !== 'undefined') && this.renderReviews()}
      </View>);
    }
}
//# sourceMappingURL=ProductMetadata.js.map