Commit 88b6ccb8 authored by d.arizona's avatar d.arizona

update

parent 15cb4e61
......@@ -10,6 +10,8 @@ import BaseText from '../Components/BaseText'
import Ionicons from 'react-native-vector-icons/Ionicons'
import firebase from '@react-native-firebase/app'
import messaging from '@react-native-firebase/messaging';
import moment from 'moment';
import momentId from 'moment/locale/id';
// create our store
const store = createStore()
......@@ -81,6 +83,7 @@ class App extends Component {
componentDidMount() {
this.checkPermission()
this.fetchToken()
moment.updateLocale('id', momentId)
}
checkPermission = async () => {
......
......@@ -18,6 +18,7 @@ import Constant from '../Lib/Constant';
import Toast from 'react-native-toast-message';
import { BarIndicator } from 'react-native-indicators';
import FontAwesome from 'react-native-vector-icons/FontAwesome'
import { NavigationEvents } from 'react-navigation';
class CartScreen extends Component {
constructor(props) {
......@@ -252,6 +253,10 @@ class CartScreen extends Component {
render () {
return (
<View style={{flex: 1, backgroundColor: '#4cc9f0'}}>
<NavigationEvents onDidFocus={() => {
this.getCurrency()
this.getCart()
}}/>
<BaseHeader onBackPress={() => this.props.navigation.goBack()} leftText={'Keranjang'} />
{this.state.loading? <View style={{flex: 1, backgroundColor: 'white', borderTopLeftRadius: 32, borderTopRightRadius: 32}}>
<BarIndicator count={5} color='#4cc9f0' size={25}/>
......
......@@ -28,6 +28,7 @@ class CheckOutScreen extends Component {
dataCheckout: [],
totalCheckout: 0,
delivery: null,
diskon: 0,
paymentMethod : null
}
}
......@@ -74,6 +75,7 @@ class CheckOutScreen extends Component {
refreshScreen() {
this.getAddress()
this.getCurrency()
console.log('ini data delivery', this.state.delivery)
}
async getCurrency() {
......@@ -95,6 +97,7 @@ class CheckOutScreen extends Component {
createOrder() {
let payloadCart = []
let diskon = 0
this.state.dataCheckout.map((item, index) => {
payloadCart.push({
"cart_id": item.cart_id,
......@@ -105,20 +108,31 @@ class CheckOutScreen extends Component {
"total_price": item.total_price,
"cart_date": null
})
diskon += item.discount_price
})
let payload = {
"address_id": this.state.address.address_id,
"payment_method": 1,
"delivery_charge": "1000",
"is_wallet": 0,
"payment_method": this.state.paymentMethod.payment_method_id,
"delivery_charge": this.state.delivery.rate_value,
"is_wallet": this.state.paymentMethod.payment_method_name == 'Wallet'? 1 : 0,
"coupon_id": null,
"coupon_discount": null,
"discount": 1000,
"discount": diskon,
"lat": this.state.address.lat,
"long": this.state.address.long,
"long": this.state.address.lng,
"cart": payloadCart,
"courier_rate_id": 1
"courier_rate_id": this.state.delivery.courier_rate_id
}
Api.create().createOrder(payload).then((response) => {
if (response.data.status == 'success') {
this.backAction()
}
console.log('tes respon',response.data)
})
// console.log('ini payload', payload)
}
render () {
......@@ -270,11 +284,11 @@ class CheckOutScreen extends Component {
</View>
<View style={{flexDirection:'row', justifyContent: 'space-between'}}>
<BaseText text={'Subtotal Pengiriman'} type={'regular'} style={{opacity: .5, fontSize: 12}}/>
<BaseText text={formatRp(this.state.currency, 0)} type={'bold'} style={{opacity: .5,fontSize: 12}}/>
<BaseText text={formatRp(this.state.currency, this.state.delivery == null? 0 : this.state.delivery.rate_value)} type={'bold'} style={{opacity: .5,fontSize: 12}}/>
</View>
<View style={{flexDirection:'row', justifyContent: 'space-between'}}>
<BaseText text={'Total Pembayaran'} type={'regular'} style={{opacity: .9}}/>
<BaseText text={formatRp(this.state.currency, this.state.totalCheckout)} type={'bold'} style={{color: '#4cc9f0'}}/>
<BaseText text={formatRp(this.state.currency, this.state.totalCheckout + (this.state.delivery == null? 0 : this.state.delivery.rate_value))} type={'bold'} style={{color: '#4cc9f0'}}/>
</View>
</View>
......@@ -286,10 +300,10 @@ class CheckOutScreen extends Component {
<View style={{flexDirection:'row', justifyContent: 'space-between', alignItems:'center'}}>
<View style={{width: '60%'}}>
<BaseText text={"Total"} type={"bold"} style={{opacity: .5, fontSize: 12}}/>
<BaseText text={formatRp(this.state.currency, this.state.totalCheckout)} type={"bold"} style={{opacity: .8, color: '#4cc9f0'}}/>
<BaseText text={formatRp(this.state.currency, this.state.totalCheckout + (this.state.delivery == null? 0 : this.state.delivery.rate_value))} type={"bold"} style={{opacity: .8, color: '#4cc9f0'}}/>
</View>
<View style={{width: '40%'}}>
<BaseButton text={'Buat Pesanan'} onPress={() => this.props.navigation.navigate('CheckOutScreen')} fontSizeText={14}/>
<BaseButton text={'Buat Pesanan'} onPress={() => this.createOrder()} fontSizeText={14}/>
</View>
</View>
</View>
......
......@@ -10,8 +10,17 @@ import BaseHeader from '../Components/BaseHeader'
import BaseText from '../Components/BaseText'
import { Images } from '../Themes'
import BaseButton from '../Components/BaseButton'
import Api from '../Services/Api'
import moment from 'moment';
class DetailOrderScreen extends Component {
constructor(props) {
super(props)
this.state = {
orderId: this.props.navigation.state.params.orderId,
dataOrder: null
}
}
backAction = () => {
this.props.navigation.goBack()
......@@ -19,8 +28,7 @@ class DetailOrderScreen extends Component {
};
componentDidMount() {
// alert('sadap')
// alert(JSON.stringify(this.props.navigation))
this.getDetailOrder()
BackHandler.addEventListener("hardwareBackPress", this.backAction);
}
......@@ -28,16 +36,25 @@ class DetailOrderScreen extends Component {
BackHandler.removeEventListener("hardwareBackPress", this.backAction);
}
getDetailOrder() {
Api.create().getDetailOrder(this.state.orderId).then((response) => {
if (response.data.status == 'success') {
this.setState({dataOrder: response.data.data})
}
console.log('ini data nya', moment(response.data.data.order_date).format('LLL'))
})
}
render () {
return (
<View style={{flex: 1, backgroundColor: '#4cc9f0'}}>
<BaseHeader leftText={'No. Order 123456'} onBackPress={this.backAction}/>
<BaseHeader leftText={`No. Order {}`} onBackPress={this.backAction}/>
<ScrollView style={[styles.scrollContent]}>
{/* Tanggal */}
<View style={{padding: 15, borderRadius: 10, elevation: 5, backgroundColor: 'white', marginVertical: 20, marginHorizontal: 5}}>
<BaseText text={"Tanggal"} type={"regular"} style={{fontSize: 10, color: '#4b4b4b', opacity: .7}}/>
<BaseText text={"18 Juli 2020, 10:38 AM"} type={"regular"} style={{fontSize: 12, opacity: .9}}/>
<BaseText text={this.state.dataOrder == null? '' : `${moment(String(this.state.dataOrder.order_date).substr(0,10)).format('DD MMMM YYYY')}, ${moment(String(this.state.dataOrder.order_date).substr(11,19)).format('LT')}`} type={"regular"} style={{fontSize: 12, opacity: .9}}/>
<View style={{marginVertical: 10, height: 1, width: '100%', backgroundColor: '#d8d8d8'}}/>
<BaseText text={"Status Pesanan"} type={"regular"} style={{fontSize: 10, color: '#4b4b4b', opacity: .7}}/>
<BaseText text={"MENUNGGU KONFIRMASI"} type={"regular"} style={{fontSize: 12, opacity: .9}}/>
......
......@@ -45,6 +45,7 @@ class ListAddressScreen extends Component {
this.setState({
data: response.data.data
})
console.log(response.data.data)
} else {
this.setState({ data: [] })
}
......
This diff is collapsed.
......@@ -76,6 +76,13 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => {
const topUpWallet = (body) => api.post('topup_wallet', body)
const getPaymentMethod = () => api.get('get_payment_method')
// Order
const createOrder = (body) => api.post('create_order', body)
const getOrder = (body) => api.post('get_order', body)
const getDetailOrder = (orderId) => api.get(`detail_order/${orderId}`)
const cancelOrder = (body) => api.post('cancel_order', body)
const getCancelReasonOrder = () => api.get('get_cancelling_reason')
const getOrderStatus = () => api.get('get_order_status')
// Courier
const getCategoryCourier = () => api.get('get_category_courier')
......@@ -197,6 +204,12 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => {
readAllNotification,
getEstimateCourier,
getEstimateDelivery,
createOrder,
getOrder,
getDetailOrder,
cancelOrder,
getCancelReasonOrder,
getOrderStatus,
}
}
......
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