import React, { Component } from 'react';
import { Image, Platform, ScrollView, StyleSheet, Text, TouchableOpacity, View, Slider, Dimensions, Alert, FlatList, AppState, BackHandler, AsyncStorage, ActivityIndicator, ToastAndroid, RefreshControl, StatusBar, Vibration, TouchableWithoutFeedback, TextInput, ViewPropTypes } from 'react-native';
import { FontAwesome, FontAwesome5, MaterialCommunityIcons, Feather, MaterialIcons, Octicons, AntDesign, Entypo } from '@expo/vector-icons';
import Constants from 'expo-constants';
import { Card, CheckBox } from 'react-native-elements';
import ModalBox from 'react-native-modalbox';
import Modal from "react-native-modal";
import { SearchBar } from 'react-native-elements';
import moment from 'moment';
import { HttpsClient } from './HttpsClient.js';
import MapView from 'react-native-maps';
import { StackNavigator } from 'react-navigation';
import * as Expo from 'expo';
import * as Permissions from 'expo-permissions';
import Svg, { Circle, Rect, Path, Defs, G, Mask } from 'react-native-svg';
import Toast, { DURATION } from 'react-native-easy-toast';
import PropTypes from 'prop-types';
const {
  width,
  height
} = Dimensions.get('window');
import i18n from 'i18n-js';
import * as Localization from 'expo-localization';

