import React, {Component} from 'react';
import {View, Text, StyleSheet, Image, TouchableOpacity} from 'react-native';
import R from '../../../assets/R';
import AppText from '../../../components/AppText';
import {getFontXD} from '../../../Config/Functions';
import {useNavigation} from '@react-navigation/native';
import {DETAILPARTNER} from '../../../routers/ScreenNames';

const Item = (props) => {
  const {
    fullname,
    picture_url,
    cqg_status_name,
    status_name,
    created,
    sponsor_name,
  } = props.item;

  const navigation = useNavigation();

  return (
    <TouchableOpacity
      onPress={() => navigation.navigate(DETAILPARTNER, {data: props.item})}
      style={[styles.container, props.isEnd ? {marginBottom: 10} : {}]}>
      <Image source={{uri: picture_url}} style={styles.img} />
      <View style={styles.wrapRight}>
        <Text style={styles.txtName}>{fullname}</Text>
        <View style={styles.row}>
          <AppText style={styles.txtTitle} i18nKey={'Status'} />
          <Text style={{fontSize: getFontXD(36)}}>{status_name}</Text>
        </View>

        <View style={styles.row}>
          <AppText style={styles.txtTitle} i18nKey={'DateJoin'} />
          <Text style={{fontSize: getFontXD(36)}}>{created}</Text>
        </View>

        <View style={styles.row}>
          <AppText style={styles.txtTitle} i18nKey={'OpenAccountExchange'} />
          <Text style={{fontSize: getFontXD(36)}}>{cqg_status_name}</Text>
        </View>
        {props.level == 1 ? null : (
          <View style={styles.row}>
            <AppText style={styles.txtTitle} i18nKey={'Sponsor'} />
            <Text style={{fontSize: getFontXD(36)}}>{sponsor_name}</Text>
          </View>
        )}
      </View>
    </TouchableOpacity>
  );
};

export default Item;

const styles = StyleSheet.create({
  container: {
    backgroundColor: R.colors.white,
    padding: 10,
    marginTop: 10,
    marginHorizontal: 10,
    borderRadius: 5,
    shadowColor: '#000',
    shadowOffset: {
      width: 0,
      height: 1,
    },
    shadowOpacity: 0.15,
    shadowRadius: 1.84,
    elevation: 2,
    flexDirection: 'row',
    alignItems: 'center',
  },
  img: {
    width: 80,
    height: 80,
    borderRadius: 45,
    borderWidth: 0.4,
    borderColor: R.colors.main,
  },
  wrapRight: {
    marginLeft: 5,
    flex: 1,
  },
  txtTitle: {
    fontSize: getFontXD(36),
    color: R.colors.color777,
    marginRight: 5,
  },
  txtName: {
    fontSize: getFontXD(42),
    color: R.colors.black,
    textTransform: 'uppercase',
  },
  row: {flexDirection: 'row', alignItems: 'center', marginTop: 2},
});
