Commit 8d6a05cd authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'deni15' into 'master'

update malem malem

See merge request !28
parents e9972f14 bd687752
......@@ -12,7 +12,7 @@ import BaseText from '../Components/BaseText'
import { Images } from '../Themes'
import Modal from 'react-native-modal';
import ImagePicker from 'react-native-image-crop-picker';
import images from '../Themes/Images'
import DropDownPicker from 'react-native-dropdown-picker';
class ComplainScreen extends Component {
constructor(props) {
......@@ -21,7 +21,15 @@ class ComplainScreen extends Component {
modalComplain: false,
check: false,
imageBukti: [],
modalPhoto: false
modalPhoto: false,
jenisKomplain: [
{ label: "Pengembalian Barang & Dana", value: 1 },
{ label: "Kirim Barang Kurang/Tidak Lengkap", value: 2 },
{ label: "Pengembalian Selisih Biaya Pengiriman", value: 3 },
{ label: "Pengembalian Barang & Dana", value: 4 },
{ label: "Penukaran Barang", value: 5 },
],
pickComplain: ""
}
}
......@@ -45,7 +53,7 @@ class ComplainScreen extends Component {
})
console.log('multiple', image)
this.setState({ imageBukti });
});
} else {
ImagePicker.openCamera({
......@@ -91,10 +99,22 @@ class ComplainScreen extends Component {
<BaseHeader leftText={'Komplain Pesanan'} onBackPress={() => this.props.navigation.goBack()} />
<ScrollView style={[styles.scrollContent]}>
<View style={{ marginTop: 20, paddingHorizontal: 10 }}>
<BaseInput
title={"Jenis Komplain"}
placeholder={"Jenis Komplain"}
blurOnSubmit={false}
<DropDownPicker
items={this.state.jenisKomplain}
placeholder={"Pilihlah Jenis Komplain"}
searchablePlaceholderTextColor="#4cc9f0"
defaultValue={this.state.pickComplain}
containerStyle={{ height: 40 }}
style={{ backgroundColor: '#fafafa', elevation: 2, zIndex: 2 }}
itemStyle={{
justifyContent: 'flex-start'
}}
labelStyle={{ color: 'grey'}}
activeLabelStyle={{ color: '#4cc9f0'}}
dropDownStyle={{ backgroundColor: '#fafafa', elevation: 2, zIndex: 2, height: 200 }}
onChangeItem={item => this.setState({
pickComplain: item.value
})}
/>
<View style={{ marginTop: 20 }}>
<BaseText type={"regular"} text={'Produk Yang Dikomplain'} style={{ fontSize: 10, color: '#4b4b4b', fontWeight: '600', opacity: .5 }} />
......@@ -128,7 +148,7 @@ class ComplainScreen extends Component {
</TouchableOpacity>
{this.state.imageBukti.map((item, index) => {
return (
<TouchableOpacity style={{ width: 56, height: 56, justifyContent: 'center', borderRadius: 10, marginLeft: 20}}>
<TouchableOpacity style={{ width: 56, height: 56, justifyContent: 'center', borderRadius: 10, marginLeft: 20 }}>
<Image source={{ uri: `data:image/gif;base64,${item.uri}` }} style={{ width: 56, height: 56, borderRadius: 10 }} resizeMode={"cover"} />
</TouchableOpacity>
)
......
This diff is collapsed.
......@@ -2,6 +2,7 @@ import React, { Component } from 'react'
import { ScrollView, Text, KeyboardAvoidingView, Image, View, BackHandler, TouchableOpacity, StatusBar, AsyncStorage } from 'react-native'
import { connect } from 'react-redux'
import { withNavigationFocus, NavigationEvents } from 'react-navigation';
import AuthAction from '../Redux/AuthRedux'
// Add Actions - replace 'Your' with whatever your reducer is called :)
// import YourActions from '../Redux/YourRedux'
......@@ -22,7 +23,8 @@ class ProfileScreen extends Component {
data: this.props.auth.user.data,
modalPhoto: false,
user_image: "",
auth: this.props.auth
auth: this.props.auth,
modalPhoto: false
}
}
backAction = () => {
......@@ -32,6 +34,7 @@ class ProfileScreen extends Component {
componentDidMount() {
BackHandler.addEventListener("hardwareBackPress", this.backAction);
// this.getDataProfile()
console.log('auth', this.props.auth.user.data)
}
......@@ -39,17 +42,34 @@ class ProfileScreen extends Component {
BackHandler.removeEventListener("hardwareBackPress", this.backAction);
}
componentDidUpdate(prevProps, prevState) {
if (prevState.auth !== this.state.auth) {
this.setState({ auth: prevState.auth })
let auth = this.state.auth
if (auth !== null && !auth.fetching) {
console.log('tag', auth)
}
}
}
static getDerivedStateFromProps(nextProps, prevState) {
if (nextProps.auth !== prevState.auth) {
return { auth: nextProps.auth };
}
else return null;
}
handleImagePicker(type) {
if (type == 'Galeri') {
ImagePicker.openPicker({
width: 480,
height: 296,
height: 480,
cropping: true,
compressImageQuality: 0.7,
mediaType: 'photo',
includeBase64: true,
}).then(image => {
console.log(image.mime)
// console.log(image.mime)
this.setState({ user_image: image.data });
if (this.props.auth != null) {
let data = this.props.auth.user.data
......@@ -57,20 +77,27 @@ class ProfileScreen extends Component {
"image_type": image.mime,
"user_image": image.data
}
Api.create().editPhotoProfile(body).then((response) => {
console.log(response)
})
this.props.authPhotoRequest(body)
}
});
} else {
ImagePicker.openCamera({
width: 480,
height: 296,
height: 480,
cropping: true,
compressImageQuality: 0.7,
mediaType: 'photo'
mediaType: 'photo',
includeBase64: true,
}).then(image => {
// console.log(image)
this.setState({ user_image: image.data });
console.log(image)
if (this.props.auth != null) {
let body = {
"image_type": image.mime,
"user_image": image.data
}
this.props.authPhotoRequest(body)
}
});
}
}
......@@ -89,9 +116,6 @@ class ProfileScreen extends Component {
let { data } = this.state
return (
<View style={{ flex: 1, backgroundColor: '#fff' }}>
<NavigationEvents
onDidFocus={() => this.getDataProfile()}
/>
<StatusBar backgroundColor={'transparent'} translucent={true} barStyle={'light-content'} />
<Modal animationOut='slideOutRight' animationOutTiming={1000} isVisible={this.state.modalPhoto} onBackButtonPress={() => this.setState({ modalPhoto: false })} style={{ paddingHorizontal: 10 }}>
<View style={{ backgroundColor: 'white', width: '90%', alignSelf: 'center' }}>
......@@ -101,7 +125,7 @@ class ProfileScreen extends Component {
<TouchableOpacity style={{ paddingHorizontal: 20, paddingVertical: 10, borderBottomColor: 'black', borderBottomWidth: .4, }} onPress={() => this.setState({ modalPhoto: false }, () => this.handleImagePicker('Galeri'))}>
<BaseText type={"regular"} text={'Galeri'} style={{ fontSize: 16, color: 'black' }} />
</TouchableOpacity>
<TouchableOpacity style={{ paddingHorizontal: 20, paddingVertical: 10 }}>
<TouchableOpacity style={{ paddingHorizontal: 20, paddingVertical: 10 }} onPress={() => this.setState({ modalPhoto: false }, () => this.handleImagePicker('Camera'))}>
<BaseText type={"regular"} text={'Kamera'} style={{ fontSize: 16, color: 'black' }} />
</TouchableOpacity>
</View>
......@@ -111,7 +135,7 @@ class ProfileScreen extends Component {
{/* <BaseText text={this.state.activeIndex} type={"bold"} style={{color: 'red', fontSize: 16, backgroundColor: 'yellow', width: '100%'}}/> */}
<View style={{ justifyContent: 'center', flexDirection: 'row', marginBottom: 20 }}>
<TouchableOpacity style={{ alignSelf: 'center', elevation: 5, width: 100, height: 100, borderRadius: 100, borderWidth: 54, borderColor: 'white', marginTop: 25, backgroundColor: 'red', alignItems: 'center', justifyContent: 'center' }} onPress={() => this.setState({ modalPhoto: true })}>
<Image source={this.state.user_image == "" ? Images.beautyProduct : { uri: `data:image/gif;base64,${this.state.user_image}` }} style={{ width: 100, height: 100, borderRadius: 100 }} resizeMode={"cover"} />
<Image source={this.state.user_image == "" ? { uri: 'https://apiecart.eksad.com/' + data.user_image } : { uri: `data:image/gif;base64,${this.state.user_image}` }} style={{ width: 100, height: 100, borderRadius: 100 }} resizeMode={"cover"} />
</TouchableOpacity>
<View style={{ justifyContent: 'flex-end', elevation: 9 }}>
<Image source={Images.editFoto} style={{ width: 50, height: 50, borderRadius: 40, alignSelf: 'flex-end', marginLeft: -40 }} />
......@@ -170,6 +194,7 @@ const mapStateToProps = (state) => {
const mapDispatchToProps = (dispatch) => {
return {
authPhotoRequest: obj => dispatch(AuthAction.authPhotoRequest(obj)),
}
}
......
......@@ -83,7 +83,7 @@ class RincianProfilScreen extends Component {
let body = {
"user_name": "",
"user_email": "",
"user_phone": this.state.phone,
"user_phone": "0" + this.state.phone,
"user_image": ""
}
this.props.authEditRequest(body)
......
......@@ -23,6 +23,6 @@ export function titleCase(text) {
}
export function handlePhone(angka) {
let value = String(angka).replace(/^[A-Za-z\s]+$/g, '')
let value = String(angka).replace(/\D+/g, "");
return value
}
......@@ -21,6 +21,10 @@ const { Types, Creators } = createActions({
authEditSuccess: ['payload'],
authEditFailed: ['payload'],
authEditFailure: null,
authPhotoRequest: ['data'],
authPhotoSuccess: ['payload'],
authPhotoFailed: ['payload'],
authPhotoFailure: null,
})
export const AuthTypes = Types
......@@ -88,4 +92,8 @@ export const reducer = createReducer(INITIAL_STATE, {
[Types.AUTH_EDIT_SUCCESS]: success,
[Types.AUTH_EDIT_FAILED]: failed,
[Types.AUTH_EDIT_FAILURE]: failure,
[Types.AUTH_PHOTO_REQUEST]: request,
[Types.AUTH_PHOTO_SUCCESS]: success,
[Types.AUTH_PHOTO_FAILED]: failed,
[Types.AUTH_PHOTO_FAILURE]: failure,
})
......@@ -101,4 +101,26 @@ export function * editAuth (api, action) {
} else {
yield put(AuthActions.authEditFailure())
}
}
export function * photoAuth (api, action) {
const { data } = action
// get current data from Store
// const currentData = yield select(AuthSelectors.getData)
// make the call to the api
const response = yield call(api.editPhotoProfile, data)
// success?
if (response.ok) {
console.log('foto', response.data)
// You might need to change the response here - do this with a 'transform',
// located in ../Transforms/. Otherwise, just pass the data back from the api.
if (response.data.status == 'success') {
yield put(AuthActions.authPhotoSuccess(response.data))
} else {
yield put(AuthActions.authPhotoFailed(response.data))
}
} else {
yield put(AuthActions.authPhotoFailure())
}
}
\ No newline at end of file
......@@ -13,7 +13,7 @@ import { AuthTypes } from '../Redux/AuthRedux'
import { startup } from './StartupSagas'
import { getUserAvatar } from './GithubSagas'
import { getAuth, registerAuth, verificationAuth, editAuth} from './AuthSagas'
import { getAuth, registerAuth, verificationAuth, editAuth, photoAuth} from './AuthSagas'
/* ------------- API ------------- */
......@@ -33,6 +33,7 @@ export default function * root () {
takeLatest(AuthTypes.AUTH_REQUEST, getAuth, api),
takeLatest(AuthTypes.AUTH_REGISTER_REQUEST, registerAuth, api),
takeLatest(AuthTypes.AUTH_VERIFICATION_REQUEST, verificationAuth, api),
takeLatest(AuthTypes.AUTH_EDIT_REQUEST, editAuth, api)
takeLatest(AuthTypes.AUTH_EDIT_REQUEST, editAuth, api),
takeLatest(AuthTypes.AUTH_PHOTO_REQUEST, photoAuth, api),
])
}
......@@ -26,24 +26,24 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => {
api.addAsyncRequestTransform(request => async () => {
var token
try {
const res = await AsyncStorage.getItem("TOKEN")
if (res != null) {
const res = await AsyncStorage.getItem("TOKEN")
if (res != null) {
token = res
// alert(url)
// api.setBaseURL(`${url}/api/`)
} else {
} else {
token = null
// url = Constant.BASE_URL.MASTER + '/api/'
// alert(url)
// api.setBaseURL(`${url}/api/`)
}
}
} catch (error) {
// console.tron.log(error)
// console.tron.log(error)
}
// console.log(token)
request.headers['token'] = token
// console.tron.log(url)
})
})
// ------
// STEP 2
......@@ -61,16 +61,24 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => {
//
const getRoot = () => api.get('')
const getRate = () => api.get('rate_limit')
const getUser = (username) => api.get('search/users', {q: username})
const getUser = (username) => api.get('search/users', { q: username })
const login = (body) => api.post('login', body)
const registerUser = (body) => api.post('register', body)
const registerUser = (body) => api.post('register', body)
const resendOtpEmail = (email) => api.post('resend_otp_email', email)
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 getWhislist = () => api.get('get_wishlist')
const searchWhislist = (body) => api.post('search_wishlist', body)
const editProfile = (body) => api.post('edit_profile', body)
const editPhotoProfile = (body) => api.post('edit_photo', body)
const getAddress = () => api.get('get_address')
const getWhislist = () => api.get('get_wishlist')
const searchWhislist = (body) => api.post('search_wishlist', body)
// Address
const getProvinsi = () => api.get('get_province')
const getKota = (body) => api.get('get_kab_kot/' + body)
const getKecamatan = (body) => api.get('get_kecamatan/' + body)
const getKelurahan = (body) => api.get('get_kelurahan/' + body)
const getKodePos = (body) => api.get('get_kode_pos/' + body)
const addAddress = (body) => api.post('add_address/', body)
// About App
const appInfo = () => api.get('app_info')
......@@ -108,6 +116,12 @@ const create = (baseURL = 'https://apiecart.eksad.com/mobile/') => {
getAddress,
getWhislist,
searchWhislist,
getProvinsi,
getKota,
getKecamatan,
getKelurahan,
getKodePos,
addAddress
}
}
......
......@@ -11144,6 +11144,14 @@ react-native-drawer@2.5.1:
prop-types "^15.5.8"
tween-functions "^1.0.1"
react-native-dropdown-picker@^3.1.11:
version "3.1.11"
resolved "https://registry.yarnpkg.com/react-native-dropdown-picker/-/react-native-dropdown-picker-3.1.11.tgz#663efcef168e7e56bb34fb8e1d54bc5e2de82b22"
integrity sha512-2dY5Kt9iVN/IXSfruU89rIEM0WXjfspKuJ/hVobaHYiTzJ2gy7xHRakUYkbDrsWrMgAq7+Q+iTp3c92CQjnTWg==
dependencies:
prop-types "^15.7.2"
react-native-vector-icons "^7.0.0"
react-native-easy-grid@0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/react-native-easy-grid/-/react-native-easy-grid-0.2.2.tgz#f0be33620be1ebe2d2295918eb58b0a27e8272ab"
......@@ -11311,6 +11319,15 @@ react-native-vector-icons@^6.6.0:
prop-types "^15.7.2"
yargs "^15.0.2"
react-native-vector-icons@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/react-native-vector-icons/-/react-native-vector-icons-7.0.0.tgz#5b92ed363c867645daad48c559e1f99efcfbb813"
integrity sha512-Ku8+dTUAnR9pexRPQqsUcQEZlxEpFZsIy8iOFqVL/3mrUyncZJHtqJyx2cUOmltZIC6W2GI4IkD3EYzPerXV5g==
dependencies:
lodash "^4.17.15"
prop-types "^15.7.2"
yargs "^15.0.2"
react-native-webview@^10.3.2:
version "10.3.2"
resolved "https://registry.yarnpkg.com/react-native-webview/-/react-native-webview-10.3.2.tgz#c634946152099c95d521a3abc71065d1d642e192"
......
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