-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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> --------- Co-authored-by: Olasunkanmi Oyinlola <143487325+olasunkanmiraymond@users.noreply.github.com> Co-authored-by: Olasunkanmi Oyinlola <olasunkanmioyinlola@Olasunkanmis-MacBook-Air.local>
- Loading branch information
1 parent
03c3e22
commit e297ace
Showing
8 changed files
with
82 additions
and
16 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
backend/src/infrastructure/data_access/repositories/order.repository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { SelectedItem } from "./../reducers/cartReducer"; | ||
import { useShoppingCart } from "../hooks/UseShoppingCart"; | ||
|
||
export const createOrder = async (order: any) => {}; | ||
|
||
const getOrderSummary = () => { | ||
const { GetOrderSummary } = useShoppingCart(); | ||
return GetOrderSummary(); | ||
}; | ||
|
||
const reduceSelectedItems = () => { | ||
const orderSummary = getOrderSummary(); | ||
let selectedItems: SelectedItem[] = []; | ||
if (orderSummary?.length) { | ||
selectedItems = orderSummary.reduce((result: SelectedItem[], item) => { | ||
if (item.menus?.length) { | ||
item.menus.forEach((menu) => { | ||
if (menu.selectedItems) { | ||
menu.selectedItems.forEach((selectedItem) => { | ||
const itemId = selectedItem.id; | ||
const existingItem = result.find( | ||
(item: any) => item.id === itemId | ||
); | ||
if (existingItem) { | ||
existingItem.price += selectedItem.price; | ||
existingItem.quantity! += selectedItem.quantity!; | ||
} else { | ||
result.push({ ...selectedItem }); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
return result; | ||
}, []); | ||
} | ||
return selectedItems; | ||
}; | ||
|
||
// const getCartItems = () => { | ||
// const orderSummary = getOrderSummary(); | ||
// if (orderSummary?.length) { | ||
// const selectedItemsMap = new Map<string, SelectedItem>(); | ||
// reduceSelectedItems.forEach((item) => {}); | ||
// orderSummary.map((summary) => { | ||
// const cartItem = summary.menus; | ||
// }); | ||
// } | ||
// }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export interface IOrder { | ||
state: string; | ||
type: string; | ||
merchantId: string; | ||
total: number; | ||
cartItems: IcartItems[]; | ||
} | ||
|
||
export interface IcartItems { | ||
menuId: string; | ||
total: number; | ||
quantity: number; | ||
selectedItems: IselectedItems[]; | ||
} | ||
|
||
export interface IselectedItems { | ||
itemId: string; | ||
menuId: string; | ||
price: number; | ||
quantity: number; | ||
} |