import React, {Component} from 'react'
import {Linking, View} from "react-native";
import {WebView} from "react-native-webview";
import Config from "../../utils/Config";
import { connect } from "react-redux";

class RoomReservationWebView extends Component {
  constructor(props) {
    super(props);

  }

  render() {
    let source_webview = {
      baseUrl: '',
      // uri: `${Config.API_BASE_URL_POWER_CONDO_PROD}/online-booking?token=${this.props.token}`
      uri: `${this.props.server_mode === 'production' ? Config.API_BASE_URL_POWER_CONDO_PROD : Config.API_BASE_URL_POWER_CONDO_DEV}/online-booking?token=${this.props.token}`
    };

    return (
      <View style={{flex: 1}}>
          <WebView style={{ backgroundColor: 'white' , flex: 1}}
                  originWhitelist={['*']}
                  source={source_webview}
                  ref={(ref) => { this.webview = ref; }}
                  javaScriptEnabled={true}
                  domStorageEnabled={true}
          />
      </View>
    )
  }
}

const mapStateToProps = state => {
  return {
    token: state.app.token,
    server_mode: state.app.server_mode
  }
}

export default connect(mapStateToProps)(RoomReservationWebView)