class ContactCreation extends React.Component {
  constructor(props) {
    super(props);

    this.changeVal = () => {
      this.setState({
        bool: !this.state.bool
      }, () => {
        this.setState({
          bool: true
        });
      });
    };

    this.clearData = item => {
      if (!this.state.edit) {
        this.setState({
          firstName: '',
          companyName: '',
          phone: '',
          email: '',
          location: '',
          pincode: '',
          companyList: [],
          show: false,
          isSez: false,
          showMore: false,
          selectedCompany: null,
          selectedPincode: null,
          designation: '',
          gstin: '',
          createdoc: false,
          newdoc: false,
          viewContact: [],
          contactSaved: false
        });
      } else {
        this.setState({
          createdoc: false,
          contactSaved: false
        });
      }

      this.props.redirectPageTo(item, this.state.viewContact);
    };

    this.companyClearData = item => {
      if (this.state.isCompany) {
        this.setState({
          firstName: '',
          phone: '',
          email: '',
          location: '',
          pincode: '',
          companyList: [],
          show: false,
          isSez: false,
          showMore: false,
          selectedPincode: null,
          designation: '',
          createdoc: false,
          newdoc: false,
          viewContact: [],
          contactSaved: false
        });
      } else {
        this.setState({
          createdoc: false,
          contactSaved: false
        });
      }

      this.props.redirectPageTo(item, this.state.viewContact);
    };

    this.setUrl = async () => {
      var SERVER_URL = await AsyncStorage.getItem('SERVER_URL');
      this.setState({
        SERVER_URL
      });
    };

    this.componentDidMount = () => {
      console.log(this.props.redirectPage, 'navfggfigateToooo');
      this.setUrl();
    };

    this.getCompany = async text => {
      this.setState({
        companyName: text,
        selectedCompany: null
      });

      if (text.length == 0) {
        this.setState({
          companyList: [],
          show: false
        });
        return;
      }

      var SERVER_URL = await AsyncStorage.getItem('SERVER_URL');
      var url = SERVER_URL + '/api/ERP/service/?limit=10&name__icontains=' + text;
      var data = await HttpsClient.get(url);
      console.log(SERVER_URL + '/api/ERP/service/?limit=10&name__icontains=' + text, data);

      if (data.type == 'success') {
        console.log(data.data.results, 'dfbsbn');
        this.setState({
          companyList: data.data.results
        });

        if (data.data.results.length > 0) {
          this.setState({
            show: true
          });
        } else {
          this.setState({
            show: false
          });
        }
      } else {
        return;
      }
    };

    this.renderHeader = () => {
      return /*#__PURE__*/React.createElement(View, {
        style: {
          flexDirection: 'row',
          height: 55,
          alignItems: 'center'
        }
      }, /*#__PURE__*/React.createElement(TouchableOpacity, {
        onPress: () => {
          this.props.navigation.goBack();
        },
        style: {
          justifyContent: 'center',
          alignItems: 'center',
          width: width * 0.15
        }
      }, /*#__PURE__*/React.createElement(MaterialIcons, {
        name: "arrow-back",
        size: 24,
        color: "black"
      })), /*#__PURE__*/React.createElement(View, {
        style: {
          width: width * 0.7,
          alignItems: 'center',
          justifyContent: 'center'
        }
      }, /*#__PURE__*/React.createElement(Text, {
        style: {
          fontSize: 20,
          color: '#000'
        }
      }, this.state.edit ? 'Edit' : 'Create', " Contact")), !this.state.contactSaved && /*#__PURE__*/React.createElement(TouchableOpacity, {
        onPress: () => {
          this.save();
        },
        style: {
          justifyContent: 'center',
          alignItems: 'center',
          width: width * 0.15
        }
      }, /*#__PURE__*/React.createElement(Text, {
        style: {
          fontSize: 18,
          color: '#07823c'
        }
      }, "Save")));
    };

    this.navigateToScreen = item => {
      console.log(item, this.state.navigateTo, 'vickyupdateee'); // return

      if (this.state.isCompany) {
        this.companyClearData(item);
      } else {
        this.clearData(item);
      }
    };

    this.changeShowMore = showMore => {
      this.setState({
        showMore: !showMore
      });
      var showMore = !showMore;

      if (showMore) {
        setTimeout(() => {
          this.scrollView.scrollToEnd({
            animated: true
          });
        }, 100);
      }
    };

    this.save = async () => {
      if (this.state.firstName.length == 0) {
        ToastAndroid.showWithGravityAndOffset("Enter Name", ToastAndroid.LONG, ToastAndroid.BOTTOM, 25, 50);
        return;
      }

      if (this.state.phone.length != 10) {
        ToastAndroid.showWithGravityAndOffset("Enter Correct Mobile No", ToastAndroid.LONG, ToastAndroid.BOTTOM, 25, 50);
        return;
      }

      if (this.state.email.length == 0) {
        ToastAndroid.showWithGravityAndOffset("Enter Email", ToastAndroid.LONG, ToastAndroid.BOTTOM, 25, 50);
        return;
      }

      if (this.state.companyName.length == 0 && this.state.selectedCompany == null) {
        ToastAndroid.showWithGravityAndOffset("Enter Company", ToastAndroid.LONG, ToastAndroid.BOTTOM, 25, 50);
        return;
      }

      if (this.state.selectedPincode == null) {
        ToastAndroid.showWithGravityAndOffset("Enter Correct Pincode", ToastAndroid.LONG, ToastAndroid.BOTTOM, 25, 50);
        return;
      }

      var sendData = {
        name: this.state.firstName,
        email: this.state.email,
        mobile: this.state.phone,
        street: this.state.location,
        pincode: this.state.pincode,
        city: this.state.city,
        state: this.state.state,
        country: this.state.country,
        isGst: this.state.isSez,
        company: this.state.companyName
      };

      if (this.state.selectedCompany != null) {
        sendData.company = this.state.selectedCompany;
        sendData.companypk = this.state.selectedCompany.pk;
      }

      if (this.state.gstin != null && this.state.gstin.length > 0) {
        sendData.gstin = this.state.gstin;
      }

      if (this.state.designation != null && this.state.designation != undefined && this.state.designation.length > 0) {
        sendData.designation = this.state.designation;
      }

      if (this.state.edit) {
        sendData.pk = this.state.data.pk;
      } // return


      var url = this.state.SERVER_URL + '/api/clientRelationships/createContact/';
      var data = await HttpsClient.post(url, sendData);
      console.log(sendData, data, 'dfbsbn');

      if (data.type == 'success') {
        this.setState({
          viewContact: data.data,
          contactSaved: true
        });

        if (!this.props.redirect) {
          this.props.navigation.goBack();
        } else {
          this.setState({
            newdoc: true
          });
        }
      } else {
        return;
      }
    };

    this.renderModalCreateDoc = () => {
      if (this.state.createdoc) {
        return /*#__PURE__*/React.createElement(Modal, {
          isVisible: this.state.createdoc,
          propagateSwipe: true,
          animationIn: "fadeIn",
          useNativeDriver: true,
          animationOut: "fadeOut",
          hasBackdrop: true,
          useNativeDriver: true,
          propagateSwipe: true,
          onRequestClose: () => {
            this.setState({
              createdoc: false
            });
          },
          onBackdropPress: () => {
            this.setState({
              createdoc: false
            });
          }
        }, /*#__PURE__*/React.createElement(View, {
          style: [styles.modalViewUpdate, {
            maxHeight: height * 0.8,
            overflow: 'hidden'
          }]
        }, /*#__PURE__*/React.createElement(ScrollView, null, this.state.createdoc && this.state.allDocs.length > 0 && /*#__PURE__*/React.createElement(View, {
          style: {
            borderWidth: 1,
            borderColor: 'rgba(0, 0, 0, 0.1)',
            borderRadius: 5,
            borderTopWidth: 0
          }
        }, /*#__PURE__*/React.createElement(View, {
          style: {
            margin: 10
          }
        }, /*#__PURE__*/React.createElement(FlatList, {
          contentContainerStyle: {
            borderWidth: 0,
            borderColor: 'rgba(0, 0, 0, 0.1)',
            borderRadius: 5,
            borderTopWidth: 0
          },
          data: this.state.allDocs,
          keyExtractor: (item, index) => index.toString(),
          renderItem: ({
            item,
            index
          }) => {
            return /*#__PURE__*/React.createElement(View, {
              style: {
                marginVertical: 4,
                backgroundColor: '#000',
                borderRadius: 15,
                borderColor: '#f2f2f2',
                paddingHorizontal: 10,
                height: 40,
                justifyContent: 'center',
                borderBottomWidth: 1,
                borderColor: '#f2f2f2'
              }
            }, /*#__PURE__*/React.createElement(TouchableOpacity, {
              onPress: () => {
                this.navigateToScreen(item);
              }
            }, /*#__PURE__*/React.createElement(View, {
              style: {}
            }, /*#__PURE__*/React.createElement(Text, {
              style: {
                color: '#fff',
                fontSize: 14,
                fontWeight: '600'
              },
              numberOfLines: 2
            }, item.heading))));
          }
        }))))));
      } else {
        return null;
      }
    };

    this.createDoc = async () => {
      var url = this.state.SERVER_URL + '/api/clientRelationships/crmtermsAndConditions/';
      var data = await HttpsClient.get(url);
      console.log(data);

      if (data.type == 'success') {
        this.setState({
          allDocs: data.data,
          createdoc: true
        });
      } else {
        this.setState({
          allDocs: [],
          createdoc: false
        });
      }
    };

    this.setCompany = item => {
      this.setState({
        selectedCompany: item,
        companyName: item.name,
        city: item.address.city,
        country: item.address.country,
        pincode: item.address.pincode,
        state: item.address.state,
        location: item.address.street,
        gstin: item.tin,
        companyList: [],
        show: false,
        selectedPincode: item.address
      });
    };

    this.getPincode = async query => {
      this.setState({
        pincode: query
      });

      if (query.length == 6) {
        var url = this.state.SERVER_URL + '/api/ERP/genericPincode/?pincode=' + query;
        var data = await HttpsClient.get(url);
        console.log(data);

        if (data.type == 'success') {
          if (data.data.length > 0) {
            this.setState({
              city: data.data[0].city,
              state: data.data[0].state,
              country: data.data[0].country,
              pincode: data.data[0].pincode,
              selectedPincode: data.data[0]
            });
          }
        } else {
          return;
        }
      } else {
        this.setState({
          city: '',
          state: '',
          country: '',
          selectedPincode: null
        });
      }
    };

    this.renderFooter = () => {
      return /*#__PURE__*/React.createElement(View, {
        style: {
          height: 50,
          position: 'absolute',
          bottom: 0,
          left: 0,
          right: 0
        }
      }, /*#__PURE__*/React.createElement(TouchableOpacity, {
        onPress: () => {
          this.createDoc();
        },
        style: {
          flex: 1,
          justifyContent: 'center',
          alignItems: 'center',
          backgroundColor: '#CD0000'
        }
      }, /*#__PURE__*/React.createElement(Text, {
        style: {
          color: '#fff',
          fontWeight: '700',
          fontSize: 18
        }
      }, "Create Documents")));
    };

    var edit = false;
    var _data = null;
    var firstName = '';
    var companyName = '';
    var phone = '';
    var email = '';
    var location = '';
    var pincode = '';
    var isSez = false;
    var _showMore = false;
    var selectedCompany = null;
    var selectedPincode = null;
    var city = '';
    var state = '';
    var country = '';
    var designation = '';
    var gstin = '';
    var isCompany = false;
    console.log(props.edit, 'adsfdgfdghfhfhfgjh');

    if (props.edit) {
      edit = true;
      _data = props.data;
      firstName = _data.name;
      phone = _data.mobile;
      email = _data.email;
      pincode = _data.pincode;
      city = _data.city;
      state = _data.state;
      country = _data.country;
      location = _data.street;
      selectedCompany = _data.company;
      selectedPincode = _data.pincode;
      isSez = _data.isGst;
      designation = _data.designation;

      if (_data.company != null && _data.company != undefined) {
        companyName = _data.company.name;
        gstin = _data.company.tin;
      }
    }

    if (props.isCompany) {
      selectedCompany = props.data;

      if (selectedCompany != null && selectedCompany != undefined) {
        companyName = selectedCompany.name;
        gstin = selectedCompany.tin;
        isCompany = true;
      }
    }

    this.state = {
      SERVER_URL: '',
      firstName: firstName,
      companyName: companyName,
      phone: phone,
      email: email,
      location: location,
      pincode: pincode,
      companyList: [],
      show: false,
      isSez: isSez,
      showMore: false,
      selectedCompany: selectedCompany,
      selectedPincode: selectedPincode,
      designation: designation,
      gstin: gstin,
      createdoc: false,
      newdoc: false,
      viewContact: [],
      contactSaved: false,
      redirectPage: props.redirectPage,
      edit: edit,
      city: city,
      state: state,
      country: country,
      data: _data,
      isCompany: isCompany,
      bool: false
    };
    willFocus = props.navigation.addListener('didFocus', payload => {
      this.changeVal();
    });
  }

