import React, { Component } from "react";
import { StyleSheet, View, Text, TouchableOpacity, Image, Button, LogBox, StatusBar } from "react-native";
import { TextInput, HelperText } from 'react-native-paper';
import Colors from './Colors';
import { SCREEN_WIDTH, SCREEN_HEIGHT } from "../common/Constants";
import { getDocumentLast } from './Services/DocumentLast';

const car = require('./Image/car.png');

const thumbs_up = require('./Image/thumbs_up.png');

const checkmark = require('./Image/checkmark.png');

const support = require('./Image/support.png');

import { thank_you, your_preins_apprvd, preinsp_com_will_update, DIRECT_PORTAL_AGENTCODE, super_thank_you } from './Constants';
export default class Success extends Component {
  constructor(props) {
    super(props);
    this.state = {
      documentLastData: "",
      thankYou: "",
      message: ""
    };
  }

  componentDidMount() {
    this.documentLast();
    this.renderDataToScreen();
  }

  renderDataToScreen() {
    const {
      details: approved,
      agentCode: agentCode
    } = this.state.documentLastData;
    console.log("    *********************          ", approved, agentCode);

    if (approved != null) {
      if (approved.toUpperCase() == "UPDATE") {
        if (agentCode != undefined) {
          if (agentCode == DIRECT_PORTAL_AGENTCODE) {
            this.setState({
              thankYou: super_thank_you,
              message: your_preins_apprvd
            });
          }
        } else {
          this.setState({
            thankYou: super_thank_you,
            message: your_preins_apprvd
          });
        }
      } else {
        this.setState({
          thankYou: thank_you,
          message: preinsp_com_will_update
        });
      }
    } else {
      this.setState({
        thankYou: thank_you,
        message: preinsp_com_will_update
      });
    }
  }

  async documentLast() {
    getDocumentLast({
      body: {
        "activityId": this.props.screenProps.activityId,
        "isLast": true,
        "source": "DIGITEDGE"
      }
    }).then(data => {
      this.setState({
        documentLastData: data
      });
    });
    console.log(':>>>>>>>>>>>>>>>>>>>>             >>>>>>>>>>>> ', this.state.documentLastData);
  }

  thankYouScreens() {
    return /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 1
      }
    }, /*#__PURE__*/React.createElement(View, {
      style: styles.SuccessTextView
    }, /*#__PURE__*/React.createElement(Text, {
      style: styles.superTextStyle
    }, thankYou), /*#__PURE__*/React.createElement(Text, {
      style: {
        marginLeft: 16,
        fontFamily: 'Muli-Regular',
        fontSize: 16
      }
    }, message), /*#__PURE__*/React.createElement(View, {
      style: styles.inspectTextView
    }, /*#__PURE__*/React.createElement(TouchableOpacity, {
      onPress: () => this.props.navigation.navigate("PI")
    }, /*#__PURE__*/React.createElement(Text, {
      style: {
        fontSize: 20,
        fontFamily: 'Muli-Regular',
        color: Colors.digitYellow
      }
    }, "Inspect Another Vechicle")))), /*#__PURE__*/React.createElement(View, {
      style: styles.SuccessImageView
    }, /*#__PURE__*/React.createElement(Image, {
      source: car,
      style: {
        alignSelf: 'center',
        width: SCREEN_WIDTH,
        resizeMode: 'contain',
        height: SCREEN_HEIGHT / 3
      }
    })));
  }

  render() {
    const {
      thankYou,
      message
    } = this.state;
    return /*#__PURE__*/React.createElement(View, {
      style: styles.main
    }, /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.45
      }
    }, /*#__PURE__*/React.createElement(View, {
      style: {
        flexDirection: "row",
        flex: 1,
        marginLeft: 16
      }
    }, /*#__PURE__*/React.createElement(View, {
      style: {
        alignSelf: "flex-end"
      }
    }, /*#__PURE__*/React.createElement(Image, {
      source: thumbs_up,
      style: {
        width: 90,
        height: 90
      }
    }), /*#__PURE__*/React.createElement(Text, {
      style: styles.superTextStyle
    }, thankYou)))), /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.15
      }
    }, /*#__PURE__*/React.createElement(View, {
      style: {
        flexDirection: "row",
        flex: 1,
        marginLeft: 16,
        marginRight: 16
      }
    }, /*#__PURE__*/React.createElement(Image, {
      source: checkmark,
      style: {
        width: 50,
        height: 50,
        alignSelf: 'center'
      }
    }), /*#__PURE__*/React.createElement(Text, {
      style: styles.subTextStyle
    }, message))), /*#__PURE__*/React.createElement(View, {
      style: {
        flex: 0.4,
        flexDirection: 'row'
      }
    }, /*#__PURE__*/React.createElement(View, {
      style: {
        alignSelf: 'flex-end',
        flex: 1,
        marginBottom: 8,
        minHeight: 40,
        maxHeight: 50,
        flexDirection: 'row'
      }
    }, /*#__PURE__*/React.createElement(Image, {
      source: support,
      style: {
        width: 40,
        height: 40,
        alignSelf: 'center',
        marginLeft: 16
      }
    }), /*#__PURE__*/React.createElement(Text, {
      style: styles.subTextStyle
    }, "1800-258-5956"))));
  }

}
const styles = StyleSheet.create({
  main: {
    flex: 1 // backgroundColor: Colors.white,

  },
  SuccessTextView: {
    flex: 0.7,
    justifyContent: 'center'
  },
  SuccessImageView: {
    flex: 0.3
  },
  superTextStyle: {
    marginLeft: 16,
    fontSize: 20,
    fontFamily: 'Muli-Bold',
    alignSelf: 'center',
    marginRight: 16
  },
  subTextStyle: {
    marginLeft: 16,
    fontSize: 18,
    fontFamily: 'Muli-Regular',
    alignSelf: 'center'
  },
  inspectTextView: {
    marginTop: 22,
    alignSelf: 'center'
  },
  SuccessImageView: {
    flex: 0.5,
    justifyContent: 'flex-end'
  }
});
//# sourceMappingURL=Success.js.map