Commit 560b2871 authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

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

# Conflicts:
#	view/ShoppingCart.js
parents c54fc936 3d11b3d8
......@@ -24,7 +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'
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,
......
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,24 +51,46 @@ class DeliveryAddrees extends React.Component {
})
}
addAdreess(){
addAdreess() {
this.props.navigation.navigate('Address Detail', { 'data': 'sample', onChangeAddress: this.onChangeAddress })
}
onSave(address) {
Alert.alert(
'',
'Apakah anda akan memilih alamat untuk pengiriman ?',
[
{text: 'OK', onPress: () => this.props.navigation.navigate('')},
],
{ cancelable: false }
)
let setDataAddress = {
address : address
}
this.props.setAddress(setDataAddress);
}
render() {
function Item({ name,description,address }) {
function Item({ name, description, address }) {
return (
<View style={styles.list_addrees}>
<View style={{ margin: 5, }}>
<Text style={{ fontWeight: 'bold', fontSize: 20 }}>{name}</Text>
</View>
<Text style={{ margin: 5 }}>
{address}
</Text>
<Text style={{ margin: 5 }}>
Patokan : {description}
</Text>
<TouchableOpacity onPress={()=>this.onSave(address)}>
<View style={{ margin: 5, }}>
<Text style={{ fontWeight: 'bold', fontSize: 20 }}>{name}</Text>
</View>
<Text style={{ margin: 5 }}>
{address}
</Text>
<Text style={{ margin: 5 }}>
Patokan : {description}
</Text>
</TouchableOpacity>
</View>
);
}
......@@ -84,7 +107,7 @@ class DeliveryAddrees extends React.Component {
<FlatList
data={this.state.data}
renderItem={({ item }) => <Item name={item.name} description = {item.description} address = {item.address} /> }
renderItem={({ item }) => <Item name={item.name} description={item.description} address={item.address} />}
keyExtractor={item => item.id}
/>
{/*
......@@ -144,5 +167,18 @@ const mapStateToProps = (state) => {
}
}
const mapDispatchToProps = (dispacth) => {
return {
setAddress: (setDataAddress) => dispacth({
type: ActionType.SET_ADDRESS,
data: {
address: setDataAddress.address,
}
}),
}
}
export default connect(mapStateToProps)(DeliveryAddrees)
......@@ -131,18 +131,20 @@ class MenuSelection extends React.Component {
this.props.reduceQuantityItem(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
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
})
}
const listMenu = [...this.state.listMenu]
listMenu[index].qty = quantity
this.setState({
listMenu
})
}
render() {
......@@ -152,23 +154,12 @@ class MenuSelection extends React.Component {
<StatusBar hidden={true} />
<View style={{ flex: 0.7, height: 90, flexDirection: 'row', borderWidth: 1, }}>
<FlatList horizontal={true} style={{ flexDirection: 'row' }}
data={this.state.list_category}
data={this.state.listCategory}
renderItem={this.renderTabBar}
keyExtractor= {(item) => item.id}
/>
</View>
<View style={{ flex: 3 }}>
{/* <SafeAreaView style={styles.container}>
<SectionList
sections={this.state.listMenu}
keyExtractor={item => item.id}
renderItem={({ item }) => (item={item})}
renderSectionHeader={({ section }) => (
<Text >{section.category.name}</Text>
)}
/>
</SafeAreaView> */}
<FlatList
data={this.state.listMenu}
renderItem={({ item, index }) => (
......
......@@ -9,62 +9,6 @@ import i18n from 'i18n-js';
import CurrencyFormat from 'react-currency-format';
import Axios from 'axios'
class Items extends React.Component {
render() {
const { item } = this.props
// console.log('ini props nya item : ' + JSON.stringify(item))
console.log(this.props)
const { description, name, image, price, qty } = item
return (
<View style={{ flex: 1, margin: 10 }}>
<View style={{ flexDirection: 'row' }}>
<View style={{ borderRadius: 20 }}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Menu Detail', { Foto: image, nama: name, desc: description })}>
<Image style={{ height: 100, width: 100, resizeMode: 'contain' }}
source={{
uri: image
}}
/>
</TouchableOpacity>
</View>
<View>
<View style={{ margin: 5, }}>
<Text style={{ fontWeight: 'bold', fontSize: 20 }}> Nama Menu : {name}</Text>
</View>
<Text style={{ margin: 5 }}>
Description : {description}
</Text>
<View style={{ margin: 5 }}>
<CurrencyFormat value={price} displayType={'text'}
thousandSeparator={true}
prefix={'Rp '}
renderText={value => <Text>{value}</Text>} />
</View>
<View style={{ flexDirection: 'row', margin: 5 }}>
<Text>Quantity : </Text>
<TouchableOpacity onPress={() => this.props.minusQty()}>
<AntDesign name='minuscircleo'
size={20}
color={'blue'}
/>
</TouchableOpacity>
<Text> {qty} </Text>
<TouchableOpacity onPress={() => this.props.plusQty()}>
<AntDesign name='pluscircleo'
size={20}
color={'blue'}
/>
</TouchableOpacity>
</View>
</View>
</View>
</View>
)
}
}
class ShoppingCart extends React.Component {
constructor(props) {
super(props)
......@@ -73,7 +17,9 @@ class ShoppingCart extends React.Component {
kasproPoint: '',
checkedBalance: false,
checkedPoint: false,
checkedBalancePoint: false
checkedBalancePoint: false,
balanceused: 0,
pointsused: 0,
}
}
......@@ -92,9 +38,6 @@ class ShoppingCart extends React.Component {
}
}
plusQty(item, index) {
this.setState({
......@@ -114,19 +57,26 @@ class ShoppingCart extends React.Component {
this.setState({
checkedBalance: true,
checkedPoint: false,
checkedBalancePoint: false
checkedBalancePoint: false,
balanceused: this.props.order_total,
pointsused: 0
})
} else if (val == 'point') {
this.setState({
checkedBalance: false,
checkedPoint: true,
checkedBalancePoint: false
checkedBalancePoint: false,
pointsused: this.props.order_total,
balanceused: 0
})
} else {
this.setState({
checkedBalance: false,
checkedPoint: false,
checkedBalancePoint: true
checkedBalancePoint: true,
pointsused : this.state.kasproPoint,
balanceused : this.props.order_total - this.state.kasproPoint
})
}
}
......@@ -156,7 +106,6 @@ class ShoppingCart extends React.Component {
}
render() {
return (
<ScrollView style={styles.container}>
<View style={{ flexDirection: 'row', justifyContent: 'center' }}>
......@@ -182,9 +131,10 @@ 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}>
{this.props.order_item.map((item, i) => {
return (
<View style={{ flex: 1, margin: 10 }} key={i}>
<View style={{ flexDirection: 'row' }}>
<View >
<Image source={{ uri: item.image }} style={{ height: 100, width: 100, borderRadius: 5, top: 5 }}></Image>
......@@ -198,11 +148,11 @@ class ShoppingCart extends React.Component {
<TouchableOpacity onPress={() => this.props.handleMin()}>
<Text style={{ fontSize: 20, margin: 2 }}> - </Text>
</TouchableOpacity>
<TextInput
style={{ height: 25, padding: 2,textAlign:'center',margin:2 }}
autoCapitalize="none">
{item.quantity}
</TextInput>
<TextInput
style={{ height: 25, padding: 2, textAlign: 'center', margin: 2 }}
autoCapitalize="none">
{item.quantity}
</TextInput>
<TouchableOpacity onPress={() => this.props.handleAdd()}>
<Text style={{ fontSize: 20, margin: 2 }}> + </Text>
</TouchableOpacity>
......@@ -211,70 +161,150 @@ class ShoppingCart extends React.Component {
</View>
</View>
</View>
)
})}
)
})}
</View>
<View style={styles.payment}>
<Text>PAYMENT METHODS</Text>
</View>
<View style={{ alignItems: 'center' }}>
<Card style={{ margin: 5, padding: 10 }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
<View>
<Text>EXCELSO BALANCE</Text>
<Text style={{ color: 'gray' }}>Your Balance : IDR {this.state.kasproBalance}</Text>
</View>
<View style={{ paddingRight: 10 }}>
<CheckBox
onClick={() => {
this.checkedSelection('balance')
}}
isChecked={this.state.checkedBalance}
checkedImage={<FontAwesome name='check-circle' size={30} color={'#ccb46c'} />}
unCheckedImage={<FontAwesome name='circle-o' size={30} color={'#ccb46c'} />}
/>
</View>
</View>
</Card>
{
this.state.kasproBalance < this.props.order_total ? (
<Card style={{ margin: 5, padding: 10, backgroundColor: 'gray' }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
<View>
<Text>EXCELSO BALANCE</Text>
</View>
<View style={{ paddingRight: 10 }}>
<FontAwesome name='circle-o' size={30} color={'#ccb46c'} />
</View>
</View>
</Card>
) : (
<TouchableOpacity onPress={() => {
this.checkedSelection('balance')
}}>
<Card style={{ margin: 5, padding: 10 }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
<View>
<Text>EXCELSO BALANCE</Text>
</View>
<View style={{ paddingRight: 10 }}>
<CheckBox
onClick={() => {
this.checkedSelection('balance')
}}
isChecked={this.state.checkedBalance}
checkedImage={<FontAwesome name='check-circle' size={30} color={'#ccb46c'} />}
unCheckedImage={<FontAwesome name='circle-o' size={30} color={'#ccb46c'} />}
/>
</View>
</View>
</Card>
</TouchableOpacity>
)
}
</View>
<View style={{ alignItems: 'center' }}>
{
this.state.kasproPoint < this.props.order_total ? (
<Card style={{ margin: 5, padding: 10, backgroundColor: 'gray' }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
<View>
<Text>EXCELSO POINTS</Text>
</View>
<View style={{ paddingRight: 10 }}>
<FontAwesome name='circle-o' size={30} color={'#ccb46c'} />
</View>
</View>
</Card>
) : (
<TouchableOpacity onPress={() => {
this.checkedSelection('point')
}}>
<Card style={{ margin: 5, padding: 10 }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
<View>
<Text>EXCELSO POINTS</Text>
</View>
<View style={{ paddingRight: 10 }}>
<CheckBox
onClick={() => {
this.checkedSelection('point')
}}
isChecked={this.state.checkedPoint}
checkedImage={<FontAwesome name='check-circle' size={30} color={'#ccb46c'} />}
unCheckedImage={<FontAwesome name='circle-o' size={30} color={'#ccb46c'} />}
/>
</View>
</View>
</Card>
</TouchableOpacity>
)
}
</View>
<View style={{ alignItems: 'center' }}>
{
this.state.kasproPoint + this.state.kasproBalance >= this.props.order_total && this.state.kasproBalance != 0 ? (
<TouchableOpacity onPress={() => {
this.checkedSelection('balancepoint')
}}>
<Card style={{ margin: 5, padding: 10 }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
<View>
<Text>EXCELSO BALANCE + POINTS</Text>
</View>
<View style={{ paddingRight: 10 }}>
<CheckBox
onClick={() => {
this.checkedSelection('balancepoint')
}}
isChecked={this.state.checkedBalancePoint}
checkedImage={<FontAwesome name='check-circle' size={30} color={'#ccb46c'} />}
unCheckedImage={<FontAwesome name='circle-o' size={30} color={'#ccb46c'} />}
/>
</View>
</View>
</Card>
</TouchableOpacity>
) : (
<Card style={{ margin: 5, padding: 10, backgroundColor: 'gray' }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
<View>
<Text>EXCELSO BALANCE + POINTS</Text>
</View>
<View style={{ paddingRight: 10 }}>
<FontAwesome name='circle-o' size={30} color={'#ccb46c'} />
</View>
</View>
</Card>
)
}
</View>
<View style={{ alignItems: 'center', }}>
<Card style={{ margin: 5, padding: 10 }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', marginBottom: 5 }}>
<View>
<Text>EXCELSO POINTS</Text>
<Text style={{ color: 'gray' }}>Your Points : IDR {this.state.kasproPoint}</Text>
<Text>Your Balance</Text>
<Text>Your Points</Text>
</View>
<View style={{ paddingRight: 10 }}>
<CheckBox
onClick={() => {
this.checkedSelection('point')
}}
isChecked={this.state.checkedPoint}
checkedImage={<FontAwesome name='check-circle' size={30} color={'#ccb46c'} />}
unCheckedImage={<FontAwesome name='circle-o' size={30} color={'#ccb46c'} />}
/>
<View style={{ paddingRight: 30, alignItems: 'flex-end' }}>
<Text>{this.state.kasproBalance}</Text>
<Text>{this.state.kasproPoint}</Text>
</View>
</View>
</Card>
</View>
<View style={{ alignItems: 'center' }}>
<Card style={{ margin: 5, padding: 10 }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
<View>
<Text>EXCELSO BALANCE + EXCELSO POINTS</Text>
<Text style={{ color: 'gray' }}>Your Balance : IDR {this.state.kasproBalance}</Text>
<Text style={{ color: 'gray' }}>Your Points : IDR {this.state.kasproPoint}</Text>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', borderTopWidth: 1 }}>
<View style={{ marginTop: 5 }}>
<Text>Your Balance Used</Text>
<Text>Your Points Used</Text>
</View>
<View style={{ paddingRight: 10 }}>
<CheckBox
onClick={() => {
this.checkedSelection('balancepoint')
}}
isChecked={this.state.checkedBalancePoint}
checkedImage={<FontAwesome name='check-circle' size={30} color={'#ccb46c'} />}
unCheckedImage={<FontAwesome name='circle-o' size={30} color={'#ccb46c'} />}
/>
<View style={{ paddingRight: 30, marginTop: 5, alignItems: 'flex-end' }}>
<Text>- {this.state.balanceused}</Text>
<Text>- {this.state.pointsused}</Text>
</View>
</View>
</Card>
......@@ -296,7 +326,8 @@ 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>
<Text style={{ paddingRight: 150, paddingTop: 15, color: 'gray' }}>{this.props.order_total}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}>
......@@ -320,7 +351,8 @@ 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>
<Text style={{ fontSize: 35, color: '#ccb46c' }}>{this.props.order_total}</Text>
</View>
</View>
<View style={{ flexDirection: 'row', marginTop: 10, justifyContent: 'space-between' }}>
......@@ -362,6 +394,7 @@ const styles = StyleSheet.create({
order: {
flex: 1,
margin: 10,
backgroundColor: '#fff'
},
payment: {
......
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