-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
299 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ | |
}, | ||
"rules": { | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
language: node_js | ||
node_js: | ||
- "12.9.1" | ||
- 12.9.1 | ||
cache: | ||
directories: | ||
- "node_modules" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,77 @@ | ||
import jwt from 'jsonwebtoken'; | ||
import { users, mentors, sessions } from '../models/data'; | ||
|
||
import { users, sessions } from '../models/data'; | ||
import Responses from '../helpers/response'; | ||
|
||
export default class Sessions { | ||
// user should request a session to mentor | ||
static requestSession(req, res) { | ||
const session = { | ||
sessionId: sessions.length + 1, | ||
mentorId: req.body.mentorId, | ||
menteeId: req.userInfo.user.id, | ||
menteeId: req.userInfo.id, | ||
questions: req.body.questions, | ||
menteeEmail: req.userInfo.user.email, | ||
menteeEmail: req.userInfo.email, | ||
status: 'pending', | ||
}; | ||
sessions.push(session); | ||
res.status(200).json({ | ||
message: 'session requested successfully!', | ||
data: session, | ||
return Responses.success(res, 200, 'session requested successfully!', session); | ||
// res.status(200).json({ | ||
// message: 'session requested successfully!', | ||
// data: session, | ||
|
||
}); | ||
// }); | ||
} | ||
|
||
// mentor accepting menotorship request session | ||
static acceptSession(req, res) { | ||
const session = sessions.find((s) => s.sessionId === parseInt(req.params.sessionId, 10)); | ||
|
||
// eslint-disable-next-line consistent-return | ||
static declineSession(req, res) { | ||
// eslint-disable-next-line no-shadow | ||
// eslint-disable-next-line max-len | ||
// eslint-disable-next-line no-shadow | ||
// eslint-disable-next-line max-len | ||
const session = sessions.find((session) => session.sessionId === parseInt(req.params.sessionId, 10)); | ||
console.log(session); | ||
if (!session) { | ||
return res.status(404).json({ | ||
|
||
status: 404, | ||
message: 'session with ID you type is not found', | ||
}); | ||
return Responses.error(res, 404, `session with ID ${req.params.sessionId} you passed is not found!`); | ||
} | ||
|
||
res.status(200).json({ | ||
status: 200, | ||
data: { | ||
sessionId: req.params.sessionId, | ||
mentorId: req.body.mentorId, | ||
menteeId: req.userInfo.user.id, | ||
questions: req.body.questions, | ||
menteeEmail: req.userInfo.user.email, | ||
status: 'Accepted', | ||
}, | ||
}); | ||
const rejected = { | ||
sessionId: req.params.sessionId, | ||
mentorId: req.body.mentorId, | ||
menteeId: req.userInfo.id, | ||
questions: req.body.questions, | ||
menteeEmail: req.userInfo.email, | ||
status: 'rejected', | ||
}; | ||
// eslint-disable-next-line no-console | ||
sessions.splice(1, 1, rejected); | ||
return Responses.success(res, 200, rejected); | ||
} | ||
|
||
// mentor should be able to decline session request mentorship | ||
static declineSession(req, res) { | ||
// mentor accepting menotorship request session | ||
// eslint-disable-next-line consistent-return | ||
static acceptSession(req, res) { | ||
const session = sessions.find((s) => s.sessionId === parseInt(req.params.sessionId, 10)); | ||
|
||
if (!session) { | ||
return res.status(404).json({ | ||
status: 404, | ||
message: `session with ID ${req.params.sessionId}you passed is not found!`, | ||
}); | ||
return Responses.error(res, 404, `session with ID ${req.params.sessionId} you type is not found`); | ||
} | ||
|
||
res.status(200).json({ | ||
status: 200, | ||
data: { | ||
sessionId: req.params.sessionId, | ||
mentorId: req.body.mentorId, | ||
menteeId: req.userInfo.user.id, | ||
questions: req.body.questions, | ||
menteeEmail: req.userInfo.user.email, | ||
status: 'rejected', | ||
}, | ||
}); | ||
const data = { | ||
sessionId: req.params.sessionId, | ||
mentorId: req.body.mentorId, | ||
menteeId: req.userInfo.id, | ||
questions: req.body.questions, | ||
menteeEmail: req.userInfo.email, | ||
status: 'Accepted', | ||
}; | ||
sessions.splice(0, 1, data); | ||
return Responses.success(res, 200, data); | ||
} | ||
|
||
// mentor should be able to decline session request mentorship | ||
// eslint-disable-next-line consistent-return | ||
|
||
|
||
// get sessions | ||
static getSession(req, res) { | ||
res.status(200).json({ | ||
sessions, | ||
}); | ||
return Responses.success(res, 200, sessions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.