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) => {
// ini kalau sudah ada diupdate
if (!isNaN(parseInt(new_quantity))) {
console.log('Number : ' + parseInt(new_quantity))
exist = false
for (let i = 0; i < state.order_item.length; i++) {
const row = state.order_item[i];
......@@ -616,31 +617,42 @@ const rootReducer = (state = globalState, action) => {
exist = true
}
quantity += parseInt(row.quantity)
total += parseInt(row.price) * parseInt(row.quantity)
if (row.quantity != 0) {
if (row.quantity > 0) {
quantity += parseInt(row.quantity)
total += parseInt(row.price) * parseInt(row.quantity)
list_item.push(row)
}
}
// kalo belum ada
if (!exist) {
list_item.push(item)
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)
}
}
for (let i = 0; i < state.menu_item.length; i++) {
const row = state.menu_item[i];
console.log('MENU : ' + JSON.stringify(row))
// cari sudah ada belum di redux
let is_xist = list_item.find(it => it.id == row.id)
if (is_xist) {
row['qty'] = is_xist.quantity
row['qty'] = is_xist.quantity
} 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)
}
return {
......
......@@ -46,6 +46,8 @@ import MenuDetail from './MenuDetail';
import OrderHistory from './OrderHistory';
import OrderDetail from './OrderDetail';
import RewardsList from './RewardsList'
import RewardDetail from './RewardDetail';
enableScreens();
......@@ -192,6 +194,7 @@ class Auth extends React.Component {
<Stack.Screen name="Date Time" component={DateTime} />
<Stack.Screen name="New Register" component={NewRegister} />
<Stack.Screen name="TopUpInfo" component={TopUpInfo} />
<Stack.Screen name="Reward Detail" component={RewardDetail} />
</Stack.Navigator>
)
}
......
......@@ -5,7 +5,8 @@ import ActionType from '../redux/globalActionType';
class Item extends React.Component {
handleChangeQuantity = (item, quantity) => {
handleChangeQuantity = (item, qty) => {
this.props.onChange()
const order_item = {
id: item.id,
code: item.code,
......@@ -15,7 +16,7 @@ class Item extends React.Component {
image: item.image,
price: parseInt(item.price),
}
this.props.changeQuantity({ item: order_item, quantity: quantity })
this.props.changeQuantity({ item: order_item, quantity: qty })
}
render() {
......
......@@ -245,6 +245,11 @@ class MenuSelection extends React.Component {
}
}
onChange(params){
console.log(params);
}
handleMin(item, index) {
const list_order_item = this.props.order_item;
let is_xist = list_order_item.find(row => row.id == item.id)
......@@ -294,6 +299,7 @@ class MenuSelection extends React.Component {
item={item}
handleAdd={() => this.handleAdd(item, index)}
handleMin={() => this.handleMin(item, index)}
onChange={()=> this.onChange(item,index)}
/>
)}
keyExtractor={item => item.id}
......@@ -307,7 +313,10 @@ class MenuSelection extends React.Component {
<View style={{ flexDirection: 'row', }}>
<Text style={{ fontSize: 12, margin: 10 }}> Price Estimation / Item {this.props.order_quantity} </Text>
<Text style={{ fontSize: 12, margin: 10 }}> Ongkir {this.props.grabamount} </Text>
{this.props.type_pickup == true ? (null) : (
<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>
</View>
......@@ -348,6 +357,7 @@ const styles = StyleSheet.create({
const mapStateToProps = (state) => {
return {
type_pickup: state.type_pickup,
session_id: state.session_id,
grabamount: state.grabamount,
outlet_id: state.outlet_id,
......@@ -387,6 +397,7 @@ const mapDispatchToProps = (dispacth) => {
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