Skip to content

BlakeLein/privateLessonScheduler

Repository files navigation

logo

Welcome to Musicaly: A Private Lesson App


Table of Contents

About the Project

Tech Stack

Client
Database

Features

  • 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

Color Reference & Styles

Coolors

  • #840032.
  • #002642.
  • #E59500.
  • #E5DADA.
  • #02040F.

Environment Variables

Getting Started

Run Locally

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

Usage

Users fill out a form to sign up, the contents of the form get sent to our database to create a user.

Sign Up Page mobiledash
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.

Sign-in
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.

Dashboard
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.

Lesson Dashboard (Instructor Point of View)
Lesson Dashbopard (Student Point of View)

Contributing

Acknowledgements

A Special Thanks to our Instructor Joe and TA Violet!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published