Commit 695c4393 authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

change menu selection

parent 6e3f99c0
......@@ -6,15 +6,10 @@ class ItemShoping extends React.Component {
render() {
const { item } = this.props
console.log("ini id itemnya "+item.id)
return (
<View style={{ flex: 1, margin: 10 }} key={item.id} ref={this.props._scrollView}>
<ScrollView ref={view => this._scrollView = view}>
{item.code == 'CATEGORY' ? (
<Text style={{ fontSize: 20, color: '#c9af6d' }}>{item.name}</Text>
): (
<View style={{ flex: 1, margin: 10 }} key={item.id}>
{/* <Text style={{ fontSize: 20, color: '#c9af6d' }}>{item.name}</Text> */}
<View style={{ flexDirection: 'row' }}>
<View >
<Image source={{ uri: item.image }} style={{ height: 100, width: 100, borderRadius: 5, top: 5 }}></Image>
......@@ -31,7 +26,7 @@ class ItemShoping extends React.Component {
<TextInput
style={{ height: 25, padding: 2, textAlign: 'center', margin: 2 }}
autoCapitalize="none">
{item.qty}
{item.quantity}
</TextInput>
<TouchableOpacity onPress={() => this.props.handleAdd()}>
<Text style={{ fontSize: 20, margin: 2 }}> + </Text>
......@@ -40,9 +35,6 @@ class ItemShoping extends React.Component {
</View>
</View>
</View>
)}
</ScrollView>
</View>
)
}
......@@ -111,4 +103,4 @@ const mapStateToProps = (state) => {
}
}
export default connect(mapStateToProps)(Item)
export default connect(mapStateToProps)(ItemShoping)
......@@ -5,9 +5,6 @@ import Item from './Item';
import { connect } from 'react-redux';
import ActionType from '../redux/globalActionType';
import CurrencyFormat from 'react-currency-format';
import Constants from "expo-constants";
import { Ionicons, MaterialCommunityIcons, MaterialIcons, AntDesign } from '@expo/vector-icons';
// import { range } from 'lodash';
import _ from 'lodash';
class MenuSelection extends React.Component {
......@@ -26,9 +23,6 @@ class MenuSelection extends React.Component {
}
componentDidMount() {
this.getMenuList()
// console.log("INI TOTAL ORDER : " + this.props.orders)
// console.log("INI TOTAL QTY :" + this.props.quantity)
console.log("INI OETLET :" + JSON.stringify(this.props.outlet_id))
}
getMenuList() {
......@@ -44,11 +38,9 @@ class MenuSelection extends React.Component {
listMenu: data.menu
})
let last_category = ''
let list_menu = []
for (let i = 0; i < data.menu.length; i++) {
const row = data.menu[i];
......@@ -74,11 +66,6 @@ class MenuSelection extends React.Component {
list_menu.push(row)
}
}
// this.state.listMenu.map((i => {
// i.qty = 0
// }))
console.log('After : ' + JSON.stringify(list_menu))
this.setState({
listMenu: list_menu
})
......@@ -116,47 +103,35 @@ class MenuSelection extends React.Component {
// }
scrollToItem = () => {
// let newData = []
// newData.push(this.state.listMenu)
// console.log("DATA " + JSON.stringify(newData))
// newData.map((item => {
// let abc = item[0].category
// }))
this.props._scrollView.scrollTo({ y: 1 * 100 });
}
handleAdd(item, index) {
console.log('TAMPILIN NIH')
const order_item = {
id: item.id,
code:item.code,
name: item.name,
description: item.description,
note:'jangan garing',
price: item.price,
image: item.image
}
this.props.addToChart(order_item)
// console.log("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 quantity = 0
// for (let i = 0; i < list_order_item.length; i++) {
// const row = list_order_item[i];
// if (row.id == item.id) {
// quantity = row.quantity
// }
// }
if (is_xist) {
quantity = is_xist.quantity
}
const listMenu = [...this.state.listMenu]
// console.log("INI COY YYYY QUANTITY " + quantity)
listMenu[index].qty = quantity
this.setState({
listMenu
......@@ -173,7 +148,6 @@ class MenuSelection extends React.Component {
id: item.id,
name: item.name,
price: item.price,
}
this.props.reduceQuantityItem(order_item)
}
......@@ -280,7 +254,7 @@ const styles = StyleSheet.create({
})
const mapStateToProps = (state) => {
console.log(state)
return {
session_id: state.session_id,
outlet_id: state.outlet_id,
......
This diff is collapsed.
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