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

benerin bug item pas di klik force close

parent 86903eaf
......@@ -383,7 +383,7 @@ const rootReducer = (state = globalState, action) => {
update.quantity = 1
}
update.quantity += 1
console.log('Update : ' + JSON.stringify(update))
// console.log('Update : ' + JSON.stringify(update))
data = { ...old_data, ...update }
}
......@@ -394,7 +394,7 @@ const rootReducer = (state = globalState, action) => {
} else {
// add
addedItem.quantity = 1
console.log('Baru : ' + JSON.stringify(addedItem))
// console.log('Baru : ' + JSON.stringify(addedItem))
order_item = [...state.order_item, addedItem]
}
......@@ -590,7 +590,7 @@ const rootReducer = (state = globalState, action) => {
let quantity = state.order_quantity
let total = parseInt(state.order_total) - parseInt(addedItem.price)
console.log("UPDATE " + order_item)
// console.log("UPDATE " + order_item)
}
return {
......
......@@ -61,9 +61,7 @@ class Item extends React.Component {
render() {
const { item } = this.props
return (
<View style={{ flex: 1, margin: 10 }} key={item.id} ref={this.props._scrollView}>
<View style={{ flex: 1, margin: 10 }}>
{item.code == 'CATEGORY' ? (
<Text style={{ fontSize: 15, color: '#c9af6d', fontFamily: 'Gotham-Black' }}>{item.name}</Text>
) : (
......@@ -103,13 +101,13 @@ class Item extends React.Component {
</View>
</View>
</Modal>
<View style={{ flex: 1 }}>
<View style={{ flex: 0.6 }}>
<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 style={{ height: 100, width: 100, borderRadius: 10, }} source={item.image ? {uri: item.image } : null} />
</TouchableOpacity>
</View>
<View style={{ flex: 1}}>
<View style={{ flex: 0.7}}>
<View style={{ marginLeft: 5, marginRight: 5 }}>
{
item.motm ? (
......
......@@ -31,8 +31,8 @@ class MenuSelection extends React.Component {
indicator: true,
my_lat: 0,
my_long: 0,
data:[],
data_before_search: this.props.menu_item,
data: [],
data_before_search: '',
note: ''
}
}
......@@ -140,11 +140,7 @@ class MenuSelection extends React.Component {
let data = res.data.data
// console.log("INI DATANYA" + JSON.stringify(data))
this.setState({
listCategory: data.category,
listMenu: data.menu,
indicator: false
})
// let last_category = ''
// let list_menu = []
......@@ -177,8 +173,11 @@ class MenuSelection extends React.Component {
// })
this.props.updateMenu(data.menu)
this.setState({
listCategory: data.category,
listMenu: data.menu,
indicator: false,
data_before_search: this.props.menu_item,
indicator: false
})
......@@ -191,18 +190,26 @@ class MenuSelection extends React.Component {
}
filterSubcategory = (item) => {
try {
let index_start = _.findIndex(this.props.menu_item, ['name', item.name])
let index_next_category = _.findIndex(this.state.listCategory, ['name', item.name]) + 1
let next_category = this.state.listCategory[index_next_category]
let index_end = _.findIndex(this.props.menu_item, ['name', next_category.name])
let filter_item = this.props.menu_item.slice(index_start, index_end);
this.setState({
data_before_search: filter_item
})
} catch (error) {
let index_start = _.findIndex(this.props.menu_item, ['name', item.name])
let index_end = item.length - 1
let filter_item = this.props.menu_item.slice(index_start, index_end);
this.setState({
data_before_search: filter_item
})
}
}
renderTabBar = ({ item }) => {
return (
......@@ -220,7 +227,6 @@ class MenuSelection extends React.Component {
)
}
renderItem = ({ item, index }) => {
return (
<View>
......@@ -275,10 +281,6 @@ class MenuSelection extends React.Component {
// })
}
clearNegatif(item, index) {
const list_order_item = this.props.order_item;
for (let i = 0; i < list_order_item.length; index++) {
......@@ -333,13 +335,13 @@ class MenuSelection extends React.Component {
}
}
getItemLayout = (data, index) => (
{
length: 100,
offset: 100 * index,
index
}
)
// getItemLayout = (data, index) => (
// {
// length: 100,
// offset: 100 * index,
// index
// }
// )
// setLastIndex = (index) => {
// las
......@@ -380,8 +382,8 @@ class MenuSelection extends React.Component {
maxToRenderPerBatch={10}
windowSize={10}
/>
):(
<Text style={{ flexWrap: 'wrap', fontFamily: 'Gotham-Light', color: '#b1b1b2', textAlign: 'center',top:20 }}> Tidak Ada Menu untuk kategory ini !</Text>
) : (
<Text style={{ flexWrap: 'wrap', fontFamily: 'Gotham-Light', color: '#b1b1b2', textAlign: 'center', top: 20 }}> Tidak Ada Menu untuk kategory ini !</Text>
)
)}
</View>
......
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