Book Image

Full-Stack React Projects

By : Shama Hoque
Book Image

Full-Stack React Projects

By: Shama Hoque

Overview of this book

The benefits of using a full JavaScript stack for web development are undeniable, especially when robust and widely adopted technologies such as React, Node, and Express and are available. Combining the power of React with industry-tested, server-side technologies, such as Node, Express, and MongoDB, creates a diverse array of possibilities when developing real-world web applications. This book guides you through preparing the development environment for MERN stack-based web development, to creating a basic skeleton application and extending it to build four different web applications. These applications include a social media, an online marketplace, a media streaming, and a web-based game application with virtual reality features. While learning to set up the stack and developing a diverse range of applications with this book, you will grasp the inner workings of the MERN stack, extend its capabilities for complex features, and gain actionable knowledge of how to prepare MERN-based applications to meet the growing demands of real-world web applications.
Table of Contents (19 chapters)
Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
Index

Users as sellers


Any user that signs up on the MERN Marketplace can choose to become a seller by updating their profile:

In contrast to being a regular user, becoming sellers will allow users to create and manage their own shops where they can manage products:

To add this seller feature, we need to update the user model, the Edit Profile view, and add a MY SHOPS link to the menu that will only be visible to sellers.

Updating the user model

The user model will need a seller value that will be set to false by default to represent regular users, and can be set to true to represent users who are also sellers.

mern-marketplace/server/models/user.model.js:

seller: {
    type: Boolean,
    default: false
}

Note

The seller value must be sent to the client with the user details received on successful sign-in, so the view can be rendered accordingly to show information relevant to the seller.

Updating the Edit Profile view

A signed-in user will see a toggle in the Edit Profile view, to either activate or deactivate...