WithdrawView.js 1.52 KB
Newer Older
Giang Tran committed
1 2 3
import React, {useEffect, useState} from 'react';
import {View, Text, StyleSheet, FlatList, Platform, Alert} from 'react-native';
import R from '../../../assets/R';
Giang Tran committed
4
import HeaderBack from '../../../components/Header/HeaderBack';
Giang Tran committed
5 6 7
import Item from './Item';
import {getListWidthDraw} from '../../../apis/Functions/Widthdraw';
import {connect} from 'react-redux';
Giang Tran committed
8
import I18n from '../../../helper/i18/i18n';
Giang Tran committed
9
import {showAlert, TYPE} from '../../../components/DropdownAlert';
Giang Tran committed
10

Giang Tran committed
11
const WithdrawView = (props) => {
Giang Tran committed
12 13 14 15 16 17 18 19 20 21 22 23 24
  const [data, setData] = useState([]);

  useEffect(() => {
    getData();
  }, []);

  const getData = async () => {
    const res = await getListWidthDraw({
      platform: Platform.OS,
    });
    if (res.data.code == 200 && res.data.data) {
      setData(res.data.data);
    } else {
Giang Tran committed
25
      showAlert(TYPE.ERROR, I18n.t('Notification'), I18n.t('Can_not_get_data'));
Giang Tran committed
26 27 28
    }
  };

Giang Tran committed
29
  return (
Giang Tran committed
30
    <View style={{flex: 1}}>
Giang Tran committed
31
      <HeaderBack title={'SelectPaymentMethod'} />
Giang Tran committed
32 33 34 35 36 37 38 39 40 41 42 43
      <View style={{flex: 1}}>
        <FlatList
          keyExtractor={(item) => item.id}
          showsVerticalScrollIndicator={false}
          numColumns={2}
          columnWrapperStyle={{
            marginHorizontal: 20,
            justifyContent: 'space-between',
          }}
          data={data}
          renderItem={({item}) => <Item userId={props.user.uid} item={item} />}
        />
Giang Tran committed
44
      </View>
Giang Tran committed
45 46 47 48
    </View>
  );
};

Giang Tran committed
49 50 51 52 53 54
const mapStateToProps = (state) => {
  return {
    user: state.userReducer,
  };
};
export default connect(mapStateToProps, {})(WithdrawView);