Commit da2e8427 authored by Trisno's avatar Trisno

logic remove voucher di shopping cart

parent 0cc3e4d5
...@@ -40,7 +40,8 @@ const ActionType = { ...@@ -40,7 +40,8 @@ const ActionType = {
SET_VOUCHER:'SET_VOUCHER', SET_VOUCHER:'SET_VOUCHER',
SET_EDIT_NOTE:'SET_EDIT_NOTE', SET_EDIT_NOTE:'SET_EDIT_NOTE',
SET_HOME_ADDRESS:'SET_HOME_ADDRESS', SET_HOME_ADDRESS:'SET_HOME_ADDRESS',
SET_REEDEM :'SET_REEDEM' SET_REEDEM :'SET_REEDEM',
REMOVE_VOUCHER : 'REMOVE_VOUCHER'
} }
export default ActionType; export default ActionType;
\ No newline at end of file
...@@ -576,6 +576,14 @@ const rootReducer = (state = globalState, action) => { ...@@ -576,6 +576,14 @@ const rootReducer = (state = globalState, action) => {
} }
} }
case ActionType.REMOVE_VOUCHER: {
return {
...state,
voucher: [],
value_voucher: ''
}
}
case ActionType.UPDATE_MENU: { case ActionType.UPDATE_MENU: {
const menu = action.data.menu; const menu = action.data.menu;
let total = 0 let total = 0
......
...@@ -116,7 +116,7 @@ class ShoppingCart extends React.Component { ...@@ -116,7 +116,7 @@ class ShoppingCart extends React.Component {
console.log(params); console.log(params);
} }
handleChangeVoucher() { handleRemoveVoucher() {
this.setState({ this.setState({
checkedBalance: false, checkedBalance: false,
checkedPoint: false, checkedPoint: false,
...@@ -124,7 +124,7 @@ class ShoppingCart extends React.Component { ...@@ -124,7 +124,7 @@ class ShoppingCart extends React.Component {
pointsused: 0, pointsused: 0,
balanceused: 0 balanceused: 0
}) })
this.props.navigation.navigate('Reward Select') this.props.removeVoucher()
} }
handleAddVoucher() { handleAddVoucher() {
...@@ -420,7 +420,7 @@ class ShoppingCart extends React.Component { ...@@ -420,7 +420,7 @@ class ShoppingCart extends React.Component {
render() { render() {
// console.log('496000'.replace(/,/g, '')) // console.log('496000'.replace(/,/g, ''))
// console.log(this.state.kasproBalance) // console.log(this.props)
// console.log(this.props.order_total) // console.log(this.props.order_total)
// console.log(this.props.order_item.length) // console.log(this.props.order_item.length)
return ( return (
...@@ -459,7 +459,7 @@ class ShoppingCart extends React.Component { ...@@ -459,7 +459,7 @@ class ShoppingCart extends React.Component {
</View> </View>
<View style={styles.header}> <View style={styles.header}>
<Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color: 'grey' }}>YOUR ORDER(S)</Text> <Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color: 'grey' }}>YOUR ORDER(S)</Text>
<TouchableOpacity style={{marginRight:-8}} onPress={() => this.props.navigation.goBack()}> <TouchableOpacity style={{ marginRight: -8 }} onPress={() => this.props.navigation.goBack()}>
<Text style={{ textAlign: 'center', fontSize: 12, color: '#CFB368', fontFamily: 'Gotham-Light' }}>+ ADD MORE</Text> <Text style={{ textAlign: 'center', fontSize: 12, color: '#CFB368', fontFamily: 'Gotham-Light' }}>+ ADD MORE</Text>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
...@@ -489,8 +489,8 @@ class ShoppingCart extends React.Component { ...@@ -489,8 +489,8 @@ class ShoppingCart extends React.Component {
<Text style={{ fontSize: 12, fontFamily: 'Gotham-Black', color: '#838383' }}>{this.props.voucher.reward.title}</Text> <Text style={{ fontSize: 12, fontFamily: 'Gotham-Black', color: '#838383' }}>{this.props.voucher.reward.title}</Text>
</View> </View>
<View style={{ flex: 0.5, alignItems: 'flex-end', marginRight: -5 }}> <View style={{ flex: 0.5, alignItems: 'flex-end', marginRight: -5 }}>
<TouchableOpacity onPress={() => this.handleChangeVoucher()}> <TouchableOpacity onPress={() => this.handleRemoveVoucher()}>
<Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: '#CFB368' }}>Change Voucher</Text> <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: '#CFB368' }}>Remove Voucher</Text>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
</View> </View>
...@@ -603,7 +603,7 @@ class ShoppingCart extends React.Component { ...@@ -603,7 +603,7 @@ class ShoppingCart extends React.Component {
</View> </View>
</Card> </Card>
</TouchableOpacity> </TouchableOpacity>
) : ( ) : (
<Card style={{ margin: 5, padding: 10, backgroundColor: 'gray' }}> <Card style={{ margin: 5, padding: 10, backgroundColor: 'gray' }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}> <View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
...@@ -653,7 +653,7 @@ class ShoppingCart extends React.Component { ...@@ -653,7 +653,7 @@ class ShoppingCart extends React.Component {
<View style={{ paddingLeft: 20 }}> <View style={{ paddingLeft: 20 }}>
<Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>Harga</Text> <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>Harga</Text>
</View> </View>
<View style={{ alignItems: 'flex-end', paddingRight:20 }}> <View style={{ alignItems: 'flex-end', paddingRight: 20 }}>
<NumberFormat decimalScale={0} value={this.props.order_total} renderText={value => <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>Rp. {value}</Text>} displayType={'text'} thousandSeparator={true} prefix={''} /> <NumberFormat decimalScale={0} value={this.props.order_total} renderText={value => <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>Rp. {value}</Text>} displayType={'text'} thousandSeparator={true} prefix={''} />
</View> </View>
</View> </View>
...@@ -670,7 +670,7 @@ class ShoppingCart extends React.Component { ...@@ -670,7 +670,7 @@ class ShoppingCart extends React.Component {
{/* <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>{this.props.grabamount}</Text> */} {/* <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>{this.props.grabamount}</Text> */}
<NumberFormat decimalScale={0} value={this.props.grabamount} renderText={value => <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>Rp. {value}</Text>} displayType={'text'} thousandSeparator={true} prefix={''} /> <NumberFormat decimalScale={0} value={this.props.grabamount} renderText={value => <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>Rp. {value}</Text>} displayType={'text'} thousandSeparator={true} prefix={''} />
</View> </View>
) : (<View style={{ paddingRight:20, paddingTop: 5, alignItems: 'flex-end' }}> ) : (<View style={{ paddingRight: 20, paddingTop: 5, alignItems: 'flex-end' }}>
<NumberFormat decimalScale={0} value={0} renderText={value => <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>Rp. {value}</Text>} displayType={'text'} thousandSeparator={true} prefix={''} /> <NumberFormat decimalScale={0} value={0} renderText={value => <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>Rp. {value}</Text>} displayType={'text'} thousandSeparator={true} prefix={''} />
</View>)} </View>)}
</View>)} </View>)}
...@@ -683,7 +683,7 @@ class ShoppingCart extends React.Component { ...@@ -683,7 +683,7 @@ class ShoppingCart extends React.Component {
<View style={{ paddingLeft: 20, paddingTop: 5, }}> <View style={{ paddingLeft: 20, paddingTop: 5, }}>
<Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>Diskon</Text> <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>Diskon</Text>
</View> </View>
<View style={{ paddingRight:20, paddingTop: 5, alignItems: 'flex-end' }}> <View style={{ paddingRight: 20, paddingTop: 5, alignItems: 'flex-end' }}>
<NumberFormat decimalScale={0} value={this.props.voucher.reward.value} renderText={value => <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>Rp. {value}</Text>} displayType={'text'} thousandSeparator={true} prefix={''} /> <NumberFormat decimalScale={0} value={this.props.voucher.reward.value} renderText={value => <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'gray' }}>Rp. {value}</Text>} displayType={'text'} thousandSeparator={true} prefix={''} />
</View> </View>
</View> </View>
...@@ -691,12 +691,12 @@ class ShoppingCart extends React.Component { ...@@ -691,12 +691,12 @@ class ShoppingCart extends React.Component {
) )
} }
<View style={{ flexDirection: 'row', justifyContent: 'space-between'}}> <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
<View style={{ marginTop: 10, paddingLeft: 20 }}> <View style={{ marginTop: 10, paddingLeft: 20 }}>
<Text style={{ fontSize: 20, color: '#CFB368', fontFamily: 'Gotham-Black', }}>TOTAL</Text> <Text style={{ fontSize: 20, color: '#CFB368', fontFamily: 'Gotham-Black', }}>TOTAL</Text>
</View> </View>
{this.props.type_pickup == true ? ( {this.props.type_pickup == true ? (
<View style={{ marginTop: 10, paddingRight:20, alignItems: 'flex-end' }}> <View style={{ marginTop: 10, paddingRight: 20, alignItems: 'flex-end' }}>
{ {
this.props.value_voucher == '' ? ( this.props.value_voucher == '' ? (
<NumberFormat decimalScale={0} value={this.props.order_total} renderText={value => <Text style={{ fontSize: 20, color: '#CFB368', fontFamily: 'Gotham-Black' }}>Rp. {value}</Text>} displayType={'text'} thousandSeparator={true} prefix={''} /> <NumberFormat decimalScale={0} value={this.props.order_total} renderText={value => <Text style={{ fontSize: 20, color: '#CFB368', fontFamily: 'Gotham-Black' }}>Rp. {value}</Text>} displayType={'text'} thousandSeparator={true} prefix={''} />
...@@ -832,7 +832,7 @@ const styles = StyleSheet.create({ ...@@ -832,7 +832,7 @@ const styles = StyleSheet.create({
marginVertical: 25, marginVertical: 25,
marginHorizontal: 30, marginHorizontal: 30,
borderRadius: 10, borderRadius: 10,
height:40, height: 40,
alignItems: 'center', alignItems: 'center',
justifyContent: 'center' justifyContent: 'center'
}, },
...@@ -980,6 +980,9 @@ const mapDispatchToProps = (dispacth) => { ...@@ -980,6 +980,9 @@ const mapDispatchToProps = (dispacth) => {
} }
}), }),
removeVoucher: () => dispacth({
type: ActionType.REMOVE_VOUCHER
}),
} }
} }
......
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