  render() {
    return /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 1,
        backgroundColor: "#f2f2f2"
      }
    }, /*#__PURE__*/React.createElement(View, {
      style: {
        height: Constants.statusBarHeight,
        backgroundColor: '#f2f2f2'
      }
    }, /*#__PURE__*/React.createElement(StatusBar, {
      translucent: true,
      barStyle: "dark-content",
      backgroundColor: '#f2f2f2',
      networkActivityIndicatorVisible: false
    })), this.renderHeader(), this.renderModalCreateDoc(), /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 1
      }
    }, /*#__PURE__*/React.createElement(ScrollView, {
      ref: view => {
        this.scrollView = view;
      }
    }, /*#__PURE__*/React.createElement(View, {
      style: {
        marginTop: 30,
        marginHorizontal: 25,
        marginVertical: 10
      }
    }, /*#__PURE__*/React.createElement(Text, {
      style: {
        color: '#000',
        fontSize: 16,
        paddingBottom: 10
      }
    }, i18n.t('name')), /*#__PURE__*/React.createElement(View, {
      style: {
        flexDirection: 'row'
      }
    }, /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.15,
        alignItems: 'center',
        justifyContent: 'center',
        backgroundColor: 'rgba(0, 0, 0, 0.1)',
        borderTopLeftRadius: 10,
        borderBottomLeftRadius: 10
      }
    }, /*#__PURE__*/React.createElement(Feather, {
      name: "user",
      size: 20,
      color: "black"
    })), /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.85,
        alignItems: 'center',
        justifyContent: 'center'
      }
    }, /*#__PURE__*/React.createElement(TextInput, {
      style: {
        height: 50,
        borderWidth: 1,
        borderColor: 'rgba(0, 0, 0, 0.1)',
        width: '100%',
        borderTopRightRadius: 10,
        borderBottomRightRadius: 10,
        backgroundColor: '#fff',
        paddingHorizontal: 15,
        fontSize: 16
      },
      placeholder: i18n.t('name'),
      placeholderTextColor: "rgba(0, 0, 0, 0.5)",
      selectionColor: '#000',
      onChangeText: query => {
        this.setState({
          firstName: query
        });
      },
      value: this.state.firstName
    })))), /*#__PURE__*/React.createElement(View, {
      style: {
        marginHorizontal: 25,
        marginVertical: 10
      }
    }, /*#__PURE__*/React.createElement(Text, {
      style: {
        color: '#000',
        fontSize: 16,
        paddingBottom: 10
      }
    }, i18n.t('mobileno')), /*#__PURE__*/React.createElement(View, {
      style: {
        flexDirection: 'row'
      }
    }, /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.15,
        alignItems: 'center',
        justifyContent: 'center',
        backgroundColor: 'rgba(0, 0, 0, 0.1)',
        borderTopLeftRadius: 10,
        borderBottomLeftRadius: 10
      }
    }, /*#__PURE__*/React.createElement(MaterialIcons, {
      name: "phone",
      size: 20,
      color: "black"
    })), /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.85,
        alignItems: 'center',
        justifyContent: 'center'
      }
    }, /*#__PURE__*/React.createElement(TextInput, {
      style: {
        height: 50,
        borderWidth: 1,
        borderColor: 'rgba(0, 0, 0, 0.1)',
        width: '100%',
        borderTopRightRadius: 10,
        borderBottomRightRadius: 10,
        backgroundColor: '#fff',
        paddingHorizontal: 15,
        fontSize: 16
      },
      placeholder: i18n.t('mobileno'),
      selectionColor: '#000',
      placeholderTextColor: "rgba(0, 0, 0, 0.5)",
      onChangeText: query => {
        this.setState({
          phone: query
        });
      },
      value: this.state.phone,
      maxLength: 10,
      keyboardType: 'numeric'
    })))), /*#__PURE__*/React.createElement(View, {
      style: {
        marginHorizontal: 25,
        marginVertical: 10
      }
    }, /*#__PURE__*/React.createElement(Text, {
      style: {
        color: '#000',
        fontSize: 16,
        paddingBottom: 10
      }
    }, i18n.t('email')), /*#__PURE__*/React.createElement(View, {
      style: {
        flexDirection: 'row'
      }
    }, /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.15,
        alignItems: 'center',
        justifyContent: 'center',
        backgroundColor: 'rgba(0, 0, 0, 0.1)',
        borderTopLeftRadius: 10,
        borderBottomLeftRadius: 10
      }
    }, /*#__PURE__*/React.createElement(MaterialCommunityIcons, {
      name: "email-outline",
      size: 22,
      color: "black"
    })), /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.85,
        alignItems: 'center',
        justifyContent: 'center'
      }
    }, /*#__PURE__*/React.createElement(TextInput, {
      style: {
        height: 50,
        borderWidth: 1,
        borderColor: 'rgba(0, 0, 0, 0.1)',
        width: '100%',
        borderTopRightRadius: 10,
        borderBottomRightRadius: 10,
        backgroundColor: '#fff',
        paddingHorizontal: 15,
        fontSize: 16
      },
      placeholder: i18n.t('email'),
      selectionColor: '#000',
      placeholderTextColor: "rgba(0, 0, 0, 0.5)",
      onChangeText: query => {
        this.setState({
          email: query
        });
      },
      value: this.state.email
    })))), /*#__PURE__*/React.createElement(View, {
      style: {
        marginHorizontal: 25,
        marginVertical: 10
      }
    }, /*#__PURE__*/React.createElement(Text, {
      style: {
        color: '#000',
        fontSize: 16,
        paddingBottom: 10
      }
    }, i18n.t('company')), /*#__PURE__*/React.createElement(View, {
      style: {
        flexDirection: 'row'
      }
    }, /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.15,
        alignItems: 'center',
        justifyContent: 'center',
        backgroundColor: 'rgba(0, 0, 0, 0.1)',
        borderTopLeftRadius: 10,
        borderBottomLeftRadius: 10
      }
    }, /*#__PURE__*/React.createElement(FontAwesome5, {
      name: "building",
      size: 20,
      color: "black"
    })), /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.85,
        alignItems: 'center',
        justifyContent: 'center'
      }
    }, /*#__PURE__*/React.createElement(TextInput, {
      style: {
        height: 50,
        borderWidth: 1,
        borderColor: 'rgba(0, 0, 0, 0.1)',
        width: '100%',
        borderTopRightRadius: 10,
        borderBottomRightRadius: this.state.show && this.state.companyList.length > 0 ? 0 : 10,
        backgroundColor: '#fff',
        paddingHorizontal: 15,
        fontSize: 16
      },
      placeholder: i18n.t('company'),
      selectionColor: '#000',
      placeholderTextColor: "rgba(0, 0, 0, 0.5)",
      onChangeText: query => {
        this.getCompany(query);
      },
      value: this.state.companyName
    }))), /*#__PURE__*/React.createElement(View, {
      style: {
        flexDirection: 'row'
      }
    }, /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.15
      }
    }), /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.85
      }
    }, this.state.show && this.state.companyList.length > 0 && /*#__PURE__*/React.createElement(View, {
      style: {}
    }, /*#__PURE__*/React.createElement(View, {
      style: {}
    }, /*#__PURE__*/React.createElement(FlatList, {
      contentContainerStyle: {
        borderWidth: 1,
        borderColor: 'rgba(0, 0, 0, 0.1)',
        borderBottomLeftRadius: 5,
        borderBottomRightRadius: 5,
        borderTopWidth: 0
      },
      data: this.state.companyList,
      keyExtractor: (item, index) => index.toString(),
      renderItem: ({
        item,
        index
      }) => {
        return /*#__PURE__*/React.createElement(View, {
          style: {
            marginVertical: 0,
            backgroundColor: '#fff',
            borderRadius: 5,
            borderColor: '#f2f2f2',
            paddingHorizontal: 10,
            height: 40,
            justifyContent: 'center'
          }
        }, /*#__PURE__*/React.createElement(TouchableOpacity, {
          onPress: () => {
            this.setCompany(item);
          }
        }, /*#__PURE__*/React.createElement(View, {
          style: {}
        }, /*#__PURE__*/React.createElement(Text, {
          style: {
            color: '#000',
            fontSize: 16,
            fontWeight: '600'
          }
        }, item.name))));
      }
    })))))), /*#__PURE__*/React.createElement(View, {
      style: {
        marginHorizontal: 25,
        marginVertical: 10
      }
    }, /*#__PURE__*/React.createElement(Text, {
      style: {
        color: '#000',
        fontSize: 16,
        paddingBottom: 10
      }
    }, i18n.t('address')), /*#__PURE__*/React.createElement(View, {
      style: {
        flexDirection: 'row'
      }
    }, /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.15,
        alignItems: 'center',
        justifyContent: 'center',
        backgroundColor: 'rgba(0, 0, 0, 0.1)',
        borderTopLeftRadius: 10,
        borderBottomLeftRadius: 10
      }
    }, /*#__PURE__*/React.createElement(Octicons, {
      name: "location",
      size: 20,
      color: "black"
    })), /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.85,
        alignItems: 'center',
        justifyContent: 'center'
      }
    }, /*#__PURE__*/React.createElement(TextInput, {
      style: {
        height: 50,
        borderWidth: 1,
        borderColor: 'rgba(0, 0, 0, 0.1)',
        width: '100%',
        borderTopRightRadius: 10,
        borderBottomRightRadius: 10,
        backgroundColor: '#fff',
        paddingHorizontal: 15,
        fontSize: 16
      },
      placeholder: i18n.t('address'),
      selectionColor: '#000',
      placeholderTextColor: "rgba(0, 0, 0, 0.5)",
      onChangeText: query => {
        this.setState({
          location: query
        });
      },
      value: this.state.location
    })))), /*#__PURE__*/React.createElement(View, {
      style: {
        marginHorizontal: 25,
        marginVertical: 10
      }
    }, /*#__PURE__*/React.createElement(Text, {
      style: {
        color: '#000',
        fontSize: 16,
        paddingBottom: 10
      }
    }, i18n.t('pincode')), /*#__PURE__*/React.createElement(View, {
      style: {
        flexDirection: 'row'
      }
    }, /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.15,
        alignItems: 'center',
        justifyContent: 'center',
        backgroundColor: 'rgba(0, 0, 0, 0.1)',
        borderTopLeftRadius: 10,
        borderBottomLeftRadius: 10
      }
    }, /*#__PURE__*/React.createElement(Octicons, {
      name: "location",
      size: 20,
      color: "black"
    })), /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.85,
        alignItems: 'center',
        justifyContent: 'center'
      }
    }, /*#__PURE__*/React.createElement(TextInput, {
      style: {
        height: 50,
        borderWidth: 1,
        borderColor: 'rgba(0, 0, 0, 0.1)',
        width: '100%',
        borderTopRightRadius: 10,
        borderBottomRightRadius: 10,
        backgroundColor: '#fff',
        paddingHorizontal: 15,
        fontSize: 16
      },
      placeholder: i18n.t('pincode'),
      selectionColor: '#000',
      placeholderTextColor: "rgba(0, 0, 0, 0.5)",
      onChangeText: query => {
        this.getPincode(query);
      },
      value: typeof this.state.pincode == 'number' ? JSON.stringify(this.state.pincode) : this.state.pincode,
      keyboardType: 'numeric'
    })))), this.state.selectedPincode != null && /*#__PURE__*/React.createElement(View, {
      style: {
        marginHorizontal: 25,
        marginVertical: 15
      }
    }, /*#__PURE__*/React.createElement(Text, {
      style: {
        color: 'rgba(0, 0, 0, 0.7)',
        fontSize: 18
      }
    }, this.state.city, " ", this.state.state, " ", this.state.country)), /*#__PURE__*/React.createElement(View, {
      style: {
        flexDirection: 'row',
        marginHorizontal: 25,
        marginVertical: 15,
        marginBottom: 0,
        marginLeft: 10
      }
    }, /*#__PURE__*/React.createElement(CheckBox, {
      center: true,
      title: "SEZ Customer",
      containerStyle: {
        backgroundColor: '#f2f2f2',
        borderColor: '#f2f2f2',
        margin: 0,
        paddingVertical: 0
      },
      checked: this.state.isSez,
      checkedColor: 'green',
      onPress: () => this.setState({
        isSez: !this.state.isSez
      })
    })), /*#__PURE__*/React.createElement(TouchableOpacity, {
      style: {
        marginHorizontal: 25,
        paddingTop: 20,
        paddingBottom: this.state.showMore ? 10 : 60
      },
      onPress: () => {
        this.changeShowMore(this.state.showMore);
      }
    }, /*#__PURE__*/React.createElement(Text, {
      style: {
        color: '#306f8a',
        fontSize: 15
      }
    }, this.state.showMore ? i18n.t('showless') : i18n.t('showmore'))), this.state.showMore && /*#__PURE__*/React.createElement(View, {
      style: {
        paddingBottom: 60
      }
    }, /*#__PURE__*/React.createElement(View, {
      style: {
        marginHorizontal: 25,
        marginVertical: 10
      }
    }, /*#__PURE__*/React.createElement(Text, {
      style: {
        color: '#000',
        fontSize: 16,
        paddingBottom: 10
      }
    }, "GSTIN"), /*#__PURE__*/React.createElement(View, {
      style: {
        flexDirection: 'row'
      }
    }, /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.15,
        alignItems: 'center',
        justifyContent: 'center',
        backgroundColor: 'rgba(0, 0, 0, 0.1)',
        borderTopLeftRadius: 10,
        borderBottomLeftRadius: 10
      }
    }, /*#__PURE__*/React.createElement(AntDesign, {
      name: "paperclip",
      size: 20,
      color: "black"
    })), /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.85,
        alignItems: 'center',
        justifyContent: 'center'
      }
    }, /*#__PURE__*/React.createElement(TextInput, {
      style: {
        height: 50,
        borderWidth: 1,
        borderColor: 'rgba(0, 0, 0, 0.1)',
        width: '100%',
        borderTopRightRadius: 10,
        borderBottomRightRadius: 10,
        backgroundColor: '#fff',
        paddingHorizontal: 15,
        fontSize: 16
      },
      placeholder: "GSTIN",
      selectionColor: '#000',
      placeholderTextColor: "rgba(0, 0, 0, 0.5)",
      onChangeText: query => {
        this.setState({
          gstin: query
        });
      },
      value: this.state.gstin
    })))), /*#__PURE__*/React.createElement(View, {
      style: {
        marginHorizontal: 25,
        marginVertical: 10,
        marginBottom: 30
      }
    }, /*#__PURE__*/React.createElement(Text, {
      style: {
        color: '#000',
        fontSize: 16,
        paddingBottom: 10
      }
    }, i18n.t('designation')), /*#__PURE__*/React.createElement(View, {
      style: {
        flexDirection: 'row'
      }
    }, /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.15,
        alignItems: 'center',
        justifyContent: 'center',
        backgroundColor: 'rgba(0, 0, 0, 0.1)',
        borderTopLeftRadius: 10,
        borderBottomLeftRadius: 10
      }
    }, /*#__PURE__*/React.createElement(Entypo, {
      name: "briefcase",
      size: 20,
      color: "black"
    })), /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.85,
        alignItems: 'center',
        justifyContent: 'center'
      }
    }, /*#__PURE__*/React.createElement(TextInput, {
      style: {
        height: 50,
        borderWidth: 1,
        borderColor: 'rgba(0, 0, 0, 0.1)',
        width: '100%',
        borderTopRightRadius: 10,
        borderBottomRightRadius: 10,
        backgroundColor: '#fff',
        paddingHorizontal: 15,
        fontSize: 16
      },
      placeholder: i18n.t('designation'),
      selectionColor: '#000',
      placeholderTextColor: "rgba(0, 0, 0, 0.5)",
      onChangeText: query => {
        this.setState({
          designation: query
        });
      },
      value: this.state.designation
    })))))), this.state.newdoc && /*#__PURE__*/React.createElement(View, null, this.renderFooter())));
  }

}

