Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-049
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
2021-049
2021-049
Commits
e46eca11
Commit
e46eca11
authored
Oct 14, 2021
by
Hasitha Samarasekara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create User Login - Tutor DashBoard - 2
parent
477ad330
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
121 additions
and
68 deletions
+121
-68
BackEnd/WebBackEnd/routes/userAccount.route.js
BackEnd/WebBackEnd/routes/userAccount.route.js
+12
-8
WebFrontEnd/smartcoach-frontend/src/Components/Admin/Dashboard.js
...End/smartcoach-frontend/src/Components/Admin/Dashboard.js
+3
-1
WebFrontEnd/smartcoach-frontend/src/Components/HomePage/TutorProfileView.js
...oach-frontend/src/Components/HomePage/TutorProfileView.js
+99
-55
WebFrontEnd/smartcoach-frontend/src/Components/Navbar.js
WebFrontEnd/smartcoach-frontend/src/Components/Navbar.js
+4
-3
WebFrontEnd/smartcoach-frontend/src/Components/Student/StudentDashboard.js
...coach-frontend/src/Components/Student/StudentDashboard.js
+3
-1
No files found.
BackEnd/WebBackEnd/routes/userAccount.route.js
View file @
e46eca11
...
...
@@ -28,20 +28,21 @@ router.route('/getCredentials').post((req, res) => {
const
email
=
req
.
body
.
user_email
;
const
password
=
req
.
body
.
user_password
;
console
.
log
(
email
);
userAccount
.
find
({
user_email
:
email
},
function
(
err
,
User
)
{
}).
then
(
User
=>
{
let
payload
=
{
user_id
:
User
[
0
].
user_id
,
user_email
:
User
[
0
].
user_email
,
user_name
:
''
,
user_type
:
User
[
0
].
user_type
}
console
.
log
(
User
);
if
(
User
.
length
>
0
){
let
payload
=
{
user_id
:
User
[
0
].
user_id
,
user_email
:
User
[
0
].
user_email
,
user_name
:
''
,
user_type
:
User
[
0
].
user_type
}
console
.
log
(
password
);
console
.
log
(
User
[
0
].
user_password
);
if
(
User
[
0
].
user_password
===
password
){
...
...
@@ -90,7 +91,10 @@ router.route('/getCredentials').post((req, res) => {
})
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error:
'
+
err
));
.
catch
(
err
=>
{
console
.
log
(
err
);
res
.
status
(
400
).
json
(
'
Error:
'
+
err
)
});
});
...
...
WebFrontEnd/smartcoach-frontend/src/Components/Admin/Dashboard.js
View file @
e46eca11
...
...
@@ -115,7 +115,9 @@ export default class Dashboard extends Component {
<
div
className
=
"
dropdown-content1 dropdown-menu-right
"
>
<
button
type
=
"
button
"
className
=
"
dropdown-item
"
>
User
Account
<
/button
>
<
button
type
=
"
button
"
className
=
"
dropdown-item
"
style
=
{{
color
:
"
red
"
}}
onClick
=
{()
=>
{
window
.
location
.
replace
(
"
/UserLogin
"
);}}
>
Sign
Out
<
/button
>
<
button
type
=
"
button
"
className
=
"
dropdown-item
"
style
=
{{
color
:
"
red
"
}}
onClick
=
{()
=>
{
localStorage
.
clear
();
window
.
location
.
replace
(
"
/UserLogin
"
);}}
>
Sign
Out
<
/button
>
<
/div
>
<
/div
>
<
/div
>
...
...
WebFrontEnd/smartcoach-frontend/src/Components/HomePage/TutorProfileView.js
View file @
e46eca11
...
...
@@ -6,6 +6,7 @@ import axios from "axios";
import
*
as
configs
from
"
../../Config/config
"
;
import
*
as
Icon
from
"
react-bootstrap-icons
"
;
import
moment
from
"
moment
"
;
import
swal
from
"
sweetalert
"
;
export
default
class
TutorProfileView
extends
Component
{
...
...
@@ -53,10 +54,29 @@ export default class TutorProfileView extends Component{
this
.
onSID
=
this
.
onSID
.
bind
(
this
);
this
.
onTutorID
=
this
.
onTutorID
.
bind
(
this
);
this
.
submitRating
=
this
.
submitRating
.
bind
(
this
);
this
.
getTutorRatingAndReviews
=
this
.
getTutorRatingAndReviews
.
bind
(
this
);
}
componentDidMount
()
{
const
user_email
=
localStorage
.
getItem
(
"
email
"
);
const
user_id
=
localStorage
.
getItem
(
"
userID
"
);
const
user_name
=
localStorage
.
getItem
(
"
userName
"
);
const
user_type
=
localStorage
.
getItem
(
"
userType
"
);
if
(
user_id
!==
"
"
){
this
.
setState
({
isLogged
:
true
})
}
this
.
setState
({
user_email
:
user_email
,
student_id
:
user_id
,
user_name
:
user_name
,
user_type
:
user_type
})
axios
.
get
(
configs
.
BASE_URL
+
'
/tutorSingUp/
'
+
this
.
state
.
tutor_id
)
.
then
(
response
=>
{
console
.
log
(
response
.
data
);
...
...
@@ -105,53 +125,7 @@ export default class TutorProfileView extends Component{
},
()
=>
{
axios
.
get
(
configs
.
BASE_URL
+
'
/tutorRatings/
'
+
this
.
state
.
tutor_id
)
.
then
(
response
=>
{
console
.
log
(
response
.
data
);
let
TotalRating
=
0
;
let
Rating5
=
0
;
let
Rating4
=
0
;
let
Rating3
=
0
;
let
Rating2
=
0
;
let
Rating1
=
0
;
response
.
data
.
map
((
rate
)
=>
{
TotalRating
=
TotalRating
+
Number
(
rate
.
rating
);
if
(
Number
(
rate
.
rating
)
===
5
){
Rating5
++
}
else
if
(
Number
(
rate
.
rating
)
===
4
){
Rating4
++
}
else
if
(
Number
(
rate
.
rating
)
===
3
){
Rating3
++
}
else
if
(
Number
(
rate
.
rating
)
===
2
){
Rating2
++
}
else
if
(
Number
(
rate
.
rating
)
===
1
){
Rating1
++
}
})
console
.
log
(
TotalRating
)
this
.
setState
({
detailReviewList
:
response
.
data
.
sort
((
a
,
b
)
=>
b
.
rating
-
a
.
rating
),
overRollRating
:
Number
(
TotalRating
/
response
.
data
.
length
),
ratingCount
:
response
.
data
.
length
,
ratingFive
:
Rating5
,
ratingFour
:
Rating4
,
ratingThree
:
Rating3
,
ratingTwo
:
Rating2
,
ratingOne
:
Rating1
,
},
()
=>
{
console
.
log
(
this
.
state
.
overRollRating
)
})
})
this
.
getTutorRatingAndReviews
();
})
...
...
@@ -164,6 +138,56 @@ export default class TutorProfileView extends Component{
})
}
getTutorRatingAndReviews
(){
axios
.
get
(
configs
.
BASE_URL
+
'
/tutorRatings/
'
+
this
.
state
.
tutor_id
)
.
then
(
response
=>
{
console
.
log
(
response
.
data
);
let
TotalRating
=
0
;
let
Rating5
=
0
;
let
Rating4
=
0
;
let
Rating3
=
0
;
let
Rating2
=
0
;
let
Rating1
=
0
;
response
.
data
.
map
((
rate
)
=>
{
TotalRating
=
TotalRating
+
Number
(
rate
.
rating
);
if
(
Number
(
rate
.
rating
)
===
5
){
Rating5
++
}
else
if
(
Number
(
rate
.
rating
)
===
4
){
Rating4
++
}
else
if
(
Number
(
rate
.
rating
)
===
3
){
Rating3
++
}
else
if
(
Number
(
rate
.
rating
)
===
2
){
Rating2
++
}
else
if
(
Number
(
rate
.
rating
)
===
1
){
Rating1
++
}
})
console
.
log
(
TotalRating
)
this
.
setState
({
detailReviewList
:
response
.
data
.
sort
((
a
,
b
)
=>
b
.
rating
-
a
.
rating
),
overRollRating
:
Number
(
TotalRating
/
response
.
data
.
length
),
ratingCount
:
response
.
data
.
length
,
ratingFive
:
Rating5
,
ratingFour
:
Rating4
,
ratingThree
:
Rating3
,
ratingTwo
:
Rating2
,
ratingOne
:
Rating1
,
},
()
=>
{
console
.
log
(
this
.
state
.
overRollRating
)
})
})
}
onClickRatingValue
(
e
)
{
console
.
log
(
e
.
target
.
value
);
this
.
setState
({
...
...
@@ -214,13 +238,33 @@ export default class TutorProfileView extends Component{
}
// console.log("payload");
console
.
log
(
payload
);
axios
.
post
(
configs
.
BASE_URL
+
'
/tutorRatings/add
'
,
payload
)
.
then
(
response
=>
{
alert
(
"
One Review added!!!
"
)
});
if
(
this
.
state
.
student_id
!==
null
){
if
(
this
.
state
.
review
!==
""
){
if
(
this
.
state
.
rating
!==
0
){
console
.
log
(
payload
);
axios
.
post
(
configs
.
BASE_URL
+
'
/tutorRatings/add
'
,
payload
)
.
then
(
response
=>
{
swal
(
"
Thank You
"
,
"
Your Review Added Successfully
"
,
"
success
"
);
this
.
getTutorRatingAndReviews
();
});
}
else
{
swal
(
"
Sorry
"
,
"
Please give a rating first
"
,
"
warning
"
);
}
}
else
{
swal
(
"
Sorry
"
,
"
Please add a review first
"
,
"
warning
"
);
}
}
else
{
swal
(
"
Sorry
"
,
"
You Need to Login to the system...
"
,
"
warning
"
);
}
// console.log("payload");
}
render
()
{
...
...
@@ -406,7 +450,7 @@ export default class TutorProfileView extends Component{
<label>{tutorClass.class_conduct_day} - {tutorClass.class_conduct_time}</label>
</div>
<div className="col">
<button className="rounded" style={{background:
'
Orange
'
, padding:
'
3
px
'
, width:
'
60
px
'
}} value={""}
onClick={e => this.onSelectOneClass(e)}
>View</button>
<button className="rounded" style={{background:
'
Orange
'
, padding:
'
3
px
'
, width:
'
60
px
'
}} value={""} >View</button>
</div>
</div>
...
...
@@ -549,7 +593,7 @@ export default class TutorProfileView extends Component{
<div className="col">
<div className="row" style={{padding:
'
15
px
'
}}>
<h2 style={{marginLeft:
'
15
px
'
}}><span style={{color:
'
gray
'
}}><b
style={{fontSize:
'
40
px
'
, color: "black"}}>{this.state.overRollRating}</b>/5</span></h2>
style={{fontSize:
'
40
px
'
, color: "black"}}>{this.state.overRollRating
.toFixed(1)
}</b>/5</span></h2>
</div>
<div className="row">
{[...Array(5)].map((star, i) => {
...
...
WebFrontEnd/smartcoach-frontend/src/Components/Navbar.js
View file @
e46eca11
...
...
@@ -67,12 +67,13 @@ export default class NavBar extends Component {
color
:
'
#EAE4E4
'
,
marginRight
:
'
50px
'
}}
><
h5
>
{
this
.
state
.
user_name
!==
null
?
<
span
style
=
{{
cursor
:
'
pointer
'
}}
onClick
=
{()
=>
{
window
.
location
.
replace
(
"
/studentDashboard
"
);}}
>
{
this
.
state
.
user_name
}
<
/span> : <label onClick={
()
=>
{
window
.
location
.
replace
(
"
UserLogin
"
);
// window.location.replace("UserLogin");
window
.
location
=
'
/UserLogin
'
;
}}
>
Login
<
/label>} </
h5
><
/label
>
{
this
.
state
.
user_name
!==
null
&&
<
img
src
=
{
logout
}
onClick
=
{()
=>
{
localStorage
.
clear
();
window
.
location
.
replace
(
"
/UserLogin
"
)
;
}}
style
=
{{
position
:
'
absolute
'
,
top
:
'
1
0px
'
,
right
:
'
30px
'
,
width
:
'
40px
'
,
height
:
'
4
0px
'
,
cursor
:
'
pointer
'
}}
/>
}
window
.
location
=
'
/UserLogin
'
;
}}
style
=
{{
position
:
'
absolute
'
,
top
:
'
1
5px
'
,
right
:
'
30px
'
,
width
:
'
30px
'
,
height
:
'
3
0px
'
,
cursor
:
'
pointer
'
}}
/>
}
{
/*{this.state.user_name !== null && <h5 onClick={() => {*/
}
{
/* localStorage.clear();*/
}
...
...
WebFrontEnd/smartcoach-frontend/src/Components/Student/StudentDashboard.js
View file @
e46eca11
...
...
@@ -112,7 +112,9 @@ export default class StudentDashboard extends Component {
<
div
className
=
"
dropdown-content1 dropdown-menu-right
"
>
<
button
type
=
"
button
"
className
=
"
dropdown-item
"
onClick
=
{()
=>
{
window
.
location
.
replace
(
"
/Home
"
);}}
>
Back
To
Home
<
/button
>
<
button
type
=
"
button
"
className
=
"
dropdown-item
"
style
=
{{
color
:
"
red
"
}}
onClick
=
{()
=>
{
window
.
location
.
replace
(
"
/UserLogin
"
);}}
>
Sign
Out
<
/button
>
<
button
type
=
"
button
"
className
=
"
dropdown-item
"
style
=
{{
color
:
"
red
"
}}
onClick
=
{()
=>
{
localStorage
.
clear
();
window
.
location
.
replace
(
"
/UserLogin
"
);}}
>
Sign
Out
<
/button
>
<
/div
>
<
/div
>
<
/div
>
...
...
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