Commit 649131b9 authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'deni(lptp)' into 'master'

Deni(lptp)

See merge request !34
parents 5f0a869e df96505a
This diff is collapsed.
...@@ -11,6 +11,7 @@ import CountDown from 'react-native-countdown-component'; ...@@ -11,6 +11,7 @@ import CountDown from 'react-native-countdown-component';
import BaseHeader from '../Components/BaseHeader' import BaseHeader from '../Components/BaseHeader'
import { Images } from '../Themes' import { Images } from '../Themes'
import BaseText from '../Components/BaseText'; import BaseText from '../Components/BaseText';
import Api from '../Services/Api';
class DealsOfTheDayScreen extends Component { class DealsOfTheDayScreen extends Component {
constructor(props) { constructor(props) {
...@@ -25,6 +26,9 @@ class DealsOfTheDayScreen extends Component { ...@@ -25,6 +26,9 @@ class DealsOfTheDayScreen extends Component {
{ nama: 'Compass x Pot Meets Pop', harga: 'Rp. 3.700.000', color: 'rgba(158, 212, 185, 0.44)', diskon: 'Rp. 2.000.000', jual: 28 }, { nama: 'Compass x Pot Meets Pop', harga: 'Rp. 3.700.000', color: 'rgba(158, 212, 185, 0.44)', diskon: 'Rp. 2.000.000', jual: 28 },
], ],
progressStatus: 20, progressStatus: 20,
data: [],
count: 500,
countdown: false
} }
this.anim = new Animated.Value(0); this.anim = new Animated.Value(0);
} }
...@@ -37,6 +41,7 @@ class DealsOfTheDayScreen extends Component { ...@@ -37,6 +41,7 @@ class DealsOfTheDayScreen extends Component {
componentDidMount() { componentDidMount() {
this.onAnimate(); this.onAnimate();
BackHandler.addEventListener("hardwareBackPress", this.backAction); BackHandler.addEventListener("hardwareBackPress", this.backAction);
this.getDOTD()
} }
componentWillUnmount() { componentWillUnmount() {
...@@ -51,42 +56,66 @@ class DealsOfTheDayScreen extends Component { ...@@ -51,42 +56,66 @@ class DealsOfTheDayScreen extends Component {
duration: 30000, duration: 30000,
}).start(); }).start();
} }
getDOTD() {
Api.create().getDealOfTheDay().then(response => {
if (response.data.status == "success") {
this.setState({ data: response.data.data, count: response.data.data[0].remaining, countdown: true })
} else {
this.setState({ data: [], count: 0 })
}
console.log(JSON.stringify(response.data))
})
}
number(num) {
var rupiah = '';
var angkarev = num.toString().split('').reverse().join('');
for (var i = 0; i < angkarev.length; i++) if (i % 3 == 0) rupiah += angkarev.substr(i, 3) + '.';
return 'Rp. ' + rupiah.split('', rupiah.length - 1).reverse().join('');
}
render() { render() {
return ( return (
<View style={{ flex: 1, backgroundColor: '#4cc9f0' }}> <View style={{ flex: 1, backgroundColor: '#4cc9f0' }}>
<BaseHeader leftText={'Deals Of The Day'} onBackPress={() => this.props.navigation.goBack()} /> <BaseHeader leftText={'Deals Of The Day'} onBackPress={() => this.props.navigation.goBack()} />
<View style={{ flex: 1, backgroundColor: '#fff', borderTopLeftRadius: 30, borderTopRightRadius: 30, width: '100%', paddingTop: 20 }}> <View style={{ flex: 1, backgroundColor: '#fff', borderTopLeftRadius: 30, borderTopRightRadius: 30, width: '100%', paddingTop: 20 }}>
<ScrollView> <ScrollView>
<View style={{ width: '90%', elevation: 5, alignSelf: 'center', backgroundColor: 'white', flexDirection: 'row', justifyContent: 'space-between', paddingLeft: 20, borderRadius: 10 }}> {this.state.countdown && (
<Image source={Images.flash} style={{ width: 58, height: 30, marginVertical: 5 }} /> <View style={{ width: '90%', elevation: 5, alignSelf: 'center', backgroundColor: 'white', flexDirection: 'row', justifyContent: 'space-between', paddingLeft: 20, borderRadius: 10 }}>
<View style={{ width: 130, backgroundColor: '#4cc9f0', borderRadius: 10, justifyContent: 'center' }}> <Image source={Images.flash} style={{ width: 58, height: 30, marginVertical: 5 }} />
<CountDown <View style={{ width: 130, backgroundColor: '#4cc9f0', borderRadius: 10, justifyContent: 'center' }}>
size={13}
until={1000} <CountDown
onFinish={() => alert('Finished')} size={13}
digitStyle={{ backgroundColor: '#FFF', borderWidth: 2, borderColor: '#4cc9f0' }} until={this.state.count}
digitTxtStyle={{ color: 'black' }} onFinish={() => alert('Flash Sale Telah Berakhir')}
timeLabelStyle={{ color: 'red', fontWeight: 'bold' }} digitStyle={{ backgroundColor: '#FFF', borderWidth: 2, borderColor: '#4cc9f0' }}
separatorStyle={{ color: '#fff' }} digitTxtStyle={{ color: 'black' }}
timeToShow={['H', 'M', 'S']} timeLabelStyle={{ color: 'red', fontWeight: 'bold' }}
timeLabels={{ m: null, s: null }} separatorStyle={{ color: '#fff' }}
showSeparator timeToShow={['H', 'M', 'S']}
/> timeLabels={{ m: null, s: null }}
showSeparator
/>
</View>
</View> </View>
</View> )}
<View style={{ marginTop: 30, paddingHorizontal: 20 }}> <View style={{ marginTop: 30, paddingHorizontal: 20 }}>
<FlatList <FlatList
scrollEnabled={false} scrollEnabled={false}
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
data={this.state.dummyList} data={this.state.data}
renderItem={({ item, index }) => ( renderItem={({ item, index }) => (
<View style={{ flex: 1, flexDirection: 'row', marginTop: index == 0 ? 0 : 10, borderRadius: 15, elevation: 5, backgroundColor: 'white', marginHorizontal: 10, marginBottom: index == this.state.dummyList.length - 1 ? 15 : 0 }}> <View style={{ flex: 1, flexDirection: 'row', marginTop: index == 0 ? 0 : 0, borderRadius: 15, elevation: 5, backgroundColor: 'white', marginHorizontal: 10, marginBottom: 15 }}>
<View style={{ width: '36%', backgroundColor: item.color, borderTopLeftRadius: 15, borderBottomLeftRadius: 15 }} /> <View style={{ width: '36%', backgroundColor: item.color, borderTopLeftRadius: 15, borderBottomLeftRadius: 15 }}>
<Image source={{ uri: item.product_image }} style={{ width: 110, height: 110, borderTopLeftRadius: 15, borderBottomLeftRadius: 15 }} />
</View>
<View style={{ width: '45%', justifyContent: 'flex-start', paddingHorizontal: 10, backgroundColor: 'white', borderTopRightRadius: 15, borderBottomRightRadius: 15, paddingVertical: 5 }}> <View style={{ width: '45%', justifyContent: 'flex-start', paddingHorizontal: 10, backgroundColor: 'white', borderTopRightRadius: 15, borderBottomRightRadius: 15, paddingVertical: 5 }}>
<BaseText type={"regular"} text={item.nama} style={{ fontSize: 10, color: 'black', textAlign: 'left', }} ellipsizeMode={"tail"} numberOfLines={1} /> <BaseText type={"regular"} text={item.product_name} style={{ fontSize: 10, color: 'black', textAlign: 'left', }} ellipsizeMode={"tail"} numberOfLines={2} />
<BaseText type={"regular"} text={item.harga} style={{ fontSize: 10, color: '#d8d8d8', textAlign: 'left', textDecorationLine: 'line-through', marginTop: 10 }} /> <BaseText type={"regular"} text={this.number(item.price)} style={{ fontSize: 10, color: '#d8d8d8', textAlign: 'left', textDecorationLine: 'line-through', marginTop: 10 }} />
<BaseText type={"bold"} text={item.diskon} style={{ fontSize: 12, color: '#4cc9f0', textAlign: 'left', marginTop: 5 }} /> <BaseText type={"bold"} text={this.number(item.deal_price)} style={{ fontSize: 12, color: '#4cc9f0', textAlign: 'left', marginTop: 5 }} />
<BaseText type={"bold"} text={`${item.jual} TERJUAL`} style={{ fontSize: 10, color: 'black', textAlign: 'left', marginTop: 5 }} /> <BaseText type={"bold"} text={`20 TERJUAL`} style={{ fontSize: 10, color: 'black', textAlign: 'left', marginTop: 5 }} />
<Progress.Bar progress={this.state.progressStatus / 100} color={'#ffe500'} width={120} height={12} style={{ justifyContent: 'center', marginTop: 5, borderColor: '#fff', backgroundColor: '#eaeaea', borderRadius: 10 }}> <Progress.Bar progress={this.state.progressStatus / 100} color={'#ffe500'} width={120} height={12} style={{ justifyContent: 'center', marginTop: 5, borderColor: '#fff', backgroundColor: '#eaeaea', borderRadius: 10 }}>
<Animated.Text style={{ <Animated.Text style={{
fontSize: 10, fontSize: 10,
......
...@@ -47,7 +47,8 @@ class ProfileScreen extends Component { ...@@ -47,7 +47,8 @@ class ProfileScreen extends Component {
this.setState({ auth: prevState.auth }) this.setState({ auth: prevState.auth })
let auth = this.state.auth let auth = this.state.auth
if (auth !== null && !auth.fetching) { if (auth !== null && !auth.fetching) {
console.log('tag', auth) console.log('tag', auth.user.data)
this.setState({ data: auth.user.data})
} }
} }
} }
......
...@@ -10,8 +10,8 @@ import { View } from 'react-native-animatable' ...@@ -10,8 +10,8 @@ import { View } from 'react-native-animatable'
import BaseHeader from '../Components/BaseHeader' import BaseHeader from '../Components/BaseHeader'
import BaseText from '../Components/BaseText' import BaseText from '../Components/BaseText'
import BaseInput from '../Components/BaseInput' import BaseInput from '../Components/BaseInput'
import Api from '../Services/Api'
import { handlePhone } from '../Lib/Utils' import { handlePhone } from '../Lib/Utils'
import R from 'ramda'
class RincianProfilScreen extends Component { class RincianProfilScreen extends Component {
constructor(props) { constructor(props) {
...@@ -24,6 +24,9 @@ class RincianProfilScreen extends Component { ...@@ -24,6 +24,9 @@ class RincianProfilScreen extends Component {
email: "", email: "",
phone: "", phone: "",
auth: this.props.auth, auth: this.props.auth,
errorName: "",
errorPhone: false,
textErrorPhone: ""
} }
} }
...@@ -49,19 +52,26 @@ class RincianProfilScreen extends Component { ...@@ -49,19 +52,26 @@ class RincianProfilScreen extends Component {
validate(type) { validate(type) {
if (type == 'name') { if (type == 'name') {
if (this.props.auth != null) { if (R.isEmpty(this.state.firstName)) {
let data = this.props.auth.user.data this.setState({ errorName: 'Nama tidak boleh kosong' })
let name = this.state.lastName == "" ? this.state.firstName : this.state.firstName + ' ' + this.state.lastName }
let body = { else if (this.state.firstName.length < 3) {
"user_name": name, this.setState({ errorName: 'Nama Tidak Boleh Kurang Dari 3 Karakter' })
"user_email": "", } else {
"user_phone": "", if (this.props.auth != null) {
"user_image": "" let data = this.props.auth.user.data
let name = this.state.lastName == "" ? this.state.firstName : this.state.firstName + ' ' + this.state.lastName
let body = {
"user_name": name,
"user_email": "",
"user_phone": "",
"user_image": ""
}
this.props.authEditRequest(body)
// Api.create().editProfile(body).then((response) => {
// console.log(response)
// })
} }
this.props.authEditRequest(body)
// Api.create().editProfile(body).then((response) => {
// console.log(response)
// })
} }
} else if (type == 'email') { } else if (type == 'email') {
if (this.props.auth != null) { if (this.props.auth != null) {
...@@ -78,18 +88,21 @@ class RincianProfilScreen extends Component { ...@@ -78,18 +88,21 @@ class RincianProfilScreen extends Component {
// }) // })
} }
} else if (type == 'hp') { } else if (type == 'hp') {
if (this.props.auth != null) { if (R.isEmpty(this.state.phone)) {
let data = this.props.auth.user.data this.setState({ textErrorPhone: 'Nomor Handphone Tidak Boleh Kosong', errorPhone: true })
let body = { } else if (this.state.phone.length < 9) {
"user_name": "", this.setState({ textErrorPhone: 'Nomor Handphone Kurang Dari 10 Digit', errorPhone: true })
"user_email": "", } else {
"user_phone": "0" + this.state.phone, if (this.props.auth != null) {
"user_image": "" let data = this.props.auth.user.data
let body = {
"user_name": "",
"user_email": "",
"user_phone": "0" + this.state.phone,
"user_image": ""
}
this.props.authEditRequest(body)
} }
this.props.authEditRequest(body)
// Api.create().editProfile(body).then((response) => {
// console.log(response)
// })
} }
} }
} }
...@@ -156,7 +169,7 @@ class RincianProfilScreen extends Component { ...@@ -156,7 +169,7 @@ class RincianProfilScreen extends Component {
<BaseText type={"bold"} text={'Harap diisi sesuai dengan nomor handphone Anda yang aktif untuk mempermudah proses verifikasi'} style={{ fontSize: 12, color: '#4b4b4b', alignSelf: 'center', textAlign: 'center' }} /> <BaseText type={"bold"} text={'Harap diisi sesuai dengan nomor handphone Anda yang aktif untuk mempermudah proses verifikasi'} style={{ fontSize: 12, color: '#4b4b4b', alignSelf: 'center', textAlign: 'center' }} />
<View style={{ marginTop: 30 }}> <View style={{ marginTop: 30 }}>
<BaseText text={"No. Handphone"} type={"bold"} style={{ fontSize: 12, color: '#4b4b4b', opacity: .6 }} /> <BaseText text={"No. Handphone"} type={"bold"} style={{ fontSize: 12, color: '#4b4b4b', opacity: .6 }} />
<View style={{ flexDirection: 'row', flexGrow: 1, borderBottomColor: '#d8d8d8', borderBottomWidth: 1, alignItems: 'center', }}> <View style={{ flexDirection: 'row', flexGrow: 1, borderBottomColor: this.state.errorPhone ? 'red' : '#d8d8d8', borderBottomWidth: 1, alignItems: 'center', }}>
<View style={{ width: '15%', flexDirection: 'row' }}> <View style={{ width: '15%', flexDirection: 'row' }}>
<BaseText text={"+62"} type={"bold"} style={{ fontSize: 14, color: '#4b4b4b', opacity: .8 }} /> <BaseText text={"+62"} type={"bold"} style={{ fontSize: 14, color: '#4b4b4b', opacity: .8 }} />
<BaseText text={"|"} type={"light"} style={{ fontSize: 18, color: '#4b4b4b', opacity: .5, marginHorizontal: 10, marginTop: -3 }} /> <BaseText text={"|"} type={"light"} style={{ fontSize: 18, color: '#4b4b4b', opacity: .5, marginHorizontal: 10, marginTop: -3 }} />
...@@ -170,7 +183,7 @@ class RincianProfilScreen extends Component { ...@@ -170,7 +183,7 @@ class RincianProfilScreen extends Component {
// ref={(ref) => { this.phone = ref; }} // ref={(ref) => { this.phone = ref; }}
maxLength={13} maxLength={13}
onChangeText={(phone) => { onChangeText={(phone) => {
this.setState({ phone: handlePhone(phone) }) this.setState({ phone: handlePhone(phone), errorPhone: false })
}} }}
// onSubmitEditing={() => { // onSubmitEditing={() => {
// this.focusNextField('password'); // this.focusNextField('password');
...@@ -179,6 +192,11 @@ class RincianProfilScreen extends Component { ...@@ -179,6 +192,11 @@ class RincianProfilScreen extends Component {
/> />
</View> </View>
</View> </View>
{this.state.errorPhone && (
<View>
<BaseText type={"bold"} text={this.state.textErrorPhone} style={{ fontSize: 12, marginTop: 10, color: 'red', opacity: .5 }} />
</View>
)}
<View style={{ flexDirection: 'row', justifyContent: 'space-around', marginTop: 30, width: '100%' }}> <View style={{ flexDirection: 'row', justifyContent: 'space-around', marginTop: 30, width: '100%' }}>
<TouchableOpacity style={{ backgroundColor: '#fff', height: 45, borderRadius: 30, width: '45%', borderColor: '#4cc9f0', borderWidth: 1 }}> <TouchableOpacity style={{ backgroundColor: '#fff', height: 45, borderRadius: 30, width: '45%', borderColor: '#4cc9f0', borderWidth: 1 }}>
<BaseText type={"regular"} text={'Tidak'} style={{ fontSize: 16, textAlign: 'center', marginTop: 10, color: '#4cc9f0' }} /> <BaseText type={"regular"} text={'Tidak'} style={{ fontSize: 16, textAlign: 'center', marginTop: 10, color: '#4cc9f0' }} />
...@@ -197,11 +215,11 @@ class RincianProfilScreen extends Component { ...@@ -197,11 +215,11 @@ class RincianProfilScreen extends Component {
title={"Nama Depan"} title={"Nama Depan"}
placeholder={"Nama Depan"} placeholder={"Nama Depan"}
value={this.state.firstName} value={this.state.firstName}
onChangeText={(firstName) => this.setState({ firstName: firstName.replace(/[^a-zA-Z.', ]/g, "") })} onChangeText={(firstName) => this.setState({ firstName: firstName.replace(/[^a-zA-Z.', ]/g, ""), errorName: "" })}
blurOnSubmit={false} blurOnSubmit={false}
// lineColor={this.state.errorName ? 'red' : '#d8d8d8'} lineColor={this.state.errorName ? 'red' : '#d8d8d8'}
// notes={this.state.errorName ? 'Nama Tidak Boleh Kosong' : ''} notes={this.state.errorName ? this.state.errorName : ''}
// notesColor={this.state.errorName ? 'red' : '#4b4b4b'} notesColor={this.state.errorName ? 'red' : '#4b4b4b'}
/> />
</View> </View>
<View style={{ marginTop: 20 }}> <View style={{ marginTop: 20 }}>
......
...@@ -70,7 +70,7 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => { ...@@ -70,7 +70,7 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => {
const verifikasiOtpEmail = (otp) => api.post('verify_otp_signup_email', otp) const verifikasiOtpEmail = (otp) => api.post('verify_otp_signup_email', otp)
const editProfile = (body) => api.post('edit_profile', body) const editProfile = (body) => api.post('edit_profile', body)
const editPhotoProfile = (body) => api.post('edit_photo', body) const editPhotoProfile = (body) => api.post('edit_photo', body)
const getAddress = () => api.get('get_address') const getDealOfTheDay = () => api.get('get_deal_of_the_day')
// Wishlist // Wishlist
const getWhislist = (body) => api.post('get_wishlist', body) const getWhislist = (body) => api.post('get_wishlist', body)
...@@ -79,6 +79,7 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => { ...@@ -79,6 +79,7 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => {
const deleteWishlist = (wishlistId) => api.post(`delete_wishlist/${wishlistId}`) const deleteWishlist = (wishlistId) => api.post(`delete_wishlist/${wishlistId}`)
// Address // Address
const getAddress = () => api.get('get_address')
const getProvinsi = () => api.get('get_province') const getProvinsi = () => api.get('get_province')
const getKota = (body) => api.get('get_kab_kot/' + body) const getKota = (body) => api.get('get_kab_kot/' + body)
const getKecamatan = (body) => api.get('get_kecamatan/' + body) const getKecamatan = (body) => api.get('get_kecamatan/' + body)
...@@ -158,7 +159,8 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => { ...@@ -158,7 +159,8 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => {
getProductDetail, getProductDetail,
getPriceRange, getPriceRange,
addWishlist, addWishlist,
deleteWishlist deleteWishlist,
getDealOfTheDay
} }
} }
......
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