import React, { Component } from 'react';
import { Image, Text, View } from 'react-native';
import { ReviewIndicator } from './ReviewIndicator';
import { MoreText } from './MoreText';
import { Button } from './Button';
import { style as S } from '../styles/ReviewItem';
import FSI18n, { translationKeys } from '@brandingbrand/fsi18n';
const componentTranslationKeys = translationKeys.flagship.reviews;
export class ReviewItem extends Component {
    constructor() {
        super(...arguments);
        this.onHelpful = () => {
            const { onHelpful } = this.props;
            if (onHelpful) {
                onHelpful(this.props);
            }
        };
        this.onNotHelpful = () => {
            const { onNotHelpful } = this.props;
            if (onNotHelpful) {
                onNotHelpful(this.props);
            }
        };
    }
    render() {
        const { rating, title, text = '', user, created, verifiedImage, feedback, reviewIndicatorProps = {}, moreTextProps = {}, style, titleStyle, userStyle, verifiedStyle, verifiedImageStyle, verifiedRowStyle, helpfulStyle, buttonStyle, rowStyle, onHelpful, onNotHelpful, moreTextStyle, recommendedImage, recommendedStyle, recommendedImageStyle, recommendedImageBoxStyle, recommendedRowStyle, isRecommended } = this.props;
        return (<View style={[S.container, style]}>
        <View style={[S.row, rowStyle]}>
          <ReviewIndicator value={rating} style={S.indicator} {...reviewIndicatorProps}/>
          {title && (<Text style={[S.title, titleStyle]}>{title}</Text>)}
        </View>
        {(user || created) && (<View style={[S.row, rowStyle]}>
          <Text style={[S.user, userStyle]}>
            {user && user.name && 'By ' + user.name}
            {(created ? ' on ' + (new Date(created)).toLocaleDateString() : '')}
          </Text>
        </View>)}
        {user && user.isVerifiedBuyer && (<View style={[S.row, { paddingBottom: 3 }, rowStyle, verifiedRowStyle]}>
            {verifiedImage && (<Image style={verifiedImageStyle} source={verifiedImage}/>)}
            <Text style={[S.verified, verifiedStyle]}>
              {FSI18n.string(componentTranslationKeys.verified)}
            </Text>
          </View>)}
        {!!text && (<MoreText text={text} textMoreLessStyle={moreTextStyle} containerStyle={S.row} numberOfCharacters={325} {...moreTextProps}/>)}
        {isRecommended !== undefined && (<View style={[S.row, rowStyle, recommendedRowStyle]}>
            {recommendedImage && (<View style={recommendedImageBoxStyle}>
                <Image style={recommendedImageStyle} source={recommendedImage}/>
              </View>)}
            <Text style={[S.recommended, recommendedStyle]}>
              {isRecommended ?
            FSI18n.string(componentTranslationKeys.recommended) :
            FSI18n.string(componentTranslationKeys.notRecommended)}
            </Text>
          </View>)}
        {feedback && feedback.positive && (<View style={[S.row, rowStyle]}>
          <Text style={[S.helpful, helpfulStyle]}>
            {FSI18n.string(componentTranslationKeys.helpfulCount, {
            count: feedback.positive
        })}
          </Text>
        </View>)}
        {onHelpful && onNotHelpful && (<View style={[S.row, { flexDirection: 'row' }, rowStyle]}>
          <Button title={FSI18n.string(componentTranslationKeys.helpful)} light onPress={this.onHelpful} style={[S.button, buttonStyle]}/>
          <Button title={FSI18n.string(componentTranslationKeys.notHelpful)} light onPress={this.onNotHelpful} style={[S.button, buttonStyle]}/>
        </View>)}
      </View>);
    }
}
//# sourceMappingURL=ReviewItem.js.map