Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
safetcut-app
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
atichat
safetcut-app
Commits
7e4f60cc
Commit
7e4f60cc
authored
Sep 25, 2019
by
Tonk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update edit profile
parent
81ccd73d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
19 deletions
+24
-19
reduxStore/actions/cerrentUserAction.js
+10
-7
screens/Private/ProfileScreen/EditProfileScreen.js
+10
-7
screens/Private/ProfileScreen/ProfileScreen.js
+4
-5
No files found.
reduxStore/actions/cerrentUserAction.js
View file @
7e4f60cc
import
app
from
'../../firebase'
;
export
const
GET_CURRENT_USER
=
'GET_CURRENT_USER'
;
export
const
getCurrentUserAction
=
(
displayName
,
email
,
emailVerified
,
phoneNumber
,
uid
,
photoURL
)
=>
({
...
...
@@ -18,18 +20,19 @@ export const getCurrentUser = user => async dispatch => {
export
const
updateUser
=
userData
=>
async
(
dispatch
,
getState
)
=>
{
const
{
currentUserReducer
}
=
getState
();
const
{
displayName
,
email
,
emailVerified
,
uid
,
phoneNumber
,
photoURL
}
=
currentUserReducer
;
const
{
email
,
emailVerified
,
uid
,
photoURL
}
=
currentUserReducer
;
try
{
await
user
.
updateProfile
({
displayName
:
`
${
userData
.
firstName
}
${
userData
.
lastName
}
`
,
phoneNumber
:
userData
.
phoneNumber
,
});
const
newDisplayName
=
`
${
userData
.
firstName
}
${
userData
.
lastName
}
`
;
const
newPhoneNumber
=
userData
.
phoneNumber
;
dispatch
(
getCurrentUserAction
(
newDisplayName
,
email
,
emailVerified
,
uid
,
newPhoneNumber
,
photoURL
));
const
user
=
app
.
auth
().
currentUser
;
await
user
.
updateProfile
({
displayName
:
newDisplayName
,
phoneNumber
:
newPhoneNumber
,
});
dispatch
(
getCurrentUserAction
(
newDisplayName
,
email
,
emailVerified
,
newPhoneNumber
,
uid
,
photoURL
));
}
catch
(
error
)
{
console
.
log
(
'Update user failed!'
,
error
);
}
...
...
screens/Private/ProfileScreen/EditProfileScreen.js
View file @
7e4f60cc
...
...
@@ -24,11 +24,15 @@ class EditProfileScreen extends React.Component {
state
=
{
confirmModal
:
false
,
p
rofileImg
:
this
.
props
.
profileImg
,
firstName
:
this
.
props
.
firstName
,
lastName
:
this
.
props
.
lastName
,
p
hotoURL
:
this
.
props
.
photoURL
,
firstName
:
''
,
lastName
:
''
,
phoneNumber
:
this
.
props
.
phoneNumber
,
};
componentDidMount
()
{
const
splitName
=
this
.
props
.
displayName
?
this
.
props
.
displayName
.
split
(
' '
)
:
null
;
this
.
setState
({
firstName
:
splitName
[
0
],
lastName
:
splitName
[
1
]
});
}
toggleModal
=
value
=>
{
this
.
setState
({
confirmModal
:
value
});
};
...
...
@@ -41,7 +45,7 @@ class EditProfileScreen extends React.Component {
};
render
()
{
const
{
p
rofileImg
,
firstName
,
lastName
,
phoneNumber
,
confirmModal
}
=
this
.
state
;
const
{
p
hotoURL
,
firstName
,
lastName
,
phoneNumber
,
confirmModal
}
=
this
.
state
;
return
(
<
View
style
=
{
theme
.
container
}
>
<
Text
style
=
{[
theme
.
normalText
,
theme
.
textDark
,
theme
.
mt2
,
{
marginLeft
:
20
}]}
>
Edit
Profile
<
/Text
>
...
...
@@ -131,9 +135,8 @@ const styles = StyleSheet.create({
const
mapStateToProps
=
state
=>
({
email
:
state
.
currentUserReducer
.
email
,
phoneNumber
:
state
.
currentUserReducer
.
phoneNumber
,
firstName
:
state
.
currentUserReducer
.
firstName
,
lastName
:
state
.
currentUserReducer
.
lastName
,
profileImg
:
state
.
currentUserReducer
.
profileImg
,
displayName
:
state
.
currentUserReducer
.
displayName
,
photoURL
:
state
.
currentUserReducer
.
photoURL
,
});
const
mapDispatchToProps
=
{
...
...
screens/Private/ProfileScreen/ProfileScreen.js
View file @
7e4f60cc
...
...
@@ -32,12 +32,12 @@ class ProfileScreen extends React.Component {
});
render
()
{
const
{
email
,
phoneNumber
,
p
rofileImg
,
displayName
}
=
this
.
props
;
const
{
email
,
phoneNumber
,
p
hotoURL
,
displayName
}
=
this
.
props
;
return
(
<
View
style
=
{
theme
.
container
}
>
<
View
style
=
{
styles
.
headerStyle
}
>
<
Card
style
=
{
styles
.
imgProfileContainer
}
>
{
p
rofileImg
?
(
{
p
hotoURL
?
(
<><
/
>
)
:
(
<
Icon
...
...
@@ -136,9 +136,8 @@ const styles = StyleSheet.create({
const
mapStateToProps
=
state
=>
({
email
:
state
.
currentUserReducer
.
email
,
phoneNumber
:
state
.
currentUserReducer
.
phoneNumber
,
firstName
:
state
.
currentUserReducer
.
firstName
,
lastName
:
state
.
currentUserReducer
.
lastName
,
profileImg
:
state
.
currentUserReducer
.
profileImg
,
displayName
:
state
.
currentUserReducer
.
displayName
,
photoURL
:
state
.
currentUserReducer
.
photoURL
,
});
const
mapDispatchToProps
=
{};
...
...
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