diff --git a/src/components/PaymentMethods/PaymentMethods.tsx b/src/components/PaymentMethods/PaymentMethods.tsx index 18d41c3..e5a82ad 100644 --- a/src/components/PaymentMethods/PaymentMethods.tsx +++ b/src/components/PaymentMethods/PaymentMethods.tsx @@ -13,6 +13,7 @@ import { useAppDispatch, useAppSelector } from "redux/hooks"; import { colors, ProGray1 } from "../../ThemeConstants"; import ProInputCard from "../ProInputCard/ProInputCard"; import styles from "./PaymentMethods.module.css"; +import { OrderType } from "pages/checkout/hooks/types.ts"; const PaymentMethods = () => { const { t } = useTranslation(); @@ -28,7 +29,7 @@ const PaymentMethods = () => { style?: React.CSSProperties; hideCurrency?: boolean; }[] = [ - ...(orderType !== "gift" + ...(orderType !== OrderType.Gift ? [ { label: t("checkout.cash"), diff --git a/src/features/order/orderSlice.ts b/src/features/order/orderSlice.ts index a0fa9cd..264c75e 100644 --- a/src/features/order/orderSlice.ts +++ b/src/features/order/orderSlice.ts @@ -53,7 +53,7 @@ interface CartState { collectionMethod: string; phone: string; paymentMethod: string; - orderType: string; + orderType: OrderType | ""; useLoyaltyPoints: boolean; loyaltyValidationError: string | null; } @@ -127,7 +127,7 @@ const initialState: CartState = { ), phone: getFromLocalStorage(CART_STORAGE_KEYS.PHONE, ""), paymentMethod: getFromLocalStorage(CART_STORAGE_KEYS.PAYMENT_METHOD, ""), - orderType: getFromLocalStorage(CART_STORAGE_KEYS.ORDER_TYPE, ""), + orderType: getFromLocalStorage(CART_STORAGE_KEYS.ORDER_TYPE, "" as OrderType | ""), useLoyaltyPoints: getFromLocalStorage( CART_STORAGE_KEYS.USE_LOYALTY_POINTS, false, @@ -435,7 +435,7 @@ const orderSlice = createSlice({ ); } }, - updateOrderType(state, action: PayloadAction) { + updateOrderType(state, action: PayloadAction) { state.orderType = action.payload; // Sync to localStorage @@ -604,7 +604,7 @@ export const selectGrandTotal = (state: RootState) => { const taxAmount = selectTaxAmount(state); const subtotal = selectCartTotal(state); const deliveryFee = - state.order.orderType != OrderType.DineIn + state.order.orderType !== OrderType.DineIn ? Number(state.order.restaurant?.delivery_fees) || 0 : 0; diff --git a/src/pages/address/page.tsx b/src/pages/address/page.tsx index 5742092..d826316 100644 --- a/src/pages/address/page.tsx +++ b/src/pages/address/page.tsx @@ -11,6 +11,7 @@ import { useAppSelector } from "redux/hooks"; import { colors, ProBlack2, ProGray1 } from "ThemeConstants"; import { AddressSummary } from "../checkout/components/AddressSummary"; import styles from "./address.module.css"; +import { OrderType } from "pages/checkout/hooks/types.ts"; export default function AddressPage() { const { t } = useTranslation(); @@ -165,7 +166,7 @@ export default function AddressPage() { to={`/${id}/menu?orderType=delivery`} style={{ width: "100%" }} onClick={() => { - localStorage.setItem("orderType", "delivery"); + localStorage.setItem("orderType", OrderType.Delivery); }} > - + {!shouldHidePickup && (