/** Contains the base fields for a contact reuse **/
import React, { Component } from 'react';
import { View } from 'react-native';
import { Tile } from 'react-native-elements';
import { PROFILE_FORM, CONTACT_FORM, SOCIAL_FORM } from '../FormTypes';
import { Spacer } from '../common';
import { strings } from '../../locales/i18n';
import styles from './styles';

// Since we have duplicate keys between contact and profile we can't use this.props
// so we track what has been populated here

export default class BizCard extends Component {

  /**
  * Renders the business card tile
  **/
  renderBusinessCardTile() {
    let base64 = '';
    if (this.props.formType === CONTACT_FORM) {
      base64 = this.props.contactBizCardImg;
    } else if (this.props.formType === PROFILE_FORM) {
      base64 = this.props.profileBizCardImg;
    } else if (this.props.formType === SOCIAL_FORM) {
      base64 = this.props.socialBizCardImg;
    }
    if (base64) {
      return (
        <Tile
          imageSrc={{ uri: base64 }}
          featured
          containerStyle={styles.tileContainerStyle}
          imageContainerStyle={styles.tileStyle}
        />
      );
    }
    return (
      <Tile
        featured
        title={strings('bizCard.photoTile_noCard')}
        containerStyle={styles.tileContainerStyle}
        imageContainerStyle={styles.tileStyle}
      />
    );
  }

  /**
  * Render method
  **/
  render() {
    return (
      <View style={styles.viewStyle}>
        <Spacer space={45} />
        {this.renderBusinessCardTile()}
        <View style={styles.buttonContainerStyle} />
      </View>
    );
  }
}