ContactCreation.propTypes = { ...ViewPropTypes,
  url: PropTypes.string,
  redirect: PropTypes.bool,
  redirectPage: PropTypes.string,
  edit: PropTypes.bool,
  data: PropTypes.object,
  isCompany: PropTypes.bool
};
ContactCreation.defaultProps = {
  url: 'https://klouderp.com',
  redirect: true,
  redirectPage: 'ViewNewContract',
  edit: false,
  isCompany: false,
  data: null
};
const styles = StyleSheet.create({
  container: {
    flex: 1
  },
  shadow: {
    shadowColor: "#000",
    shadowOffset: {
      width: 0,
      height: 2
    },
    shadowOpacity: 0.25,
    shadowRadius: 3.84,
    elevation: 0,
    borderColor: '#fff'
  },
  center: {
    alignItems: 'center',
    justifyContent: 'center'
  },
  iconStyle: {
    width: width * 0.2,
    height: width * 0.15,
    resizeMode: 'contain'
  },
  iconContainer: {
    width: width * 0.3,
    height: width * 0.3,
    margin: 0,
    padding: 15,
    marginHorizontal: 0,
    borderRadius: 10
  },
  iconText: {
    fontWeight: '700',
    color: '#444',
    fontSize: 18,
    marginVertical: 5
  },
  modalViewUpdate: {
    backgroundColor: '#fff',
    marginHorizontal: width * 0.05,
    borderRadius: 5
  }
});
export default ContactCreation;