Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I_Helmet
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 62
I_Helmet
Commits
eb3d178e
Commit
eb3d178e
authored
Apr 28, 2022
by
Balasuriya D.A.M.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Frontend signup Cont../Frontend login functionality/Guest Login
parent
9f40704e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
136 additions
and
6 deletions
+136
-6
IT18021080/Telemedicine-Chat-App/frontend/src/components/Authentication/Login.js
...-Chat-App/frontend/src/components/Authentication/Login.js
+67
-4
IT18021080/Telemedicine-Chat-App/frontend/src/components/Authentication/Signup.js
...Chat-App/frontend/src/components/Authentication/Signup.js
+69
-2
No files found.
IT18021080/Telemedicine-Chat-App/frontend/src/components/Authentication/Login.js
View file @
eb3d178e
...
@@ -5,16 +5,77 @@
...
@@ -5,16 +5,77 @@
import
{
Button
,
FormControl
,
FormLabel
,
Input
,
InputGroup
,
InputRightElement
,
VStack
}
from
"
@chakra-ui/react
"
;
import
{
Button
,
FormControl
,
FormLabel
,
Input
,
InputGroup
,
InputRightElement
,
VStack
}
from
"
@chakra-ui/react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
useToast
}
from
"
@chakra-ui/react
"
;
import
axios
from
"
axios
"
;
import
{
useHistory
}
from
"
react-router-dom
"
;
const
Login
=
()
=>
{
const
Login
=
()
=>
{
const
[
show
,
setShow
]
=
useState
(
false
);
const
[
show
,
setShow
]
=
useState
(
false
);
const
[
email
,
setEmail
]
=
useState
();
const
[
email
,
setEmail
]
=
useState
();
const
[
password
,
setPassword
]
=
useState
();
const
[
password
,
setPassword
]
=
useState
();
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
toast
=
useToast
();
const
history
=
useHistory
();
const
handleClick
=
()
=>
setShow
(
!
show
);
const
handleClick
=
()
=>
setShow
(
!
show
);
const
submitHandler
=
()
=>
{
};
const
submitHandler
=
async
()
=>
{
setLoading
(
true
);
if
(
!
email
||
!
password
)
{
toast
({
title
:
"
Please Fill all the Fields
"
,
status
:
"
warning
"
,
duration
:
5000
,
isClosable
:
true
,
position
:
"
bottom
"
,
});
setLoading
(
false
);
return
;
}
//console.log(email,password);
try
{
const
config
=
{
headers
:
{
"
Content-type
"
:
"
application/json
"
,
},
};
const
{
data
}
=
await
axios
.
post
(
"
/api/user/login
"
,
{
email
,
password
,
},
config
);
//console.log(JSON.stringfy(data));
toast
({
title
:
"
Login Successfull
"
,
status
:
"
success
"
,
duration
:
5000
,
isClosable
:
true
,
position
:
"
bottom
"
,
});
localStorage
.
setItem
(
"
userInfo
"
,
JSON
.
stringify
(
data
));
setLoading
(
false
);
//if the user has been succefully log in push him to chat page
history
.
push
(
"
/chats
"
);
}
catch
(
error
)
{
toast
({
//give the description of the error
title
:
"
Error Occured!
"
,
description
:
error
.
response
.
data
.
message
,
status
:
"
error
"
,
duration
:
5000
,
isClosable
:
true
,
position
:
"
bottom
"
,
});
setLoading
(
false
);
}
};
return
(
return
(
//Use vstack to allign verticaly
//Use vstack to allign verticaly
...
@@ -24,6 +85,7 @@ const Login = () => {
...
@@ -24,6 +85,7 @@ const Login = () => {
<
FormControl
id
=
"
email
"
isRequired
>
<
FormControl
id
=
"
email
"
isRequired
>
<
FormLabel
>
Email
<
/FormLabel
>
<
FormLabel
>
Email
<
/FormLabel
>
<
Input
<
Input
value
=
{
email
}
placeholder
=
"
Enter Your Email
"
placeholder
=
"
Enter Your Email
"
onChange
=
{(
e
)
=>
setEmail
(
e
.
target
.
value
)}
onChange
=
{(
e
)
=>
setEmail
(
e
.
target
.
value
)}
...
@@ -38,6 +100,7 @@ const Login = () => {
...
@@ -38,6 +100,7 @@ const Login = () => {
<
Input
<
Input
type
=
{
show
?
"
text
"
:
"
password
"
}
type
=
{
show
?
"
text
"
:
"
password
"
}
placeholder
=
"
Enter Your Password
"
placeholder
=
"
Enter Your Password
"
value
=
{
password
}
onChange
=
{(
e
)
=>
setPassword
(
e
.
target
.
value
)}
onChange
=
{(
e
)
=>
setPassword
(
e
.
target
.
value
)}
/
>
/
>
...
@@ -56,7 +119,7 @@ const Login = () => {
...
@@ -56,7 +119,7 @@ const Login = () => {
width
=
"
100%
"
width
=
"
100%
"
style
=
{{
marginTop
:
15
}}
style
=
{{
marginTop
:
15
}}
onClick
=
{
submitHandler
}
onClick
=
{
submitHandler
}
isLoading
=
{
loading
}
>
>
Login
Login
...
...
IT18021080/Telemedicine-Chat-App/frontend/src/components/Authentication/Signup.js
View file @
eb3d178e
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
import
{
Button
,
FormControl
,
FormLabel
,
Input
,
InputGroup
,
InputRightElement
,
VStack
}
from
"
@chakra-ui/react
"
;
import
{
Button
,
FormControl
,
FormLabel
,
Input
,
InputGroup
,
InputRightElement
,
VStack
}
from
"
@chakra-ui/react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
useToast
}
from
"
@chakra-ui/react
"
;
import
{
useToast
}
from
"
@chakra-ui/react
"
;
import
axios
from
"
axios
"
;
import
{
useHistory
}
from
"
react-router-dom
"
;
const
Signup
=
()
=>
{
const
Signup
=
()
=>
{
...
@@ -17,6 +19,7 @@ const Signup = () => {
...
@@ -17,6 +19,7 @@ const Signup = () => {
const
[
pic
,
setPic
]
=
useState
();
const
[
pic
,
setPic
]
=
useState
();
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
toast
=
useToast
();
const
toast
=
useToast
();
const
history
=
useHistory
();
const
handleClick
=
()
=>
setShow
(
!
show
);
const
handleClick
=
()
=>
setShow
(
!
show
);
...
@@ -64,8 +67,72 @@ const Signup = () => {
...
@@ -64,8 +67,72 @@ const Signup = () => {
}
}
};
};
const
submitHandler
=
()
=>
{
const
submitHandler
=
async
()
=>
{
setLoading
(
true
);
//going to check is all of the fields check by user or not
if
(
!
name
||
!
email
||
!
password
||
!
confirmpassword
)
{
toast
({
title
:
"
Please Fill all the Feilds
"
,
status
:
"
warning
"
,
duration
:
5000
,
isClosable
:
true
,
position
:
"
bottom
"
,
});
setLoading
(
false
);
return
;
}
//going to check both of the password is match or not (password/conformpassword)
if
(
password
!==
confirmpassword
)
{
toast
({
title
:
"
Passwords Do Not Match
"
,
status
:
"
warning
"
,
duration
:
5000
,
isClosable
:
true
,
position
:
"
bottom
"
,
});
return
;
}
//Make API request to store that in to DB
try
{
const
config
=
{
headers
:
{
"
Content-type
"
:
"
application/json
"
,
},
};
const
{
data
}
=
await
axios
.
post
(
"
/api/user
"
,
{
name
,
email
,
password
,
pic
},
config
);
//toast if registration is succesfull
toast
({
title
:
"
Registration Successfull
"
,
status
:
"
success
"
,
duration
:
5000
,
isClosable
:
true
,
position
:
"
bottom
"
,
});
localStorage
.
setItem
(
"
userInfo
"
,
JSON
.
stringify
(
data
));
setLoading
(
false
);
//if the user has been succefully log in push him to chat page
history
.
push
(
"
/chats
"
);
}
catch
(
error
)
{
toast
({
//give the description of the error
title
:
"
Error Occured!
"
,
description
:
error
.
response
.
data
.
message
,
status
:
"
error
"
,
duration
:
5000
,
isClosable
:
true
,
position
:
"
bottom
"
,
});
setLoading
(
false
);
}
};
};
return
(
return
(
...
...
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