Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
21_22-J 38
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
21_22-J 38
21_22-J 38
Commits
c32a69cd
Commit
c32a69cd
authored
Apr 24, 2022
by
Neranga K.T.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
89274bdb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
1 deletion
+88
-1
frontend/App.js
frontend/App.js
+3
-1
frontend/src/data/dummy-data.js
frontend/src/data/dummy-data.js
+28
-0
frontend/src/model/Users.js
frontend/src/model/Users.js
+10
-0
frontend/src/screen/auth/Login.js
frontend/src/screen/auth/Login.js
+20
-0
frontend/src/store/actions/login.js
frontend/src/store/actions/login.js
+5
-0
frontend/src/store/reducers/login.js
frontend/src/store/reducers/login.js
+22
-0
No files found.
frontend/App.js
View file @
c32a69cd
...
...
@@ -20,12 +20,14 @@ import {createStore, combineReducers} from 'redux';
import
{
Provider
}
from
'
react-redux
'
;
import
memoryReducer
from
'
./src/store/reducers/memory
'
;
import
timeReducer
from
'
./src/store/reducers/memory
'
import
userReducer
from
'
./src/store/reducers/login
'
;
import
AppRouter
from
"
./src/router/router
"
const
rootReducer
=
combineReducers
({
memory
:
memoryReducer
,
time
:
timeReducer
time
:
timeReducer
,
users
:
userReducer
});
const
store
=
createStore
(
rootReducer
);
...
...
frontend/src/data/dummy-data.js
0 → 100644
View file @
c32a69cd
import
Users
from
'
../model/Users
'
;
export
const
USERS
=
[
new
Users
(
'
1
'
,
'
teran@helply.com
'
,
'
12345678
'
,
'
teran
'
),
new
Users
(
'
2
'
,
'
rusiru@helply.com
'
,
'
12345678
'
,
'
rusiru
'
),
new
Users
(
'
3
'
,
'
madawa@helply.com
'
,
'
12345678
'
,
'
madawa
'
),
new
Users
(
'
4
'
,
'
navodh@helply.com
'
,
'
12345678
'
,
'
navodh
'
),
]
\ No newline at end of file
frontend/src/model/Users.js
0 → 100644
View file @
c32a69cd
class
Users
{
constructor
(
uid
,
email
,
password
,
name
){
this
.
uid
=
uid
,
this
.
email
=
email
,
this
.
password
=
password
,
this
.
name
=
name
}
}
export
default
Users
;
\ No newline at end of file
frontend/src/screen/auth/Login.js
View file @
c32a69cd
...
...
@@ -2,6 +2,8 @@ import { useNavigation } from "@react-navigation/native";
import
Orientation
from
'
react-native-orientation-locker
'
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
SafeAreaView
,
ScrollView
,
View
,
StyleSheet
,
ImageBackground
,
Text
,
TextInput
,
TouchableOpacity
,
Image
}
from
"
react-native
"
;
import
{
useSelector
,
useDispatch
}
from
'
react-redux
'
;
import
{
userLogin
}
from
'
../../store/actions/login
'
;
import
client
from
"
../client/Client
"
;
...
...
@@ -23,6 +25,10 @@ const isValidEmail = (value) => {
const
Login
=
()
=>
{
const
dispatch
=
useDispatch
();
const
users
=
useSelector
(
state
=>
state
.
users
.
users
);
const
navigation
=
useNavigation
();
React
.
useEffect
(()
=>
{
...
...
@@ -66,6 +72,20 @@ const Login = () => {
return
true
;
}
const
loginHandler
=
()
=>
{
const
loggedInUser
=
users
.
find
(
user
=>
user
.
email
===
email
&&
user
.
password
===
password
)
if
(
loggedInUser
){
console
.
log
(
loggedInUser
);
dispatch
(
userLogin
({
name
:
loggedInUser
.
name
,
id
:
loggedInUser
.
uid
}));
navigation
.
navigate
(
'
Home
'
);
}
else
{
console
.
log
(
'
Invalid user credentials...
'
);
}
}
const
submitForm
=
()
=>
{
if
(
isValidForm
()){
...
...
frontend/src/store/actions/login.js
0 → 100644
View file @
c32a69cd
export
const
USER_LOGIN
=
'
USER_LOGIN
'
;
export
const
userLogin
=
(
user
)
=>
{
return
{
type
:
USER_LOGIN
,
user
:
user
}
}
\ No newline at end of file
frontend/src/store/reducers/login.js
0 → 100644
View file @
c32a69cd
import
{
USER_LOGIN
}
from
'
../actions/login
'
;
import
{
USERS
}
from
'
../../data/dummy-data
'
;
const
initialState
=
{
users
:
USERS
,
loggedInUser
:
{}
}
const
userReducer
=
(
state
=
initialState
,
action
)
=>
{
switch
(
action
.
type
)
{
case
USER_LOGIN
:
return
{
...
state
,
loggedInUser
:
action
.
user
}
default
:
return
state
;
}
return
state
;
}
export
default
userReducer
;
\ No newline at end of file
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