Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
InvestCustomer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Giang Tran
InvestCustomer
Commits
009bc5a8
Commit
009bc5a8
authored
Mar 11, 2021
by
Giang Tran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
connect api
parent
15e98723
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
126 additions
and
34 deletions
+126
-34
index.js
index.js
+1
-2
Login.js
src/Screens/Authen/Login.js
+47
-20
Registor.js
src/Screens/Authen/Registor.js
+53
-7
Home.js
src/Screens/Home/Home.js
+9
-2
users.js
src/apis/Functions/users.js
+5
-0
url.js
src/apis/url.js
+1
-2
InputIcon.js
src/components/Input/InputIcon.js
+10
-1
No files found.
index.js
View file @
009bc5a8
...
@@ -5,6 +5,5 @@
...
@@ -5,6 +5,5 @@
import
{
AppRegistry
}
from
'react-native'
;
import
{
AppRegistry
}
from
'react-native'
;
import
App
from
'./App'
;
import
App
from
'./App'
;
import
{
name
as
appName
}
from
'./app.json'
;
import
{
name
as
appName
}
from
'./app.json'
;
import
Payment
from
'./src/Screens/Payment/Payment'
;
AppRegistry
.
registerComponent
(
appName
,
()
=>
Payment
);
AppRegistry
.
registerComponent
(
appName
,
()
=>
App
);
src/Screens/Authen/Login.js
View file @
009bc5a8
...
@@ -15,33 +15,53 @@ import R from '../../assets/R';
...
@@ -15,33 +15,53 @@ import R from '../../assets/R';
import
{
useNavigation
}
from
'@react-navigation/native'
;
import
{
useNavigation
}
from
'@react-navigation/native'
;
import
{
TABNAVIGATOR
,
FORGOTPASSWORD
}
from
'../../routers/ScreenNames'
;
import
{
TABNAVIGATOR
,
FORGOTPASSWORD
}
from
'../../routers/ScreenNames'
;
import
{
checkFormatArray
}
from
'../../Config/Functions'
;
import
{
checkFormatArray
}
from
'../../Config/Functions'
;
import
{
loginApi
}
from
'../../apis/Functions/users'
;
import
KEY
from
'../../assets/AsynStorage'
;
import
AsyncStorage
from
'@react-native-community/async-storage'
;
import
{
showLoading
,
hideLoading
}
from
'../../actions/loadingAction'
;
import
{
saveUserToRedux
}
from
'../../actions/users'
;
import
{
connect
}
from
'react-redux'
;
const
Login
=
(
props
)
=>
{
const
Login
=
(
props
)
=>
{
const
{
navigation
}
=
props
;
const
{
navigation
}
=
props
;
const
[
email
,
setEmail
]
=
useState
(
''
);
const
[
email
,
setEmail
]
=
useState
(
'
Tdgiang@dcv.vn
'
);
const
[
pass
,
setPass
]
=
useState
(
''
);
const
[
pass
,
setPass
]
=
useState
(
'
123456
'
);
const
navigate
=
useNavigation
();
const
navigate
=
useNavigation
();
const
onSubmitLogin
=
()
=>
{
const
onSubmitLogin
=
async
()
=>
{
navigate
.
reset
({
props
.
showLoading
();
index
:
1
,
const
titles
=
[
'tên đăng nhập'
,
'mật khẩu'
];
routes
:
[{
name
:
TABNAVIGATOR
}],
const
index
=
checkFormatArray
([
email
,
pass
]);
});
// const titles = ['tên đăng nhập', 'mật khẩu'];
// const index = checkFormatArray([email, pass]);
// console.log(index);
// if (index === true) {
if
(
index
===
true
)
{
// console.log('OK');
console
.
log
(
'OK'
);
// navigate.reset({
const
firebase
=
await
AsyncStorage
.
getItem
(
KEY
.
FIREBASE
);
// index: 1,
// routes: [{name: TABNAVIGATOR}],
const
res
=
await
loginApi
({
// });
email
,
// } else {
password
:
pass
,
// Alert.alert('Thông báo!', 'Vui lòng điền ' + titles[index]);
platform
:
Platform
.
OS
,
// }
device_token
:
firebase
,
account_type
:
'CUSTOMER'
,
});
console
.
log
(
res
.
data
);
props
.
hideLoading
();
if
(
res
.
data
.
code
==
200
&&
res
.
data
.
data
)
{
AsyncStorage
.
setItem
(
KEY
.
TOKEN
,
res
.
data
.
data
.
token
);
props
.
saveUserToRedux
(
res
.
data
.
data
);
navigate
.
reset
({
index
:
1
,
routes
:
[{
name
:
TABNAVIGATOR
}],
});
}
else
{
Alert
.
alert
(
'Thông báo!'
,
res
.
data
.
message
);
}
}
else
{
Alert
.
alert
(
'Thông báo!'
,
'Vui lòng điền '
+
titles
[
index
]);
}
};
};
return
(
return
(
...
@@ -134,4 +154,11 @@ const styles = StyleSheet.create({
...
@@ -134,4 +154,11 @@ const styles = StyleSheet.create({
},
},
});
});
export
default
Login
;
const
mapStateToProps
=
(
state
)
=>
{
return
{};
};
export
default
connect
(
mapStateToProps
,
{
showLoading
,
hideLoading
,
saveUserToRedux
,
})(
Login
);
src/Screens/Authen/Registor.js
View file @
009bc5a8
import
React
,
{
useState
}
from
'react'
;
import
React
,
{
useState
}
from
'react'
;
import
{
View
,
Text
,
StyleSheet
,
Image
,
TouchableOpacity
}
from
'react-native'
;
import
{
View
,
Text
,
StyleSheet
,
Image
,
TouchableOpacity
,
Alert
,
}
from
'react-native'
;
import
InputIcon
from
'../../components/Input/InputIcon'
;
import
InputIcon
from
'../../components/Input/InputIcon'
;
import
{
getFontXD
,
HEIGHTXD
,
WIDTHXD
}
from
'../../Config/Functions'
;
import
{
getFontXD
,
HEIGHTXD
,
WIDTHXD
}
from
'../../Config/Functions'
;
import
R
from
'../../assets/R'
;
import
R
from
'../../assets/R'
;
import
{
useForm
,
Controller
}
from
'react-hook-form'
;
import
{
checkFormatArray
}
from
'../../Config/Functions'
;
import
{
showLoading
,
hideLoading
}
from
'../../actions/loadingAction'
;
import
{
connect
}
from
'react-redux'
;
import
{
registorApi
}
from
'../../apis/Functions/users'
;
const
Registor
=
(
props
)
=>
{
const
Registor
=
(
props
)
=>
{
const
{
navigation
}
=
props
;
const
{
navigation
}
=
props
;
const
{
control
,
handleSubmit
,
errors
}
=
useForm
();
const
onSubmit
=
(
data
)
=>
console
.
log
(
data
);
const
[
email
,
setEmail
]
=
useState
(
''
);
const
[
password
,
setPassword
]
=
useState
(
''
);
const
[
password_confirmation
,
setPasswordConfirm
]
=
useState
(
''
);
const
registorClick
=
async
()
=>
{
props
.
showLoading
();
const
titles
=
[
'email'
,
'mật khẩu'
,
'xác nhận mật khẩu'
];
const
index
=
checkFormatArray
([
email
,
password
,
password_confirmation
]);
if
(
index
===
true
)
{
const
res
=
await
registorApi
({
email
,
password
,
platform
:
Platform
.
OS
,
password_confirmation
,
});
if
(
res
.
data
.
code
==
200
&&
res
.
data
.
data
)
{
Alert
.
alert
(
'Đăng ký tài khoản thành công!'
);
navigation
.
navigate
(
'LOGIN'
);
}
else
{
Alert
.
alert
(
'Thông báo!'
,
res
.
data
.
message
);
}
}
else
{
Alert
.
alert
(
'Thông báo!'
,
'Vui lòng điền '
+
titles
[
index
]);
}
props
.
hideLoading
();
};
return
(
return
(
<
View
<
View
...
@@ -29,11 +65,15 @@ const Registor = (props) => {
...
@@ -29,11 +65,15 @@ const Registor = (props) => {
icon
=
{
R
.
images
.
iconLock
}
icon
=
{
R
.
images
.
iconLock
}
title
=
{
'Mật khẩu'
}
title
=
{
'Mật khẩu'
}
placeholder
=
{
'Nhập mật khẩu'
}
placeholder
=
{
'Nhập mật khẩu'
}
onChangeText
=
{(
val
)
=>
setPassword
(
val
)}
isPassWord
=
{
true
}
/
>
/
>
<
InputIcon
<
InputIcon
icon
=
{
R
.
images
.
iconLock
}
icon
=
{
R
.
images
.
iconLock
}
title
=
{
'Nhập lại mật khẩu'
}
title
=
{
'Nhập lại mật khẩu'
}
placeholder
=
{
'Nhập mật khẩu'
}
placeholder
=
{
'Nhập mật khẩu'
}
onChangeText
=
{(
val
)
=>
setPasswordConfirm
(
val
)}
isPassWord
=
{
true
}
/
>
/
>
<
View
<
View
...
@@ -42,10 +82,10 @@ const Registor = (props) => {
...
@@ -42,10 +82,10 @@ const Registor = (props) => {
alignItems
:
'center'
,
alignItems
:
'center'
,
}}
>
}}
>
<
View
style
=
{
styles
.
wrapLogin
}
>
<
TouchableOpacity
onPress
=
{
registorClick
}
style
=
{
styles
.
wrapLogin
}
>
<
Text
style
=
{
styles
.
txtLogin
}
>
Đă
ng
k
ý
<
/Text
>
<
Text
style
=
{
styles
.
txtLogin
}
>
Đă
ng
k
ý
<
/Text
>
<
Image
source
=
{
R
.
images
.
iconRight1
}
style
=
{
styles
.
imgIcon
}
/
>
<
Image
source
=
{
R
.
images
.
iconRight1
}
style
=
{
styles
.
imgIcon
}
/
>
<
/
View
>
<
/
TouchableOpacity
>
<
View
style
=
{
styles
.
row
}
>
<
View
style
=
{
styles
.
row
}
>
<
Text
style
=
{
styles
.
txtTitle
}
>
B
ạ
n
đã
c
ó
t
à
i
kho
ả
n
?
<
/Text
>
<
Text
style
=
{
styles
.
txtTitle
}
>
B
ạ
n
đã
c
ó
t
à
i
kho
ả
n
?
<
/Text
>
...
@@ -99,4 +139,10 @@ const styles = StyleSheet.create({
...
@@ -99,4 +139,10 @@ const styles = StyleSheet.create({
},
},
});
});
export
default
Registor
;
const
mapStateToProps
=
(
state
)
=>
{
return
{};
};
export
default
connect
(
mapStateToProps
,
{
showLoading
,
hideLoading
,
})(
Registor
);
src/Screens/Home/Home.js
View file @
009bc5a8
import
React
from
'react'
;
import
React
from
'react'
;
import
{
connect
}
from
'react-redux'
;
import
HomeView
from
'./HomeView'
;
import
HomeView
from
'./HomeView'
;
const
Home
=
props
=>
{
const
Home
=
(
props
)
=>
{
console
.
log
(
'Information in home'
,
props
.
user
);
return
<
HomeView
/>
;
return
<
HomeView
/>
;
};
};
export
default
Home
;
const
mapStateToProps
=
(
state
)
=>
{
return
{
user
:
state
.
userReducer
,
};
};
export
default
connect
(
mapStateToProps
,
{})(
Home
);
src/apis/Functions/users.js
View file @
009bc5a8
...
@@ -7,6 +7,11 @@ export const loginApi = async (body) =>
...
@@ -7,6 +7,11 @@ export const loginApi = async (body) =>
.
then
((
res
)
=>
res
)
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
err
);
.
catch
((
err
)
=>
err
);
export
const
registorApi
=
async
(
body
)
=>
PostLogin
(
url
.
urlRegistor
,
body
)
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
err
);
export
const
logoutApi
=
async
(
body
)
=>
export
const
logoutApi
=
async
(
body
)
=>
PostData
(
'http://api.dcvinvest.com/api/auth/logout'
,
body
)
PostData
(
'http://api.dcvinvest.com/api/auth/logout'
,
body
)
.
then
((
res
)
=>
res
)
.
then
((
res
)
=>
res
)
...
...
src/apis/url.js
View file @
009bc5a8
import
{
NetworkSetting
}
from
'../config/Setting'
;
const
root
=
'http://api.dcvinvest.com/'
;
const
root
=
'http://api.dcvinvest.com/'
;
export
default
{
export
default
{
urllogin
:
root
+
'/api/auth/customer-login'
,
urllogin
:
root
+
'/api/auth/customer-login'
,
urlRegistor
:
root
+
'api/auth/customer-register'
,
};
};
src/components/Input/InputIcon.js
View file @
009bc5a8
...
@@ -4,7 +4,15 @@ import R from '../../assets/R';
...
@@ -4,7 +4,15 @@ import R from '../../assets/R';
import
{
WIDTHXD
,
HEIGHTXD
,
getFontXD
}
from
'../../Config/Functions'
;
import
{
WIDTHXD
,
HEIGHTXD
,
getFontXD
}
from
'../../Config/Functions'
;
const
InputIcon
=
(
props
)
=>
{
const
InputIcon
=
(
props
)
=>
{
const
{
title
,
placeholder
,
icon
,
onChangeText
,
maxLength
,
isPassWord
}
=
props
;
const
{
title
,
placeholder
,
icon
,
onChangeText
,
maxLength
,
isPassWord
,
value
,
}
=
props
;
const
{
wrapLeft
,
wrapRight
,
container
,
iconImg
,
txtInput
}
=
styles
;
const
{
wrapLeft
,
wrapRight
,
container
,
iconImg
,
txtInput
}
=
styles
;
return
(
return
(
<
View
style
=
{
container
}
>
<
View
style
=
{
container
}
>
...
@@ -18,6 +26,7 @@ const InputIcon = (props) => {
...
@@ -18,6 +26,7 @@ const InputIcon = (props) => {
placeholderTextColor
=
{
R
.
colors
.
placeHolder
}
placeholderTextColor
=
{
R
.
colors
.
placeHolder
}
placeholder
=
{
placeholder
}
placeholder
=
{
placeholder
}
secureTextEntry
=
{
isPassWord
}
secureTextEntry
=
{
isPassWord
}
value
=
{
value
}
/
>
/
>
<
/View
>
<
/View
>
<
/View
>
<
/View
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment