diff --git a/src/assets/locals/en.json b/src/assets/locals/en.json index 554d29e..a3dffc9 100644 --- a/src/assets/locals/en.json +++ b/src/assets/locals/en.json @@ -180,6 +180,7 @@ }, "cart": { "leaveANoteHere": "Leave a note here..", + "changeTable": "Change Table", "title": "Cart", "emptyCart": "Cart is empty", "emptyCartMessage": "Looks like you haven't added any items to your cart yet. Start exploring our menu to find delicious meals!", diff --git a/src/features/order/orderSlice.ts b/src/features/order/orderSlice.ts index 02e5d35..58f9e2b 100644 --- a/src/features/order/orderSlice.ts +++ b/src/features/order/orderSlice.ts @@ -55,7 +55,7 @@ interface CartState { giftDetails: GiftDetailsType | null; coupon: string; tip: string; - tables: string[]; + table: string; estimateTime: Date; estimateTimeDate: Date; estimateTimeTime: string; @@ -152,7 +152,7 @@ const initialState: CartState = { giftDetails: getFromLocalStorage(CART_STORAGE_KEYS.GIFT_DETAILS, null), coupon: getFromLocalStorage(CART_STORAGE_KEYS.COUPON, ""), tip: getFromLocalStorage(CART_STORAGE_KEYS.TIP, ""), - tables: getFromLocalStorage(CART_STORAGE_KEYS.TABLES, []), + table: getFromLocalStorage(CART_STORAGE_KEYS.TABLES, ""), estimateTime: new Date( getFromLocalStorage( CART_STORAGE_KEYS.ESTIMATE_TIME, @@ -198,7 +198,7 @@ const initialState: CartState = { pickupDate: getFromLocalStorage(CART_STORAGE_KEYS.PICKUP_DATE, ""), pickupTime: getFromLocalStorage(CART_STORAGE_KEYS.PICKUP_TIME, ""), pickupType: getFromLocalStorage(CART_STORAGE_KEYS.PICKUP_TYPE, ""), - estimateWay: getFromLocalStorage(CART_STORAGE_KEYS.ESTIMATE_WAY, "now"), + estimateWay: getFromLocalStorage(CART_STORAGE_KEYS.ESTIMATE_WAY, ""), order: getFromLocalStorage(CART_STORAGE_KEYS.ORDER, null), splitBillAmount: 0, customerName: "", @@ -352,7 +352,7 @@ const orderSlice = createSlice({ state.phone = ""; state.coupon = ""; state.tip = ""; - state.tables = []; + state.table = ""; state.location = null; state.roomDetails = null; state.officeDetails = null; @@ -410,19 +410,19 @@ const orderSlice = createSlice({ localStorage.setItem(CART_STORAGE_KEYS.TIP, JSON.stringify(state.tip)); } }, - updateTables(state, action: PayloadAction) { - state.tables = action.payload; + updateTables(state, action: PayloadAction) { + state.table = action.payload; // Sync to localStorage if (typeof window !== "undefined") { localStorage.setItem( CART_STORAGE_KEYS.TABLES, - JSON.stringify(state.tables), + JSON.stringify(state.table), ); } }, removeTable(state) { - state.tables = []; + state.table = ""; // Sync to localStorage if (typeof window !== "undefined") { @@ -681,7 +681,10 @@ const orderSlice = createSlice({ updateEstimateWay(state, action: PayloadAction) { state.estimateWay = action.payload; if (typeof window !== "undefined") { - localStorage.setItem(CART_STORAGE_KEYS.ESTIMATE_WAY, JSON.stringify(state.estimateWay)); + localStorage.setItem( + CART_STORAGE_KEYS.ESTIMATE_WAY, + JSON.stringify(state.estimateWay), + ); } }, updateOrder(state, action: PayloadAction) { diff --git a/src/pages/cart/components/CartMobileTabletLayout.tsx b/src/pages/cart/components/CartMobileTabletLayout.tsx index 171283b..0423acd 100644 --- a/src/pages/cart/components/CartMobileTabletLayout.tsx +++ b/src/pages/cart/components/CartMobileTabletLayout.tsx @@ -66,7 +66,7 @@ export default function CartMobileTabletLayout({ > {/* Table Number */} {(orderType === OrderType.DineIn || - orderType === OrderType.ToOffice) && } + orderType === OrderType.ToOffice) && }
diff --git a/src/pages/cart/components/TableNumberCard.tsx b/src/pages/cart/components/TableNumberCard.tsx index 4002ac4..954cad2 100644 --- a/src/pages/cart/components/TableNumberCard.tsx +++ b/src/pages/cart/components/TableNumberCard.tsx @@ -1,5 +1,6 @@ import { Form, Select } from "antd"; import ProInputCard from "components/ProInputCard/ProInputCard.tsx"; +import ProText from "components/ProText"; import { removeTable, selectCart, @@ -7,14 +8,16 @@ import { } from "features/order/orderSlice.ts"; import styles from "pages/cart/cart.module.css"; import { OrderType } from "pages/checkout/hooks/types"; +import { useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { useGetTablesQuery } from "redux/api/others"; import { useAppDispatch, useAppSelector } from "redux/hooks.ts"; export default function TableNumberCard() { const { t } = useTranslation(); - const { tables, orderType } = useAppSelector(selectCart); + const { table, orderType } = useAppSelector(selectCart); const dispatch = useAppDispatch(); + const [isEditing, setIsEditing] = useState(false); const { data: tableList } = useGetTablesQuery( { restaurantID: localStorage.getItem("restaurantID") || "", @@ -25,6 +28,12 @@ export default function TableNumberCard() { }, ); + const selectedTableName = useMemo(() => { + if (!table || !tableList) return table; + const foundTable = tableList.find((t: any) => t.id === table); + return foundTable?.name || table; + }, [table, tableList]); + return ( <> setIsEditing(true)} + style={{ + fontWeight: 500, + fontStyle: "Medium", + fontSize: 14, + lineHeight: "140%", + letterSpacing: "0%", + color: "#FFB700", + cursor: "pointer", + }} + > + {t("cart.changeTable")} + + ) : undefined + } className={styles.tableNumberCard} - dividerStyle={{ margin: "5px 0 0 0" }} > - - ({ + label: table.name, + value: table.id, + }))} + style={{ + width: "100%", + height: 50, + fontSize: 12, + borderRadius: 888, + }} + onChange={(value) => { + console.log(value); + dispatch(updateTables(value)); + setIsEditing(false); + }} + onClear={() => { + dispatch(removeTable()); + }} + allowClear + /> + + ) : ( + { - console.log(value); - dispatch(updateTables([value as string])); - }} - onClear={() => { - dispatch(removeTable()); - }} - allowClear - /> - + > + {selectedTableName} + + )} ); diff --git a/src/pages/cart/components/timeEstimate/TimeEstimateCard.tsx b/src/pages/cart/components/timeEstimate/TimeEstimateCard.tsx index c9ad91e..ffa8b11 100644 --- a/src/pages/cart/components/timeEstimate/TimeEstimateCard.tsx +++ b/src/pages/cart/components/timeEstimate/TimeEstimateCard.tsx @@ -39,6 +39,8 @@ export default function TimeEstimateCard() { useEffect(() => { form.setFieldsValue({ estimateWay }); }, [estimateWay]); + + console.log(estimateWay); return ( diff --git a/src/pages/cart/components/youMayLike/YouMayAlsoLike.module.css b/src/pages/cart/components/youMayLike/YouMayAlsoLike.module.css index 64cfcc6..f4603c4 100644 --- a/src/pages/cart/components/youMayLike/YouMayAlsoLike.module.css +++ b/src/pages/cart/components/youMayLike/YouMayAlsoLike.module.css @@ -10,6 +10,7 @@ padding: 0; scroll-behavior: smooth; scrollbar-width: none; + gap: 16px; } :global(.darkApp) .youMightAlsoLikeContainer path { diff --git a/src/pages/cart/components/youMayLike/YouMightAlsoLike.tsx b/src/pages/cart/components/youMayLike/YouMightAlsoLike.tsx index f3cd228..b99dd01 100644 --- a/src/pages/cart/components/youMayLike/YouMightAlsoLike.tsx +++ b/src/pages/cart/components/youMayLike/YouMightAlsoLike.tsx @@ -1,10 +1,8 @@ import { PlusOutlined } from "@ant-design/icons"; -import { Space } from "antd"; import ArabicPrice from "components/ArabicPrice"; import BackIcon from "components/Icons/BackIcon"; import NextIcon from "components/Icons/NextIcon"; import ImageWithFallback from "components/ImageWithFallback"; -import { ItemDescriptionIcons } from "components/ItemDescriptionIcons/ItemDescriptionIcons.tsx"; import ProText from "components/ProText.tsx"; import { menuItems } from "data/menuItems.ts"; import { addItem } from "features/order/orderSlice.ts"; @@ -12,10 +10,10 @@ import useBreakPoint from "hooks/useBreakPoint"; import { useEffect, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import { useAppDispatch, useAppSelector } from "redux/hooks.ts"; -import { colors } from "ThemeConstants.ts"; import { default_image } from "utils/constants.ts"; import { Product } from "utils/types/appTypes.ts"; import styles from "./YouMayAlsoLike.module.css"; +import ProInputCard from "components/ProInputCard/ProInputCard"; export default function YouMightAlsoLike() { const { t } = useTranslation(); @@ -182,114 +180,98 @@ export default function YouMightAlsoLike() { )} -
- {menuItems.map((item: Product) => ( -
-
+ +
+ {menuItems.map((item: Product) => ( +
- { - e.stopPropagation(); - handleQuickAdd(item); - }} +
-
- - - - -
- + { + e.stopPropagation(); + handleQuickAdd(item); }} - > - {item.name} - + style={{ + color: "#302E3E", + fontSize: isMobile ? 14 : 16, + }} + />
+ + + -
+ > + {item.name} + +
-
- ))} -
+ ))} +
+
); diff --git a/src/pages/checkout/hooks/useOrder.ts b/src/pages/checkout/hooks/useOrder.ts index 23a83a5..2a022ac 100644 --- a/src/pages/checkout/hooks/useOrder.ts +++ b/src/pages/checkout/hooks/useOrder.ts @@ -28,7 +28,7 @@ export default function useOrder() { items, coupon, tip, - tables, + table, specialRequest, phone, estimateTime, @@ -74,7 +74,7 @@ export default function useOrder() { comment: specialRequest, delivery_method: getDeliveryMethod(), timeslot: "", - table_id: tables[0], + table_id: table, deliveryType: orderType, type: "table-pickup", // user_id: id, @@ -169,7 +169,7 @@ export default function useOrder() { phone, specialRequest, getDeliveryMethod, - tables, + table, orderType, restaurantID, items, diff --git a/src/pages/redeem/page.tsx b/src/pages/redeem/page.tsx index 673af65..8fe0e1b 100644 --- a/src/pages/redeem/page.tsx +++ b/src/pages/redeem/page.tsx @@ -254,7 +254,7 @@ export default function RedeemPage() {
- + {/* */}