import React, {Component} from 'react'
import { getRewardTermAndCondition } from '../../api/UserApi'
import LinearGradient from "react-native-linear-gradient";
import {BackgroundImage} from "../../components/BackgroundImage";
import { View, Text, ScrollView } from 'react-native'
import {Card} from 'native-base';
import { BackgroundImage_RegisterForm } from '../../components/BackgroundImage_RegisterForm'

class RewardTermCondition extends Component {
  constructor(props){
    super(props)
    this.state = {
      term_condition: ''
    }
  }

  componentDidMount() {
    this.getTerm()
  }

  getTerm = () => {
    let reward_id = this.props.navigation.state.params.id;
    getRewardTermAndCondition(reward_id)
      .then(res => {
        if(res.data && res.data.success){
          this.setState({
            term_condition: res.data.massage
          })
        }
      })
  }

  render() {
    return (
      <LinearGradient colors={['#3AA40C', '#2C7C0B']} style={{
        flex: 1,
        width: null,
        height: null,
        resizeMode: 'cover'
      }}>
        <BackgroundImage>
          
            <ScrollView showsVerticalScrollIndicator={false}
                        scrollEventThrottle={16}
                        style={{padding: 20}}
              >
                <Card style={{ borderRadius: 5, backgroundColor: '#00420A', borderColor: 'rbga(0,0,0,0)', flex: 1, padding: 15}}>
                  <BackgroundImage_RegisterForm>
                      {
                        this.state.term_condition && this.state.term_condition.length > 0 ?
                        this.state.term_condition.map((item) => (
                            <Text style={{color: 'white', fontSize: 16, marginBottom: 10, fontFamily: 'Prompt-Regular'}}>{item}</Text>
                        ))

                        : <View></View>
                      }
                  </BackgroundImage_RegisterForm>
                </Card>
              </ScrollView>
        </BackgroundImage>
      </LinearGradient>
    )
  }

}

export default RewardTermCondition;