Commit 402157f6 authored by Devinda's avatar Devinda

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	WebFrontEnd/smartcoach-frontend/src/App.js
parents 847a6825 09e07a18
...@@ -94,7 +94,7 @@ router.route('/add').post(async(req,res) =>{ ...@@ -94,7 +94,7 @@ router.route('/add').post(async(req,res) =>{
router.route('/tutorClass/:id').get(function (req, res) { router.route('/tutorClass/:id').get(function (req, res) {
let id = req.params.id; let id = req.params.id;
//console.log("TutorId : " + id) //console.log("TutorId : " + id)
classes.find({"tutor_id": id}).populate('institute_id').then(tutorsClasses => { classes.find({"tutor_id": id,"isActiveForStudent": true}).populate('institute_id').then(tutorsClasses => {
///console.log(tutor); ///console.log(tutor);
res.json(tutorsClasses); res.json(tutorsClasses);
}).catch(err => res.status(400).json('Eroor: '+ err)); }).catch(err => res.status(400).json('Eroor: '+ err));
......
...@@ -85,36 +85,36 @@ router.route('/add').post(async(req,res) =>{ ...@@ -85,36 +85,36 @@ router.route('/add').post(async(req,res) =>{
.then(newUser =>{ .then(newUser =>{
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
// const content = ` const content = `
// Hi ${institute_name},\n Hi ${institute_name},\n
// You are Create a Institute Account on SmartCoach.\n You are Create a Institute Account on SmartCoach.\n
// You can verify your email address click on 'http://localhost:3000/AccountVerified/${newUser.id}' You can verify your email address click on 'http://localhost:3000/AccountVerified/${newUser.id}'
//
// Used institute email address as the username : ${user_email} Used institute email address as the username : ${user_email}
// Used given password as the password Used given password as the password
// Thank You, Thank You,
// Team SmartCoach Team SmartCoach
// `; `;
//
// var mail = { var mail = {
// from: institute_name, from: institute_name,
// to: user_email, to: user_email,
// subject: 'Email Verification - Institute', subject: 'Email Verification - Institute',
// text: content text: content
// } }
//
// transporter.sendMail(mail, (err, data) => { transporter.sendMail(mail, (err, data) => {
// if (err) { if (err) {
// res.json({ res.json({
// msg: 'fail' msg: 'fail'
// }) })
// } else { } else {
// res.json({ res.json({
// msg: 'success' msg: 'success'
// }) })
// } }
// }) })
// ; ;
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
}) })
......
...@@ -133,41 +133,41 @@ router.route('/add').post(async(req,res) =>{ ...@@ -133,41 +133,41 @@ router.route('/add').post(async(req,res) =>{
.then(newUser =>{ .then(newUser =>{
console.log("Inside the Email Send part") console.log("Inside the Email Send part")
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
// const content = ` const content = `
// Hi ${tutor_name},\n Hi ${tutor_name},\n
// You are Create a Tutor Account on SmartCoach.\n You are Create a Tutor Account on SmartCoach.\n
// You can verify your email address click on 'http://localhost:3000/AccountVerified/${newUser.id}' You can verify your email address click on 'http://localhost:3000/AccountVerified/${newUser.id}'
//
// Used your email address as username : ${user_email} Used your email address as username : ${user_email}
// Thank You, Thank You,
// Team SmartCoach Team SmartCoach
// `; `;
//
// var mail = { var mail = {
// from: tutor_name, from: tutor_name,
// to: user_email, to: user_email,
// subject: 'Email Verification - Tutor', subject: 'Email Verification - Tutor',
// text: content text: content
// } }
//
// transporter.sendMail(mail, (err, data) => { transporter.sendMail(mail, (err, data) => {
// if (err) { if (err) {
// res.json({ res.json({
// msg: 'fail' msg: 'fail'
// }) })
// } else { } else {
// res.json({ res.json({
// msg: 'success' msg: 'success'
// }) })
// } }
// }) })
// ; ;
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
}) })
.catch(err =>res.status(400).json('Error: '+err)); .catch(err =>res.status(400).json('Error: '+err));
// res.json('Tutor Successfully Added....'); res.json('Tutor Successfully Added....');
......
...@@ -29,4 +29,14 @@ router.route('/add').post(async(req,res) =>{ ...@@ -29,4 +29,14 @@ router.route('/add').post(async(req,res) =>{
}); });
router.route('/:id').get(function (req, res) {
let id = req.params.id;
//console.log("TutorId : " + id)
tutorRatingsRoute.find({"tutor_id": id}).populate('student_id').then(tutorReview => {
///console.log(tutor);
res.json(tutorReview);
}).catch(err => res.status(400).json('Eroor: '+ err));
});
module.exports = router; module.exports = router;
const router = require('express').Router(); const router = require('express').Router();
let userAccount = require('../models/userAccount.user.model'); let userAccount = require('../models/userAccount.user.model');
let StudentAccount = require('../models/student.user.model');
let TutorAccount = require('../models/tutor.user.model');
let InstituteAccount = require('../models/institute.user.model');
router.route('/update/:id').post((req,res) =>{ router.route('/update/:id').post((req,res) =>{
userAccount.findById(req.params.id, function(err, details){ userAccount.findById(req.params.id, function(err, details){
...@@ -25,9 +28,68 @@ router.route('/getCredentials').post((req, res) => { ...@@ -25,9 +28,68 @@ router.route('/getCredentials').post((req, res) => {
const email = req.body.user_email; const email = req.body.user_email;
const password = req.body.user_password; const password = req.body.user_password;
userAccount.find({user_email:email, user_password:password}, function (err, User) {
}).then(User => res.json(User))
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){
console.log(password);
console.log(User[0].user_password);
if(User[0].user_password === password){
console.log("inside password")
if(User[0].confirmed){
console.log("inside Confirmed")
if(User[0].user_type === "Student"){
console.log("inside student")
StudentAccount.findById(User[0].user_id).then(result=>{
console.log(result);
payload.user_name = result.student_name
res.json(payload)
})
}
else if(User[0].user_type === "Tutor"){
console.log("inside Tutor")
TutorAccount.findById(User[0].user_id).then(result=>{
payload.user_name = result.tutor_name
res.json(payload)
})
}
else if(User[0].user_type === "Institute"){
InstituteAccount.findById(User[0].user_id).then(result=>{
payload.user_name = result.institute_name
res.json(payload)
})
}
}
else {
res.json("Not Verified")
}
}
else {
res.json("Invalid Password")
}
}
else {
res.json("Not registered")
}
})
.catch(err => res.status(400).json('Error: ' + err)); .catch(err => res.status(400).json('Error: ' + err));
......
...@@ -7,8 +7,45 @@ import ViewFinance from './view_financial_details'; ...@@ -7,8 +7,45 @@ import ViewFinance from './view_financial_details';
import EditFinance from './edit_financial_details'; import EditFinance from './edit_financial_details';
import AddClass from './add_class_details'; import AddClass from './add_class_details';
import studentRequest from './StudentRequestForClass'; import studentRequest from './StudentRequestForClass';
import TestTeacher from "../../Images/defaultimageicon.jpg";
export default class Dashboard extends Component { export default class Dashboard extends Component {
constructor(props) {
super(props);
this.state = {
user_email : '',
user_id : '',
user_name :'',
user_type :'',
isLogged : false
}
}
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,
user_id : user_id,
user_name : user_name,
user_type : user_type
})
}
render() { render() {
return ( return (
...@@ -72,19 +109,20 @@ export default class Dashboard extends Component { ...@@ -72,19 +109,20 @@ export default class Dashboard extends Component {
<div className="widget-content-left"> <div className="widget-content-left">
<div className="btn-group"> <div className="btn-group">
<div className="dropdown1"> <div className="dropdown1">
<img width="42" className="rounded-circle" src="DashboardAssets/images/user.jpg" alt=""/> <img src={TestTeacher} className="rounded-circle" style={{width:'50px', height:'50px', float:'left', margin:'0px'}}/>
{/*<img width="42" className="rounded-circle" src="DashboardAssets/images/user.jpg" alt=""/>*/}
<i className="fa fa-angle-down ml-2 opacity-8"/> <i className="fa fa-angle-down ml-2 opacity-8"/>
<div className="dropdown-content1 dropdown-menu-right"> <div className="dropdown-content1 dropdown-menu-right">
<button type="button" className="dropdown-item">User Account</button> <button type="button" className="dropdown-item">User Account</button>
<button type="button" className="dropdown-item" style={{color:"red"}}>Sign Out</button> <button type="button" className="dropdown-item" style={{color:"red"}} onClick={()=>{window.location.replace("/UserLogin");}}>Sign Out</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div className="widget-content-left ml-3 header-user-info"> <div className="widget-content-left ml-3 header-user-info">
<div className="widget-heading"> <div className="widget-heading">
Bandara Dissanayake {this.state.user_name}
</div> </div>
<div className="widget-subheading"> <div className="widget-subheading">
Tutor Tutor
......
...@@ -33,6 +33,11 @@ export default class StudentRequestForClass extends Component{ ...@@ -33,6 +33,11 @@ export default class StudentRequestForClass extends Component{
labelClassID:'', labelClassID:'',
typedNIC:'', typedNIC:'',
ClassStudentList:[], ClassStudentList:[],
user_email : '',
user_id : '',
user_name :'',
user_type :'',
isLogged : false
} }
this.onChangeClassMethod = this.onChangeClassMethod.bind(this); this.onChangeClassMethod = this.onChangeClassMethod.bind(this);
...@@ -45,38 +50,59 @@ export default class StudentRequestForClass extends Component{ ...@@ -45,38 +50,59 @@ export default class StudentRequestForClass extends Component{
} }
componentDidMount() { componentDidMount() {
axios.get(configs.BASE_URL + '/tutorSingUp/'+this.state.tutorID ) const user_email = localStorage.getItem("email");
.then(response =>{ const user_id = localStorage.getItem("userID");
console.log(response.data); const user_name = localStorage.getItem("userName");
//console.log(response.data); const user_type = localStorage.getItem("userType");
if(user_id !== " "){
this.setState({
isLogged : true
})
}
this.setState({
user_email: user_email,
user_id : user_id,
tutorID: user_id,
user_name : user_name,
user_type : user_type
},()=>{
axios.get(configs.BASE_URL + '/tutorSingUp/'+this.state.tutorID )
.then(response =>{
console.log(response.data);
//console.log(response.data);
this.setState({
instituteList : response.data.tutor_instituteIDList,
ClassMethods : response.data.tutor_class_type,
subjectList : response.data.tutor_subjects,
}, ()=>{ this.setState({
axios.get(configs.BASE_URL + '/createClass/tutorClass/'+this.state.tutorID ) instituteList : response.data.tutor_instituteIDList,
.then(response =>{ ClassMethods : response.data.tutor_class_type,
console.log(response.data); subjectList : response.data.tutor_subjects,
}, ()=>{
axios.get(configs.BASE_URL + '/createClass/tutorClass/'+this.state.tutorID )
.then(response =>{
console.log(response.data);
this.setState({
TutorClassList : response.data
}, ()=>{
})
this.setState({
TutorClassList : response.data
}, ()=>{
}) })
})
})
}) })
})
})
} }
GetStudentList(){ GetStudentList(){
...@@ -307,9 +333,12 @@ export default class StudentRequestForClass extends Component{ ...@@ -307,9 +333,12 @@ export default class StudentRequestForClass extends Component{
<div className="" style={{marginTop:'15px'}}> <div className="" style={{marginTop:'15px'}}>
<div className="table-dark row"> <div className="table-dark row">
<div className="col-md-4" style={{textAlign:'left', paddingLeft:'30px'}}> <div className="col" style={{textAlign:'left', paddingLeft:'30px'}}>
<label>Batch Name</label> <label>Batch Name</label>
</div> </div>
<div className="col">
<label>Year</label>
</div>
<div className="col"> <div className="col">
<label>Starting Date</label> <label>Starting Date</label>
</div> </div>
...@@ -335,9 +364,12 @@ export default class StudentRequestForClass extends Component{ ...@@ -335,9 +364,12 @@ export default class StudentRequestForClass extends Component{
{this.state.TutorClassList.map((oneClass)=>{ {this.state.TutorClassList.map((oneClass)=>{
return( return(
<div className="row" style={{background:'#DCDCDC', paddingBottom:'5px', paddingTop:'5px', borderBottom: 'inset'}}> <div className="row" style={{background:'#DCDCDC', paddingBottom:'5px', paddingTop:'5px', borderBottom: 'inset'}}>
<div className="col-md-4" style={{textAlign:'left'}}> <div className="col" style={{textAlign:'left'}}>
<label style={{marginLeft:'20px'}}>{oneClass.batch_no}</label> <label style={{marginLeft:'20px'}}>{oneClass.batch_no}</label>
</div> </div>
<div className="col">
<label>{oneClass.batchYear}</label>
</div>
<div className="col"> <div className="col">
<label>{moment(oneClass.class_startingDate).format("L") }</label> <label>{moment(oneClass.class_startingDate).format("L") }</label>
</div> </div>
...@@ -525,16 +557,31 @@ export default class StudentRequestForClass extends Component{ ...@@ -525,16 +557,31 @@ export default class StudentRequestForClass extends Component{
<div className="row" style={{background:'#DCDCDC', paddingBottom:'5px', paddingTop:'5px', borderBottom: 'inset'}}> <div className="row" style={{background:'#DCDCDC', paddingBottom:'5px', paddingTop:'5px', borderBottom: 'inset'}}>
<div className="col-md-4" style={{textAlign:'left'}}> <div className="col-md-4" style={{textAlign:'left'}}>
<label ></label> <label >200114712426</label>
</div>
<div className="col">
<label>Amila Thenuwara</label>
</div>
<div className="col">
<button className="rounded" style={{background:'#086232', padding:'3px', width:'35px'}}><Icon.ArrowLeftCircle color="white" size={20}/></button>
<button className="rounded" style={{background:'#8D2828', padding:'3px', width:'35px', marginLeft:'10px'}}><Icon.Eraser color="white" size={20}/></button>
</div>
</div>
<div className="row" style={{background:'#DCDCDC', paddingBottom:'5px', paddingTop:'5px', borderBottom: 'inset'}}>
<div className="col-md-4" style={{textAlign:'left'}}>
<label >200177014551</label>
</div> </div>
<div className="col"> <div className="col">
<label></label> <label>Supun Malshan</label>
</div> </div>
<div className="col"> <div className="col">
<button className="rounded" style={{background:'#086232', padding:'3px', width:'35px'}}><Icon.ArrowLeftCircle color="white" size={20}/></button> <button className="rounded" style={{background:'#086232', padding:'3px', width:'35px'}}><Icon.ArrowLeftCircle color="white" size={20}/></button>
<button className="rounded" style={{background:'#8D2828', padding:'3px', width:'35px'}}><Icon.Eraser color="white" size={20}/></button> <button className="rounded" style={{background:'#8D2828', padding:'3px', width:'35px', marginLeft:'10px'}}><Icon.Eraser color="white" size={20}/></button>
</div> </div>
</div> </div>
......
...@@ -10,7 +10,7 @@ export default class AddClassDetails extends Component { ...@@ -10,7 +10,7 @@ export default class AddClassDetails extends Component {
super(props); super(props);
this.state = { this.state = {
tutorID: '6127b1d7ed4ff23bb0344538', tutorID: '',
instituteList: [], instituteList: [],
ClassMethods: [], ClassMethods: [],
subjectList: [], subjectList: [],
...@@ -35,6 +35,11 @@ export default class AddClassDetails extends Component { ...@@ -35,6 +35,11 @@ export default class AddClassDetails extends Component {
selectedDay:'', selectedDay:'',
HoursTime :'', HoursTime :'',
AdmissionFee : '', AdmissionFee : '',
user_email : '',
user_id : '',
user_name :'',
user_type :'',
isLogged : false
} }
this.onChangeClassMethod = this.onChangeClassMethod.bind(this); this.onChangeClassMethod = this.onChangeClassMethod.bind(this);
...@@ -52,42 +57,69 @@ export default class AddClassDetails extends Component { ...@@ -52,42 +57,69 @@ export default class AddClassDetails extends Component {
this.onChangeDay = this.onChangeDay.bind(this); this.onChangeDay = this.onChangeDay.bind(this);
this.onChangeHours = this.onChangeHours.bind(this); this.onChangeHours = this.onChangeHours.bind(this);
this.onChangeAdmissionFee = this.onChangeAdmissionFee.bind(this); this.onChangeAdmissionFee = this.onChangeAdmissionFee.bind(this);
this.GetTutorClasses = this.GetTutorClasses.bind(this);
} }
componentDidMount() { componentDidMount() {
axios.get(configs.BASE_URL + '/tutorSingUp/' + this.state.tutorID) const user_email = localStorage.getItem("email");
.then(response => { const user_id = localStorage.getItem("userID");
console.log(response.data); const user_name = localStorage.getItem("userName");
//console.log(response.data); const user_type = localStorage.getItem("userType");
if(user_id !== " "){
this.setState({
isLogged : true
})
}
this.setState({ this.setState({
instituteList: response.data.tutor_instituteIDList, user_email: user_email,
ClassMethods: response.data.tutor_class_type, user_id : user_id,
subjectList: response.data.tutor_subjects, tutorID: user_id,
user_name : user_name,
user_type : user_type
},()=>{
axios.get(configs.BASE_URL + '/tutorSingUp/' + this.state.tutorID)
.then(response => {
console.log(response.data);
//console.log(response.data);
}, () => {
axios.get(configs.BASE_URL + '/createClass/tutorClass/' + this.state.tutorID)
.then(response => {
console.log(response.data);
this.setState({ this.setState({
TutorClassList: response.data instituteList: response.data.tutor_instituteIDList,
ClassMethods: response.data.tutor_class_type,
subjectList: response.data.tutor_subjects,
}, () => {
this.GetTutorClasses();
})
}, () => { })
})
}) }
GetTutorClasses(){
axios.get(configs.BASE_URL + '/createClass/tutorClass/' + this.state.tutorID)
.then(response => {
console.log(response.data);
this.setState({
TutorClassList: response.data
}, () => {
})
}) })
}) })
} }
onChangeAdmissionFee(e) { onChangeAdmissionFee(e) {
this.setState({ this.setState({
AdmissionFee: e.target.value AdmissionFee: e.target.value
...@@ -241,6 +273,7 @@ export default class AddClassDetails extends Component { ...@@ -241,6 +273,7 @@ export default class AddClassDetails extends Component {
.then(res => { .then(res => {
console.log(res) console.log(res)
swal("success!!!", res.data, "success").then(() => { swal("success!!!", res.data, "success").then(() => {
this.GetTutorClasses();
// e.target.reset(); // e.target.reset();
//window.location(); //window.location();
}); });
...@@ -514,9 +547,12 @@ export default class AddClassDetails extends Component { ...@@ -514,9 +547,12 @@ export default class AddClassDetails extends Component {
<div className="container" style={{marginTop: '15px'}}> <div className="container" style={{marginTop: '15px'}}>
<div className="table-dark row"> <div className="table-dark row">
<div className="col-md-4" style={{textAlign: 'left'}}> <div className="col" style={{textAlign: 'left'}}>
<label>Batch Name</label> <label>Batch Name</label>
</div> </div>
<div className="col" >
<label>Year</label>
</div>
<div className="col"> <div className="col">
<label>Starting Date</label> <label>Starting Date</label>
</div> </div>
...@@ -546,9 +582,12 @@ export default class AddClassDetails extends Component { ...@@ -546,9 +582,12 @@ export default class AddClassDetails extends Component {
paddingTop: '5px', paddingTop: '5px',
borderBottom: 'inset' borderBottom: 'inset'
}}> }}>
<div className="col-md-4" style={{textAlign: 'left', marginLeft:'10px'}}> <div className="col" style={{textAlign: 'left', marginLeft:'10px'}}>
<label style={{}}>{oneClass.batch_no}</label> <label style={{}}>{oneClass.batch_no}</label>
</div> </div>
<div className="col">
<label>{oneClass.batchYear}</label>
</div>
<div className="col"> <div className="col">
<label>{moment(oneClass.class_startingDate).format("L")}</label> <label>{moment(oneClass.class_startingDate).format("L")}</label>
</div> </div>
......
...@@ -356,9 +356,15 @@ export default class Home extends Component{ ...@@ -356,9 +356,15 @@ export default class Home extends Component{
valueForRating = 100 valueForRating = 100
} }
else if(Number(tutor.tutor_avg_rating) > 4.75){ else if(Number(tutor.tutor_avg_rating) > 4.75){
valueForRating = 75 valueForRating = 90
}
else if(Number(tutor.tutor_avg_rating) > 4.25){
valueForRating = 80
} }
else if(Number(tutor.tutor_avg_rating) > 4){ else if(Number(tutor.tutor_avg_rating) > 4){
valueForRating = 70
}
else if(Number(tutor.tutor_avg_rating) > 3.5){
valueForRating = 60 valueForRating = 60
} }
else if(Number(tutor.tutor_avg_rating) > 2){ else if(Number(tutor.tutor_avg_rating) > 2){
......
...@@ -5,6 +5,7 @@ import Star from "../../Images/star.png"; ...@@ -5,6 +5,7 @@ import Star from "../../Images/star.png";
import ReviewImg from "../../Images/note.png"; import ReviewImg from "../../Images/note.png";
import Calender from "../../Images/calender.png"; import Calender from "../../Images/calender.png";
import RecommendIcon from "../../Images/recomended.png"; import RecommendIcon from "../../Images/recomended.png";
import {Link} from "react-router-dom";
export default class TutorCard extends Component{ export default class TutorCard extends Component{
...@@ -77,15 +78,16 @@ export default class TutorCard extends Component{ ...@@ -77,15 +78,16 @@ export default class TutorCard extends Component{
</div> </div>
<div className="row"> <div className="row">
<div className="col-1"> <div className="col-1">
<img src={Calender} style={{width:'20px', height:'20px'}}/> <br/>
{/*<img src={Calender} style={{width:'20px', height:'20px'}}/>*/}
</div> </div>
<div className="col"> <div className="col">
<h5 style={{float:"left"}}>6y experience</h5> {/*<h5 style={{float:"left"}}>6y experience</h5>*/}
</div> </div>
</div> </div>
<div className="row"> <div className="row">
<button className="form-control" value={this.props.data._id} <Link to={`/Home/ViewProfile/${this.props.data.tutor_id}`}> <button className="form-control"
style={{background:"#216E9B", color:"white", marginLeft:'15px', marginRight:'15px'}}><b>View Profile</b></button> style={{background:"#216E9B", color:"white", marginLeft:'15px', marginRight:'15px'}}><b>View Profile</b></button></Link>
</div> </div>
</div> </div>
......
import React, {Component} from "react"; import React, {Component} from "react";
import ItemNav from "./Navbar"; import ItemNav from "./Navbar";
import axios from "axios"; import axios from "axios";
import * as configs from "../Config/config";
import swal from "sweetalert";
export default class Login extends Component{ export default class Login extends Component{
...@@ -28,31 +30,53 @@ export default class Login extends Component{ ...@@ -28,31 +30,53 @@ export default class Login extends Component{
const email = this.state.email; const email = this.state.email;
axios.post('http://localhost:5000/userAccount/getCredentials', LogUser) axios.post(configs.BASE_URL + '/userAccount/getCredentials', LogUser)
.then(response => { .then(response => {
console.log(response.data); console.log(response.data);
if (response.data.length > 0) { //console.log(response.data.length);
console.log(response.data); // if (response.data.length > 0) {
console.log(response.data.password); //console.log(response.data);
//console.log(response.data.password);
// localStorage.setItem("Name",response.data[0].name); if(response.data === "Invalid Password"){
// localStorage.setItem("userID",response.data[0].id); swal("Sorry", "Invalid Password", "warning");
if(response.data[0].user_type === 'Student'){
window.location = '/Home';
} }
else if(response.data[0].user_type === 'Tutor'){ else if(response.data === "Not registered"){
window.location = '/admin'; swal("Sorry", "This email not registered!!!", "warning");
} }
else if(response.data[0].user_type === 'Institute'){ else if(response.data === "Not Verified"){
window.location = '/admin'; swal("Sorry", "This email is not Verified\nPlease verify your email first", "warning");
}else {
console.log(response.data);
console.log(response.data.user_email);
console.log(response.data.user_name);
localStorage.setItem("email",response.data.user_email);
localStorage.setItem("userID",response.data.user_id);
localStorage.setItem("userName",response.data.user_name);
localStorage.setItem("userType",response.data.user_type);
if(response.data.user_type === 'Student'){
window.location = '/Home';
}
else if(response.data.user_type === 'Tutor'){
window.location = '/admin';
}
else if(response.data.user_type === 'Institute'){
window.location = '/admin';
}
} }
//window.location = '/Places'; //window.location = '/Places';
} //}
else { // else {
alert("Email or Password Invalid!!!") // swal("Sorry", response.data, "warning");
} //
// }
}); });
......
import React, {Component} from 'react'; import React, {Component} from 'react';
import Logo from "../Images/logo.jpg"; import Logo from "../Images/logo.jpg";
import logout from "../Images/logout2.png";
export default class NavBar extends Component { export default class NavBar extends Component {
constructor(props) {
super(props);
this.state = {
user_email : '',
user_id : '',
user_name :'',
user_type :'',
isLogged : false
}
}
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,
user_id : user_id,
user_name : user_name,
user_type : user_type
})
console.log(user_email);
console.log(user_name);
}
render() { render() {
return ( return (
...@@ -16,26 +55,29 @@ export default class NavBar extends Component { ...@@ -16,26 +55,29 @@ export default class NavBar extends Component {
<img src={Logo} style={{width:'200px', height:'50px'}}/> <img src={Logo} style={{width:'200px', height:'50px'}}/>
<div className="collapse navbar-collapse" id="navbarNavAltMarkup"> <div className="collapse navbar-collapse" id="navbarNavAltMarkup">
<div className="navbar-nav"> <div className="navbar-nav">
<a className="nav-item nav-link " style={{color:'white', marginLeft:'50px'}} href="/Home">Home <span <a className="nav-item nav-link " style={{color:'white', marginLeft:'50px'}} href="/Home"><h5>Home</h5> <span
className="sr-only">(current)</span></a> className="sr-only">(current)</span></a>
</div> </div>
<label style={{ <label style={{
position: 'absolute', position: 'absolute',
top: '15px', top: '15px',
right: '120px', right: '120px',
color: '#EAE4E4' color: '#EAE4E4',
}}>{localStorage.getItem("Name") != null ? localStorage.getItem("Name") : <label onClick={() => { 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");
}}>Login</label>} </label> }}>Login</label>} </h5></label>
{localStorage.getItem("Name") != null && <label onClick={() => { {this.state.user_name !== null && <img src={logout} onClick={() => {
localStorage.clear(); localStorage.clear();
window.location.replace("/UserLogin"); window.location.replace("/UserLogin");
}} style={{position: 'absolute', top: '15px', right: '30px', color: '#EAE4E4'}}>Logout</label>} }} style={{position: 'absolute', top: '10px', right: '30px', width:'40px', height:'40px',cursor:'pointer'}}/>}
{/*{this.state.user_name !== null && <h5 onClick={() => {*/}
{/* localStorage.clear();*/}
{/* window.location.replace("/UserLogin");*/}
{/*}} style={{position: 'absolute', top: '15px', right: '30px', color: 'darkred'}}><b>Logout</b></h5>}*/}
</div> </div>
</nav> </nav>
......
...@@ -580,7 +580,7 @@ export default class SignUp extends Component { ...@@ -580,7 +580,7 @@ export default class SignUp extends Component {
else { else {
axios.post(configs.BASE_URL + '/studentSingUp/add', student) axios.post(configs.BASE_URL + '/studentSingUp/add', student)
.then(res =>{ .then(res =>{
console.log("Inside Then") //console.log("Inside Then")
window.location = '/beforeConfirm' window.location = '/beforeConfirm'
}) })
.catch(function (error) { .catch(function (error) {
...@@ -664,7 +664,7 @@ export default class SignUp extends Component { ...@@ -664,7 +664,7 @@ export default class SignUp extends Component {
axios.post(configs.BASE_URL + '/tutorSingUp/add', Tutor) axios.post(configs.BASE_URL + '/tutorSingUp/add', Tutor)
.then(res =>{ .then(res =>{
console.log("Inside Then") //console.log("Inside Then")
window.location = '/beforeConfirm' window.location = '/beforeConfirm'
}) })
.catch(function (error) { .catch(function (error) {
...@@ -716,7 +716,7 @@ export default class SignUp extends Component { ...@@ -716,7 +716,7 @@ export default class SignUp extends Component {
axios.post(configs.BASE_URL + '/instituteSingUp/add', institute) axios.post(configs.BASE_URL + '/instituteSingUp/add', institute)
.then(res =>{ .then(res =>{
console.log("Inside Then") //console.log("Inside Then")
window.location = '/beforeConfirm' window.location = '/beforeConfirm'
}) })
.catch(function (error) { .catch(function (error) {
......
...@@ -3,8 +3,46 @@ import React, {Component} from 'react'; ...@@ -3,8 +3,46 @@ import React, {Component} from 'react';
import {Link, Route} from "react-router-dom"; import {Link, Route} from "react-router-dom";
import {NavLink} from "react-router-dom"; import {NavLink} from "react-router-dom";
import ALResults from "./ALResults"; import ALResults from "./ALResults";
import TestTeacher from "../../Images/defaultimageicon.jpg";
export default class StudentDashboard extends Component { export default class StudentDashboard extends Component {
constructor(props) {
super(props);
this.state = {
user_email : '',
user_id : '',
user_name :'',
user_type :'',
isLogged : false
}
}
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,
user_id : user_id,
user_name : user_name,
user_type : user_type
})
}
render() { render() {
return ( return (
...@@ -68,22 +106,23 @@ export default class StudentDashboard extends Component { ...@@ -68,22 +106,23 @@ export default class StudentDashboard extends Component {
<div className="widget-content-left"> <div className="widget-content-left">
<div className="btn-group"> <div className="btn-group">
<div className="dropdown1"> <div className="dropdown1">
<img width="42" className="rounded-circle" src="DashboardAssets/images/user.jpg" alt=""/> <img src={TestTeacher} className="rounded-circle" style={{width:'50px', height:'50px', float:'left', margin:'0px'}}/>
<i className="fa fa-angle-down ml-2 opacity-8"/> <i className="fa fa-angle-down ml-2 opacity-8"/>
<div className="dropdown-content1 dropdown-menu-right"> <div className="dropdown-content1 dropdown-menu-right">
<button type="button" className="dropdown-item">User Account</button> <button type="button" className="dropdown-item" onClick={()=>{window.location.replace("/Home");}}>Back To Home</button>
<button type="button" className="dropdown-item" style={{color:"red"}}>Sign Out</button> <button type="button" className="dropdown-item" style={{color:"red"}} onClick={()=>{window.location.replace("/UserLogin");}}>Sign Out</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div className="widget-content-left ml-3 header-user-info"> <div className="widget-content-left ml-3 header-user-info">
<div className="widget-heading"> <div className="widget-heading">
Bandara Dissanayake {this.state.user_name}
</div> </div>
<div className="widget-subheading"> <div className="widget-subheading">
Tutor Student
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment