Commit 8509f180 authored by Trisno's avatar Trisno

Merge branch 'master' of ssh://repo.cs.co.id:2222/wahyu/bahanoprek

# Conflicts:
#	view/Auth.js
parents 111cb9cc 0594aa98
...@@ -606,6 +606,7 @@ const rootReducer = (state = globalState, action) => { ...@@ -606,6 +606,7 @@ const rootReducer = (state = globalState, action) => {
// ini kalau sudah ada diupdate // ini kalau sudah ada diupdate
if (!isNaN(parseInt(new_quantity))) { if (!isNaN(parseInt(new_quantity))) {
console.log('Number : ' + parseInt(new_quantity))
exist = false exist = false
for (let i = 0; i < state.order_item.length; i++) { for (let i = 0; i < state.order_item.length; i++) {
const row = state.order_item[i]; const row = state.order_item[i];
...@@ -616,29 +617,40 @@ const rootReducer = (state = globalState, action) => { ...@@ -616,29 +617,40 @@ const rootReducer = (state = globalState, action) => {
exist = true exist = true
} }
if (row.quantity > 0) {
quantity += parseInt(row.quantity) quantity += parseInt(row.quantity)
total += parseInt(row.price) * parseInt(row.quantity) total += parseInt(row.price) * parseInt(row.quantity)
if (row.quantity != 0) {
list_item.push(row) list_item.push(row)
} }
} }
// kalo belum ada // kalo belum ada
if (!exist) { if (!exist) {
item.quantity = parseInt(new_quantity)
if (item.quantity < 0) {
item.quantity = 0
}
console.log('sama sekali blm ada : ' + JSON.stringify(item))
if (item.quantity > 0) {
quantity += parseInt(item.quantity)
total += parseInt(item.price) * parseInt(item.quantity)
list_item.push(item) list_item.push(item)
} }
}
for (let i = 0; i < state.menu_item.length; i++) { for (let i = 0; i < state.menu_item.length; i++) {
const row = state.menu_item[i]; const row = state.menu_item[i];
console.log('MENU : ' + JSON.stringify(row))
// cari sudah ada belum di redux // cari sudah ada belum di redux
let is_xist = list_item.find(it => it.id == row.id) let is_xist = list_item.find(it => it.id == row.id)
if (is_xist) { if (is_xist) {
row['qty'] = is_xist.quantity row['qty'] = is_xist.quantity
} else { } else {
row['qty'] = 0 console.log(parseInt(new_quantity))
if (parseInt(new_quantity) < 0) {
row.qty = 0
} else {
row.qty = 0
}
} }
list_menu.push(row) list_menu.push(row)
......
...@@ -46,6 +46,8 @@ import MenuDetail from './MenuDetail'; ...@@ -46,6 +46,8 @@ import MenuDetail from './MenuDetail';
import OrderHistory from './OrderHistory'; import OrderHistory from './OrderHistory';
import OrderDetail from './OrderDetail'; import OrderDetail from './OrderDetail';
import RewardsList from './RewardsList' import RewardsList from './RewardsList'
import RewardDetail from './RewardDetail';
enableScreens(); enableScreens();
...@@ -192,6 +194,7 @@ class Auth extends React.Component { ...@@ -192,6 +194,7 @@ class Auth extends React.Component {
<Stack.Screen name="Date Time" component={DateTime} /> <Stack.Screen name="Date Time" component={DateTime} />
<Stack.Screen name="New Register" component={NewRegister} /> <Stack.Screen name="New Register" component={NewRegister} />
<Stack.Screen name="TopUpInfo" component={TopUpInfo} /> <Stack.Screen name="TopUpInfo" component={TopUpInfo} />
<Stack.Screen name="Reward Detail" component={RewardDetail} />
</Stack.Navigator> </Stack.Navigator>
) )
} }
......
...@@ -5,7 +5,8 @@ import ActionType from '../redux/globalActionType'; ...@@ -5,7 +5,8 @@ import ActionType from '../redux/globalActionType';
class Item extends React.Component { class Item extends React.Component {
handleChangeQuantity = (item, quantity) => { handleChangeQuantity = (item, qty) => {
this.props.onChange()
const order_item = { const order_item = {
id: item.id, id: item.id,
code: item.code, code: item.code,
...@@ -15,7 +16,7 @@ class Item extends React.Component { ...@@ -15,7 +16,7 @@ class Item extends React.Component {
image: item.image, image: item.image,
price: parseInt(item.price), price: parseInt(item.price),
} }
this.props.changeQuantity({ item: order_item, quantity: quantity }) this.props.changeQuantity({ item: order_item, quantity: qty })
} }
render() { render() {
......
...@@ -245,6 +245,11 @@ class MenuSelection extends React.Component { ...@@ -245,6 +245,11 @@ class MenuSelection extends React.Component {
} }
} }
onChange(params){
console.log(params);
}
handleMin(item, index) { handleMin(item, index) {
const list_order_item = this.props.order_item; const list_order_item = this.props.order_item;
let is_xist = list_order_item.find(row => row.id == item.id) let is_xist = list_order_item.find(row => row.id == item.id)
...@@ -294,6 +299,7 @@ class MenuSelection extends React.Component { ...@@ -294,6 +299,7 @@ class MenuSelection extends React.Component {
item={item} item={item}
handleAdd={() => this.handleAdd(item, index)} handleAdd={() => this.handleAdd(item, index)}
handleMin={() => this.handleMin(item, index)} handleMin={() => this.handleMin(item, index)}
onChange={()=> this.onChange(item,index)}
/> />
)} )}
keyExtractor={item => item.id} keyExtractor={item => item.id}
...@@ -307,7 +313,10 @@ class MenuSelection extends React.Component { ...@@ -307,7 +313,10 @@ class MenuSelection extends React.Component {
<View style={{ flexDirection: 'row', }}> <View style={{ flexDirection: 'row', }}>
<Text style={{ fontSize: 12, margin: 10 }}> Price Estimation / Item {this.props.order_quantity} </Text> <Text style={{ fontSize: 12, margin: 10 }}> Price Estimation / Item {this.props.order_quantity} </Text>
{this.props.type_pickup == true ? (null) : (
<Text style={{ fontSize: 12, margin: 10 }}> Ongkir {this.props.grabamount} </Text> <Text style={{ fontSize: 12, margin: 10 }}> Ongkir {this.props.grabamount} </Text>
)}
<Text style={{ fontSize: 20, margin: 10, marginBottom: 10 }}> Rp. {this.props.order_total}</Text> <Text style={{ fontSize: 20, margin: 10, marginBottom: 10 }}> Rp. {this.props.order_total}</Text>
</View> </View>
...@@ -348,6 +357,7 @@ const styles = StyleSheet.create({ ...@@ -348,6 +357,7 @@ const styles = StyleSheet.create({
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
return { return {
type_pickup: state.type_pickup,
session_id: state.session_id, session_id: state.session_id,
grabamount: state.grabamount, grabamount: state.grabamount,
outlet_id: state.outlet_id, outlet_id: state.outlet_id,
...@@ -387,6 +397,7 @@ const mapDispatchToProps = (dispacth) => { ...@@ -387,6 +397,7 @@ const mapDispatchToProps = (dispacth) => {
name_outlet: OutletChange.name_outlet, name_outlet: OutletChange.name_outlet,
} }
}), }),
} }
} }
......
import React from 'react';
import { View, Text, TextInput, StyleSheet, ScrollView, Alert, TouchableOpacity, Image,Button } from 'react-native';
import { Card } from 'react-native-shadow-cards'
import { connect } from 'react-redux';
import Axios from 'axios';
import session from '../function/session';
import HTML from 'react-native-render-html';
class RewardDetail extends React.Component {
constructor(props) {
super(props)
this.state = {
image: '',
title: '',
subtitle: '',
deskripsi: '',
expire : ''
}
}
componentDidMount() {
this.detailReward()
}
detailReward() {
let params = {
session_id: this.props.session_id,
reward_id: "72770d93-ee13-451e-818b-60d55e9ea79e"
}
console.log(params);
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/reward/get_detail', params).then(res => {
this.setState({
image: res.data.reward.reward.content_image,
title: res.data.reward.reward.title,
subtitle: res.data.reward.reward.subtitle,
deskripsi: res.data.reward.reward.content,
expire: res.data.reward.expire_time,
})
// console.log("INI TITLE : " + JSON.stringify())
// console.log("INI SUBTITILE : " + JSON.stringify())
console.log("INI IMAGE : " + JSON.stringify())
// console.log("INI DESKRIPSI : " + JSON.stringify(res.data.reward.reward.subtitle))
})
}
render() {
return (
<View style={styles.container}>
<ScrollView style={styles.body}>
<View style={styles.body}>
{/* <View style={styles.images}> */}
<Image style={{ height: 250, width: '100%' }} source={this.state.image ? { uri: this.state.image } : null} />
{/* </View> */}
<View style={styles.content}>
<Text style={{margin:10 , textAlign:'center', fontWeight:'bold'}}>{this.state.title}</Text>
<Text style={{marginRight:10,marginLeft:10}}>{this.state.deskripsi}</Text>
<Text style={{top:1 , textAlign:'center'}}>EXPIRE : {this.state.expire}</Text>
</View>
<View style={{margin:10}}>
<Button title="Validate" />
</View>
</View>
</ScrollView>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
},
header: {
flex: 0.5,
},
images: {
margin: 10,
flex: 2,
justifyContent: 'center',
},
content: {
flex: 2,
},
body: {
flex: 3,
},
})
const mapStateToProps = (state) => {
return {
session_id: state.session_id,
}
}
export default connect(mapStateToProps)(RewardDetail);
\ No newline at end of file
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