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

add notes

parent cb49347b
......@@ -707,13 +707,12 @@ const rootReducer = (state = globalState, action) => {
case ActionType.SET_EDIT_NOTE: {
const update = action.data.item;
updated_data = []
for (let i = 0; i < state.order_item.length; i++) {
const old_data = state.order_item[i];
const data = old_data;
// dicari dulu yu object mana yg mau diupdate
// dicari dulu object mana yg mau diupdate
if (old_data.id == update.id) {
// kalo ketemu update data notenya
data.note = update.note
......@@ -729,7 +728,6 @@ const rootReducer = (state = globalState, action) => {
order_item: updated_data,
}
}
default:
......
......@@ -46,12 +46,7 @@ class Item extends React.Component {
handleEdit = (item) =>{
const order_item = {
id: item.id,
code: item.code,
name: item.name,
description: item.description,
note: this.state.note,
image: item.image,
price: parseInt(item.price),
}
this.props.setNotes({ item: order_item })
......
......@@ -12,7 +12,8 @@ class ItemShoping extends React.Component {
this.state = {
value: 0,
modalVisible: false,
description: ''
description: '',
note:''
}
}
handleChangeQuantity = (item, quantity) => {
......@@ -28,7 +29,7 @@ class ItemShoping extends React.Component {
code: item.code,
name: item.name,
description: item.description,
note: item.note,
note: this.state.note,
image: item.image,
price: parseInt(item.price),
}
......@@ -41,6 +42,18 @@ class ItemShoping extends React.Component {
})
}
handleEdit = (item) =>{
const order_item = {
id: item.id,
note: this.state.note,
}
this.props.setNotes({ item: order_item })
this.setState({
modalVisible: false
})
}
render() {
const { item } = this.props
// console.log(this.props)
......@@ -62,16 +75,23 @@ class ItemShoping extends React.Component {
<View style={{ margin: 10 }}>
<TextInput
style={styles.textInput}
onChangeText={(description) => this.setState({ description })}
value={this.state.description}
onChangeText={(note) => this.setState({ note })}
value={this.state.note}
textAlign='center'
/>
</View>
<TouchableOpacity onPress={() => this.setState({ modalVisible: false })}>
<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>
......@@ -234,6 +254,12 @@ const mapDispatchToProps = (dispacth) => {
new_quantity: params.quantity
}
}),
setNotes: (params) => dispacth({
type: ActionType.SET_EDIT_NOTE,
data: {
item: params.item,
}
}),
}
}
......
......@@ -27,7 +27,7 @@ class MenuConfirmation extends React.Component {
componentDidMount() {
// console.log(" DESTINASI : "+ this.props.grabdestination)
// console.log("ONGKIR"+ this.props.grabamount)
console.log("ONGKIR"+ this.props.grabamount)
// console.log("drop off"+this.props.grabdropoff)
// console.log("pickup"+this.props.grabpickup)
// console.log("type" +this.props.grabtype)
......@@ -189,6 +189,7 @@ class MenuConfirmation extends React.Component {
// session(response, navigation)
console.log("INI ERROR : " + JSON.stringify(error) )
Alert.alert(error.response.msg);
Alert.alert(error)
this.setState({
spinner: false,
})
......
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