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
......@@ -14,7 +14,7 @@ import { Images } from '../Themes'
import DropDownPicker from 'react-native-dropdown-picker';
import Api from '../Services/Api';
import { handlePhone } from '../Lib/Utils';
import { NavigationEvents } from 'react-navigation';
import R from 'ramda'
class CreateAddressScreen extends Component {
constructor(props) {
......@@ -38,7 +38,17 @@ class CreateAddressScreen extends Component {
lat: "",
addressID: "",
type: "",
street: ""
street: "",
errorAddType: "",
errorName: "",
errorPhone: "",
errPhone: false,
errorProvinsi: "",
errorKota: "",
errorKecamatan: "",
errorKelurahan: "",
errorKodePos: "",
errorAddress: ""
}
}
......@@ -76,7 +86,7 @@ class CreateAddressScreen extends Component {
lat: Number(item.lat)
}).then(res => {
console.log(JSON.stringify(res))
this.setState({ street: res[0].formattedAddress})
this.setState({ street: res[0].formattedAddress })
})
})
} else {
......@@ -167,50 +177,94 @@ class CreateAddressScreen extends Component {
}
createAddress() {
let body = {
"address_type": this.state.addressType,
"receiver_name": this.state.receiverName,
"receiver_phone": "0" + this.state.phone,
"provinsi_id": this.state.provinsi,
"kabupaten_kota_id": this.state.kota,
"kecamatan_id": this.state.kecamatan,
"kelurahan_id": this.state.kelurahan,
"kode_pos": this.state.kodePos,
"address": this.state.address,
"long": String(this.state.long),
"lat": String(this.state.lat)
}
// console.log(body)
Api.create().addAddress(body).then((response) => {
console.log(JSON.stringify(response))
if (response.data.status == "success") {
this.backAction()
if (R.isEmpty(this.state.addressType)) {
this.setState({ errorAddType: "Nama Alamat Tidak Boleh Kosong" })
} else if (R.isEmpty(this.state.receiverName)) {
this.setState({ errorName: "Nama Penerima Tidak Boleh Kosong" })
} else if (R.isEmpty(this.state.phone)) {
this.setState({ errorPhone: "Nomor Handphone Tidak Boleh Kosong", errPhone: true })
} else if (this.state.phone.length < 9) {
this.setState({ errorPhone: "Nomor Handphone Tidak Boleh Kurang Dari 10 Digit", errPhone: true })
} else if (this.state.provinsi == null) {
this.setState({ errorProvinsi: "Provinsi Harus Di Isi" })
} else if (this.state.kota == null) {
this.setState({ errorKota: "Kabupaten/Kota Harus Di Isi" })
} else if (this.state.kecamatan == null) {
this.setState({ errorKecamatan: "Kecamatan Harus Di Isi" })
} else if (this.state.kelurahan == null) {
this.setState({ errorKelurahan: "Kelurahan Harus Di Isi" })
} else if (this.state.kodePos == null) {
this.setState({ errorKodePos: "Kode Pos Harus Di Isi" })
} else if (R.isEmpty(this.state.address)) {
this.setState({ errorAddress: "Alamat Tidak Boleh Kosong" })
} else {
let body = {
"address_type": this.state.addressType,
"receiver_name": this.state.receiverName,
"receiver_phone": "0" + this.state.phone,
"provinsi_id": this.state.provinsi,
"kabupaten_kota_id": this.state.kota,
"kecamatan_id": this.state.kecamatan,
"kelurahan_id": this.state.kelurahan,
"kode_pos": this.state.kodePos,
"address": this.state.address,
"long": String(this.state.long),
"lat": String(this.state.lat)
}
})
// console.log(body)
Api.create().addAddress(body).then((response) => {
console.log(JSON.stringify(response))
if (response.data.status == "success") {
this.backAction()
}
})
}
}
updateAddress() {
let body = {
"address_id": this.state.addressID,
"address_type": this.state.addressType,
"receiver_name": this.state.receiverName,
"receiver_phone": "0" + this.state.phone,
"provinsi_id": this.state.provinsi,
"kabupaten_kota_id": this.state.kota,
"kecamatan_id": this.state.kecamatan,
"kelurahan_id": this.state.kelurahan,
"kode_pos": this.state.kodePos,
"address": this.state.address,
"long": String(this.state.long),
"lat": String(this.state.lat)
}
// console.log(body)
Api.create().editAddress(body).then((response) => {
console.log(JSON.stringify(response))
if (response.data.status == "success") {
this.backAction()
if (R.isEmpty(this.state.addressType)) {
this.setState({ errorAddType: "Nama Alamat Tidak Boleh Kosong" })
} else if (R.isEmpty(this.state.receiverName)) {
this.setState({ errorName: "Nama Penerima Tidak Boleh Kosong" })
} else if (R.isEmpty(this.state.phone)) {
this.setState({ errorPhone: "Nomor Handphone Tidak Boleh Kosong", errPhone: true })
} else if (this.state.phone.length < 9) {
this.setState({ errorPhone: "Nomor Handphone Tidak Boleh Kurang Dari 10 Digit", errPhone: true })
} else if (this.state.provinsi == null) {
this.setState({ errorProvinsi: "Provinsi Harus Di Isi" })
} else if (this.state.kota == null) {
this.setState({ errorKota: "Kabupaten/Kota Harus Di Isi" })
} else if (this.state.kecamatan == null) {
this.setState({ errorKecamatan: "Kecamatan Harus Di Isi" })
} else if (this.state.kelurahan == null) {
this.setState({ errorKelurahan: "Kelurahan Harus Di Isi" })
} else if (this.state.kodePos == null) {
this.setState({ errorKodePos: "Kode Pos Harus Di Isi" })
} else if (R.isEmpty(this.state.address)) {
this.setState({ errorAddress: "Alamat Tidak Boleh Kosong" })
} else {
let body = {
"address_id": this.state.addressID,
"address_type": this.state.addressType,
"receiver_name": this.state.receiverName,
"receiver_phone": "0" + this.state.phone,
"provinsi_id": this.state.provinsi,
"kabupaten_kota_id": this.state.kota,
"kecamatan_id": this.state.kecamatan,
"kelurahan_id": this.state.kelurahan,
"kode_pos": this.state.kodePos,
"address": this.state.address,
"long": String(this.state.long),
"lat": String(this.state.lat)
}
})
// console.log(body)
Api.create().editAddress(body).then((response) => {
console.log(JSON.stringify(response))
if (response.data.status == "success") {
this.backAction()
}
})
}
}
render() {
......@@ -225,8 +279,11 @@ class CreateAddressScreen extends Component {
placeholder={"Masukkan Nama Alamat Anda"}
blurOnSubmit={false}
onChangeText={(e) => {
this.setState({ addressType: e })
this.setState({ addressType: e, errorAddType: "" })
}}
lineColor={this.state.errorAddType ? 'red' : '#d8d8d8'}
notes={this.state.errorAddType ? this.state.errorAddType : ''}
notesColor={this.state.errorAddType ? 'red' : '#4b4b4b'}
/>
<BaseText type={"regular"} text={'Contoh: Rumah, Kantor, Apartemen'} style={{ fontSize: 10, marginTop: 10, color: '#4b4b4b', opacity: .5 }} />
</View>
......@@ -237,13 +294,16 @@ class CreateAddressScreen extends Component {
placeholder={"Masukkan Nama Penerima"}
blurOnSubmit={false}
onChangeText={(e) => {
this.setState({ receiverName: e })
this.setState({ receiverName: e, errorName: "" })
}}
lineColor={this.state.errorName ? 'red' : '#d8d8d8'}
notes={this.state.errorName ? this.state.errorName : ''}
notesColor={this.state.errorName ? 'red' : '#4b4b4b'}
/>
</View>
<View style={{ marginTop: 20 }}>
<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: R.isEmpty(this.state.errorPhone) ? '#d8d8d8' : 'red', borderBottomWidth: 1, alignItems: 'center', }}>
<View style={{ width: '15%', flexDirection: 'row' }}>
<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 }} />
......@@ -257,13 +317,18 @@ class CreateAddressScreen extends Component {
// ref={(ref) => { this.phone = ref; }}
maxLength={13}
onChangeText={(phone) => {
this.setState({ phone: handlePhone(phone) })
this.setState({ phone: handlePhone(phone), errPhone: false, errorPhone: "" })
}}
blurOnSubmit={false}
/>
</View>
</View>
</View>
{this.state.errPhone && (
<View>
<BaseText type={"bold"} text={this.state.errorPhone} style={{ fontSize: 12, marginTop: 10, color: 'red', opacity: .5 }} />
</View>
)}
<View style={{ marginTop: 20 }}>
<BaseText type={"regular"} text={'Provinsi'} style={{ fontSize: 12, color: 'black', opacity: .7 }} />
<DropDownPicker
......@@ -274,7 +339,7 @@ class CreateAddressScreen extends Component {
searchablePlaceholder={"Cari Provinsi"}
defaultValue={this.state.provinsi}
containerStyle={{ height: 40 }}
style={{ marginHorizontal: 0, paddingHorizontal: 0, backgroundColor: '#fff', zIndex: 1, borderTopWidth: 0, borderLeftWidth: 0, borderRightWidth: 0 }}
style={{ marginHorizontal: 0, paddingHorizontal: 0, backgroundColor: '#fff', zIndex: 1, borderTopWidth: 0, borderLeftWidth: 0, borderRightWidth: 0, borderBottomColor: this.state.errorProvinsi == "" ? "#d8d8d8" : "red" }}
itemStyle={{
justifyContent: 'flex-start'
}}
......@@ -288,10 +353,15 @@ class CreateAddressScreen extends Component {
dropDownMaxHeight={200}
dropDownStyle={{ backgroundColor: '#fff', height: 200 }}
onChangeItem={item => this.setState({
provinsi: item.value, kota: null, kecamatan: null, kelurahan: null, kodePos: null
provinsi: item.value, kota: null, kecamatan: null, kelurahan: null, kodePos: null, errorProvinsi: ""
}, () => this.getKota(item.value))}
/>
</View>
{this.state.errorProvinsi != "" ? (
<View>
<BaseText type={"bold"} text={this.state.errorProvinsi} style={{ fontSize: 12, marginTop: 10, color: 'red', opacity: .5 }} />
</View>
) : null}
<View style={{ marginTop: 20 }}>
<BaseText type={"regular"} text={'Kota'} style={{ fontSize: 12, color: 'black', opacity: .7 }} />
<DropDownPicker
......@@ -303,7 +373,7 @@ class CreateAddressScreen extends Component {
searchable={true}
searchablePlaceholder={"Cari Kota"}
containerStyle={{ height: 40 }}
style={{ marginHorizontal: 0, paddingHorizontal: 0, backgroundColor: '#fff', zIndex: 1, borderTopWidth: 0, borderLeftWidth: 0, borderRightWidth: 0 }}
style={{ marginHorizontal: 0, paddingHorizontal: 0, backgroundColor: '#fff', zIndex: 1, borderTopWidth: 0, borderLeftWidth: 0, borderRightWidth: 0, borderBottomColor: this.state.errorKota == "" ? "#d8d8d8" : "red" }}
itemStyle={{
justifyContent: 'flex-start'
}}
......@@ -317,10 +387,15 @@ class CreateAddressScreen extends Component {
dropDownMaxHeight={200}
dropDownStyle={{ backgroundColor: '#fff', height: 200 }}
onChangeItem={item => this.setState({
kota: item.value, kecamatan: null, kelurahan: null, kodePos: null
kota: item.value, kecamatan: null, kelurahan: null, kodePos: null, errorKota: ""
}, () => this.getKecamatan(item.value))}
/>
</View>
{this.state.errorKota != "" ? (
<View>
<BaseText type={"bold"} text={this.state.errorKota} style={{ fontSize: 12, marginTop: 10, color: 'red', opacity: .5 }} />
</View>
) : null}
<View style={{ marginTop: 20 }}>
<BaseText type={"regular"} text={'Kecamatan'} style={{ fontSize: 12, color: 'black', opacity: .7 }} />
<DropDownPicker
......@@ -332,7 +407,7 @@ class CreateAddressScreen extends Component {
searchable={true}
searchablePlaceholder={"Cari Kecamatan"}
containerStyle={{ height: 40 }}
style={{ marginHorizontal: 0, paddingHorizontal: 0, backgroundColor: '#fff', zIndex: 1, borderTopWidth: 0, borderLeftWidth: 0, borderRightWidth: 0 }}
style={{ marginHorizontal: 0, paddingHorizontal: 0, backgroundColor: '#fff', zIndex: 1, borderTopWidth: 0, borderLeftWidth: 0, borderRightWidth: 0, borderBottomColor: this.state.errorKecamatan == "" ? "#d8d8d8" : "red" }}
itemStyle={{
justifyContent: 'flex-start'
}}
......@@ -346,10 +421,15 @@ class CreateAddressScreen extends Component {
dropDownMaxHeight={200}
dropDownStyle={{ backgroundColor: '#fff', height: 200 }}
onChangeItem={item => this.setState({
kecamatan: item.value, kelurahan: null, kodePos: null
kecamatan: item.value, kelurahan: null, kodePos: null, errorKecamatan: ""
}, () => this.getKelurahan(item.value))}
/>
</View>
{this.state.errorKecamatan != "" ? (
<View>
<BaseText type={"bold"} text={this.state.errorKecamatan} style={{ fontSize: 12, marginTop: 10, color: 'red', opacity: .5 }} />
</View>
) : null}
<View style={{ marginTop: 20 }}>
<BaseText type={"regular"} text={'Kelurahan'} style={{ fontSize: 12, color: 'black', opacity: .7 }} />
<DropDownPicker
......@@ -361,7 +441,7 @@ class CreateAddressScreen extends Component {
searchable={true}
searchablePlaceholder={"Cari Kelurahan"}
containerStyle={{ height: 40 }}
style={{ marginHorizontal: 0, paddingHorizontal: 0, backgroundColor: '#fff', zIndex: 1, borderTopWidth: 0, borderLeftWidth: 0, borderRightWidth: 0 }}
style={{ marginHorizontal: 0, paddingHorizontal: 0, backgroundColor: '#fff', zIndex: 1, borderTopWidth: 0, borderLeftWidth: 0, borderRightWidth: 0, borderBottomColor: this.state.errorKelurahan == "" ? "#d8d8d8" : "red" }}
itemStyle={{
justifyContent: 'flex-start'
}}
......@@ -375,10 +455,15 @@ class CreateAddressScreen extends Component {
dropDownMaxHeight={200}
dropDownStyle={{ backgroundColor: '#fff', height: 200 }}
onChangeItem={item => this.setState({
kelurahan: item.value, kodePos: null
kelurahan: item.value, kodePos: null, errorKelurahan: ""
}, () => this.getKodePos(item.value))}
/>
</View>
{this.state.errorKelurahan != "" ? (
<View>
<BaseText type={"bold"} text={this.state.errorKelurahan} style={{ fontSize: 12, marginTop: 10, color: 'red', opacity: .5 }} />
</View>
) : null}
<View style={{ marginTop: 20 }}>
<BaseText type={"regular"} text={'Kode Pos'} style={{ fontSize: 12, color: 'black', opacity: .7 }} />
<DropDownPicker
......@@ -390,7 +475,7 @@ class CreateAddressScreen extends Component {
searchable={true}
searchablePlaceholder={"Cari Kode Pos"}
containerStyle={{ height: 40 }}
style={{ marginHorizontal: 0, paddingHorizontal: 0, backgroundColor: '#fff', zIndex: 1, borderTopWidth: 0, borderLeftWidth: 0, borderRightWidth: 0 }}
style={{ marginHorizontal: 0, paddingHorizontal: 0, backgroundColor: '#fff', zIndex: 1, borderTopWidth: 0, borderLeftWidth: 0, borderRightWidth: 0, borderBottomColor: this.state.errorKodePos == "" ? "#d8d8d8" : "red" }}
itemStyle={{
justifyContent: 'flex-start'
}}
......@@ -404,18 +489,26 @@ class CreateAddressScreen extends Component {
dropDownMaxHeight={200}
dropDownStyle={{ backgroundColor: '#fff', height: 200 }}
onChangeItem={item => this.setState({
kodePos: item.value
kodePos: item.value, errorKodePos: ""
})}
/>
</View>
{this.state.errorKodePos != "" ? (
<View>
<BaseText type={"bold"} text={this.state.errorKodePos} style={{ fontSize: 12, marginTop: 10, color: 'red', opacity: .5 }} />
</View>
) : null}
<View style={{ marginTop: 20 }}>
<BaseInput
title={"Alamat Pengirim"}
placeholder={"Masukkan Alamat Pengirim"}
value={this.state.address}
onChangeText={(e) => {
this.setState({ address: e })
this.setState({ address: e, errorAddress: "" })
}}
lineColor={this.state.errorAddress ? 'red' : '#d8d8d8'}
notes={this.state.errorAddress ? this.state.errorAddress : ''}
notesColor={this.state.errorAddress ? 'red' : '#4b4b4b'}
/>
</View>
<View style={{ marginTop: 20, marginBottom: 10 }}>
......@@ -429,7 +522,7 @@ class CreateAddressScreen extends Component {
{this.state.long != "" ?
<View style={{ width: '80%' }}>
<View style={{ flexDirection: 'row' }}>
<View style={{ }}>
<View style={{}}>
<BaseText text={this.state.street == "" ? "-" : this.state.street} type={"regular"} style={{ fontSize: 12, color: '#4b4b4b', opacity: .7 }} />
</View>
</View>
......
......@@ -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,
......
......@@ -47,7 +47,8 @@ class ProfileScreen extends Component {
this.setState({ auth: prevState.auth })
let auth = this.state.auth
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'
import BaseHeader from '../Components/BaseHeader'
import BaseText from '../Components/BaseText'
import BaseInput from '../Components/BaseInput'
import Api from '../Services/Api'
import { handlePhone } from '../Lib/Utils'
import R from 'ramda'
class RincianProfilScreen extends Component {
constructor(props) {
......@@ -24,6 +24,9 @@ class RincianProfilScreen extends Component {
email: "",
phone: "",
auth: this.props.auth,
errorName: "",
errorPhone: false,
textErrorPhone: ""
}
}
......@@ -49,19 +52,26 @@ class RincianProfilScreen extends Component {
validate(type) {
if (type == 'name') {
if (this.props.auth != null) {
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": ""
if (R.isEmpty(this.state.firstName)) {
this.setState({ errorName: 'Nama tidak boleh kosong' })
}
else if (this.state.firstName.length < 3) {
this.setState({ errorName: 'Nama Tidak Boleh Kurang Dari 3 Karakter' })
} else {
if (this.props.auth != null) {
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') {
if (this.props.auth != null) {
......@@ -78,18 +88,21 @@ class RincianProfilScreen extends Component {
// })
}
} else if (type == 'hp') {
if (this.props.auth != null) {
let data = this.props.auth.user.data
let body = {
"user_name": "",
"user_email": "",
"user_phone": "0" + this.state.phone,
"user_image": ""
if (R.isEmpty(this.state.phone)) {
this.setState({ textErrorPhone: 'Nomor Handphone Tidak Boleh Kosong', errorPhone: true })
} else if (this.state.phone.length < 9) {
this.setState({ textErrorPhone: 'Nomor Handphone Kurang Dari 10 Digit', errorPhone: true })
} else {
if (this.props.auth != null) {
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 {
<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 }}>
<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' }}>
<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 }} />
......@@ -170,7 +183,7 @@ class RincianProfilScreen extends Component {
// ref={(ref) => { this.phone = ref; }}
maxLength={13}
onChangeText={(phone) => {
this.setState({ phone: handlePhone(phone) })
this.setState({ phone: handlePhone(phone), errorPhone: false })
}}
// onSubmitEditing={() => {
// this.focusNextField('password');
......@@ -179,6 +192,11 @@ class RincianProfilScreen extends Component {
/>
</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%' }}>
<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' }} />
......@@ -197,11 +215,11 @@ class RincianProfilScreen extends Component {
title={"Nama Depan"}
placeholder={"Nama Depan"}
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}
// lineColor={this.state.errorName ? 'red' : '#d8d8d8'}
// notes={this.state.errorName ? 'Nama Tidak Boleh Kosong' : ''}
// notesColor={this.state.errorName ? 'red' : '#4b4b4b'}
lineColor={this.state.errorName ? 'red' : '#d8d8d8'}
notes={this.state.errorName ? this.state.errorName : ''}
notesColor={this.state.errorName ? 'red' : '#4b4b4b'}
/>
</View>
<View style={{ marginTop: 20 }}>
......
......@@ -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