Commit e06d0bfb authored by Deni Rinaldi's avatar Deni Rinaldi

wallet

parent 0b574058
...@@ -101,14 +101,14 @@ class HomePageScreen extends Component { ...@@ -101,14 +101,14 @@ class HomePageScreen extends Component {
<TouchableOpacity style={{ alignItems: 'center', flexDirection: 'column', paddingTop: 5, marginLeft: 25 }} <TouchableOpacity style={{ alignItems: 'center', flexDirection: 'column', paddingTop: 5, marginLeft: 25 }}
onPress={() => { onPress={() => {
this.toggleOpen() this.toggleOpen()
this.props.navigation.navigate('RewardScreen')}}> this.state.user == null? this.handleLogin() : this.props.navigation.navigate('RewardScreen')}}>
<Image source={Images.icon_rewards} style={{ width: 25, height: 25 }} /> <Image source={Images.icon_rewards} style={{ width: 25, height: 25 }} />
<BaseText type={"regular"} text={'Kupon & Rewards'} style={{ fontSize: 9, marginTop: 5 }} /> <BaseText type={"regular"} text={'Kupon & Rewards'} style={{ fontSize: 9, marginTop: 5 }} />
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity style={{ alignItems: 'center', flexDirection: 'column', paddingTop: 9, marginLeft: 25 }} <TouchableOpacity style={{ alignItems: 'center', flexDirection: 'column', paddingTop: 9, marginLeft: 25 }}
onPress={() => { onPress={() => {
this.toggleOpen() this.toggleOpen()
this.props.navigation.navigate('RewardScreen', { intent: 'Dompet' })}}> this.state.user == null? this.handleLogin() : this.props.navigation.navigate('RewardScreen', { intent: 'Dompet' })}}>
<Image source={Images.icon_dompetsaya} style={{ width: 25, height: 20 }} /> <Image source={Images.icon_dompetsaya} style={{ width: 25, height: 20 }} />
<BaseText type={"regular"} text={'Dompet Saya'} style={{ fontSize: 9, marginTop: 5 }} /> <BaseText type={"regular"} text={'Dompet Saya'} style={{ fontSize: 9, marginTop: 5 }} />
</TouchableOpacity> </TouchableOpacity>
......
...@@ -127,7 +127,7 @@ class ListAddressScreen extends Component { ...@@ -127,7 +127,7 @@ class ListAddressScreen extends Component {
<BaseText type={"regular"} text={`${item.address}, ${item.kelurahan_name}, ${item.kecamatan_name}, ${item.kabupaten_kota_name}, ${item.provinsi_name} ${item.kode_pos}`} style={{ fontSize: 10, color: '#4b4b4b', marginTop: 5 }} /> <BaseText type={"regular"} text={`${item.address}, ${item.kelurahan_name}, ${item.kecamatan_name}, ${item.kabupaten_kota_name}, ${item.provinsi_name} ${item.kode_pos}`} style={{ fontSize: 10, color: '#4b4b4b', marginTop: 5 }} />
<View style={{ flexDirection: 'row', marginTop: 10, height: 20 }}> <View style={{ flexDirection: 'row', marginTop: 10, height: 20 }}>
<Image source={Images.map} style={{ height: 16, width: 12 }} /> <Image source={Images.map} style={{ height: 16, width: 12 }} />
<BaseText type={"regular"} text={item.lat == "" ? "Belum Pin point" : 'Sudah Pin Point'} style={{ fontSize: 10, color: '#4b4b4b', alignSelf: 'center', marginLeft: 10 }} /> <BaseText type={"regular"} text={item.lat == "" ? "Belum Pinpoint" : 'Sudah Pinpoint'} style={{ fontSize: 10, color: '#4b4b4b', alignSelf: 'center', marginLeft: 10 }} />
</View> </View>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', marginTop: 10 }}> <View style={{ flexDirection: 'row', justifyContent: 'space-between', marginTop: 10 }}>
{item.select_status == 0 ? <View /> : <View> {item.select_status == 0 ? <View /> : <View>
......
...@@ -12,6 +12,7 @@ import FontAwesome from 'react-native-vector-icons/FontAwesome' ...@@ -12,6 +12,7 @@ import FontAwesome from 'react-native-vector-icons/FontAwesome'
import { Images } from '../Themes'; import { Images } from '../Themes';
import Modal from 'react-native-modal'; import Modal from 'react-native-modal';
import BaseHeader from '../Components/BaseHeader'; import BaseHeader from '../Components/BaseHeader';
import Api from '../Services/Api';
const { StatusBarManager } = NativeModules; const { StatusBarManager } = NativeModules;
const STATUSBAR_HEIGHT = Platform.OS === 'ios' ? 20 : StatusBarManager.HEIGHT; const STATUSBAR_HEIGHT = Platform.OS === 'ios' ? 20 : StatusBarManager.HEIGHT;
...@@ -25,7 +26,10 @@ class RewardScreen extends Component { ...@@ -25,7 +26,10 @@ class RewardScreen extends Component {
open: false, open: false,
intent: "", intent: "",
modalIsiUlang: false, modalIsiUlang: false,
modalTopUp: false modalTopUp: false,
wallet: 0,
rewardPoint: 0,
amount: 0
} }
} }
backAction = () => { backAction = () => {
...@@ -101,6 +105,7 @@ class RewardScreen extends Component { ...@@ -101,6 +105,7 @@ class RewardScreen extends Component {
if (this.props.navigation.state.params) { if (this.props.navigation.state.params) {
if (this.props.navigation.state.params.intent == 'Dompet') { if (this.props.navigation.state.params.intent == 'Dompet') {
this.setState({ intent: 'Dompet' }) this.setState({ intent: 'Dompet' })
this.getWallet()
} else { } else {
this.setState({ intent: 'Rewards' }) this.setState({ intent: 'Rewards' })
} }
...@@ -113,6 +118,36 @@ class RewardScreen extends Component { ...@@ -113,6 +118,36 @@ class RewardScreen extends Component {
componentWillUnmount() { componentWillUnmount() {
BackHandler.removeEventListener("hardwareBackPress", this.backAction); BackHandler.removeEventListener("hardwareBackPress", this.backAction);
} }
getWallet() {
Api.create().getWallet().then(response => {
if (response.data.status == "success") {
this.setState({
wallet: response.data.data.wallet
})
}
})
}
topUpWallet() {
let body = {
"amount": this.state.amount,
"recharge_status": "success"
}
Api.create().topUpWallet(body).then(response => {
if (response.data.status == "success") {
this.getWallet()
}
})
}
number(num) {
var rupiah = '';
var angkarev = num.toString().split('').reverse().join('');
for (var i = 0; i < angkarev.length; i++) if (i % 3 == 0) rupiah += angkarev.substr(i, 3) + '.';
return 'Rp. ' + rupiah.split('', rupiah.length - 1).reverse().join('');
}
render() { render() {
return ( return (
<View style={{ backgroundColor: '#4cc9f0', flex: 1 }}> <View style={{ backgroundColor: '#4cc9f0', flex: 1 }}>
...@@ -132,12 +167,13 @@ class RewardScreen extends Component { ...@@ -132,12 +167,13 @@ class RewardScreen extends Component {
<BaseText type={"regular"} text={'Nominal Saldo'} style={{ fontSize: 12, marginLeft: 5, color: '#4b4b4b' }} /> <BaseText type={"regular"} text={'Nominal Saldo'} style={{ fontSize: 12, marginLeft: 5, color: '#4b4b4b' }} />
<TextInput <TextInput
placeholder={"Masukkan Nominal Angka Yang Akan Anda Isi"} placeholder={"Masukkan Nominal Angka Yang Akan Anda Isi"}
// editable={false} onChangeText={(amount) => this.setState({ amount })}
keyboardType={"number-pad"}
style={{ fontSize: 12 }} style={{ fontSize: 12 }}
maxLength={40} maxLength={40}
underlineColorAndroid={'#d8d8d8'} underlineColorAndroid={'#d8d8d8'}
/> />
<TouchableOpacity style={{ backgroundColor: '#4cc9f0', height: 45, borderRadius: 30, width: '100%', alignSelf: 'center', marginTop: 20 }} onPress={() => this.setState({ modalIsiUlang: false, modalTopUp: true })}> <TouchableOpacity style={{ backgroundColor: '#4cc9f0', height: 45, borderRadius: 30, width: '100%', alignSelf: 'center', marginTop: 20 }} onPress={() => this.setState({ modalIsiUlang: false }, () => this.topUpWallet())}>
<BaseText type={"regular"} text={'Lanjutkan'} style={{ fontSize: 16, textAlign: 'center', marginTop: 10, color: 'white' }} /> <BaseText type={"regular"} text={'Lanjutkan'} style={{ fontSize: 16, textAlign: 'center', marginTop: 10, color: 'white' }} />
</TouchableOpacity> </TouchableOpacity>
</View> </View>
...@@ -167,7 +203,7 @@ class RewardScreen extends Component { ...@@ -167,7 +203,7 @@ class RewardScreen extends Component {
<ScrollView style={{ backgroundColor: '#fff', borderTopRightRadius: 20, borderTopLeftRadius: 20 }} onScroll={this.handleScroll} showsVerticalScrollIndicator={false}> <ScrollView style={{ backgroundColor: '#fff', borderTopRightRadius: 20, borderTopLeftRadius: 20 }} onScroll={this.handleScroll} showsVerticalScrollIndicator={false}>
<Image source={this.state.intent == 'Dompet' ? Images.dompet : Images.reward} style={{ width: 100, height: 100, resizeMode: 'contain', marginTop: 50, alignSelf: 'center' }} /> <Image source={this.state.intent == 'Dompet' ? Images.dompet : Images.reward} style={{ width: 100, height: 100, resizeMode: 'contain', marginTop: 50, alignSelf: 'center' }} />
<BaseText type={"bold"} text={this.state.intent == 'Dompet' ? 'Sisa Saldo Dompet Saya' : 'Rewards Point'} style={{ fontSize: 16, textAlign: 'center', marginTop: 10 }} /> <BaseText type={"bold"} text={this.state.intent == 'Dompet' ? 'Sisa Saldo Dompet Saya' : 'Rewards Point'} style={{ fontSize: 16, textAlign: 'center', marginTop: 10 }} />
<BaseText type={"bold"} text={this.state.intent == 'Dompet' ? 'Rp. 2.500.000' : '0'} style={{ fontSize: 16, textAlign: 'center', marginTop: 10, color: '#4cc9f0' }} /> <BaseText type={"bold"} text={this.state.intent == 'Dompet' ? this.number(this.state.wallet) : String(this.state.rewardPoint)} style={{ fontSize: 16, textAlign: 'center', marginTop: 10, color: '#4cc9f0' }} />
{this.state.intent == 'Dompet' ? {this.state.intent == 'Dompet' ?
<TouchableOpacity style={{ backgroundColor: '#4cc9f0', height: 45, borderRadius: 30, width: '80%', alignSelf: 'center', marginTop: 30 }} onPress={() => this.setState({ modalIsiUlang: true })}> <TouchableOpacity style={{ backgroundColor: '#4cc9f0', height: 45, borderRadius: 30, width: '80%', alignSelf: 'center', marginTop: 30 }} onPress={() => this.setState({ modalIsiUlang: true })}>
<BaseText type={"regular"} text={'Isi Ulang Saldo'} style={{ fontSize: 16, textAlign: 'center', marginTop: 10, color: 'white' }} /> <BaseText type={"regular"} text={'Isi Ulang Saldo'} style={{ fontSize: 16, textAlign: 'center', marginTop: 10, color: 'white' }} />
......
...@@ -72,6 +72,8 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => { ...@@ -72,6 +72,8 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => {
const editProfile = (body) => api.post('edit_profile', body) const editProfile = (body) => api.post('edit_profile', body)
const editPhotoProfile = (body) => api.post('edit_photo', body) const editPhotoProfile = (body) => api.post('edit_photo', body)
const getDealOfTheDay = () => api.get('get_deal_of_the_day') const getDealOfTheDay = () => api.get('get_deal_of_the_day')
const getWallet = () => api.get('get_wallet')
const topUpWallet = (body) => api.post('topup_wallet', body)
// Wishlist // Wishlist
const getWhislist = (body) => api.post('get_wishlist', body) const getWhislist = (body) => api.post('get_wishlist', body)
...@@ -82,13 +84,13 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => { ...@@ -82,13 +84,13 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => {
// Address // Address
const getAddress = () => api.get('get_address') const getAddress = () => api.get('get_address')
const getProvinsi = () => api.get('get_province') const getProvinsi = () => api.get('get_province')
const getKota = (body) => api.get('get_kab_kot/' + body) const getKota = (provID) => api.get(`get_kab_kot/${provID}`)
const getKecamatan = (body) => api.get('get_kecamatan/' + body) const getKecamatan = (kabKotID) => api.get(`get_kecamatan/${kabKotID}`)
const getKelurahan = (body) => api.get('get_kelurahan/' + body) const getKelurahan = (kecID) => api.get(`get_kelurahan/${kecID}`)
const getKodePos = (body) => api.get('get_kode_pos/' + body) const getKodePos = (kelID) => api.get(`get_kode_pos/${kelID}`)
const addAddress = (body) => api.post('add_address/', body) const addAddress = (body) => api.post('add_address/', body)
const editAddress = (body) => api.post('edit_address/', body) const editAddress = (body) => api.post('edit_address/', body)
const deleteAddress = (body) => api.post('delete_address/' + body) const deleteAddress = (body) => api.post(`delete_address/${body}`)
const selectAddress = (body) => api.post('select_address', body) const selectAddress = (body) => api.post('select_address', body)
// Cart // Cart
...@@ -167,6 +169,8 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => { ...@@ -167,6 +169,8 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => {
getDealOfTheDay, getDealOfTheDay,
deleteAddress, deleteAddress,
selectAddress, selectAddress,
getWallet,
topUpWallet,
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment