Commit 3b481e0a authored by Trisno's avatar Trisno

Merge branch 'master' of ssh://repo.cs.co.id:2222/wahyu/bahanoprek

# Conflicts:
#	view/ShoppingCart.js
parents 987b2cca 03e4a898
import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';
import * as Device from 'expo-device';
export default _getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
Alert.alert('Akses tidak dizinkan!')
} else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert('Silahkan anda coba di real Device')
} else {
this._getCurrentPosisition()
}
}
_getCurrentPosisition = async () => {
this.setState({
spinner: true,
})
let location = await Location.getCurrentPositionAsync({
accuracy: Location.Accuracy.Highest
})
let latitude = location.coords.latitude;
let longitude = location.coords.longitude;
this.setState({
my_lat: latitude,
my_long: longitude
})
console.log("MY LAT : " + this.state.my_lat)
console.log("MY LONG : " + this.state.my_long)
this.getOutlet()
}
function getOutlet() {
this.setState({
spinner: true,
})
let params = {
session_id: this.props.session_id
}
Axios.post("https://excelsocrm.ravintoladev.com/crm/v2/outlet/get_list", params).then(res => {
let dataOutlets = res.data.outlets;
for (let i = 0; i < dataOutlets.length; i++) {
dataOutlets[i]['distance'] = this.distance(dataOutlets[i]['lat'], dataOutlets[i]['long']);
let address = dataOutlets[i]['address'];
if (dataOutlets[i]['city'] !== '') {
if (address !== '') {
address = address + ', ' + dataOutlets[i]['city'];
} else {
address = dataOutlets[i]['city'];
}
}
if (dataOutlets[i]['province']) {
if (address !== '') {
address = address + ', ' + dataOutlets[i]['province'];
} else {
address = dataOutlets[i]['province'];
}
}
if (dataOutlets[i]['postal_code']) {
if (address !== '') {
address = address + ' ' + dataOutlets[i]['postal_code'];
} else {
address = dataOutlets[i]['postal_code'];
}
}
dataOutlets[i]['full_address'] = address;
}
this.setState({
dataOutlets: dataOutlets,
data_before_search: dataOutlets,
})
this.setState({
spinner: false,
})
}).catch(error => {
let response = error.response.data;
Alert.alert(response.msg);
this.setState({
spinner: false,
})
})
}
function toRad(value) {
return value * Math.PI / 180;
}
function distance(locationLat, locationLong) {
let R = 6371;
let dLat = this.toRad(locationLat - this.state.my_lat); // Javascript functions in radians
let dLon = this.toRad(locationLong - this.state.my_long);
let a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(this.toRad(this.state.my_lat)) * Math.cos(this.toRad(locationLat)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
let c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
let d = R * c;
return Math.round(d * 10) / 10;
}
......@@ -24,6 +24,8 @@ const ActionType = {
SET_CHANGE_SHOP:'SET_CHANGE_SHOP',
ADD_TO_CHART:'ADD_TO_CHART',
REMOVE_FROM_CHART:'REMOVE_FROM_CHART',
REDUCE_QUANTITY_ITEM :'REDUCE_QUANTITY_ITEM',
SET_ADDRESS :'SET_ADDRESS'
}
......
......@@ -56,7 +56,9 @@ const globalState = {
order_item: [],
order_quantity: 0,
order_total: 0
order_total: 0,
address:''
}
const rootReducer = (state = globalState, action) => {
......@@ -200,6 +202,13 @@ const rootReducer = (state = globalState, action) => {
...state
}
}
case ActionType.SET_ADDRESS:{
return{
...state,
address: action.data.address
}
}
case ActionType.SET_LOGOUT:{
return{
...state,
......@@ -213,15 +222,19 @@ const rootReducer = (state = globalState, action) => {
let order_item = []
if (is_exist) {
// update
addedItem.quantity += 1
console.log('Update : ' + JSON.stringify(addedItem))
updated_data = []
for (let i = 0; i < state.order_item.length; i++) {
const old_data = state.order_item[i];
const data = old_data;
if (old_data.id == addedItem.id) {
data = {...old_data, ...addedItem}
update = old_data
if (update.quantity == NaN){
update.quantity = 1
}
update.quantity += 1
console.log('Update : ' + JSON.stringify(update))
data = {...old_data, ...update}
}
......@@ -245,6 +258,80 @@ const rootReducer = (state = globalState, action) => {
order_total: total
}
}
case ActionType.REDUCE_QUANTITY_ITEM:{
let addedItem = action.data.item
let is_exist = state.order_item.find(item => addedItem.id == item.id)
let order_item = []
if (is_exist) {
// update
updated_data = []
for (let i = 0; i < state.order_item.length; i++) {
const old_data = state.order_item[i];
const data = old_data;
if (old_data.id == addedItem.id) {
update = old_data
if (update.quantity == NaN){
update.quantity = 1
}
update.quantity -= 1
console.log('Update : ' + JSON.stringify(update))
data = {...old_data, ...update}
}
updated_data.push(data)
}
order_item = updated_data
} else {
// add
addedItem.quantity = 1
console.log('Baru : ' + JSON.stringify(addedItem))
order_item = [...state.order_item, addedItem]
}
let quantity = state.order_quantity - 1
let total = parseInt(state.order_total) - parseInt(addedItem.price)
return{
...state,
order_item: order_item,
order_quantity: quantity,
order_total: total
}
}
case ActionType.REMOVE_FROM_CHART:{
let addedItem = action.data.item
let is_exist = state.order_item.find(item => addedItem.id == item.id)
let order_item = []
if (is_exist) {
// update
updated_data = []
for (let i = 0; i < state.order_item.length; i++) {
const old_data = state.order_item[i];
const data = old_data;
if (old_data.id != addedItem.id) {
updated_data.push(data)
quantity += data.quantity
total += (data.quantity * data.price)
}
}
order_item = updated_data
}
return{
...state,
order_item: order_item,
order_quantity: quantity,
order_total: total
}
}
default:
......
import React from 'react';
import { View, Text, StyleSheet, Button, FlatList } from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';
import { View, Text, StyleSheet, Button, FlatList, Alert } from 'react-native';
import { ScrollView, TouchableOpacity } from 'react-native-gesture-handler';
import { connect } from 'react-redux';
import Axios from 'axios';
import ActionType from '../redux/globalActionType';
class DeliveryAddrees extends React.Component {
constructor(props) {
super(props)
this.state = {
data:[]
data: []
}
}
componentDidMount() {
this.getAddreess()
console.log(this.props)
this.getAddreess()
console.log(this.props)
}
onChangeAddress = data => {
......@@ -22,7 +23,7 @@ class DeliveryAddrees extends React.Component {
this.getAddreess()
}
getAddreess(){
getAddreess() {
let params = {
session_id: this.props.session_id,
}
......@@ -50,27 +51,51 @@ class DeliveryAddrees extends React.Component {
})
}
addAdreess(){
addAdreess() {
this.props.navigation.navigate('Address Detail', { 'data': 'sample', onChangeAddress: this.onChangeAddress })
}
render() {
function Item({ name,description,address }) {
return (
<View style={styles.list_addrees}>
onSave(address) {
Alert.alert(
'',
'Apakah anda akan memilih alamat untuk pengiriman ?',
[
{text: 'OK', onPress: () => this.props.navigation.navigate('Menu Select')},
],
{ cancelable: false }
)
let setDataAddress = {
address : address
}
this.props.setAddress(setDataAddress);
}
renderItem = ({item})=>{
return (
<View style={styles.list_addrees}>
<TouchableOpacity onPress={()=> this.onSave(item.address)}>
<View style={{ margin: 5, }}>
<Text style={{ fontWeight: 'bold', fontSize: 20 }}>{name}</Text>
<Text style={{ fontWeight: 'bold', fontSize: 20 }}>{item.name}</Text>
</View>
<Text style={{ margin: 5 }}>
{address}
{item.address}
</Text>
<Text style={{ margin: 5 }}>
Patokan : {description}
Patokan : {item.description}
</Text>
</View>
);
}
</TouchableOpacity>
</View>
);
}
render() {
return (
<View style={styles.container}>
<View style={styles.header}>
......@@ -84,7 +109,7 @@ class DeliveryAddrees extends React.Component {
<FlatList
data={this.state.data}
renderItem={({ item }) => <Item name={item.name} description = {item.description} address = {item.address} /> }
renderItem={this.renderItem}
keyExtractor={item => item.id}
/>
{/*
......@@ -144,5 +169,18 @@ const mapStateToProps = (state) => {
}
}
export default connect(mapStateToProps)(DeliveryAddrees)
const mapDispatchToProps = (dispacth) => {
return {
setAddress: (setDataAddress) => dispacth({
type: ActionType.SET_ADDRESS,
data: {
address: setDataAddress.address,
}
}),
}
}
export default connect(mapStateToProps,mapDispatchToProps)(DeliveryAddrees)
// import { BASE_URL_GET_CARAOUSEL, BASE_URL_CHANGE_PASSWORD } from '../model/Base_Model';
// import Swiper from 'react-native-swiper';
import * as React from 'react';
import { View, Text, StyleSheet, StatusBar, ScrollView, TouchableOpacity, Alert ,Button} from 'react-native';
import { View, Text, StyleSheet, ScrollView, TouchableOpacity, Alert } from 'react-native';
import { SliderBox } from "react-native-image-slider-box";
import { IndicatorViewPager, PagerDotIndicator, PagerTabIndicator } from '@shankarmorwal/rn-viewpager';
import { Card } from 'react-native-shadow-cards';
import { connect } from 'react-redux';
import Axios from 'axios';
import ActionType from '../redux/globalActionType';
import Account from './Account';
import TopUpInfo from './TopUpInfo';
// import SmsConfirmation from './SmsConfirmation';
import i18n from 'i18n-js';
import _ from 'lodash';
class Home extends React.Component {
......@@ -20,20 +16,28 @@ class Home extends React.Component {
this.state = {
data_baner: [],
images: [],
balance:"",
point:"",
account_number:""
balance: "",
point: "",
account_number: "",
my_lat: 0,
my_long: 0,
}
}
componentDidMount() {
this._renderCarousell()
this._account()
console.log("INI SESSION"+this.props.session_id)
}
_renderCarousell() {
//fungsi untuk get current posisi
clear = () => {
this.state.search.clear();
};
_renderCarousell() {
Axios.get('https://excelsocrm.ravintoladev.com/cms/v2/list/promotions-carousel').then(respon => {
// console.log(respon);
const dataCarousell = respon.data.contents;
......@@ -51,30 +55,29 @@ class Home extends React.Component {
})
}
_account(){
let params = {
session_id: this.props.session_id
}
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/member/get_profile', params).then(res => {
console.log('ini res ' + JSON.stringify(res.data))
const dataCard = res.data
let point = dataCard.kaspro_point
let balance = dataCard.kaspro_balance
let expire = dataCard.expire_date
let account_number = dataCard.kaspro_account_number
_account() {
let params = {
session_id: this.props.session_id
}
this.setState({
point: point,
balance: balance,
account_number: account_number,
expire_date:expire,
})
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/member/get_profile', params).then(res => {
const dataCard = res.data
let point = dataCard.kaspro_point
let balance = dataCard.kaspro_balance
let expire = dataCard.expire_date
let account_number = dataCard.kaspro_account_number
console.log(this.state.expire_date)
}).catch(error => {
console.log('ini error ' + error)
this.setState({
point: point,
balance: balance,
account_number: account_number,
expire_date: expire,
})
console.log(this.state.expire_date)
}).catch(error => {
console.log('ini error ' + error)
})
}
render() {
......@@ -145,49 +148,49 @@ class Home extends React.Component {
{
this.state.account_number === "" ? (
<View style={styles.card}>
<Card style={{ padding: 10, margin: 10, alignContent: 'center' }}>
<Text style={{textAlign:"center"} }> Anda belum aktivasi kartu</Text>
<Text>
{/* {i18n.t('yourCardNumber')} | {this.state.expire_date}{'\n'} */}
</Text>
<Text style={{ textAlign: "center", fontSize: 40, color: '#c9af6d' }}>
{/* {this.state.account_number} */}
</Text>
<View style={styles.line}></View>
<Text style={{ textAlign: 'left', fontWeight: 'bold' }}> {'\n'}
{/* {i18n.t('balance')} {this.state.balance}{'\n'} */}
</Text>
<View style={styles.line}></View>
<Text style={{ textAlign: 'left', fontWeight: 'bold' }}>{'\n'}
{/* {i18n.t('point')} {this.state.point} */}
</Text>
</Card>
</View>
):(
<View style={styles.card}>
<Card style={{ padding: 10, margin: 10, alignContent: 'center' }}>
<Text>
{i18n.t('yourCardNumber')} | {this.state.expire_date}{'\n'}
</Text>
<Text style={{ textAlign: "center", fontSize: 40, color: '#c9af6d' }}>
{this.state.account_number}
</Text>
<View style={styles.line}></View>
<Text style={{ textAlign: 'left', fontWeight: 'bold' }}> {'\n'}
{i18n.t('balance')} {this.state.balance}{'\n'}
</Text>
<View style={styles.line}></View>
<Text style={{ textAlign: 'left', fontWeight: 'bold' }}>{'\n'}
{i18n.t('point')} {this.state.point}
</Text>
</Card>
{/* <Button title="upgrade premium" onPress={()=>this.props.navigation.navigate("Upgrade Premium")}></Button> */}
</View>
)
<Card style={{ padding: 10, margin: 10, alignContent: 'center' }}>
<Text style={{ textAlign: "center" }}> Anda belum aktivasi kartu</Text>
<Text>
{/* {i18n.t('yourCardNumber')} | {this.state.expire_date}{'\n'} */}
</Text>
<Text style={{ textAlign: "center", fontSize: 40, color: '#c9af6d' }}>
{/* {this.state.account_number} */}
</Text>
<View style={styles.line}></View>
<Text style={{ textAlign: 'left', fontWeight: 'bold' }}> {'\n'}
{/* {i18n.t('balance')} {this.state.balance}{'\n'} */}
</Text>
<View style={styles.line}></View>
<Text style={{ textAlign: 'left', fontWeight: 'bold' }}>{'\n'}
{/* {i18n.t('point')} {this.state.point} */}
</Text>
</Card>
</View>
) : (
<View style={styles.card}>
<Card style={{ padding: 10, margin: 10, alignContent: 'center' }}>
<Text>
{i18n.t('yourCardNumber')} | {this.state.expire_date}{'\n'}
</Text>
<Text style={{ textAlign: "center", fontSize: 40, color: '#c9af6d' }}>
{this.state.account_number}
</Text>
<View style={styles.line}></View>
<Text style={{ textAlign: 'left', fontWeight: 'bold' }}> {'\n'}
{i18n.t('balance')} {this.state.balance}{'\n'}
</Text>
<View style={styles.line}></View>
<Text style={{ textAlign: 'left', fontWeight: 'bold' }}>{'\n'}
{i18n.t('point')} {this.state.point}
</Text>
</Card>
{/* <Button title="upgrade premium" onPress={()=>this.props.navigation.navigate("Upgrade Premium")}></Button> */}
</View>
)
}
<View style={{height:60}}></View>
<View style={{ height: 60 }}></View>
</View>
</View>
</ScrollView>
......
import React from 'react';
import { View, Text, StyleSheet, ScrollView, TouchableOpacity, Image, TextInput } from 'react-native';
export default class Item extends React.Component {
import { connect } from 'react-redux';
class Item extends React.Component {
render() {
const { item } = this.props
// console.log('ini props nya item : ' + JSON.stringify(item))
const { description, name, image, price, qty, } = item
return (
<View style={{ flex: 1, margin: 10 }}>
<Text style={{ fontSize: 20, color: '#c9af6d' }}>{item.category.name}</Text>
<ScrollView ref={view => this._scrollView = view}>
{/* <Text style={{ fontSize: 20, color: '#c9af6d' }}>{item.category.name}</Text> */}
<View style={{ flexDirection: 'row' }}>
<View >
<Image source={{ uri: item.image }} style={{ height: 100, width: 100, borderRadius: 5, top: 5 }}></Image>
......@@ -19,16 +21,14 @@ export default class Item extends React.Component {
<View style={{ flexDirection: 'row', flex: 1 }}>
<View style={styles.shadowEdit}></View>
<View style={styles.shadowAdd}>
<TouchableOpacity>
<TouchableOpacity onPress={() => this.props.handleMin()}>
<Text style={{ fontSize: 20, margin: 2 }}> - </Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.props.handleRemove()}>
<TextInput
style={{ height: 25, padding: 2,textAlign:'center',margin:2 }}
autoCapitalize="none">
{item.qty}
</TextInput>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.props.handleAdd()}>
<Text style={{ fontSize: 20, margin: 2 }}> + </Text>
</TouchableOpacity>
......@@ -36,6 +36,7 @@ export default class Item extends React.Component {
</View>
</View>
</View>
</ScrollView>
</View>
)
}
......@@ -92,3 +93,16 @@ const styles = StyleSheet.create({
marginTop: 10,
}
})
const mapStateToProps = (state) => {
console.log(state)
return {
session_id: state.session_id,
outlet_id: state.outlet_id,
order_quantity : state.order_quantity,
order_total : state.order_total,
quantity: state.quantity,
}
}
export default connect(mapStateToProps)(Item)
import React from 'react';
import { View, Text, StyleSheet, ScrollView, TouchableOpacity, Image, FlatList, Button, Alert, StatusBar } from 'react-native';
import { View, Text, StyleSheet, ScrollView, TouchableOpacity, Image, FlatList, Button, Alert, StatusBar, SafeAreaView, SectionList } from 'react-native';
import Axios from 'axios';
import Item from './Item';
import { connect } from 'react-redux';
import ActionType from '../redux/globalActionType';
import CurrencyFormat from 'react-currency-format';
import Constants from "expo-constants";
import { Ionicons, MaterialCommunityIcons, MaterialIcons, AntDesign } from '@expo/vector-icons';
// import { range } from 'lodash';
import _ from 'lodash';
......@@ -14,11 +15,12 @@ class MenuSelection extends React.Component {
super(props)
this.state = {
listCategory: [],
list_category:[],
listMenu: [],
list_orders: [],
outlet_id: '',
qty: 1,
order_list:[],
order_list: [],
list_cart: [],
}
}
......@@ -35,13 +37,16 @@ class MenuSelection extends React.Component {
outlet_id: "dec1abbb-95d0-46ae-a6cd-2bf306590f15"
}
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/menu/get_list', params).then(res => {
let data = res.data.data
this.setState({
listCategory: data.category,
listMenu: data.menu
})
this.state.listMenu.map((i) => (
i.qty = 0
))
}).catch(error => {
let response = error.response.data;
......@@ -50,12 +55,10 @@ class MenuSelection extends React.Component {
renderTabBar = ({ item }) => {
return (
<View style={{ margin: 10 }}>
<ScrollView horizontal={true} ref={'scrollview'}>
<TouchableOpacity onPress={() => this.scroll(item)}>
<TouchableOpacity onPress={() => this.scrollToItem()}>
<Image style={{ height: 50, width: 50, borderRadius: 25 }} source={{ uri: item.image }} />
<Text>{item.name}</Text>
</TouchableOpacity>
</ScrollView>
</View>
)
}
......@@ -64,50 +67,96 @@ class MenuSelection extends React.Component {
}
refresh() {
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
})
}
// handleRemove(item, index) {
// const listMenu = [...this.state.listMenu]
// if (listMenu[index].qty !== 0) {
// listMenu[index].qty -= 1
// this.setState({
// listMenu
// })
// }
// }
scrollToItem = () => {
// let newData = []
// newData.push(this.state.listMenu)
// console.log("DATA " + JSON.stringify(newData))
// newData.map((item => {
// let abc = item[0].category
// }))
this.props._scrollView.scrollTo({ y: 1 * 100});
}
handleAdd(item) {
handleAdd(item, index) {
const order_item = {
id: item.id,
name: item.name,
price: item.price,
image: item.image
}
this.props.addToChart(order_item)
const list_order_item = this.props.order_item;
let quantity = 0
for (let i = 0; i < list_order_item.length; i++) {
const row = list_order_item[i];
if (row.id == item.id) {
quantity = row.quantity
}
}
const listMenu = [...this.state.listMenu]
listMenu[index].qty = quantity
this.setState({
listMenu
})
}
handleMin(item, index) {
const order_item = {
id: item.id,
name: item.name,
price: item.price,
render() {
const { list_orders } = this.state;
let totalQuantity = 0;
let totalPrice = 0;
}
list_orders.forEach((item) => {
totalQuantity += item.qty;
totalPrice += item.qty * item.price;
})
this.props.reduceQuantityItem(order_item)
const list_order_item = this.props.order_item;
let quantity = 0
if (quantity != 0) {
quantity = quantity - 1
for (let i = 0; i < list_order_item.length; i++) {
const row = list_order_item[i];
if (row.id == item.id) {
quantity = row.quantity
}
}
const listMenu = [...this.state.listMenu]
listMenu[index].qty = quantity
this.setState({
listMenu
})
}
}
render() {
return (
<View style={styles.container}>
<StatusBar hidden={true} />
<View style={{ flex: 0.7, height: 90, flexDirection: 'row', borderWidth: 1, }}>
<FlatList style={{ flexDirection: 'row' }}
<FlatList horizontal={true} style={{ flexDirection: 'row' }}
data={this.state.listCategory}
renderItem={this.renderTabBar}
keyExtractor={item => item.id}
numColumns={5}
keyExtractor= {(item) => item.id}
/>
</View>
<View style={{ flex: 3 }}>
......@@ -116,9 +165,8 @@ class MenuSelection extends React.Component {
renderItem={({ item, index }) => (
<Item navigation={this.props.navigation}
item={item}
handleAdd={() => this.handleAdd(item)}
handleRemove={() => this.handleRemove(item, index)}
refreshing={this.state.isFetching}
handleAdd={() => this.handleAdd(item, index)}
handleMin={() => this.handleMin(item, index)}
/>
)}
keyExtractor={item => item.id}
......@@ -126,8 +174,8 @@ class MenuSelection extends React.Component {
</View>
<View style={styles.shadow}>
<View style={{ flexDirection: 'row', }}>
<Text style={{ fontSize: 12, margin: 10 }}> Price Estimation / Item {this.state.qty} </Text>
<Text style={{ fontSize: 20, margin: 10, marginBottom: 10 }}> Rp. {totalPrice}</Text>
<Text style={{ fontSize: 12, margin: 10 }}> Price Estimation / Item {this.props.order_quantity} </Text>
<Text style={{ fontSize: 20, margin: 10, marginBottom: 10 }}> Rp. {this.props.order_total}</Text>
</View>
<View>
<Button title="VIEW CART" onPress={() => this.props.navigation.navigate('Shopping Cart')}></Button>
......@@ -166,12 +214,18 @@ const mapStateToProps = (state) => {
return {
session_id: state.session_id,
outlet_id: state.outlet_id,
qty: state.qty,
totalOrder: state.totalOrder,
totalQty: state.totalQty,
order_item: state.order_item,
order_quantity: state.order_quantity,
order_total: state.order_total,
quantity: state.quantity,
orders: state.orders,
cart_shop: state.cart_shop
address: state.address
// qty: state.qty,
// totalOrder: state.totalOrder,
// totalQty: state.totalQty,
// orders: state.orders,
// cart_shop: state.cart_shop,
}
}
......@@ -190,6 +244,13 @@ const mapDispatchToProps = (dispacth) => {
item: item
}
}),
//REDUCE QUANTITY ITEM
reduceQuantityItem: (item) => dispacth({
type: ActionType.REDUCE_QUANTITY_ITEM,
data: {
item: item
}
}),
}
}
......
......@@ -9,6 +9,8 @@ import { MaterialCommunityIcons, Ionicons } from '@expo/vector-icons';
import _ from 'lodash';
import * as Location from 'expo-location';
import { connect } from 'react-redux';
import * as Permissions from 'expo-permissions';
import * as Device from 'expo-device';
class PickupName extends React.Component {
constructor(props) {
......@@ -28,10 +30,22 @@ class PickupName extends React.Component {
}
componentDidMount() {
this._getCurrentPosisition()
this._getPermissions()
}
_getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
Alert.alert('Akses tidak dizinkan!')
} else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert('Silahkan anda coba di real Device')
} else {
this._getCurrentPosisition()
}
}
_getCurrentPosisition = async () => {
this.setState({
spinner: true,
......@@ -54,9 +68,6 @@ class PickupName extends React.Component {
this.props.navigation.navigate('Outlet Detail',{id:id})
}
getOutlet() {
this.setState({
spinner: true,
......@@ -111,7 +122,6 @@ class PickupName extends React.Component {
})
}
toRad(value) {
return value * Math.PI / 180;
}
......
......@@ -40,7 +40,6 @@ class ShoppingCart extends React.Component {
}
}
plusQty(item, index) {
this.setState({
......@@ -147,6 +146,7 @@ class ShoppingCart extends React.Component {
</TouchableOpacity>
</View>
<View style={styles.order}>
{this.props.order_item.map((item, i) => {
return (
<View style={{ flex: 1, margin: 10 }} key={i}>
......@@ -176,10 +176,10 @@ class ShoppingCart extends React.Component {
</View>
</View>
</View>
)
})}
</View>
<View style={styles.voucher}>
<TouchableOpacity>
......@@ -340,6 +340,7 @@ class ShoppingCart extends React.Component {
<Text style={{ paddingLeft: 20, paddingTop: 15, color: 'gray' }}>Harga</Text>
</View>
<View>
<Text style={{ paddingRight: 150, paddingTop: 15, color: 'gray' }}>{this.props.order_total}</Text>
</View>
</View>
......@@ -364,6 +365,7 @@ class ShoppingCart extends React.Component {
<Text style={{ fontSize: 35, color: '#ccb46c' }}>Total</Text>
</View>
<View style={{ marginTop: 15, paddingRight: 60, paddingTop: 10 }}>
<Text style={{ fontSize: 35, color: '#ccb46c' }}>{this.props.order_total}</Text>
</View>
</View>
......@@ -372,7 +374,7 @@ class ShoppingCart extends React.Component {
<Text style={{ paddingLeft: 20, paddingTop: 10, color: 'gray' }}>Tujuan</Text>
</View>
<View>
<Text style={{ color: '#ccb46c', paddingRight: 150, paddingTop: 10 }}>undefined</Text>
<Text style={{ color: '#ccb46c', paddingRight: 150, paddingTop: 10 }}>{this.props.address}</Text>
</View>
</View>
<View style={{ margin: 20, }}>
......@@ -515,16 +517,19 @@ const styles = StyleSheet.create({
})
const mapStateToProps = (state) => {
console.log(state)
return {
session_id: state.session_id,
outlet_id: state.outlet_id,
order_quantity: state.order_quantity,
order_total: state.order_total,
order_item: state.order_item,
quantity: state.quantity,
address: state.address
}
}
export default connect(mapStateToProps)(ShoppingCart)
\ No newline at end of file
export default connect(mapStateToProps)(ShoppingCart)
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