Commit 2ef8194c authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

home spinner

parent dc1734cc
...@@ -262,8 +262,6 @@ const rootReducer = (state = globalState, action) => { ...@@ -262,8 +262,6 @@ const rootReducer = (state = globalState, action) => {
} }
} }
case ActionType.ADD_TO_CHART: { case ActionType.ADD_TO_CHART: {
let addedItem = action.data.item let addedItem = action.data.item
...@@ -367,8 +365,6 @@ const rootReducer = (state = globalState, action) => { ...@@ -367,8 +365,6 @@ const rootReducer = (state = globalState, action) => {
order_total: total order_total: total
} }
} }
case ActionType.REMOVE_FROM_CHART: { case ActionType.REMOVE_FROM_CHART: {
......
...@@ -45,13 +45,6 @@ class DeliveryAddrees extends React.Component { ...@@ -45,13 +45,6 @@ class DeliveryAddrees extends React.Component {
this.props.setGrab(setGrabProps); this.props.setGrab(setGrabProps);
// let OutletChange = {
// outlet_id: this.state.outlet_id ,
// }
// this.props.setChangeOutletProps(OutletChange);
}).catch(error => { }).catch(error => {
console.log('ini error ' + error) console.log('ini error ' + error)
}) })
...@@ -98,22 +91,23 @@ class DeliveryAddrees extends React.Component { ...@@ -98,22 +91,23 @@ class DeliveryAddrees extends React.Component {
onSave(address) { onSave(address) {
let setDataAddress = {
address : address,
addressId : this.state.data[0].id
}
this.props.setAddress(setDataAddress);
Alert.alert( Alert.alert(
'', '',
'Apakah anda akan memilih alamat untuk pengiriman ?', 'Apakah anda akan memilih alamat untuk pengiriman ?',
[ [
{text: 'OK', onPress: () => this.props.navigation.navigate('Home', { screen: 'MENU' })}, {text: 'OK', onPress: () => this.props.navigation.navigate("Menu Select")},
], ],
{ cancelable: false } { cancelable: false }
) )
let setDataAddress = {
address : address,
addressId : this.state.data[0].id
}
this.props.setAddress(setDataAddress);
} }
......
import * as React from 'react'; import * as React from 'react';
import { View, Text, StyleSheet, ScrollView, TouchableOpacity, Alert } from 'react-native'; import { View, Text, StyleSheet, ScrollView, TouchableOpacity, Alert, ActivityIndicator } from 'react-native';
import { SliderBox } from "react-native-image-slider-box"; import { SliderBox } from "react-native-image-slider-box";
import { Card } from 'react-native-shadow-cards'; import { Card } from 'react-native-shadow-cards';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
...@@ -25,22 +25,16 @@ class Home extends React.Component { ...@@ -25,22 +25,16 @@ class Home extends React.Component {
account_number: "", account_number: "",
my_lat: 0, my_lat: 0,
my_long: 0, my_long: 0,
indicator: true
} }
} }
componentDidMount() { componentDidMount() {
this._getPermissions() this._getPermissions()
this._renderCarousell() this._renderCarousell()
console.log(" ini yaaaaa"+ this.props.name_outlet) this._account();
} }
//fungsi untuk get current posisi
clear = () => {
this.state.search.clear();
};
_getPermissions = async () => { _getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION); let { status } = await Permissions.askAsync(Permissions.LOCATION);
...@@ -52,8 +46,8 @@ class Home extends React.Component { ...@@ -52,8 +46,8 @@ class Home extends React.Component {
} else { } else {
this._getCurrentPosisition() this._getCurrentPosisition()
} }
} }
_getCurrentPosisition = async () => { _getCurrentPosisition = async () => {
this.setState({ this.setState({
spinner: true, spinner: true,
}) })
...@@ -69,15 +63,12 @@ _getCurrentPosisition = async () => { ...@@ -69,15 +63,12 @@ _getCurrentPosisition = async () => {
my_long: longitude my_long: longitude
}) })
this._account() this._getOutletClosest();
} }
_renderCarousell() { _renderCarousell() {
Axios.get('https://excelsocrm.ravintoladev.com/cms/v2/list/promotions-carousel').then(respon => { Axios.get('https://excelsocrm.ravintoladev.com/cms/v2/list/promotions-carousel').then(respon => {
// console.log(respon);
const dataCarousell = respon.data.contents; const dataCarousell = respon.data.contents;
// console.log(dataCarousell);
// console.log(dataCarousell);
let imageLink = [] let imageLink = []
for (let i = 0; i < dataCarousell.length; i++) { for (let i = 0; i < dataCarousell.length; i++) {
...@@ -93,57 +84,67 @@ _getCurrentPosisition = async () => { ...@@ -93,57 +84,67 @@ _getCurrentPosisition = async () => {
_account() { _account() {
let params = { let params = {
session_id: this.props.session_id, session_id: this.props.session_id,
lat: this.state.my_lat,
long: this.state.my_long,
closest_outlet: 1
} }
console.log(params); console.log(params);
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/member/get_profile', params).then(res => { Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/member/get_profile', params).then(res => {
console.log("INI RESPON GET PROFILE : " + JSON.stringify(res))
const dataCard = res.data const dataCard = res.data
let point = dataCard.kaspro_point let point = dataCard.kaspro_point
let balance = dataCard.kaspro_balance let balance = dataCard.kaspro_balance
let expire = dataCard.expire_date let expire = dataCard.expire_date
let account_number = dataCard.kaspro_account_number let account_number = dataCard.kaspro_account_number
let outlet_id = dataCard.outlet_closest.outlet_id
let outlet_name = dataCard.outlet_closest.outlet_name
let OutletChange = {
outlet_id: outlet_id,
name_outlet : outlet_name
}
this.props.setChangeOutletProps(OutletChange);
this.setState({ this.setState({
point: point, point: point,
balance: balance, balance: balance,
account_number: account_number, account_number: account_number,
expire_date: expire, expire_date: expire,
indicator: false
}) })
}).catch(error => {
console.log('ini error ' + error)
})
}
_getOutletClosest() {
let params = {
session_id: this.props.session_id,
lat: this.state.my_lat,
long: this.state.my_long
}
console.log(params);
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/outlet/get_closest', params).then(res => {
console.log(this.state.expire_date)
let outletId = res.data.data.outlet_id
let outletName = res.data.data.outlet_name
let OutletChange = {
outlet_id: outletId,
name_outlet: outletName,
}
this.props.setChangeOutletProps(OutletChange);
this.setState({
indicator: false
})
}).catch(error => { }).catch(error => {
console.log('ini error ' + error) console.log('ini error ' + error)
}) })
} }
render() { render() {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<ScrollView> <ScrollView>
<View style={{ flex: 1 }}> <View style={{ flex: 6 }}>
<SliderBox <SliderBox
images={this.state.images} images={this.state.images}
// onCurrentImagePressed={index =>console.warn(`image ${index} pressed`)}
autoplay autoplay
circleLoop circleLoop
dotColor='black' dotColor='black'
inactiveDotColor='white' inactiveDotColor='white'
sliderBoxHeight={300} sliderBoxHeight={300}
// currentImageEmitter={index => console.warn(`current pos is: ${index}`)}
paginationBoxVerticalPadding={20} paginationBoxVerticalPadding={20}
resizeMethod={'resize'} resizeMethod={'resize'}
resizeMode={'stretch'} resizeMode={'stretch'}
...@@ -155,7 +156,6 @@ _getCurrentPosisition = async () => { ...@@ -155,7 +156,6 @@ _getCurrentPosisition = async () => {
alignSelf: 'center', alignSelf: 'center',
justifyContent: 'center', justifyContent: 'center',
paddingVertical: 10, paddingVertical: 10,
// backgroundColor : ''
}} }}
dotStyle={{ dotStyle={{
width: 10, width: 10,
...@@ -164,12 +164,9 @@ _getCurrentPosisition = async () => { ...@@ -164,12 +164,9 @@ _getCurrentPosisition = async () => {
marginHorizontal: 0, marginHorizontal: 0,
padding: 0, padding: 0,
margin: 0, margin: 0,
// backgroundColor: ''
}} }}
ImageComponentStyle={{ ImageComponentStyle={{
// borderRadius: 5,
width: '100%', width: '100%',
// marginTop : 5
}} }}
imageLoadingColor='#c7c7c7' imageLoadingColor='#c7c7c7'
/> />
...@@ -188,37 +185,40 @@ _getCurrentPosisition = async () => { ...@@ -188,37 +185,40 @@ _getCurrentPosisition = async () => {
<Text style={{ textAlign: 'center', fontSize: 12, }}> <Text style={{ textAlign: 'center', fontSize: 12, }}>
{i18n.t('orderInfo')} {i18n.t('orderInfo')}
</Text> </Text>
<Text style={{ textAlign: "center", fontSize: 12, top: 5 }}> {this.state.indicator == true ? (
{this.props.name_outlet} <ActivityIndicator size="small" color="#c9af6d" />
) : (
<Text style={{ textAlign: "center", fontSize: 12, top: 5, fontWeight: 'bold' }}>
Excelso {this.props.name_outlet}
</Text> </Text>
<TouchableOpacity style={styles.submitOrder} activeOpacity={.5} onPress={this.onPress}> )}
<TouchableOpacity style={styles.submitOrder} activeOpacity={.5} onPress={() => this.props.navigation.navigate("Menu Select")}>
<Text style={{ textAlign: 'center', bottom: 5, color: 'white' }}>{i18n.t('orderNow')}</Text> <Text style={{ textAlign: 'center', bottom: 5, color: 'white' }}>{i18n.t('orderNow')}</Text>
</TouchableOpacity> </TouchableOpacity>
</Card> </Card>
{ {
this.state.indicator == true ? (<ActivityIndicator style={{ top: 20, justifyContent: "center" }} size="large" color="#c9af6d" />) :
this.state.account_number === "" ? ( this.state.account_number === "" ? (
<View style={styles.card}> <View style={styles.card}>
<Card style={{ padding: 10, margin: 10, alignContent: 'center' }}> <Card style={{ padding: 10, margin: 10, alignContent: 'center' }}>
<Text style={{ textAlign: "center" }}> Anda belum aktivasi kartu</Text> <Text style={{ textAlign: "center" }}> Anda belum aktivasi kartu</Text>
<Text> <Text>
{/* {i18n.t('yourCardNumber')} | {this.state.expire_date}{'\n'} */}
</Text> </Text>
<Text style={{ textAlign: "center", fontSize: 40, color: '#c9af6d' }}> <Text style={{ textAlign: "center", fontSize: 40, color: '#c9af6d' }}>
{/* {this.state.account_number} */}
</Text> </Text>
<View style={styles.line}></View> <View style={styles.line}></View>
<Text style={{ textAlign: 'left', fontWeight: 'bold' }}> {'\n'} <Text style={{ textAlign: 'left', fontWeight: 'bold' }}> {'\n'}
{/* {i18n.t('balance')} {this.state.balance}{'\n'} */}
</Text> </Text>
<View style={styles.line}></View> <View style={styles.line}></View>
<Text style={{ textAlign: 'left', fontWeight: 'bold' }}>{'\n'} <Text style={{ textAlign: 'left', fontWeight: 'bold' }}>{'\n'}
{/* {i18n.t('point')} {this.state.point} */}
</Text> </Text>
</Card> </Card>
</View> </View>
) : ( ) :
(
<View style={styles.card}> <View style={styles.card}>
<Card style={{ padding: 10, margin: 10, alignContent: 'center' }}> <Card style={{ padding: 10, margin: 10, alignContent: 'center' }}>
<Text> <Text>
...@@ -236,10 +236,12 @@ _getCurrentPosisition = async () => { ...@@ -236,10 +236,12 @@ _getCurrentPosisition = async () => {
{i18n.t('point')} {this.state.point} {i18n.t('point')} {this.state.point}
</Text> </Text>
</Card> </Card>
{/* <Button title="upgrade premium" onPress={()=>this.props.navigation.navigate("Upgrade Premium")}></Button> */}
</View> </View>
) )
} }
<TouchableOpacity style={styles.submitUpgradePemium} activeOpacity={.5} onPress={this.onPress}>
<Text style={{ textAlign: 'center', bottom: 5, color: 'white' }}>TOP BALANCE </Text>
</TouchableOpacity>
<View style={{ height: 60 }}></View> <View style={{ height: 60 }}></View>
</View> </View>
</View> </View>
...@@ -260,8 +262,8 @@ const styles = StyleSheet.create({ ...@@ -260,8 +262,8 @@ const styles = StyleSheet.create({
}, },
card: { card: {
top: 20, top: 20,
alignSelf: 'center', flex: 1,
flex: 1 alignItems: 'center'
}, },
buttonDelivery: { buttonDelivery: {
marginTop: 10, marginTop: 10,
...@@ -277,6 +279,7 @@ const styles = StyleSheet.create({ ...@@ -277,6 +279,7 @@ const styles = StyleSheet.create({
top: -20, top: -20,
}, },
buttonPickup: { buttonPickup: {
height: 50,
marginTop: 10, marginTop: 10,
paddingTop: 15, paddingTop: 15,
paddingBottom: 15, paddingBottom: 15,
...@@ -295,7 +298,19 @@ const styles = StyleSheet.create({ ...@@ -295,7 +298,19 @@ const styles = StyleSheet.create({
paddingTop: 15, paddingTop: 15,
paddingBottom: 5, paddingBottom: 5,
backgroundColor: '#c9af6d', backgroundColor: '#c9af6d',
borderRadius: 20, borderRadius: 10,
borderWidth: 0,
borderColor: '#fff',
},
submitUpgradePemium: {
top: 20,
margin: 20,
paddingTop: 15,
paddingBottom: 5,
backgroundColor: '#c9af6d',
borderRadius: 10,
width: "90%",
borderWidth: 0, borderWidth: 0,
borderColor: '#fff', borderColor: '#fff',
}, },
...@@ -346,4 +361,4 @@ const mapStateToProps = (state) => { ...@@ -346,4 +361,4 @@ const mapStateToProps = (state) => {
export default connect(mapStateToProps,mapDispatchToProps)(Home) export default connect(mapStateToProps, mapDispatchToProps)(Home)
\ No newline at end of file \ No newline at end of file
import React from 'react'; import React from 'react';
import { View, Text, StyleSheet, ScrollView, TouchableOpacity, Image, FlatList, Button, Alert, StatusBar, SafeAreaView, SectionList } from 'react-native'; import { View, Text, StyleSheet, ScrollView, TouchableOpacity, Image, FlatList, Button, StatusBar, ActivityIndicator } from 'react-native';
import Axios from 'axios'; import Axios from 'axios';
import Item from './Item'; import Item from './Item';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
...@@ -19,10 +19,11 @@ class MenuSelection extends React.Component { ...@@ -19,10 +19,11 @@ class MenuSelection extends React.Component {
qty: 1, qty: 1,
order_list: [], order_list: [],
list_cart: [], list_cart: [],
indicator: true,
} }
} }
componentDidMount() { componentDidMount() {
console.log("INI YA :" + JSON.stringify(this.props.outlet_id) )
this.getMenuList() this.getMenuList()
} }
...@@ -37,16 +38,15 @@ class MenuSelection extends React.Component { ...@@ -37,16 +38,15 @@ class MenuSelection extends React.Component {
console.log("INI DATANYA" + JSON.stringify(data)) console.log("INI DATANYA" + JSON.stringify(data))
this.setState({ this.setState({
listCategory: data.category, listCategory: data.category,
listMenu: data.menu listMenu: data.menu,
indicator: false
}) })
let last_category = '' let last_category = ''
let list_menu = [] let list_menu = []
for (let i = 0; i < data.menu.length; i++) { for (let i = 0; i < data.menu.length; i++) {
const row = data.menu[i]; const row = data.menu[i];
// cari sudah ada belum di redux // cari sudah ada belum di redux
let is_xist = this.props.order_item.find(item => row.id == item.id) let is_xist = this.props.order_item.find(item => row.id == item.id)
if (is_xist) { if (is_xist) {
...@@ -85,25 +85,11 @@ class MenuSelection extends React.Component { ...@@ -85,25 +85,11 @@ class MenuSelection extends React.Component {
</View> </View>
) )
} }
// scroll(item) {
// this.refs._scrollView.scrollTo(0);
// }
refresh() { refresh() {
this.setState({ isFetching: true }, function () { this.getMenuList() }); this.setState({ isFetching: true }, function () { this.getMenuList() });
} }
// handleRemove(item, index) {
// const listMenu = [...this.state.listMenu]
// if (listMenu[index].qty !== 0) {
// listMenu[index].qty -= 1
// this.setState({
// listMenu
// })
// }
// }
scrollToItem = () => { scrollToItem = () => {
this.props._scrollView.scrollTo({ y: 1 * 100 }); this.props._scrollView.scrollTo({ y: 1 * 100 });
...@@ -114,11 +100,11 @@ class MenuSelection extends React.Component { ...@@ -114,11 +100,11 @@ class MenuSelection extends React.Component {
const order_item = { const order_item = {
id: item.id, id: item.id,
code:item.code, code: item.code,
name: item.name, name: item.name,
description: item.description, description: item.description,
note:'jangan garing', note: 'jangan garing',
image:item.image, image: item.image,
price: parseInt(item.price), price: parseInt(item.price),
} }
...@@ -144,7 +130,7 @@ class MenuSelection extends React.Component { ...@@ -144,7 +130,7 @@ class MenuSelection extends React.Component {
} }
clearNegatif(item,index){ clearNegatif(item, index) {
const list_order_item = this.props.order_item; const list_order_item = this.props.order_item;
for (let i = 0; i < list_order_item.length; index++) { for (let i = 0; i < list_order_item.length; index++) {
const row = list_order_item[i]; const row = list_order_item[i];
...@@ -180,16 +166,6 @@ class MenuSelection extends React.Component { ...@@ -180,16 +166,6 @@ class MenuSelection extends React.Component {
this.setState({ this.setState({
listMenu listMenu
}) })
// for (let i = 0; i < list_order_item.length; i++) {
// const row = list_order_item[i];
// if (row.id == item.id) {
// quantity = row.quantity
// }
// }
} }
} }
} }
...@@ -199,6 +175,7 @@ class MenuSelection extends React.Component { ...@@ -199,6 +175,7 @@ class MenuSelection extends React.Component {
<View style={styles.container}> <View style={styles.container}>
<StatusBar hidden={true} /> <StatusBar hidden={true} />
<View style={{ flex: 0.7, height: 90, flexDirection: 'row', borderWidth: 1, }}> <View style={{ flex: 0.7, height: 90, flexDirection: 'row', borderWidth: 1, }}>
<FlatList horizontal={true} style={{ flexDirection: 'row' }} <FlatList horizontal={true} style={{ flexDirection: 'row' }}
showsHorizontalScrollIndicator={false} showsHorizontalScrollIndicator={false}
data={this.state.listCategory} data={this.state.listCategory}
...@@ -207,6 +184,9 @@ class MenuSelection extends React.Component { ...@@ -207,6 +184,9 @@ class MenuSelection extends React.Component {
/> />
</View> </View>
<View style={{ flex: 3 }}> <View style={{ flex: 3 }}>
{this.state.indicator == true ? (
<ActivityIndicator style={{top:10}} size="large" color="#c9af6d" />
) : (
<FlatList <FlatList
data={this.state.listMenu} data={this.state.listMenu}
...@@ -219,6 +199,7 @@ class MenuSelection extends React.Component { ...@@ -219,6 +199,7 @@ class MenuSelection extends React.Component {
)} )}
keyExtractor={item => item.id} keyExtractor={item => item.id}
/> />
)}
</View> </View>
<View style={styles.shadow}> <View style={styles.shadow}>
<View style={{ flexDirection: 'row', }}> <View style={{ flexDirection: 'row', }}>
......
...@@ -65,7 +65,6 @@ class ShoppingCart extends React.Component { ...@@ -65,7 +65,6 @@ class ShoppingCart extends React.Component {
} }
} }
handleMin(item, index) { handleMin(item, index) {
console.log("hai") console.log("hai")
const list_order_item = this.props.order_item; const list_order_item = this.props.order_item;
...@@ -200,7 +199,6 @@ class ShoppingCart extends React.Component { ...@@ -200,7 +199,6 @@ class ShoppingCart extends React.Component {
console.log("INI PROPS" + this.props.address) console.log("INI PROPS" + this.props.address)
} }
_getPermissions = async () => { _getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION); let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') { if (status !== 'granted') {
...@@ -736,8 +734,6 @@ const mapDispatchToProps = (dispacth) => { ...@@ -736,8 +734,6 @@ const mapDispatchToProps = (dispacth) => {
pointused: setOrdersProps.pointused, pointused: setOrdersProps.pointused,
} }
}), }),
} }
} }
......
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