Commit df96505a authored by Deni Rinaldi's avatar Deni Rinaldi

dotd + validasi address

parent 83947640
This diff is collapsed.
......@@ -11,6 +11,7 @@ import CountDown from 'react-native-countdown-component';
import BaseHeader from '../Components/BaseHeader'
import { Images } from '../Themes'
import BaseText from '../Components/BaseText';
import Api from '../Services/Api';
class DealsOfTheDayScreen extends Component {
constructor(props) {
......@@ -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 },
],
progressStatus: 20,
data: [],
count: 500,
countdown: false
}
this.anim = new Animated.Value(0);
}
......@@ -37,6 +41,7 @@ class DealsOfTheDayScreen extends Component {
componentDidMount() {
this.onAnimate();
BackHandler.addEventListener("hardwareBackPress", this.backAction);
this.getDOTD()
}
componentWillUnmount() {
......@@ -51,42 +56,66 @@ class DealsOfTheDayScreen extends Component {
duration: 30000,
}).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() {
return (
<View style={{ flex: 1, backgroundColor: '#4cc9f0' }}>
<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 }}>
<ScrollView>
<View style={{ width: '90%', elevation: 5, alignSelf: 'center', backgroundColor: 'white', flexDirection: 'row', justifyContent: 'space-between', paddingLeft: 20, borderRadius: 10 }}>
<Image source={Images.flash} style={{ width: 58, height: 30, marginVertical: 5 }} />
<View style={{ width: 130, backgroundColor: '#4cc9f0', borderRadius: 10, justifyContent: 'center' }}>
<CountDown
size={13}
until={1000}
onFinish={() => alert('Finished')}
digitStyle={{ backgroundColor: '#FFF', borderWidth: 2, borderColor: '#4cc9f0' }}
digitTxtStyle={{ color: 'black' }}
timeLabelStyle={{ color: 'red', fontWeight: 'bold' }}
separatorStyle={{ color: '#fff' }}
timeToShow={['H', 'M', 'S']}
timeLabels={{ m: null, s: null }}
showSeparator
/>
{this.state.countdown && (
<View style={{ width: '90%', elevation: 5, alignSelf: 'center', backgroundColor: 'white', flexDirection: 'row', justifyContent: 'space-between', paddingLeft: 20, borderRadius: 10 }}>
<Image source={Images.flash} style={{ width: 58, height: 30, marginVertical: 5 }} />
<View style={{ width: 130, backgroundColor: '#4cc9f0', borderRadius: 10, justifyContent: 'center' }}>
<CountDown
size={13}
until={this.state.count}
onFinish={() => alert('Flash Sale Telah Berakhir')}
digitStyle={{ backgroundColor: '#FFF', borderWidth: 2, borderColor: '#4cc9f0' }}
digitTxtStyle={{ color: 'black' }}
timeLabelStyle={{ color: 'red', fontWeight: 'bold' }}
separatorStyle={{ color: '#fff' }}
timeToShow={['H', 'M', 'S']}
timeLabels={{ m: null, s: null }}
showSeparator
/>
</View>
</View>
</View>
)}
<View style={{ marginTop: 30, paddingHorizontal: 20 }}>
<FlatList
scrollEnabled={false}
showsVerticalScrollIndicator={false}
data={this.state.dummyList}
data={this.state.data}
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={{ width: '36%', backgroundColor: item.color, borderTopLeftRadius: 15, borderBottomLeftRadius: 15 }} />
<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 }}>
<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 }}>
<BaseText type={"regular"} text={item.nama} style={{ fontSize: 10, color: 'black', textAlign: 'left', }} ellipsizeMode={"tail"} numberOfLines={1} />
<BaseText type={"regular"} text={item.harga} 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={`${item.jual} TERJUAL`} style={{ fontSize: 10, color: 'black', textAlign: 'left', marginTop: 5 }} />
<BaseText type={"regular"} text={item.product_name} style={{ fontSize: 10, color: 'black', textAlign: 'left', }} ellipsizeMode={"tail"} numberOfLines={2} />
<BaseText type={"regular"} text={this.number(item.price)} style={{ fontSize: 10, color: '#d8d8d8', textAlign: 'left', textDecorationLine: 'line-through', marginTop: 10 }} />
<BaseText type={"bold"} text={this.number(item.deal_price)} style={{ fontSize: 12, color: '#4cc9f0', 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 }}>
<Animated.Text style={{
fontSize: 10,
......
......@@ -70,7 +70,7 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => {
const verifikasiOtpEmail = (otp) => api.post('verify_otp_signup_email', otp)
const editProfile = (body) => api.post('edit_profile', 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
const getWhislist = (body) => api.post('get_wishlist', body)
......@@ -79,6 +79,7 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => {
const deleteWishlist = (wishlistId) => api.post(`delete_wishlist/${wishlistId}`)
// Address
const getAddress = () => api.get('get_address')
const getProvinsi = () => api.get('get_province')
const getKota = (body) => api.get('get_kab_kot/' + body)
const getKecamatan = (body) => api.get('get_kecamatan/' + body)
......@@ -158,7 +159,8 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => {
getProductDetail,
getPriceRange,
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