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 { 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 NumberFormat from 'react-number-format';
import { Icon } from 'react-native-elements'
......@@ -13,7 +13,7 @@ class Item extends React.Component {
this.state = {
value: 0,
modalVisible: false,
note: ''
notes: ''
}
}
handleChangeQuantity = (item, qty) => {
......@@ -27,7 +27,6 @@ class Item extends React.Component {
code: item.code,
name: item.name,
description: item.description,
note: this.state.note,
image: item.image,
price: parseInt(item.price),
}
......@@ -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 = {
id: item.id,
note: this.state.note,
note: note,
}
this.props.setNotes({ item: order_item })
this.setState({
modalVisible: false
......@@ -56,52 +60,51 @@ class Item extends React.Component {
render() {
const { item } = this.props
console.log("ini id itemnya "+item.note)
return (
<View style={{ flex: 1, margin: 10 }} key={item.id} ref={this.props._scrollView}>
<Modal animationType="slide"
transparent={true}
visible={this.state.modalVisible}
onRequestClose={() => {
this.setState({
modalVisible: false
})
}}>
<View style={styles.centerViewModal}>
<View style={styles.modalView}>
<Text style={{ fontSize: 12, color: '#CFB368', fontFamily: 'Gotham-Black' }}>Add Description</Text>
<View style={{ margin: 10 }}>
<TextInput
style={styles.textInput}
onChangeText={(note) => this.setState({ note })}
textAlign='center'
>
{this.state.note}
{item.note}
</TextInput>
</View>
<View style={{flexDirection:'row'}}>
<TouchableOpacity style={{margin:5}} onPress={() => this.handleEdit(item) }>
<View style={styles.button}>
<Text style={{ color: 'white', fontWeight: 'bold', fontSize: 16 }}>CONFIRM</Text>
</View>
</TouchableOpacity>
<TouchableOpacity style={{margin:5}} onPress={() => this.setState({ modalVisible: false })}>
<View style={styles.button}>
<Text style={{ color: 'white', fontWeight: 'bold', fontSize: 16 }}>CANCEL</Text>
</View>
</TouchableOpacity>
</View>
</View>
</View>
</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 }}>
<Modal animationType="slide"
transparent={true}
visible={this.state.modalVisible}
onRequestClose={() => {
this.setState({
modalVisible: false
})
}}>
<View style={styles.centerViewModal}>
<View style={styles.modalView}>
<Text style={{ fontSize: 12, color: '#CFB368', fontFamily: 'Gotham-Black' }}>Add Description</Text>
<View style={{ margin: 10 }}>
<TextInput
style={styles.textInput}
onChangeText={(notes) => this.setState({ notes })}
textAlign='center'
>
{item.note}
</TextInput>
</View>
<View style={{ flexDirection: 'row' }}>
<TouchableOpacity style={{ margin: 5 }} onPress={() => this.handleEdit(item)}>
<View style={styles.button}>
<Text style={{ color: 'white', fontWeight: 'bold', fontSize: 16 }}>CONFIRM</Text>
</View>
</TouchableOpacity>
<TouchableOpacity style={{ margin: 5 }} onPress={() => this.setState({ modalVisible: false })}>
<View style={styles.button}>
<Text style={{ color: 'white', fontWeight: 'bold', fontSize: 16 }}>CANCEL</Text>
</View>
</TouchableOpacity>
</View>
</View>
</View>
</Modal>
<View style={{ flex: 1, height: 100 }}>
<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>
......@@ -235,7 +238,7 @@ const styles = StyleSheet.create({
button: {
backgroundColor: '#CFB368',
height: 40,
paddingHorizontal:20,
paddingHorizontal: 20,
borderRadius: 10,
alignItems: 'center',
justifyContent: 'center'
......@@ -273,6 +276,7 @@ const mapStateToProps = (state) => {
order_quantity: state.order_quantity,
order_total: state.order_total,
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