Commit 2c35da1c authored by Trisno's avatar Trisno

update shopping cart

parent 3b481e0a
......@@ -4,7 +4,7 @@ import { connect } from 'react-redux'
// import { CheckBox } from 'react-native-elements'
import CheckBox from 'react-native-check-box'
import { Card } from 'react-native-shadow-cards'
import { Ionicons, MaterialCommunityIcons, MaterialIcons, AntDesign, FontAwesome } from '@expo/vector-icons'
import { Entypo, Ionicons, MaterialCommunityIcons, MaterialIcons, AntDesign, FontAwesome } from '@expo/vector-icons'
import i18n from 'i18n-js';
import CurrencyFormat from 'react-currency-format';
import Axios from 'axios'
......@@ -20,6 +20,10 @@ class ShoppingCart extends React.Component {
checkedBalancePoint: false,
balanceused: 0,
pointsused: 0,
ongkir: 0,
diskon: 0,
isDelivery: false,
isPickUp: false
// dummyBalance : 155000,
// dummyPoint : 20000
}
......@@ -53,6 +57,24 @@ class ShoppingCart extends React.Component {
})
}
checkChangeTrans(val) {
console.log('hai lg di sini')
console.log(val)
if (val == 'delivery') {
this.setState({
isDelivery: true,
isPickUp: false
})
console.log('ini delivery')
} else {
this.setState({
isPickUp: true,
isDelivery: false
})
console.log('ini pickup')
}
}
checkedSelection(val) {
// console.log(val)
if (val == 'balance') {
......@@ -79,14 +101,14 @@ class ShoppingCart extends React.Component {
// balanceused : this.props.order_total - this.state.dummyPoint,
// pointsused : this.props.order_total,
})
if (this.state.kasproPoint - this.props.order_total >= -1 ) {
if (this.state.kasproPoint - this.props.order_total >= -1) {
this.setState({
pointsused: this.props.order_total
})
} else {
this.setState({
balanceused : this.props.order_total - this.state.kasproPoint,
pointsused : this.state.kasproPoint
balanceused: this.props.order_total - this.state.kasproPoint,
pointsused: this.state.kasproPoint
})
}
......@@ -124,20 +146,30 @@ class ShoppingCart extends React.Component {
return (
<ScrollView style={styles.container}>
<View style={{ flexDirection: 'row', justifyContent: 'center' }}>
<TouchableOpacity style={styles.buttonDelivery} >
<TouchableOpacity style={styles.buttonDelivery} onPress={() => this.checkChangeTrans('delivery')}>
<Text style={{ textAlign: 'center', color: '#354175', fontWeight: 'bold' }}>{i18n.t('delivery')}</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.buttonPickup} >
<TouchableOpacity style={styles.buttonPickup} onPress={() => this.checkChangeTrans('pickup')}>
<Text style={{ textAlign: 'center', color: '#fff', fontWeight: 'bold' }}>{i18n.t('pickup')}</Text>
</TouchableOpacity>
</View>
<View style={{ margin: 5 }}>
<Text style={{ textAlign: 'center', fontSize: 12, }}>
{i18n.t('orderInfo')}
</Text>
<Text style={{ textAlign: "center", fontSize: 12, top: 5 }}>
Excelso Senayan City
</Text>
<View style={{ alignItems: 'center' }}>
{
this.state.isDelivery == true ? (
<Card style={{ margin: 5, padding: 10 }}>
<Text style={{ textAlign: 'center' }}> Ambil pesanan kamu di</Text>
<Text style={{ textAlign: 'center' }}>{this.props.address}</Text>
</Card>
) : (
<Card style={{ margin: 5, padding: 10 }}>
<Text style={{ textAlign: 'center' }}> Pesanan kamu dikirim ke</Text>
<Text style={{ textAlign: 'center' }}>{this.props.address}</Text>
</Card>
)
}
</View>
<View style={styles.header}>
<Text style={{ textAlign: 'center', fontSize: 15 }}>YOUR ORDER(S)</Text>
......@@ -339,33 +371,31 @@ class ShoppingCart extends React.Component {
<View>
<Text style={{ paddingLeft: 20, paddingTop: 15, color: 'gray' }}>Harga</Text>
</View>
<View>
<Text style={{ paddingRight: 150, paddingTop: 15, color: 'gray' }}>{this.props.order_total}</Text>
<View style={{ paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}>
<Text style={{ color: 'gray' }}>{this.props.order_total}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}>
<View>
<Text style={{ paddingLeft: 20, paddingTop: 10, color: 'gray' }}>Ongkos Kirim</Text>
</View>
<View>
<Text style={{ paddingRight: 150, paddingTop: 10, color: 'gray' }}>undefined</Text>
<View style={{ paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}>
<Text style={{ color: 'gray' }}>{this.state.ongkir}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}>
<View>
<Text style={{ paddingLeft: 20, paddingTop: 10, color: 'gray' }}>Diskon</Text>
</View>
<View>
<Text style={{ paddingRight: 150, paddingTop: 10, color: 'gray' }}>undefined</Text>
<View style={{ paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}>
<Text style={{ color: 'gray' }}>{this.state.diskon}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}>
<View style={{ marginTop: 15, paddingLeft: 20, paddingTop: 10 }}>
<Text style={{ fontSize: 35, color: '#ccb46c' }}>Total</Text>
</View>
<View style={{ marginTop: 15, paddingRight: 60, paddingTop: 10 }}>
<View style={{ marginTop: 15, paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}>
<Text style={{ fontSize: 35, color: '#ccb46c' }}>{this.props.order_total}</Text>
</View>
</View>
......@@ -373,8 +403,8 @@ class ShoppingCart extends React.Component {
<View>
<Text style={{ paddingLeft: 20, paddingTop: 10, color: 'gray' }}>Tujuan</Text>
</View>
<View>
<Text style={{ color: '#ccb46c', paddingRight: 150, paddingTop: 10 }}>{this.props.address}</Text>
<View style={{ paddingRight: 30, paddingTop: 10, alignItems: 'flex-end' }}>
<Text style={{ color: '#ccb46c' }}>{this.props.address}</Text>
</View>
</View>
<View style={{ margin: 20, }}>
......
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