Express and Sequelize (MySQL)
- Make two tables
usersandshopsvia migrations in the database. userstable must containname,email,password(must be hashed),role(ENUM type havingUser,Adminvalues),createdAtandupdatedAtfields.- While
shopstable must containname,description,fk_user_id(foreign key ofuserstable),address,createdAt, andupdatedAtfields. - There should be one to many relationship between
usersandshops.i.e. one user can have multiple shops. - You have to make three APIs.
- First, you need to create login endpoint. The route will be
POST: api/users/login, which will return jwt token and the user data the provided credentials are correct. - Second, create shop API by creating
POST: api/users/:userId/shopsroute. Make sure to add middleware to authenticate the user via token. - Third, Only Admin can get all users with their shops included by creating
GET: api/usersroute that would return all users in theuserstable. - Use
async/await, not promises and thenables.
React and Redux
- Integrate the login API mentioned above and redirect the user to an admin dashboard (any theme of your choice) if the credentials are correct. Apply all the frontend validations on input fields.
- On the left sidebar, there would be two options,
HomeandShops. - In Home Screen, Show a greeting message with the name of the user included.
- In Shops Screen, Show all shops of the user in cards (Third API Integration) and on top right a button of
Create new Shopwould redirect the user to a form to create a new shop (Second API Integration).
Good Luck!