Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #300

Merged
merged 114 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
2ee3f51
update github workflow yaml file
olasunkanmi-SE Mar 21, 2023
3819c92
rename the frontend folder
olasunkanmi-SE Mar 22, 2023
930d471
create the checkout button
olasunkanmi-SE Mar 22, 2023
d271316
Merge branch 'release' into development
olasunkanmi-SE Mar 22, 2023
095f6f7
create dynamic route
olasunkanmi-SE Mar 23, 2023
4915dc1
update the routing definition and getmenubyId API call
olasunkanmi-SE Mar 24, 2023
fab228f
update the routing definition and getmenubyId API call
olasunkanmi-SE Mar 24, 2023
a465cd9
Merge branch 'release' into development
olasunkanmi-SE Mar 24, 2023
a1e1b04
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Mar 24, 2023
0856185
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Mar 24, 2023
98a0bcc
remove the styling for menu name
olasunkanmi-SE Mar 24, 2023
83b8773
optimize the components
olasunkanmi-SE Mar 24, 2023
7d810d5
conditionally render the checkout component
olasunkanmi-SE Mar 24, 2023
e788815
Merge branch 'release' into development
olasunkanmi-SE Mar 24, 2023
2d3d11b
remove code smell
olasunkanmi-SE Mar 24, 2023
2466e8d
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Mar 24, 2023
0e614cc
Merge branch 'release' into development
olasunkanmi-SE Mar 24, 2023
b074a16
Merge branch 'release' into development
olasunkanmi-SE Mar 24, 2023
3f62b73
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Mar 24, 2023
1efc8b3
update the menu item page and clean up the navigation
olasunkanmi-SE Mar 25, 2023
ce8a839
create the delete menu repo method, service and controller
olasunkanmi-SE Mar 26, 2023
48a45c4
create the delete menu API
olasunkanmi-SE Mar 26, 2023
45f4dc2
update food menu component to include item id
olasunkanmi-SE Mar 27, 2023
a72843a
update food menu component to include item id
olasunkanmi-SE Mar 27, 2023
630bacd
Merge branch 'release' into development
olasunkanmi-SE Mar 27, 2023
936d146
add the add menu item to cart functionality
olasunkanmi-SE Mar 28, 2023
40c5356
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Mar 28, 2023
82da626
implement add menu items to cart
olasunkanmi-SE Mar 28, 2023
9eb6866
fix build errors
olasunkanmi-SE Mar 28, 2023
20d151b
fix code smell
olasunkanmi-SE Mar 28, 2023
70940d2
create the item quantity button component
olasunkanmi-SE Mar 29, 2023
988de5b
Merge branch 'release' into development
olasunkanmi-SE Mar 29, 2023
140f9e8
update the menu list ui
olasunkanmi-SE Mar 30, 2023
246bab7
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Mar 30, 2023
30840d1
implement the add items to cart functionality
olasunkanmi-SE Apr 3, 2023
bf73e39
Merge branch 'release' into development
olasunkanmi-SE Apr 3, 2023
c4d2dad
fix code smell
olasunkanmi-SE Apr 3, 2023
18017e5
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Apr 3, 2023
df960d1
create the selected items summary
olasunkanmi-SE Apr 3, 2023
31a8ce0
update cart reducer
olasunkanmi-SE Apr 4, 2023
8f6f5f9
Merge branch 'release' into development
olasunkanmi-SE Apr 4, 2023
3970e77
update the add item to cart implementation
olasunkanmi-SE Apr 5, 2023
756fa20
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Apr 5, 2023
e6c5a3b
Merge branch 'release' into development
olasunkanmi-SE Apr 5, 2023
e0a7b57
create folder structure for componsnts
olasunkanmi-SE Apr 5, 2023
ae36614
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Apr 5, 2023
dc59f6b
resolve conflicts
olasunkanmi-SE Apr 5, 2023
bee779c
implement the remove from cart functionality
olasunkanmi-SE Apr 5, 2023
eaae18e
Merge branch 'release' into development
olasunkanmi-SE Apr 5, 2023
6f4723e
implement the add to cart functionality
olasunkanmi-SE Apr 7, 2023
2e9a00a
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Apr 7, 2023
5269980
Merge branch 'release' into development
olasunkanmi-SE Apr 7, 2023
bab7b83
rename add and remove from cart to add and remove menu from cart
olasunkanmi-SE Apr 8, 2023
89eb81a
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Apr 8, 2023
4e57807
Merge branch 'release' into development
olasunkanmi-SE Apr 8, 2023
fbe75f0
remove the menuid from foodmenu component
olasunkanmi-SE Apr 8, 2023
7c04f83
create the shopping component
olasunkanmi-SE Apr 8, 2023
8b52d91
implement display menu quantity, also display only menu items ata a time
olasunkanmi-SE Apr 10, 2023
a156180
Merge branch 'release' into development
olasunkanmi-SE Apr 10, 2023
f3790cc
prevent increase in total price if the menu quantity is 1
olasunkanmi-SE Apr 10, 2023
edbb276
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Apr 10, 2023
eedf3d5
fix issues with totalprice calculations
olasunkanmi-SE Apr 10, 2023
1d584a3
fix issues with menu items reduction
olasunkanmi-SE Apr 10, 2023
e0bb97e
fix the bug in shopping cart provider
olasunkanmi-SE Apr 14, 2023
7afd499
Merge branch 'release' into development
olasunkanmi-SE Apr 14, 2023
82af46d
remove menu price from global state
olasunkanmi-SE Apr 18, 2023
c56d5ac
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Apr 18, 2023
29322c2
fix bug in remove menu from cart
olasunkanmi-SE Apr 18, 2023
9c3f4b3
Merge branch 'release' into development
olasunkanmi-SE Apr 18, 2023
83a292d
fix error in menuItems calculations
olasunkanmi-SE Apr 18, 2023
1b86242
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Apr 18, 2023
e6c8fba
Merge branch 'release' into development
olasunkanmi-SE Apr 18, 2023
3fbfd34
update some names in the shoppingcart context
olasunkanmi-SE Apr 20, 2023
7349651
Merge branch 'release' into development
olasunkanmi-SE Apr 20, 2023
6240487
add the none button for food items
olasunkanmi-SE Apr 20, 2023
006073f
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Apr 20, 2023
aa1a5f2
update remove item from cart method to calculate total price correctly
olasunkanmi-SE Apr 20, 2023
be803c8
Merge branch 'release' into development
olasunkanmi-SE Apr 20, 2023
5417379
remove unused file
olasunkanmi-SE Apr 20, 2023
e5c4c7c
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Apr 20, 2023
2b15450
create the radio button
olasunkanmi-SE Apr 20, 2023
46b1489
Merge branch 'release' into development
olasunkanmi-SE Apr 20, 2023
d6e7f34
calculate order quantity
olasunkanmi-SE Apr 20, 2023
11baea1
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Apr 20, 2023
48d3e88
Merge branch 'release' into development
olasunkanmi-SE Apr 20, 2023
36d8063
remove quantity count from checkout
olasunkanmi-SE Apr 20, 2023
0b1bc8b
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Apr 20, 2023
32f135b
Calculate cart total
olasunkanmi-SE Apr 20, 2023
54d7a67
disable add to cart buttons on page load
olasunkanmi-SE Jun 4, 2023
6152014
Merge branch 'release' into development
olasunkanmi-SE Jun 4, 2023
3831455
add development branch to github workflow, in order to track and buil…
olasunkanmi-SE Jun 4, 2023
50695aa
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Jun 4, 2023
b727ece
fix code smells
olasunkanmi-SE Jun 4, 2023
5143ba5
enable the add to cart button on click none and addons
olasunkanmi-SE Jun 4, 2023
f8dd2df
Merge branch 'release' into development
olasunkanmi-SE Jun 4, 2023
7cc9ed6
Incrementing cart quantity without addons
olasunkanmi-SE Jun 4, 2023
f9d436c
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Jun 4, 2023
cb9619f
Merge branch 'release' into development
olasunkanmi-SE Jun 4, 2023
d09a551
Fix: Add to Cart without incrementing the cart quantity throws an error
olasunkanmi-SE Jun 5, 2023
8c0addb
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Jun 5, 2023
daaac86
Merge branch 'release' into development
olasunkanmi-SE Jun 5, 2023
a932f91
Create the summary modal and include error boundary in applocation
olasunkanmi-SE Jun 7, 2023
841a6c5
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Jun 7, 2023
0011871
Merge branch 'release' into development
olasunkanmi-SE Jun 7, 2023
91a8151
update error boundary url
olasunkanmi-SE Jun 7, 2023
3eaa0ad
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Jun 7, 2023
988fce5
add the edit and update button to the order summary page
olasunkanmi-SE Jun 8, 2023
d221d45
Merge branch 'release' into development
olasunkanmi-SE Jun 8, 2023
4fff988
add the call to action to clear cart
olasunkanmi-SE Jun 8, 2023
a3d1e7e
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Jun 8, 2023
71b7f24
Merge branch 'release' into development
olasunkanmi-SE Jun 8, 2023
1552d91
generate Ids for ordersummary
olasunkanmi-SE Jun 8, 2023
2fa6e2b
Merge branch 'development' of github.com:olasunkanmi-SE/restaurant in…
olasunkanmi-SE Jun 8, 2023
fff0941
generate ordersummary ids
olasunkanmi-SE Jun 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
"react-router-dom": "^6.8.0",
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"uuid": "^9.0.0",
"web-vitals": "^2.1.4",
"zod": "^3.21.4"
},
"devDependencies": {
"@types/lodash.get": "^4.4.7",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@types/uuid": "^9.0.1",
"@vitejs/plugin-react": "^3.1.0",
"typescript": "^4.9.3",
"vite": "^4.2.0"
Expand Down
93 changes: 62 additions & 31 deletions frontend/src/components/Cart/ShoppinCartDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ import { Button, Stack } from "react-bootstrap";
import { useShoppingCart } from "../../hooks/UseShoppingCart";
import { calculateTotalOrderAmount } from "../../utility/utils";
import { QtyButton } from "../MenuItems/addItemButton";
import { useNavigate } from "react-router-dom";
import { CallToAction } from "../Utilities/modal";

export const ShoppingCartDetails = () => {
const navigate = useNavigate();
const [isEdit, setIsEdit] = useState<boolean>(false);
const [itemQty, setItemQty] = useState<number>(1);
const { GetOrderSummary } = useShoppingCart();
const { GetOrderSummary, resetCart, closeCart } = useShoppingCart();
const [showModal, setShowModal] = useState(false);
const handleCloseModal = () => setShowModal(false);
const handleShowModal = () => setShowModal(true);
const orderSummary = GetOrderSummary();

const handleIncreaseQty = () => {
Expand All @@ -26,6 +32,17 @@ export const ShoppingCartDetails = () => {
setIsEdit(true);
};

const displayModal = () => {
handleShowModal();
};

const clearOrderSummary = () => {
handleCloseModal();
resetCart();
closeCart();
navigate("/");
};

return (
<div>
<div>
Expand All @@ -43,7 +60,7 @@ export const ShoppingCartDetails = () => {
) : (
<>
<span className="ms-auto">
<Button size="sm" variant="outline-success">
<Button onClick={displayModal} size="sm" variant="outline-success">
<small>CLEAR ALL</small>
</Button>
</span>
Expand Down Expand Up @@ -74,36 +91,42 @@ export const ShoppingCartDetails = () => {
</span>
</Stack>
<div style={{ marginTop: "-15px" }}>
{summary.menus[0].selectedItems
? summary.menus[0].selectedItems.map((addon, i) => (
<div key={i}>
<div>
<small
style={{
fontSize: "12.8px",
lineHeight: "19.2px",
}}
>
x{addon.quantity} {addon.name}
</small>
</div>
{summary.menus[0].selectedItems ? (
summary.menus[0].selectedItems.map((addon, i) => (
<div key={i}>
<div>
<small
style={{
fontSize: "12.8px",
lineHeight: "19.2px",
}}
>
x{addon.quantity} {addon.name}
</small>
</div>
))
: ""}
<Stack direction="horizontal" gap={3} style={{ marginLeft: "-6px", marginTop: "5px" }}>
<div>
<QtyButton sign={"decrement"} onClick={handleDecreaseQty} />
</div>
<div> {itemQty} </div>
<div>
<QtyButton sign={"increment"} onClick={handleIncreaseQty} />
</div>
<div>
<Button style={{ borderRadius: "30px" }} size="sm" variant="outline-success">
<small>EDIT</small>
</Button>
</div>
</Stack>
</div>
))
) : (
<></>
)}
{isEdit === true ? (
<Stack direction="horizontal" gap={3} style={{ marginLeft: "-6px", marginTop: "5px" }}>
<div>
<QtyButton sign={"decrement"} onClick={handleDecreaseQty} />
</div>
<div> {itemQty} </div>
<div>
<QtyButton sign={"increment"} onClick={handleIncreaseQty} />
</div>
<div>
<Button style={{ borderRadius: "30px" }} size="sm" variant="outline-success">
<small>EDIT</small>
</Button>
</div>
</Stack>
) : (
<></>
)}
<hr />
</div>
</div>
Expand All @@ -125,6 +148,14 @@ export const ShoppingCartDetails = () => {
PLACE ORDER RM{handleCalculateTotalOrder()}
</Button>
</div>
<CallToAction
handleAction={clearOrderSummary}
handleClose={handleCloseModal}
show={showModal}
header=""
body="Are you sure you want to clear the cart ?"
action="OK"
/>
</div>
);
};
32 changes: 32 additions & 0 deletions frontend/src/components/Utilities/modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Button from "react-bootstrap/Button";
import Modal from "react-bootstrap/Modal";

export type ModalProps = {
handleClose(): void;
show: boolean;
header: string;
body: string;
action: string;
handleAction: any;
};

export const CallToAction = ({ handleClose, show, header, body, action, handleAction }: ModalProps) => {
return (
<>
<Modal show={show} onHide={handleClose}>
<Modal.Header closeButton>
<Modal.Title>{header}</Modal.Title>
</Modal.Header>
<Modal.Body>{body}</Modal.Body>
<Modal.Footer>
<Button variant="inline-secondary" onClick={handleClose}>
Cancel
</Button>
<Button variant="success" onClick={handleAction}>
{action}
</Button>
</Modal.Footer>
</Modal>
</>
);
};
6 changes: 2 additions & 4 deletions frontend/src/contexts/shoppingCartContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { menuToMenuStateMapper, selectedItemToMenuMapper } from "../application/
import { ShoppingCart } from "../components/ShoppingCart";
import { CartActionsType, CartItem, OrderSummary, cartReducer, initialCartState, selectedItem } from "../reducers";
import { IMenuData } from "../models/menu.model";
import crypto from "crypto";
import { v4 as uuidv4 } from "uuid";

type shoppingCartProviderProps = {
children: React.ReactNode;
Expand Down Expand Up @@ -293,15 +293,13 @@ export const ShoppingCartProvider = ({ children }: shoppingCartProviderProps) =>
};

const addMenuToCart = (menu: IMenuData) => {
const id = crypto.randomBytes(16).toString("hex");

console.log(id);
if (!state.menus.length) {
state.menus = menuToMenuStateMapper(menu);
state.quantity = 1;
}
let { menus, quantity, orderSummary } = state;
const orderInfo: OrderSummary = {
id: uuidv4(),
menus,
quantity,
};
Expand Down
1 change: 1 addition & 0 deletions frontend/src/reducers/cartReducer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum CartActionsType {
}

export type OrderSummary = {
id: string;
menus: Partial<CartItem & { menuName?: string }>[];
quantity: number;
};
Expand Down