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