Commit c6d01124 authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

memperbaiki bug menu selection bagian edit note

parent 25f722ec
import React from 'react'; import React from 'react';
import { View, Text, StyleSheet, ScrollView, TouchableOpacity, Image, TextInput, Modal, Alert } from 'react-native'; import { View, Text, StyleSheet, ScrollView, TouchableOpacity, Image, TextInput, Modal, Alert } from 'react-native';
import { connect } from 'react-redux'; import { connect, connectAdvanced } from 'react-redux';
import ActionType from '../redux/globalActionType'; import ActionType from '../redux/globalActionType';
import NumberFormat from 'react-number-format'; import NumberFormat from 'react-number-format';
import { Icon } from 'react-native-elements' import { Icon } from 'react-native-elements'
...@@ -13,7 +13,7 @@ class Item extends React.Component { ...@@ -13,7 +13,7 @@ class Item extends React.Component {
this.state = { this.state = {
value: 0, value: 0,
modalVisible: false, modalVisible: false,
note: '' notes: ''
} }
} }
handleChangeQuantity = (item, qty) => { handleChangeQuantity = (item, qty) => {
...@@ -27,7 +27,6 @@ class Item extends React.Component { ...@@ -27,7 +27,6 @@ class Item extends React.Component {
code: item.code, code: item.code,
name: item.name, name: item.name,
description: item.description, description: item.description,
note: this.state.note,
image: item.image, image: item.image,
price: parseInt(item.price), price: parseInt(item.price),
} }
...@@ -42,12 +41,17 @@ class Item extends React.Component { ...@@ -42,12 +41,17 @@ class Item extends React.Component {
}) })
} }
handleEdit = (item) =>{ handleEdit = (item) => {
let note = ''
if (this.state.note === '') {
note = item.note;
} else {
note = this.state.notes;
}
const order_item = { const order_item = {
id: item.id, id: item.id,
note: this.state.note, note: note,
} }
this.props.setNotes({ item: order_item }) this.props.setNotes({ item: order_item })
this.setState({ this.setState({
modalVisible: false modalVisible: false
...@@ -56,9 +60,15 @@ class Item extends React.Component { ...@@ -56,9 +60,15 @@ class Item extends React.Component {
render() { render() {
const { item } = this.props const { item } = this.props
console.log("ini id itemnya "+item.note)
return ( return (
<View style={{ flex: 1, margin: 10 }} key={item.id} ref={this.props._scrollView}> <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: 15, color: '#c9af6d', fontFamily: 'Gotham-Black' }}>{item.name}</Text>
) : (
<View style={{ flex: 1, flexDirection: 'row', height: 100 }}>
<Modal animationType="slide" <Modal animationType="slide"
transparent={true} transparent={true}
visible={this.state.modalVisible} visible={this.state.modalVisible}
...@@ -73,21 +83,20 @@ class Item extends React.Component { ...@@ -73,21 +83,20 @@ class Item extends React.Component {
<View style={{ margin: 10 }}> <View style={{ margin: 10 }}>
<TextInput <TextInput
style={styles.textInput} style={styles.textInput}
onChangeText={(note) => this.setState({ note })} onChangeText={(notes) => this.setState({ notes })}
textAlign='center' textAlign='center'
> >
{this.state.note}
{item.note} {item.note}
</TextInput> </TextInput>
</View> </View>
<View style={{flexDirection:'row'}}> <View style={{ flexDirection: 'row' }}>
<TouchableOpacity style={{margin:5}} onPress={() => this.handleEdit(item) }> <TouchableOpacity style={{ margin: 5 }} onPress={() => this.handleEdit(item)}>
<View style={styles.button}> <View style={styles.button}>
<Text style={{ color: 'white', fontWeight: 'bold', fontSize: 16 }}>CONFIRM</Text> <Text style={{ color: 'white', fontWeight: 'bold', fontSize: 16 }}>CONFIRM</Text>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity style={{margin:5}} onPress={() => this.setState({ modalVisible: false })}> <TouchableOpacity style={{ margin: 5 }} onPress={() => this.setState({ modalVisible: false })}>
<View style={styles.button}> <View style={styles.button}>
<Text style={{ color: 'white', fontWeight: 'bold', fontSize: 16 }}>CANCEL</Text> <Text style={{ color: 'white', fontWeight: 'bold', fontSize: 16 }}>CANCEL</Text>
</View> </View>
...@@ -96,12 +105,6 @@ class Item extends React.Component { ...@@ -96,12 +105,6 @@ class Item extends React.Component {
</View> </View>
</View> </View>
</Modal> </Modal>
<ScrollView ref={view => this._scrollView = view}>
{item.code == 'CATEGORY' ? (
<Text style={{ fontSize: 15, color: '#c9af6d', fontFamily: 'Gotham-Black' }}>{item.name}</Text>
) : (
<View style={{ flex: 1, flexDirection: 'row', height: 100 }}>
<View style={{ flex: 1, height: 100 }}> <View style={{ flex: 1, height: 100 }}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Menu Detail', { nameMenu: item.name, desc: item.description, image: item.image })}> <TouchableOpacity onPress={() => this.props.navigation.navigate('Menu Detail', { nameMenu: item.name, desc: item.description, image: item.image })}>
<Image source={{ uri: item.image }} style={{ height: 100, width: 100, borderRadius: 10, }}></Image> <Image source={{ uri: item.image }} style={{ height: 100, width: 100, borderRadius: 10, }}></Image>
...@@ -235,7 +238,7 @@ const styles = StyleSheet.create({ ...@@ -235,7 +238,7 @@ const styles = StyleSheet.create({
button: { button: {
backgroundColor: '#CFB368', backgroundColor: '#CFB368',
height: 40, height: 40,
paddingHorizontal:20, paddingHorizontal: 20,
borderRadius: 10, borderRadius: 10,
alignItems: 'center', alignItems: 'center',
justifyContent: 'center' justifyContent: 'center'
...@@ -273,6 +276,7 @@ const mapStateToProps = (state) => { ...@@ -273,6 +276,7 @@ const mapStateToProps = (state) => {
order_quantity: state.order_quantity, order_quantity: state.order_quantity,
order_total: state.order_total, order_total: state.order_total,
quantity: state.quantity, quantity: state.quantity,
menu_item: state.menu_item
} }
} }
......
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