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

change menu selection

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