Client
- JavaScript
- Node.js
- Sequelize
- Custom HTML/CSS
Database
- Account Creation as Student or Instructor
- Ability to Create Lessons
- Ability to View Created, Available & Scheduled Lessons
- Deleting/Canceling a Lesson
- Mobile Responsive
- Changing User Settings
- #840032.
- #002642.
- #E59500.
- #E5DADA.
- #02040F.
Clone the project
https://github.com/BlakeLein/privateLessonScheduler
Go to the project directory
You must have previously installed: Node.js Nodemon Sequelize
cd privateLessonScheduler
Install dependencies
npm i
Start the server
cd controller
nodemon
Users fill out a form to sign up, the contents of the form get sent to our database to create a user.
router.post("/create-instructor-user", async (req, res) => {
const { first, last, email, password, instrument } = req.body;
try {
const salt = await bcrypt.genSalt(7);
const hashedPassword = await bcrypt.hash(password, salt);
const encryptedUser = {
firstName: first,
lastName: last,
email: email,
password: hashedPassword,
instrument: instrument,
createdAt: new Date(),
updatedAt: new Date(),
};
const createUser = await Instructors.create(encryptedUser);
res.json({
message: "Account Created",
});
res.status(200);
} catch (error) {
res.send(error.message);
}
});
When Users sign in thier credentials are checked in our database.
router.post("/instructor-sign-in", async (req, res) => {
const { user, pass } = req.body;
if (!req.body.user || !req.body.pass) {
res.status(400).json({
message: "Please enter username and password.",
});
}
try {
const instructorUser = await Instructors.findOne({
where: {
email: req.body.user,
},
});
if (!instructorUser) {
res.status(400).json({ message: "That username is incorrect." });
} else {
const userWeFound = instructorUser.dataValues;
const validPassword = await bcrypt.compare(pass, userWeFound.password);
if (!validPassword) {
res.status(400).json({
message: "That password is incorrect.",
});
} else {
req.session.user = instructorUser;
res.json({
message: "Login Success",
user: userWeFound,
});
res.status(200);
}
}
} catch (error) {
res.send(error);
}
});
From the dashboard users can view the lessons that they have scheduled.
router.post("/claimed-lessons", async (req, res) => {
const showStudentsWithLessons = await Students.findAll({
include: {
model: Lessons,
as: "lessons",
where: {
instructorId: req.session.user.id,
},
},
});
res.json(showStudentsWithLessons);
});
Each user has a specific dashboard with features unique to the type of user they are. Instructors have more features than students.
A Special Thanks to our Instructor Joe and TA Violet!