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