Express and Sequelize (MySQL)
- Make two tables
users
andshops
via migrations in the database. users
table must containname
,email
,password
(must be hashed),role
(ENUM type havingUser
,Admin
values),createdAt
andupdatedAt
fields.- While
shops
table must containname
,description
,fk_user_id
(foreign key ofusers
table),address
,createdAt
, andupdatedAt
fields. - There should be one to many relationship between
users
andshops
.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/shops
route. 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/users
route that would return all users in theusers
table. - 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,
Home
andShops
. - 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 Shop
would redirect the user to a form to create a new shop (Second API Integration).
Good Luck!