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
33af91ea
Commit
33af91ea
authored
Sep 25, 2019
by
Tonk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add register function
parent
7e4f60cc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
13 deletions
+48
-13
components/Form/RegisterForm.js
+9
-9
screens/Private/ProfileScreen/EditProfileScreen.js
+5
-1
screens/Public/RegisterScreen.js
+34
-3
No files found.
components/Form/RegisterForm.js
View file @
33af91ea
...
...
@@ -40,27 +40,27 @@ class Register extends Component {
<
View
style
=
{
theme
.
containerWithVerticalMargin
}
>
<
Field
forwardRef
ref
=
{
c
=>
(
this
.
n
ame
=
c
)}
refField
=
"
n
ame"
ref
=
{
c
=>
(
this
.
firstN
ame
=
c
)}
refField
=
"
firstN
ame"
returnKeyType
=
"next"
onSubmitEditing
=
{()
=>
this
.
surname
.
getRenderedComponent
().
refs
.
surn
ame
.
focus
()}
name
=
"
n
ame"
onSubmitEditing
=
{()
=>
this
.
lastName
.
getRenderedComponent
().
refs
.
lastN
ame
.
focus
()}
name
=
"
firstN
ame"
keyboardType
=
"default"
component
=
{
Input
}
validate
=
{[
required
]}
placeholder
=
"
N
ame"
placeholder
=
"
First n
ame"
/>
<
Field
forwardRef
ref
=
{
c
=>
(
this
.
surn
ame
=
c
)}
refField
=
"
surn
ame"
ref
=
{
c
=>
(
this
.
lastN
ame
=
c
)}
refField
=
"
lastN
ame"
returnKeyType
=
"next"
onSubmitEditing
=
{()
=>
this
.
email
.
getRenderedComponent
().
refs
.
email
.
focus
()}
name
=
"
surn
ame"
name
=
"
lastN
ame"
keyboardType
=
"default"
component
=
{
Input
}
validate
=
{[
required
]}
placeholder
=
"
Sur
name"
placeholder
=
"
Last
name"
/>
<
Field
forwardRef
...
...
screens/Private/ProfileScreen/EditProfileScreen.js
View file @
33af91ea
...
...
@@ -30,9 +30,11 @@ class EditProfileScreen extends React.Component {
phoneNumber
:
this
.
props
.
phoneNumber
,
};
componentDidMount
()
{
const
splitName
=
this
.
props
.
displayName
?
this
.
props
.
displayName
.
split
(
' '
)
:
null
;
if
(
this
.
props
.
displayName
)
{
const
splitName
=
this
.
props
.
displayName
.
split
(
' '
);
this
.
setState
({
firstName
:
splitName
[
0
],
lastName
:
splitName
[
1
]
});
}
}
toggleModal
=
value
=>
{
this
.
setState
({
confirmModal
:
value
});
};
...
...
@@ -53,6 +55,7 @@ class EditProfileScreen extends React.Component {
<
Text
style
=
{
theme
.
description
}
>
First
name
<
/Text
>
<
TextInput
value
=
{
firstName
}
placeholder
=
"e.g. John"
onChangeText
=
{
text
=>
this
.
setState
({
firstName
:
text
})}
style
=
{
styles
.
inputStyle
}
/
>
...
...
@@ -60,6 +63,7 @@ class EditProfileScreen extends React.Component {
<
Text
style
=
{
theme
.
description
}
>
Last
name
<
/Text
>
<
TextInput
value
=
{
lastName
}
placeholder
=
"e.g. Doe"
onChangeText
=
{
text
=>
this
.
setState
({
lastName
:
text
})}
style
=
{
styles
.
inputStyle
}
/
>
...
...
screens/Public/RegisterScreen.js
View file @
33af91ea
...
...
@@ -5,8 +5,11 @@ import { Platform, View, ScrollView } from 'react-native';
import
RegisterForm
from
'../../components/Form/RegisterForm'
;
import
{
HeaderButtons
,
Item
}
from
'react-navigation-header-buttons'
;
import
IoniconsHeaderButton
from
'../../components/IoniconsHeaderButton'
;
import
app
,
{
fireStore
,
baseURL
}
from
'../../firebase'
;
import
{
connect
}
from
'react-redux'
;
import
{
updateUser
}
from
'../../reduxStore/actions/cerrentUserAction'
;
export
default
class
RegisterScreen
extends
Component
{
class
RegisterScreen
extends
Component
{
static
navigationOptions
=
({
navigation
})
=>
({
title
:
undefined
,
...
...
@@ -30,9 +33,26 @@ export default class RegisterScreen extends Component {
this
.
props
.
navigation
.
navigate
(
'Success'
);
}
}
submit
=
values
=>
{
this
.
submitSuccess
();
if
(
this
.
state
.
isCheck
==
false
)
{
alert
(
'You have to accept Terms and Conditions!'
);
}
else
{
this
.
createAccount
(
values
);
}
};
createAccount
=
async
values
=>
{
const
userData
=
{
firstName
:
values
.
firstName
,
lastName
:
values
.
lastName
,
phoneNumber
:
values
.
phoneno
};
try
{
const
reg
=
app
.
auth
().
createUserWithEmailAndPassword
(
values
.
email
,
values
.
password
);
if
(
reg
)
{
this
.
props
.
updateUser
(
userData
);
app
.
auth
().
signOut
();
this
.
props
.
navigation
.
navigate
(
'Success'
);
}
}
catch
(
error
)
{
console
.
log
(
error
);
}
};
render
()
{
...
...
@@ -63,3 +83,14 @@ export default class RegisterScreen extends Component {
);
}
}
const
mapStateToProps
=
state
=>
({});
const
mapDispatchToProps
=
{
updateUser
,
};
export
default
connect
(
mapStateToProps
,
mapDispatchToProps
)(
RegisterScreen
);
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