/**
 * React Native Full App (https://store.enappd.com/product/react-native-full-app)
 *
 * Copyright © 2019-present Enappd. All rights reserved.
 *
 * This source code is licensed as per the terms found in the
 * LICENSE.md file in the root directory of this source tree.
 */
import React from 'react';
import { Text, ListItem, Left, Radio, Body, View } from 'native-base';
import styles from './styles';

interface DeliveryAddressesProps {
  selecteAddressdIndex: number;
  deliveryJson: any;
  gotoSelectAddressRadio: (index: number) => void;
}

const DeliveryAddresses = (props: DeliveryAddressesProps) => {
  const { selecteAddressdIndex, deliveryJson } = props;
  const themeColor = '#f53d3d';

  return (
    <View>
      {deliveryJson.map((item: any, index: number) => {
        return (
          <ListItem
            thumbnail
            onPress={() => props.gotoSelectAddressRadio(index)}
            key={index}
          >
            <Left>
              <Radio
                selected={selecteAddressdIndex === index}
                selectedColor={themeColor}
              />
            </Left>
            <Body>
              <Text>{item.name}</Text>
              <Text note>{item.address}</Text>
              <Text note>{item.city}</Text>
              <Text note>{item.type}</Text>
            </Body>
          </ListItem>
        );
      })}
    </View>
  );
};

export default DeliveryAddresses;
