Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #49

Merged
merged 28 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
812c0b1
building meetings routes
MAES-Pyramids Sep 10, 2023
81239af
Adding mentorRequest flow 1.0
MOHAMMED1MEDHAT Sep 10, 2023
3eab2c4
An EndPoint called set-working-hours is created to allow mentors to s…
MAES-Pyramids Sep 10, 2023
373b64f
get my meetings endpoint is created to return just the schedules meet…
MAES-Pyramids Sep 10, 2023
b292254
Merge pull request #40 from Skill-Sync/SS-1.3-Medhat
MOHAMMED1MEDHAT Sep 10, 2023
53004a5
Adding Most Relevant Mentors Route 1.0
MOHAMMED1MEDHAT Sep 10, 2023
29d90ec
Adding Most Relevant Mentors Route 1.1
MOHAMMED1MEDHAT Sep 10, 2023
9be5f4d
adding meeting standardization and create two endpoints one to get m…
MAES-Pyramids Sep 10, 2023
2a3f719
two end point has been created one to sk for session and other for me…
MAES-Pyramids Sep 10, 2023
4cc8cbe
Merge branch 'SS-1.3' into SS-1.3-Abo-El-Seoud
MAES-Pyramids Sep 10, 2023
6d44ef6
Merge pull request #41 from Skill-Sync/SS-1.3-Abo-El-Seoud
MOHAMMED1MEDHAT Sep 10, 2023
9e21401
Merge branch 'SS-1.3' into SS-1.3-Medhat
MOHAMMED1MEDHAT Sep 10, 2023
de1c707
Merge pull request #42 from Skill-Sync/SS-1.3-Medhat
MAES-Pyramids Sep 10, 2023
4fb7ba7
Merge pull request #43 from Skill-Sync/SS-1.3
MAES-Pyramids Sep 10, 2023
498820e
Resolving mentor issue 1.0
MOHAMMED1MEDHAT Sep 10, 2023
618a926
edit standardization 1.5
MAES-Pyramids Sep 10, 2023
bd50dfe
Merge pull request #44 from Skill-Sync/SS-1.3-Medhat
MOHAMMED1MEDHAT Sep 10, 2023
ac0ec92
Merge pull request #45 from Skill-Sync/SS-1.3-Medhat
MOHAMMED1MEDHAT Sep 10, 2023
5a1506a
add skill name to mentor meetings object that appears to user
MAES-Pyramids Sep 10, 2023
a77d391
Merge branch 'SS-1.3' into SS-1.3-Abo-El-Seoud
MOHAMMED1MEDHAT Sep 10, 2023
8cf5053
Merge pull request #46 from Skill-Sync/SS-1.3-Abo-El-Seoud
MOHAMMED1MEDHAT Sep 10, 2023
0131ff9
bug fixed
MAES-Pyramids Sep 10, 2023
88fe604
Resolving mentor issue 1.4
MOHAMMED1MEDHAT Sep 10, 2023
953cdc1
Merge pull request #47 from Skill-Sync/SS-1.3
MOHAMMED1MEDHAT Sep 10, 2023
c06091e
remove experience attribute from mentor
MAES-Pyramids Sep 10, 2023
96f11ca
populate the skill in relavent mentors endpoint
MAES-Pyramids Sep 10, 2023
c47650a
remove rejected meetings from mentors endpoint to get mymeeting
MAES-Pyramids Sep 10, 2023
13139fd
Merge pull request #48 from Skill-Sync/SS-1.3
MAES-Pyramids Sep 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions public/dev-data/.import-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ const Review = require('../../src/models/review.model');
dotenv.config({ path: path.join(__dirname, '..', '..', 'config.env') });
//--------------------DB-------------------//
const DB = process.env.DATABASE_Connection.replace(
'<password>',
process.env.DATABASE_Password
'<password>',
process.env.DATABASE_Password
);

mongoose
.connect(DB, {
useNewUrlParser: true,
useUnifiedTopology: true
})
.then(console.log('DB connection successful!'));
.connect(DB, {
useNewUrlParser: true,
useUnifiedTopology: true
})
.then(console.log('DB connection successful!'));
//------------------Read_File----------------//
const users = JSON.parse(fs.readFileSync(`${__dirname}/users.json`, 'utf-8'));
// const skills = JSON.parse(fs.readFileSync(`${__dirname}/skills.json`, 'utf-8'));

