Skip to content

Commit

Permalink
Release (#291)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
olasunkanmi-SE authored Jun 4, 2023
1 parent f3e6092 commit 54bba1c
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 24 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/Cart/CartItemsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const CartItemsList = ({ id }: MenuItem) => {
{itemSummaries.map((item) =>
item.qty > 0 ? (
<small style={{ marginLeft: "4px", fontSize: "11px" }} key={item.id}>
+{item.name.toLowerCase()} x {item.qty}
+ {item.name.toLowerCase()} x {item.qty}
</small>
) : (
""
Expand Down
21 changes: 18 additions & 3 deletions frontend/src/components/MenuItems/FoodItemList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,27 @@ import { useShoppingCart } from "../../hooks/UseShoppingCart";
import { storeItemProps } from "./StoreItem";
import { QtyButton } from "./addItemButton";

type foodItem = storeItemProps & { itemId: string; itemPrice: number };
type foodItem = storeItemProps & {
itemId: string;
itemPrice: number;
handleUnCheck: () => void;
enableAddToCartBtns: () => void;
};

export const FoodItemList = ({ name, itemId, itemPrice, id, basePrice }: Omit<foodItem, "items">) => {
export const FoodItemList = ({
name,
itemId,
itemPrice,
id,
basePrice,
handleUnCheck,
enableAddToCartBtns,
}: Omit<foodItem, "items" | "handleCheck" | "isChecked">) => {
const { addItemToCart, menus, removeItemFromCart } = useShoppingCart();
let itemQty: number = 0;
const handleAddItemToCart = () => {
enableAddToCartBtns();
handleUnCheck();
return addItemToCart({
id: itemId,
name,
Expand All @@ -26,7 +41,7 @@ export const FoodItemList = ({ name, itemId, itemPrice, id, basePrice }: Omit<fo
menuPrice: basePrice,
});
};
if (menus && menus.length) {
if (menus?.length) {
const selectedItems = menus.map((menu) => menu.selectedItems || []);
const flattenedSelectedItems = selectedItems.flat();
flattenedSelectedItems.forEach((item) => {
Expand Down
35 changes: 21 additions & 14 deletions frontend/src/components/MenuItems/StoreItem.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Card, Col, Row } from "react-bootstrap";
import { Item } from "../../reducers";
import { FoodItemList } from "./FoodItemList";
import { useState } from "react";
import { NoMenuItems } from "./NoMenuItems";

export type storeItemProps = {
Expand All @@ -12,19 +11,25 @@ export type storeItemProps = {
basePrice: number;
quantity: number;
items: Item[];
handleCheck: () => void;
isChecked: boolean;
handleUnCheck: () => void;
enableAddToCartBtns: () => void;
};

export const StoreItem = ({ id, name, description, imageUrl, basePrice, items, quantity }: storeItemProps) => {
const [isChecked, setIsChecked] = useState(false);
const handleCheck = () => {
setIsChecked(true);
};
const handleUnCheck = () => {
if (isChecked) {
setIsChecked(!isChecked);
}
};

export const StoreItem = ({
id,
name,
description,
imageUrl,
basePrice,
items,
quantity,
handleCheck,
isChecked,
handleUnCheck,
enableAddToCartBtns,
}: storeItemProps) => {
return (
<>
<Row>
Expand All @@ -51,12 +56,14 @@ export const StoreItem = ({ id, name, description, imageUrl, basePrice, items, q
</p>
</div>
<div>
<NoMenuItems handleCheck={handleCheck} isChecked={isChecked} />
<NoMenuItems isChecked={isChecked} handleCheck={handleCheck} />
</div>
<div onClick={handleUnCheck} className="pt-2 elBg">
<div className="pt-2 elBg">
{items.map((item) => (
<div key={item.id}>
<FoodItemList
enableAddToCartBtns={enableAddToCartBtns}
handleUnCheck={handleUnCheck}
quantity={quantity}
id={id}
itemId={item.id}
Expand Down
20 changes: 19 additions & 1 deletion frontend/src/contexts/shoppingCartContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export type shoppingCartProps = {
AddMoreMenu(id: string): number | undefined;
addMenuToCart(): void;
GetOrderSummary(): OrderSummary[];
resetCart(): void;
getMenus(): Partial<CartItem>[];
};

export const ShoppingCartProvider = ({ children }: shoppingCartProviderProps) => {
Expand All @@ -42,6 +44,10 @@ export const ShoppingCartProvider = ({ children }: shoppingCartProviderProps) =>
setIsOpen(false);
};

const getMenus = () => {
return state.menus;
};

const AddMoreMenu = (id: string): number | undefined => {
const menu = state.menus.find((menu) => menu.id === id);
if (menu?.selectedItems) {
Expand Down Expand Up @@ -242,6 +248,7 @@ export const ShoppingCartProvider = ({ children }: shoppingCartProviderProps) =>
}
}
}
console.log(state);
dispatch({
type: CartActionsType.ADD_ITEM_TO_CART,
});
Expand All @@ -259,7 +266,6 @@ export const ShoppingCartProvider = ({ children }: shoppingCartProviderProps) =>
};

const addMenuToCart = () => {
console.log(state);
let { menus, quantity, orderSummary } = state;
let stateQty = 0;
const orderInfo: OrderSummary = {
Expand All @@ -283,6 +289,16 @@ export const ShoppingCartProvider = ({ children }: shoppingCartProviderProps) =>
return state.orderSummary;
};

const resetCart = () => {
state.totalPrice = 0;
state.quantity = 0;
state.menus = [];
state.orderSummary = [];
dispatch({
type: CartActionsType.RESET_CART,
});
};

const value: shoppingCartProps = {
totalPrice: state.totalPrice,
menus: state.menus,
Expand All @@ -299,6 +315,8 @@ export const ShoppingCartProvider = ({ children }: shoppingCartProviderProps) =>
AddMoreMenu,
addMenuToCart,
GetOrderSummary,
resetCart,
getMenus,
};
return value;
}, [state]);
Expand Down
34 changes: 30 additions & 4 deletions frontend/src/pages/FoodMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { getMenuById } from "../apis";
import { useShoppingCart } from "../hooks/UseShoppingCart";
import { IItem } from "../models/item.model";
import { Item } from "../reducers";
import { CartItemsList } from "../components/Cart/CartItemsList";
import { StoreItem } from "../components/MenuItems/StoreItem";
import { AddMenuToCartButton } from "../components/Cart/AddMenuToCart";
import { useEffect, useState } from "react";
import { CartItemsList } from "../components/Cart";

const mapItems = (items: IItem[]): Item[] => {
const stateItem = items?.map((item) => {
Expand All @@ -22,7 +22,8 @@ const mapItems = (items: IItem[]): Item[] => {
};

export const FoodMenu = () => {
const { increaseMenuQuantity, quantity, totalPrice, removeMenuFromCart, getMenuQuantity } = useShoppingCart();
const { increaseMenuQuantity, quantity, totalPrice, removeMenuFromCart, getMenuQuantity, resetCart } =
useShoppingCart();
const [disableAddToCartBtns, setDisableAddToCartBtns] = useState<boolean>(false);

useEffect(() => {
Expand All @@ -32,19 +33,45 @@ export const FoodMenu = () => {
};
}, []);

const [isChecked, setIsChecked] = useState(false);

const handleCheck = () => {
setIsChecked(true);
setDisableAddToCartBtns(false);
resetCart();
};

const handleSetDisableAddToCartBtns = () => {
setDisableAddToCartBtns(false);
};

const handleUnCheck = () => {
if (isChecked) {
setIsChecked(!isChecked);
}
};

const { id } = useParams();
let response;
if (id) {
const { isLoading, data: menu } = getMenuById(id);
const items = mapItems(menu?.data?.items!);
if (isLoading) {
response = <p>...Loading</p>;
return (
<>
<p>...Loading</p>
</>
);
} else {
if (menu) {
const { name, description, imageUrl, basePrice } = menu.data;
return (
<div>
<StoreItem
enableAddToCartBtns={handleSetDisableAddToCartBtns}
handleUnCheck={handleUnCheck}
isChecked={isChecked}
handleCheck={handleCheck}
quantity={quantity}
items={items}
name={name}
Expand Down Expand Up @@ -74,6 +101,5 @@ export const FoodMenu = () => {
}
}
}

return <>{response}</>;
};
5 changes: 5 additions & 0 deletions frontend/src/reducers/cartReducer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export enum CartActionsType {
GET_MENU_PRICE = "GET_MENU_PRICE",
INCREASE_MENU_QUANTITY = "INCREASE_MENU_QUANTITY",
GET_ORDER_SUMMARY = "GET_ORDER_SUMMARY",
RESET_CART = "RESET_CART",
}

export type OrderSummary = {
Expand Down Expand Up @@ -95,6 +96,10 @@ export const cartReducer = (state = initialCartState, action: CartAction): cartS
return {
...state,
};
case CartActionsType.RESET_CART:
return {
...state,
};
default:
throw new Error(`No case for type ${type} found in shopReducer.`);
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utility/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ export const calculateTotalOrderAmount = (): number => {
const orderSummary = GetOrderSummary();
const total = orderSummary.reduce((acc, order) => acc + order.menus[0].menuTotalPrice!, 0);
return total > 0 ? total : 0;
};
};

0 comments on commit 54bba1c

Please sign in to comment.