diff --git a/src/App.css b/src/App.css
index f70efc5..5576ee1 100644
--- a/src/App.css
+++ b/src/App.css
@@ -8,7 +8,7 @@ body {
}
.App {
- overflow-x: hidden;
+ /* overflow-x: hidden; */
}
.App-logo {
diff --git a/src/App.js b/src/App.js
index 37de452..a9f209c 100644
--- a/src/App.js
+++ b/src/App.js
@@ -55,6 +55,7 @@ function App() {
const [shopIdentifier, setShopIdentifier] = useState("");
const [table, setTable] = useState([]);
const [totalItemsCount, setTotalItemsCount] = useState(0);
+ const [totalPrice, setTotalPrice] = useState(0);
const [deviceType, setDeviceType] = useState("");
const [shop, setShop] = useState([]);
const [shopItems, setShopItems] = useState([]);
@@ -78,8 +79,9 @@ function App() {
useEffect(() => {
const calculateTotalsFromLocalStorage = () => {
- const { totalCount } = calculateTotals(shopId);
+ const { totalCount, totalPrice } = calculateTotals(shopId);
setTotalItemsCount(totalCount);
+ setTotalPrice(totalPrice);
};
calculateTotalsFromLocalStorage();
@@ -563,14 +565,16 @@ function App() {
setModal={setModal} // Pass the function to open modal
loading={shop.name == null}
queue={queue}
+ cartItemsLength={totalItemsCount}
+ totalPrice={totalPrice}
/>
-
+ /> */}
>
}
/>
@@ -588,12 +592,12 @@ function App() {
removeConnectedGuestSides={rmConnectedGuestSides}
setModal={setModal} // Pass the function to open modal
/>
-
+ /> */}
>
}
/>
@@ -609,12 +613,12 @@ function App() {
totalItemsCount={totalItemsCount}
deviceType={deviceType}
/>
-
+ /> */}
>
}
/>
@@ -629,12 +633,12 @@ function App() {
socket={socket}
deviceType={deviceType}
/>
-
+ /> */}
>
}
/>
@@ -647,12 +651,12 @@ function App() {
sendParam={handleSetParam}
deviceType={deviceType}
/>
-
+ /> */}
>
}
/>
diff --git a/src/components/Item.js b/src/components/Item.js
index 94c3800..c38e60f 100644
--- a/src/components/Item.js
+++ b/src/components/Item.js
@@ -93,7 +93,7 @@ const Item = ({
{!forInvoice && (
-
+ //

-
+ //
)}
{forInvoice &&
@@ -141,7 +141,18 @@ const Item = ({
onChange={handleNameChange}
disabled={!blank && !isBeingEdit}
/> */}
-
{itemName}
+
+ {itemName}
+
{forInvoice && (
<>
x
@@ -175,16 +186,17 @@ const Item = ({
position: 'relative',
marginTop: '0.125rem',
display: 'flex',
- width: 'max-content',
+ width: '87px',
alignItems: 'center',
whiteSpace: 'nowrap',
borderRadius: '9999px',
backgroundImage: 'linear-gradient(to right, #e52535, #eb525e)',
- padding: '0.25rem 0.75rem',
+ padding: '0.25rem 0rem',
color: 'rgb(255, 255, 255)',
fontSize: '0.75rem',
fontWeight: 600,
- lineHeight: '1rem'
+ lineHeight: '1rem',
+ justifyContent: 'center'
}}>
Promo {(((initialPrice - promoPrice) / initialPrice) * 100).toFixed(0)}%
@@ -304,7 +316,13 @@ const Item = ({
{itemDescription && itemDescription != 'undefined' && itemDescription?.length &&
-
{itemDescription}
+
{itemDescription}
}
diff --git a/src/components/Item.module.css b/src/components/Item.module.css
index 669c163..3c6b497 100644
--- a/src/components/Item.module.css
+++ b/src/components/Item.module.css
@@ -46,16 +46,16 @@
.itemImage {
width: 100%;
height: 100%;
- border-radius: 10px;
- margin-right: 10px;
- object-fit: cover;
- position: relative;
}
.imageContainer {
position: relative;
width: 26vw;
height: 26vw;
+ border-radius: 10px;
+ margin-right: 10px;
+ object-fit: cover;
+ position: relative;
}
.overlay {
diff --git a/src/components/ItemLister.js b/src/components/ItemLister.js
index 1ec35c0..7c899cc 100644
--- a/src/components/ItemLister.js
+++ b/src/components/ItemLister.js
@@ -77,7 +77,8 @@ const ItemLister = ({
const updatedItems = items.map((item) => {
if (item.itemId === itemId) {
const newQty = item.qty + 1;
- updateItemQtyInCart(shopId, itemId, newQty);
+ const nowPrice = item.promoPrice > 0 ? item.promoPrice : item.price
+ updateItemQtyInCart(shopId, itemId, newQty, nowPrice);
if (forCart) refreshTotal();
@@ -93,7 +94,8 @@ const ItemLister = ({
.map((item) => {
if (item.itemId === itemId && item.qty > 0) {
const newQty = item.qty - 1;
- updateItemQtyInCart(shopId, itemId, newQty);
+ const nowPrice = item.promoPrice > 0 ? item.promoPrice : item.price
+ updateItemQtyInCart(shopId, itemId, newQty, nowPrice);
if (forCart) {
refreshTotal();
diff --git a/src/components/MusicPlayer.css b/src/components/MusicPlayer.css
index 8ad26cd..a2c16cf 100644
--- a/src/components/MusicPlayer.css
+++ b/src/components/MusicPlayer.css
@@ -25,7 +25,7 @@
/* filter: blur(1.5px);
-webkit-filter: blur(1.5px); */
/* border-radius: 13px 13px 0 0; */
- background-color: rgb(95 121 89);
+ background-color: #8ec781;
/* Rounded corners at the top */
text-align: right;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
diff --git a/src/helpers/cartHelpers.js b/src/helpers/cartHelpers.js
index 57d7255..3252e3f 100644
--- a/src/helpers/cartHelpers.js
+++ b/src/helpers/cartHelpers.js
@@ -18,7 +18,7 @@ export const getItemsByCafeId = (cafeId) => {
};
// Update quantity in localStorage for a specific cafeId and itemId
-export const updateItemQtyInCart = (cafeId, itemId, qty) => {
+export const updateItemQtyInCart = (cafeId, itemId, qty, price) => {
let cart = JSON.parse(getLocalStorage('cart')) || [];
const cafeIndex = cart.findIndex(cafeItem => cafeItem.cafeId === cafeId);
@@ -27,14 +27,15 @@ export const updateItemQtyInCart = (cafeId, itemId, qty) => {
if (itemIndex > -1) {
if (qty > 0) {
cart[cafeIndex].items[itemIndex].qty = qty; // Update qty if item exists
+ cart[cafeIndex].items[itemIndex].price = price; // Update qty if item exists
} else {
cart[cafeIndex].items.splice(itemIndex, 1); // Remove item if qty is 0
}
} else if (qty > 0) {
- cart[cafeIndex].items.push({ itemId, qty }); // Add new item
+ cart[cafeIndex].items.push({ itemId, qty, price }); // Add new item
}
} else if (qty > 0) {
- cart.push({ cafeId, items: [{ itemId, qty }] }); // Add new cafeId and item
+ cart.push({ cafeId, items: [{ itemId, qty, price }] }); // Add new cafeId and item
}
updateLocalStorage('cart', JSON.stringify(cart));
diff --git a/src/pages/CafePage.js b/src/pages/CafePage.js
index a3ea60b..214932e 100644
--- a/src/pages/CafePage.js
+++ b/src/pages/CafePage.js
@@ -22,6 +22,7 @@ import { ThreeDots } from "react-loader-spinner";
import { getLocalStorage, updateLocalStorage, removeLocalStorage } from "../helpers/localStorageHelpers";
import { unsubscribeUser } from "../helpers/subscribeHelpers.js";
import WelcomePage from "./WelcomePage.js";
+import { useNavigationHelpers } from "../helpers/navigationHelpers";
function CafePage({
shopId,
@@ -40,14 +41,22 @@ function CafePage({
removeConnectedGuestSides,
setModal,
loading,
- queue
+ queue,
+ cartItemsLength,
+ totalPrice
}) {
+
+
+ const {
+ goToCart
+ } = useNavigationHelpers(shopId, table.tableCode);
+
const location = useLocation();
const [searchParams] = useSearchParams();
const token = searchParams.get("token");
const { shopIdentifier, tableCode } = useParams();
sendParam({ shopIdentifier, tableCode });
-
+
const navigate = useNavigate();
const [screenMessage, setScreenMessage] = useState("");
@@ -140,10 +149,10 @@ function CafePage({
const moveItemTypeHandler = async (itemTypeId, direction, index) => {
const previousItems = [...shopItems];
-
+
// Update local state immediately
const newItems = [...shopItems];
-
+
let targetIndex;
if (direction === 'up' && index > 0) {
targetIndex = index - 1;
@@ -157,9 +166,9 @@ function CafePage({
[newItems[index], newItems[targetIndex]] = [newItems[targetIndex], newItems[index]];
newItems[index].order = targetIndex;
newItems[targetIndex].order = index;
-
+
setShopItems(newItems);
-
+
// Call the API to move the item type
try {
await moveItemType(itemTypeId, previousItems[targetIndex].itemTypeId, index, targetIndex);
@@ -170,7 +179,7 @@ function CafePage({
}
}
};
-
+
if (loading)
return (
@@ -235,54 +244,74 @@ function CafePage({
beingEditedType={beingEditedType}
setBeingEditedType={setBeingEditedType}
/>
-
{/*
*/}
- {shopItems
- .filter(
- (itemType) =>
- filterId == 0 || itemType.itemTypeId === filterId
- )
- .map((itemType, index) => (
-
moveItemTypeHandler(e,'up', index)}
- moveItemTypeDown={(e)=>moveItemTypeHandler(e, 'down', index)}
- isEditMode={isEditMode}
- beingEditedType={beingEditedType}
- setBeingEditedType={setBeingEditedType}
- raw={isEditMode || filterId == 0 ? false : true}
- handleCreateItem={(
- itemTypeID,
- name,
- price,
- selectedImage,
- description
- ) =>
- createItem(
- shopId,
+
+ {shopItems
+ .filter(
+ (itemType) =>
+ filterId == 0 || itemType.itemTypeId === filterId
+ )
+ .map((itemType, index) => (
+
moveItemTypeHandler(e, 'up', index)}
+ moveItemTypeDown={(e) => moveItemTypeHandler(e, 'down', index)}
+ isEditMode={isEditMode}
+ beingEditedType={beingEditedType}
+ setBeingEditedType={setBeingEditedType}
+ raw={isEditMode || filterId == 0 ? false : true}
+ handleCreateItem={(
+ itemTypeID,
name,
price,
selectedImage,
- itemTypeID,
description
- )
- }
- handleUpdateItem={(itemId, name, price, selectedImage, description, promoPrice) =>
- updateItem(itemId, name, price, selectedImage, description, promoPrice)
- }
- />
- ))}
+ ) =>
+ createItem(
+ shopId,
+ name,
+ price,
+ selectedImage,
+ itemTypeID,
+ description
+ )
+ }
+ handleUpdateItem={(itemId, name, price, selectedImage, description, promoPrice) =>
+ updateItem(itemId, name, price, selectedImage, description, promoPrice)
+ }
+ />
+ ))}
+ { }
+ {cartItemsLength > 0 &&
+
+
+
+
{cartItemsLength} item
+
+
+
+
+ }
+
+