const mentors = JSON.parse(
fs.readFileSync(`${__dirname}/mentors.json`, 'utf-8')
fs.readFileSync(`${__dirname}/mentors.json`, 'utf-8')
);
// const courses = JSON.parse(
// fs.readFileSync(`${__dirname}/courses.json`, 'utf-8')
Expand All @@ -37,35 +37,35 @@ const mentors = JSON.parse(
// );
//--------------------CRUD------------------//
async function importData() {
try {
// await skill.create(skills);
// await Course.create(courses);
// await Review.create(reviews);
await User.create(users, { validateBeforeSave: false });
await Mentor.create(mentors, { validateBeforeSave: false });
console.log('Data successfully loaded!');
} catch (err) {
console.log(err);
}
process.exit();
try {
// await skill.create(skills);
// await Course.create(courses);
// await Review.create(reviews);
await User.create(users, { validateBeforeSave: false });
await Mentor.create(mentors, { validateBeforeSave: false });
console.log('Data successfully loaded!');
} catch (err) {
console.log(err);
}
process.exit();
}

async function deleteData() {
try {
await User.deleteMany();
await skill.deleteMany();
await Mentor.deleteMany();
await Course.deleteMany();
await Review.deleteMany();
console.log('Data successfully deleted!');
} catch (err) {
console.log(err);
}
process.exit();
try {
await User.deleteMany();
await skill.deleteMany();
await Mentor.deleteMany();
await Course.deleteMany();
await Review.deleteMany();
console.log('Data successfully deleted!');
} catch (err) {
console.log(err);
}
process.exit();
}
//--------------Run_Commands----------------//
if (process.argv[2] === '--import') {
importData();
importData();
} else if (process.argv[2] === '--delete') {
deleteData();
deleteData();
}
99 changes: 36 additions & 63 deletions public/dev-data/mentors.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,38 @@
[
{
"name": "Mentor 1",
"email": "[email protected]",
"pass": "password123",
"passConfirm": "password123",
"identityCard": "12345",
"photo": "mentor1.jpg",
"about": "About Mentor 1",
"experience": [
{
"title": "Experience 1",
"description": "Description 1"
},
{
"title": "Experience 2",
"description": "Description 2"
}
],
"courses": [],
"onboarding_completed": false
},
{
"name": "Mentor 2",
"email": "[email protected]",
"pass": "password456",
"passConfirm": "password456",
"identityCard": "54321",
"photo": "mentor2.jpg",
"about": "About Mentor 2",
"experience": [
{
"title": "Experience 3",
"description": "Description 3"
},
{
"title": "Experience 4",
"description": "Description 4"
}
],
"courses": [],
"onboarding_completed": false
},
{
"name": "Mentor 3",
"email": "[email protected]",
"pass": "password789",
"passConfirm": "password789",
"identityCard": "98765",
"photo": "mentor3.jpg",
"about": "About Mentor 3",
"experience": [
{
"title": "Experience 5",
"description": "Description 5"
},
{
"title": "Experience 6",
"description": "Description 6"
}
],
"courses": [],
"onboarding_completed": false
}
{
"name": "Mentor 1",
"email": "[email protected]",
"pass": "password123",
"passConfirm": "password123",
"identityCard": "12345",
"photo": "mentor1.jpg",
"skill": "64fcb555d14e59693748102e",
"about": "About Mentor 1",
"courses": [],
"onboarding_completed": false
},
{
"name": "Mentor 2",
"email": "[email protected]",
"pass": "password456",
"passConfirm": "password456",
"identityCard": "54321",
"photo": "mentor2.jpg",
"skill": "64fcc1c431010b05d9634812",
"about": "About Mentor 2",
"courses": [],
"onboarding_completed": false
},
{
"name": "Mentor 3",
"email": "[email protected]",
"pass": "password789",
"passConfirm": "password789",
"identityCard": "98765",
"photo": "mentor3.jpg",
"skill": "64fcb555d14e59693748102e",
"about": "About Mentor 3",
"courses": [],
"onboarding_completed": false
}
]
38 changes: 34 additions & 4 deletions src/controllers/auth.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,19 @@ exports.signup = catchAsyncError(async (req, res, next) => {
//TODO:only the new users and the users with non active accounts can signup
//TODO:what if the 10m are gone and the user didn't confirm his email -> if login without confirming email -> send email again

const newUser = await (req.body.type.toLowerCase() === 'mentor'
? Mentor
: User
).create(signUpData);
let newUser;

if (req.body.type.toLowerCase() === 'mentor') {
newUser = await Mentor.findOne({ email: signUpData.email });
if (!newUser) {
return next(new AppError('No mentor found with that email', 404));
}
newUser.pass = signUpData.pass;
newUser.passConfirm = signUpData.passConfirm;
await newUser.save({ validateBeforeSave: false });
} else {
newUser = await User.create(signUpData);
}

//send Activation Mail to User

Expand All @@ -95,6 +104,27 @@ exports.signup = catchAsyncError(async (req, res, next) => {
});
});

exports.createMentorRequest = catchAsyncError(async (req, res, next) => {
let mentorRequestData = filterObj(
req.body,
'name',
'email',
'phone',
'skill',
'requestLetter'
);

mentorRequestData.pass = '12345678';
mentorRequestData.passConfirm = '12345678';

const newMentorRequest = await Mentor.create(mentorRequestData);

res.status(200).json({
status: 'success',
data: newMentorRequest
});
});

exports.confirmEmail = catchAsyncError(async (req, res, next) => {
const { token } = req.params;

Expand Down
87 changes: 80 additions & 7 deletions src/controllers/meeting.controller.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,85 @@
const Meeting = require('../models/meeting.model');
const AppError = require('../utils/appErrorsClass');
const factory = require('./controllerUtils/handlerFactory');
const catchAsyncError = require('../utils/catchAsyncErrors');
const {
standMentorsMeeting,
standUsersMeeting
} = require('../utils/ApiFeatures');
// ------------- User Operations ------------//
exports.getMyMeetings = catchAsyncError(async (req, res, next) => {});
exports.createMeeting = catchAsyncError(async (req, res, next) => {});
exports.updateMeeting = catchAsyncError(async (req, res, next) => {});
exports.getMyMeetings = catchAsyncError(async (req, res, next) => {
const userId = res.locals.userId;

const meetingsQuery =
res.locals.userType === 'mentor'
? { mentor: userId, status: { $nin: ['not-selected', 'rejected'] } }
: { user: userId };
const populateOptions =
res.locals.userType === 'mentor'
? { path: 'user' }
: {
path: 'mentor',
populate: {
path: 'skill',
select: 'name'
}
};

const meetings = await Meeting.find(meetingsQuery).populate(populateOptions);

const selectedMeetings = meetings.map(meeting => {
if (res.locals.userType === 'mentor') {
return standMentorsMeeting(meeting);
} else {
return standUsersMeeting(meeting);
}
});

res.status(res.locals.statusCode || 200).json({
status: 'success',
results: selectedMeetings.length,
data: selectedMeetings
});
});

exports.updateMeeting = catchAsyncError(async (req, res, next) => {
const status = req.body.status == 'accepted' ? 'accepted' : 'rejected';
const meeting = await Meeting.findOneAndUpdate(
{ _id: req.params.id, status: 'pending' },
{ status },
{ new: true }
);
if (!meeting) return next(new AppError('No meeting found with that ID', 404));

res.status(res.locals.statusCode || 200).json({
status: 'success',
data: meeting
});
});

exports.createMeeting = catchAsyncError(async (req, res, next) => {
const userId = res.locals.userId;
const meeting = await Meeting.findByIdAndUpdate(req.params.id, {
user: userId,
status: 'pending'
});

if (!meeting) return next(new AppError('No meeting found with that ID', 404));

res.status(res.locals.statusCode || 201).json({
status: 'success',
data: meeting
});
});
// ---------- Basic CRUD Operations ----------//
exports.getMeeting = factory.getOne(Meeting);
exports.getAllMeetings = factory.getAll(Meeting);
exports.deleteMeeting = factory.deleteOne(Meeting);
exports.getMeeting = catchAsyncError(async (req, res, next) => {
const meeting = await Meeting.find({
mentor: req.params.id
});
if (!meeting) return next(new AppError('No meeting found with that ID', 404));

res.status(res.locals.statusCode || 200).json({
status: 'success',
length: meeting.length,
data: meeting
});
});
Loading