Skip to content

Commit

Permalink
Development (#457)
Browse files Browse the repository at this point in the history
* implement the menu search

* fix code smell

* calculate service charge

* update sonar project config

* update total order calculation

* add cart items to order

* move email header check to the backend

* remove quantity from order

* update selected items to include itemId

* make cartitem and selectedCart Items optional in parent models

* create the order service

* create order controller

* checkout and fix (#391)

* Test (#393)

* checkout and fix

* fix errors and remove env from application (#392)

Co-authored-by: Olasunkanmi Oyinlola

* Offshore dev (#394)

* fix errors and remove env from application

* fix build errors

Co-authored-by: Olasunkanmi Oyinlola <143487325+olasunkanmiraymond@users.noreply.github.com>
Co-authored-by: Olasunkanmi Oyinlola <olasunkanmioyinlola@Olasunkanmis-MacBook-Air.local>

* Test (#396)

* checkout and fix

* fix errors and remove env from application (#392)

Co-authored-by: Olasunkanmi Oyinlola

* Offshore dev (#394)

* fix errors and remove env from application

* fix build errors

---------

Co-authored-by: Olasunkanmi Oyinlola <olasunkanmioyinlola@Olasunkanmis-MacBook-Air.local>

* Offshore dev (#395)

* fix errors and remove env from application

* fix build errors

* remove .env file from backend

---------

Co-authored-by: Olasunkanmi Oyinlola

---------

Co-authored-by: Olasunkanmi Oyinlola <143487325+olasunkanmiraymond@users.noreply.github.com>
Co-authored-by: Olasunkanmi Oyinlola <olasunkanmioyinlola@Olasunkanmis-MacBook-Air.local>

* Test (#400)

* checkout and fix

* fix errors and remove env from application (#392)

Co-authored-by: Olasunkanmi Oyinlola

* Offshore dev (#394)

* fix errors and remove env from application

* fix build errors

---------

Co-authored-by: Olasunkanmi Oyinlola <olasunkanmioyinlola@Olasunkanmis-MacBook-Air.local>

* Offshore dev (#395)

* fix errors and remove env from application

* fix build errors

* remove .env file from backend

---------

Co-authored-by: Olasunkanmi Oyinlola

* Offshore dev (#399)

* fix errors and remove env from application

* fix build errors

* remove .env file from backend

* fake an error

* fake an error

* fake an error

---------

Co-authored-by: Olasunkanmi Oyinlola <olasunkanmioyinlola@Olasunkanmis-MacBook-Air.local>

---------

Co-authored-by: Olasunkanmi Oyinlola <143487325+olasunkanmiraymond@users.noreply.github.com>
Co-authored-by: Olasunkanmi Oyinlola <olasunkanmioyinlola@Olasunkanmis-MacBook-Air.local>

* Test (#403)

* checkout and fix

* fix errors and remove env from application (#392)

Co-authored-by: Olasunkanmi Oyinlola

* Offshore dev (#394)

* fix errors and remove env from application

* fix build errors

---------

Co-authored-by: Olasunkanmi Oyinlola <olasunkanmioyinlola@Olasunkanmis-MacBook-Air.local>

* Offshore dev (#395)

* fix errors and remove env from application

* fix build errors

* remove .env file from backend

---------

Co-authored-by: Olasunkanmi Oyinlola

* Offshore dev (#399)

* fix errors and remove env from application

* fix build errors

* remove .env file from backend

* fake an error

* fake an error

* fake an error

---------

Co-authored-by: Olasunkanmi Oyinlola <olasunkanmioyinlola@Olasunkanmis-MacBook-Air.local>

* Add additional methods to the Generic Repository (#402)

* Release (#386)

* Development (#235)

* update github workflow yaml file

* rename the frontend folder

* Development (#237)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* Development (#239)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* Development (#241)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Development (#242)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* Development (#244)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* Development (#246)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* Development (#248)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* Development (#250)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* Development (#252)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* Development (#254)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* Development (#256)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* Development (#257)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* Development (#259)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* Development (#261)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* Development (#262)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* Development (#264)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* Development (#266)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* merge conflicts

* Development (#267)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* Development (#269)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* Development (#271)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* fix error in menuItems calculations

* Development (#273)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* fix error in menuItems calculations

* update some names in the shoppingcart context

* Development (#274)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* fix error in menuItems calculations

* update some names in the shoppingcart context

* add the none button for food items

* update remove item from cart method to calculate total price correctly

* remove unused file

* Development (#276)

* Development (#277)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* fix error in menuItems calculations

* update some names in the shoppingcart context

* add the none button for food items

* update remove item from cart method to calculate total price correctly

* remove unused file

* create the radio button

* calculate order quantity

* Development (#279)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* fix error in menuItems calculations

* update some names in the shoppingcart context

* add the none button for food items

* update remove item from cart method to calculate total price correctly

* remove unused file

* create the radio button

* calculate order quantity

* remove quantity count from checkout

* Development (#287)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* fix error in menuItems calculations

* update some names in the shoppingcart context

* add the none button for food items

* update remove item from cart method to calculate total price correctly

* remove unused file

* create the radio button

* calculate order quantity

* remove quantity count from checkout

* Calculate cart total

* disable add to cart buttons on page load

* add development branch to github workflow, in order to track and build branches created from issues

* fix code smells

* Development (#290)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* fix error in menuItems calculations

* update some names in the shoppingcart context

* add the none button for food items

* update remove item from cart method to calculate total price correctly

* remove unused file

* create the radio button

* calculate order quantity

* remove quantity count from checkout

* Calculate cart total

* disable add to cart buttons on page load

* add development branch to github workflow, in order to track and build branches created from issues

* fix code smells

* enable the add to cart button on click none and addons

* Development (#292)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* fix error in menuItems calculations

* update some names in the shoppingcart context

* add the none button for food items

* update remove item from cart method to calculate total price correctly

* remove unused file

* create the radio button

* calculate order quantity

* remove quantity count from checkout

* Calculate cart total

* disable add to cart buttons on page load

* add development branch to github workflow, in order to track and build branches created from issues

* fix code smells

* enable the add to cart button on click none and addons

* Incrementing cart quantity without addons

* Development (#295)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* fix error in menuItems calculations

* update some names in the shoppingcart context

* add the none button for food items

* update remove item from cart method to calculate total price correctly

* remove unused file

* create the radio button

* calculate order quantity

* remove quantity count from checkout

* Calculate cart total

* disable add to cart buttons on page load

* add development branch to github workflow, in order to track and build branches created from issues

* fix code smells

* enable the add to cart button on click none and addons

* Incrementing cart quantity without addons

* Fix: Add to Cart without incrementing the cart quantity throws an error

* Development (#297)

* Development (#298)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* fix error in menuItems calculations

* update some names in the shoppingcart context

* add the none button for food items

* update remove item from cart method to calculate total price correctly

* remove unused file

* create the radio button

* calculate order quantity

* remove quantity count from checkout

* Calculate cart total

* disable add to cart buttons on page load

* add development branch to github workflow, in order to track and build branches created from issues

* fix code smells

* enable the add to cart button on click none and addons

* Incrementing cart quantity without addons

* Fix: Add to Cart without incrementing the cart quantity throws an error

* Create the summary modal and include error boundary in applocation

* update error boundary url

* add the edit and update button to the order summary page

* Development (#300)

* Development (#301)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* fix error in menuItems calculations

* update some names in the shoppingcart context

* add the none button for food items

* update remove item from cart method to calculate total price correctly

* remove unused file

* create the radio button

* calculate order quantity

* remove quantity count from checkout

* Calculate cart total

* disable add to cart buttons on page load

* add development branch to github workflow, in order to track and build branches created from issues

* fix code smells

* enable the add to cart button on click none and addons

* Incrementing cart quantity without addons

* Fix: Add to Cart without incrementing the cart quantity throws an error

* Create the summary modal and include error boundary in applocation

* update error boundary url

* add the edit and update button to the order summary page

* add the call to action to clear cart

* generate Ids for ordersummary

* generate ordersummary ids

* update the cart UI

* Development (#303)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* fix error in menuItems calculations

* update some names in the shoppingcart context

* add the none button for food items

* update remove item from cart method to calculate total price correctly

* remove unused file

* create the radio button

* calculate order quantity

* remove quantity count from checkout

* Calculate cart total

* disable add to cart buttons on page load

* add development branch to github workflow, in order to track and build branches created from issues

* fix code smells

* enable the add to cart button on click none and addons

* Incrementing cart quantity without addons

* Fix: Add to Cart without incrementing the cart quantity throws an error

* Create the summary modal and include error boundary in applocation

* update error boundary url

* add the edit and update button to the order summary page

* add the call to action to clear cart

* generate Ids for ordersummary

* generate ordersummary ids

* update the cart UI

* create the localstorage utility functions

* remove uuid package

* remove crypto declaration

* save state in local storage

* persist cart state in local storage

* Development (#306)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* fix error in menuItems calculations

* update some names in the shoppingcart context

* add the none button for food items

* update remove item from cart method to calculate total price correctly

* remove unused file

* create the radio button

* calculate order quantity

* remove quantity count from checkout

* Calculate cart total

* disable add to cart buttons on page load

* add development branch to github workflow, in order to track and build branches created from issues

* fix code smells

* enable the add to cart button on click none and addons

* Incrementing cart quantity without addons

* Fix: Add to Cart without incrementing the cart quantity throws an error

* Create the summary modal and include error boundary in applocation

* update error boundary url

* add the edit and update button to the order summary page

* add the call to action to clear cart

* generate Ids for ordersummary

* generate ordersummary ids

* update the cart UI

* create the localstorage utility functions

* remove uuid package

* remove crypto declaration

* save state in local storage

* persist cart state in local storage

* Display list of car items

* Development (#308)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* fix error in menuItems calculations

* update some names in the shoppingcart context

* add the none button for food items

* update remove item from cart method to calculate total price correctly

* remove unused file

* create the radio button

* calculate order quantity

* remove quantity count from checkout

* Calculate cart total

* disable add to cart buttons on page load

* add development branch to github workflow, in order to track and build branches created from issues

* fix code smells

* enable the add to cart button on click none and addons

* Incrementing cart quantity without addons

* Fix: Add to Cart without incrementing the cart quantity throws an error

* Create the summary modal and include error boundary in applocation

* update error boundary url

* add the edit and update button to the order summary page

* add the call to action to clear cart

* generate Ids for ordersummary

* generate ordersummary ids

* update the cart UI

* create the localstorage utility functions

* remove uuid package

* remove crypto declaration

* save state in local storage

* persist cart state in local storage

* Display list of car items

* implement remove item from cart

* Development (#310)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* fix error in menuItems calculations

* update some names in the shoppingcart context

* add the none button for food items

* update remove item from cart method to calculate total price correctly

* remove unused file

* create the radio button

* calculate order quantity

* remove quantity count from checkout

* Calculate cart total

* disable add to cart buttons on page load

* add development branch to github workflow, in order to track and build branches created from issues

* fix code smells

* enable the add to cart button on click none and addons

* Incrementing cart quantity without addons

* Fix: Add to Cart without incrementing the cart quantity throws an error

* Create the summary modal and include error boundary in applocation

* update error boundary url

* add the edit and update button to the order summary page

* add the call to action to clear cart

* generate Ids for ordersummary

* generate ordersummary ids

* update the cart UI

* create the localstorage utility functions

* remove uuid package

* remove crypto declaration

* save state in local storage

* persist cart state in local storage

* Display list of car items

* implement remove item from cart

* refactor shopping cart context component, move type definition to a new folder

* Development (#312)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* fix error in menuItems calculations

* update some names in the shoppingcart context

* add the none button for food items

* update remove item from cart method to calculate total price correctly

* remove unused file

* create the radio button

* calculate order quantity

* remove quantity count from checkout

* Calculate cart total

* disable add to cart buttons on page load

* add development branch to github workflow, in order to track and build branches created from issues

* fix code smells

* enable the add to cart button on click none and addons

* Incrementing cart quantity without addons

* Fix: Add to Cart without incrementing the cart quantity throws an error

* Create the summary modal and include error boundary in applocation

* update error boundary url

* add the edit and update button to the order summary page

* add the call to action to clear cart

* generate Ids for ordersummary

* generate ordersummary ids

* update the cart UI

* create the localstorage utility functions

* remove uuid package

* remove crypto declaration

* save state in local storage

* persist cart state in local storage

* Display list of car items

* implement remove item from cart

* refactor shopping cart context component, move type definition to a new folder

* make shopping cart details child to offcanvas

* Development (#315)

* update github workflow yaml file

* rename the frontend folder

* create the checkout button

* create dynamic route

* update the routing definition and getmenubyId API call

* Merge branch 'development' of github.com:olasunkanmi-SE/restaurant into development

* remove the styling for menu name

* optimize the components

* conditionally render the checkout component

* remove code smell

* Merge branch 'release' into development

* update the menu item page and clean up the navigation

* create the delete menu repo method, service and controller

* create the delete menu API

* update food menu component to include item id

* update food menu component to include item id

* add the add menu item to cart functionality

* implement add menu items to cart

* fix build errors

* fix code smell

* create the item quantity button component

* update the menu list ui

* implement the add items to cart functionality

* fix code smell

* create the selected items summary

* update cart reducer

* update the add item to cart implementation

* create folder structure for componsnts

* implement the remove from cart functionality

* implement the add to cart functionality

* rename add and remove from cart to add and remove menu from cart

* remove the menuid from foodmenu component

* create the shopping component

* implement display menu quantity, also display only menu items ata a time

* prevent increase in total price if the menu quantity is 1

* fix issues with totalprice calculations

* fix issues with menu items reduction

* fix the bug in shopping cart provider

* remove menu price from global state

* fix bug in remove menu from cart

* fix error in menuItems calculations

* update some names in the shoppingcart context

* add the none button for food items

* update remove item from cart method to calculate total price correctly

* remove unused file

* create the radio button

* calculate order quantity

* remove quantity count from checkout

* Calculate cart total

* disable add to cart buttons on page load

* add development branch to github workflow, in order to track and build branches created from issues

* fix code smells

* enable the add to cart button on click none and addons

* Incrementing cart quantity without addons

* Fix: Add to Cart without incrementing the cart quantity throws an error

* Create the summary modal and include error boundary in applocation

* update error boundary url

* add the edit and update button to the order summary page

* add the call to action to clear cart

* generate Ids for ordersummary

* generate ordersummary ids

* update the cart UI

* create the localstorage utility functions

* remove uuid package

* remove crypto declaration

* save state in local storage

* persist cart state in local storage

* Display list of car items

* implement remove item fr…
  • Loading branch information
3 people committed Dec 5, 2023
1 parent 80c4e75 commit 9ee7851
Show file tree
Hide file tree
Showing 12 changed files with 136 additions and 2 deletions.
14 changes: 14 additions & 0 deletions backend/src/application/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,17 @@ export enum MerchantStatus {
}

export const tokenExpiresIn = 3600000;

export enum Role {
ADMIN = 'ADMIN',
USER = 'USER',
GUEST = 'CLIENT',
}

export const RoleOrder: Record<Role, number> = {
[Role.GUEST]: 1,
[Role.USER]: 2,
[Role.ADMIN]: 3,
};

export const ROLE_KEY = 'role';
2 changes: 2 additions & 0 deletions backend/src/application/constants/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ export const TYPES = {
IOrderProcessingQueueRepository: Symbol('IOrderProcessingQueueRepository'),
IOrderProcessingQueueService: Symbol('IOrderProcessingQueueService'),
IMerchantRepository: Symbol('IMerchantRepository'),
IRoleService: Symbol('IRoleService'),
IAccessControlService: Symbol('IAccessControlService'),
};
1 change: 1 addition & 0 deletions backend/src/infrastructure/decorators/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './get-user-id.decorator';
export * from './get-user.decorator';
export * from './roles.decorators';
4 changes: 4 additions & 0 deletions backend/src/infrastructure/decorators/roles.decorators.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { SetMetadata } from '@nestjs/common';
import { ROLE_KEY, Role } from '../../application';

export const Roles = (...role: Role[]) => SetMetadata(ROLE_KEY, role);
35 changes: 35 additions & 0 deletions backend/src/infrastructure/guards/role-guard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { CanActivate, ExecutionContext, Inject, Injectable } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import { Observable } from 'rxjs';
import { ROLE_KEY, Role, TYPES } from 'src/application';
import { IAccessControlService } from 'src/shared/interfaces/access_control_service.interface';
import { Context, IContextService } from '../context';

@Injectable()
export class RoleGuard implements CanActivate {
private context: Context;
constructor(
private readonly reflector: Reflector,
@Inject(TYPES.IAccessControlService) private readonly accessControlService: IAccessControlService,
@Inject(TYPES.IContextService)
private readonly contextService: IContextService,
) {
this.context = this.contextService.getContext();
}
canActivate(context: ExecutionContext): boolean | Promise<boolean> | Observable<boolean> {
const requiredRoles = this.reflector.getAllAndOverride<Role[]>(ROLE_KEY, [
context.getHandler(),
context.getClass(),
]);
for (const role of requiredRoles) {
const isAuthorized = this.accessControlService.isAuthorized({
currentRole: this.context.role as Role,
requiredRole: role,
});
if (isAuthorized) {
return true;
}
}
return false;
}
}
6 changes: 5 additions & 1 deletion backend/src/merchant/merchant.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import { CreateMerchantDTO } from './dtos/create-merchant.dto';
import { OnBoardMerchantDTO } from './dtos/on-board-merchant.dto';
import { IMerchantService } from './interface/merchant-service.interface';
import { IMerchantResponseDTO } from './merchant-response.dto';
import { RoleGuard } from 'src/infrastructure/guards/role-guard';
import { Roles } from 'src/infrastructure';
import { Role } from 'src/application';

@Controller('merchants')
export class MerchantController {
Expand All @@ -29,7 +32,8 @@ export class MerchantController {
return this.merchantService.getMerchantById(merchantId);
}

@UseGuards(AccessAuthGuard)
@UseGuards(AccessAuthGuard, RoleGuard)
@Roles(Role.ADMIN)
@Get()
@HttpCode(HttpStatus.OK)
async getMerchants(): Promise<Result<IMerchantResponseDTO[]>> {
Expand Down
6 changes: 5 additions & 1 deletion backend/src/merchant/merchant.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { MiddlewareConsumer, Module, NestModule, RequestMethod } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
import { MongooseModule } from '@nestjs/mongoose';
import { AccessControlService } from 'src/shared/services/access_control.service';
import { RoleService } from 'src/shared/services/role_service';
import { MerchantRepository } from '../infrastructure/data_access/repositories/merchant.repository';
import { TYPES } from './../application/constants/types';
import { AuditMapper } from './../audit/audit.mapper';
import { AuthModule } from './../infrastructure/auth/auth.module';
import { AuthService } from './../infrastructure/auth/auth.service';
import { ContextService } from './../infrastructure/context/context.service';
import { MerchantRepository } from '../infrastructure/data_access/repositories/merchant.repository';
import {
MerchantDataModel,
MerchantSchema,
Expand All @@ -30,6 +32,8 @@ import { MerchantService } from './merchant.service';
{ provide: TYPES.IContextService, useClass: ContextService },
{ provide: TYPES.IValidateUser, useClass: ValidateUser },
{ provide: TYPES.IMapper, useClass: MerchantMapper },
{ provide: TYPES.IAccessControlService, useClass: AccessControlService },
{ provide: TYPES.IRoleService, useClass: RoleService },
],
controllers: [MerchantController],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { IIsAuthorizedProps } from './shared.interface';

export interface IAccessControlService {
isAuthorized({ currentRole, requiredRole }: IIsAuthorizedProps): boolean;
}
5 changes: 5 additions & 0 deletions backend/src/shared/interfaces/role_service.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Role } from '../../application';

export interface IRoleService {
sortRoles(roles: Role[]): Role[];
}
6 changes: 6 additions & 0 deletions backend/src/shared/interfaces/shared.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Role } from 'src/application';

export interface IIsAuthorizedProps {
currentRole: Role;
requiredRole: Role;
}
40 changes: 40 additions & 0 deletions backend/src/shared/services/access_control.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Inject, Injectable } from '@nestjs/common';
import { Role, TYPES } from 'src/application';
import { IAccessControlService } from '../interfaces/access_control_service.interface';
import { IRoleService } from '../interfaces/role_service.interface';
import { IIsAuthorizedProps } from '../interfaces/shared.interface';

@Injectable()
export class AccessControlService implements IAccessControlService {
private hierarchies: Map<string, number>[] = [];
private priority = 1;

constructor(@Inject(TYPES.IRoleService) private readonly roleService: IRoleService) {
this.mapRoleToPriority();
}

private mapRoleToPriority(): Map<string, number> {
const sortedRoles = this.roleService.sortRoles(Object.values(Role));
if (sortedRoles?.length) {
const rolesPriorityMap = sortedRoles.reduce((map, role) => {
map.set(role, this.priority);
this.priority++;
this.hierarchies.push(map);
return map;
}, new Map<string, number>());
return rolesPriorityMap;
}
}

public isAuthorized({ currentRole, requiredRole }: IIsAuthorizedProps): boolean {
let authorized = false;
for (const hierarchy of this.hierarchies) {
const priority = hierarchy.get(currentRole);
const requirePriority = hierarchy.get(requiredRole);
if (priority && requirePriority && priority >= requirePriority) {
authorized = true;
}
}
return authorized;
}
}
14 changes: 14 additions & 0 deletions backend/src/shared/services/role_service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Injectable } from '@nestjs/common';
import { Role, RoleOrder } from '../../application';
import { IRoleService } from '../interfaces/role_service.interface';

@Injectable()
export class RoleService implements IRoleService {
sortRoles(roles: Role[]): Role[] {
const validRoles = roles.filter((role) => role in RoleOrder);
if (validRoles?.length) {
validRoles.sort((a, b) => RoleOrder[a] - RoleOrder[b]);
}
return validRoles;
}
}

0 comments on commit 9ee7851

Please sign in to comment.