"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _react = _interopRequireWildcard(require("react"));

var _reactNative = require("react-native");

var _FontAwesome = _interopRequireDefault(require("react-native-vector-icons/FontAwesome"));

var _Colors = _interopRequireDefault(require("./Colors"));

var _ApiUrls = require("../Api/ApiUrls");

var _Constants = require("./Constants");

var _surveyInstructions = require("./Services/surveyInstructions");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

class QuoteInstructions extends _react.Component {
  constructor(props) {
    super(props);

    _defineProperty(this, "renderItem", ({
      item
    }) => {
      return /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: styles.instructionText
      }, '\u2022' + " ", " ", item.instructionData);
    });

    _defineProperty(this, "renderListHeader", () => {
      const {
        description
      } = this.state.instuctionData;
      return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          marginLeft: 16,
          marginBottom: 16
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: {
          fontFamily: 'Muli-Regular',
          fontSize: 16
        }
      }, description));
    });

    _defineProperty(this, "renderListFotter", () => {
      return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          flexDirection: 'row'
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
        style: {
          flex: 0.9,
          marginLeft: 16,
          backgroundColor: '#F5F5F5'
        }
      }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: {
          fontFamily: 'Muli-Regular',
          fontSize: 16,
          marginTop: 16,
          marginLeft: 16
        }
      }, "We need the following permission before you start clicking the images."), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: {
          fontFamily: 'Muli-Regular',
          fontSize: 16,
          marginLeft: 16
        }
      }, '\u2022', " Camera"), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: {
          fontFamily: 'Muli-Regular',
          fontSize: 16,
          marginLeft: 16
        }
      }, '\u2022', " Location"), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: {
          fontFamily: 'Muli-Regular',
          fontSize: 16,
          marginLeft: 16
        }
      }, '\u2022', " Gallery"), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: {
          fontFamily: 'Muli-Regular',
          fontSize: 16,
          marginBottom: 16,
          marginLeft: 16
        }
      }, "Don't warry - we wan't peep into your phone's data!")));
    });

    this.state = {
      instuctionData: "",
      surveyInstructions: ""
    };
  }

  componentDidMount() {
    this.surveyInstructions();
  }

  async surveyInstructions() {
    // this.instructionWebOrAndroid()
    const activityTypeId = this.props.screenProps.activityTypeId;
    let updatedActivityId = this.getActivityTypeIdIfSSL(activityTypeId);
    let requestType = updatedActivityId == 6 || updatedActivityId == 7 || updatedActivityId == 8 || updatedActivityId == 9 || updatedActivityId == 10 || updatedActivityId == 11 || updatedActivityId == 15 || updatedActivityId == 31 ? _Constants.WEB_REQUEST : _Constants.ANDROID_REQUEST;
    let typeNumber;

    if (requestType = _Constants.WEB_REQUEST) {
      typeNumber = 1;
    } else {
      typeNumber = 0;
    }

    let uri = _ApiUrls.SURVEY_INSTRUCTIONS + updatedActivityId + "?" + _Constants.WEB_REQUEST + typeNumber; //for geting Survey instructions

    (0, _surveyInstructions.getSurveyInstructions)({
      uri: uri
    }).then(instuctionData => {
      //sorting the instruction on basis of surveyInstructionsId
      let surveyInstructions = instuctionData.TSurveyInstructions.sort((a, b) => a.surveyInstructionsId > b.surveyInstructionsId);
      this.setState({
        instuctionData: instuctionData,
        surveyInstructions: surveyInstructions
      }); //   console.log('Survey instructions '+JSON.stringify(surveyInstructions));
    });
  }

  getActivityTypeIdIfSSL(activityTypeId) {
    if (activityTypeId == 50) {
      // Used for SSL deeplink / mapping given by Gowtham
      activityTypeId = 5;
    } else if (activityTypeId == 49) {
      activityTypeId = 26;
    } else if (activityTypeId == 51) {
      activityTypeId = 30;
    }

    return activityTypeId;
  } //flatList


  render() {
    const {
      title,
      description
    } = this.state.instuctionData;
    const {
      surveyInstructions
    } = this.state.surveyInstructions;
    const activityTypeId = this.props.screenProps.activityTypeId;
    return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        flex: 1,
        backgroundColor: '#FFFFFF'
      }
    }, /*#__PURE__*/_react.default.createElement(_reactNative.StatusBar, {
      hidden: true
    }), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        flex: 0.9
      }
    }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        width: _Constants.SCREEN_WIDTH,
        height: 70,
        backgroundColor: '#F5F5F5',
        justifyContent: 'center',
        marginBottom: 16
      }
    }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        flexDirection: 'row'
      }
    }, /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
      onPress: () => this.props.navigation.navigate("PI")
    }, /*#__PURE__*/_react.default.createElement(_FontAwesome.default, {
      name: "arrow-left",
      size: 25,
      style: {
        marginLeft: 16,
        marginRight: 16
      }
    }))), /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
      style: {
        fontFamily: 'Muli-Bold',
        fontSize: 20,
        marginLeft: 16
      }
    }, title)))), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        flex: 1
      }
    }, /*#__PURE__*/_react.default.createElement(_reactNative.FlatList, {
      data: this.state.surveyInstructions,
      renderItem: this.renderItem,
      ListHeaderComponent: this.renderListHeader,
      ListFooterComponent: this.renderListFotter,
      style: {
        fontFamily: 'Mulli-Regular'
      }
    }))), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        flex: 0.1,
        justifyContent: 'flex-end',
        marginBottom: 8
      }
    }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: {
        marginLeft: 16
      }
    }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, null, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: styles.captureImageButtonView
    }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
      style: styles.captureImageButtonText
    }, "Let's Get Started"))))));
  }

}

exports.default = QuoteInstructions;

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

  },
  captureImageButtonView: {
    height: 48,
    borderRadius: 4,
    backgroundColor: _Colors.default.digitYellow,
    marginTop: 2,
    flexDirection: 'row',
    justifyContent: 'center',
    marginRight: 16
  },
  captureImageButtonText: {
    fontSize: 16,
    fontFamily: 'Muli-Black',
    alignSelf: 'center'
  },
  instructionText: {
    fontFamily: 'Muli_Regular',
    fontSize: 16,
    marginBottom: 8,
    marginLeft: 16
  }
});
//# sourceMappingURL=QuoteInstructions.js.map