refactor the use of plain string order types
This commit is contained in:
@@ -13,6 +13,7 @@ import { useAppDispatch, useAppSelector } from "redux/hooks";
|
|||||||
import { colors, ProGray1 } from "../../ThemeConstants";
|
import { colors, ProGray1 } from "../../ThemeConstants";
|
||||||
import ProInputCard from "../ProInputCard/ProInputCard";
|
import ProInputCard from "../ProInputCard/ProInputCard";
|
||||||
import styles from "./PaymentMethods.module.css";
|
import styles from "./PaymentMethods.module.css";
|
||||||
|
import { OrderType } from "pages/checkout/hooks/types.ts";
|
||||||
|
|
||||||
const PaymentMethods = () => {
|
const PaymentMethods = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -28,7 +29,7 @@ const PaymentMethods = () => {
|
|||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
hideCurrency?: boolean;
|
hideCurrency?: boolean;
|
||||||
}[] = [
|
}[] = [
|
||||||
...(orderType !== "gift"
|
...(orderType !== OrderType.Gift
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
label: t("checkout.cash"),
|
label: t("checkout.cash"),
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ interface CartState {
|
|||||||
collectionMethod: string;
|
collectionMethod: string;
|
||||||
phone: string;
|
phone: string;
|
||||||
paymentMethod: string;
|
paymentMethod: string;
|
||||||
orderType: string;
|
orderType: OrderType | "";
|
||||||
useLoyaltyPoints: boolean;
|
useLoyaltyPoints: boolean;
|
||||||
loyaltyValidationError: string | null;
|
loyaltyValidationError: string | null;
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,7 @@ const initialState: CartState = {
|
|||||||
),
|
),
|
||||||
phone: getFromLocalStorage(CART_STORAGE_KEYS.PHONE, ""),
|
phone: getFromLocalStorage(CART_STORAGE_KEYS.PHONE, ""),
|
||||||
paymentMethod: getFromLocalStorage(CART_STORAGE_KEYS.PAYMENT_METHOD, ""),
|
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(
|
useLoyaltyPoints: getFromLocalStorage(
|
||||||
CART_STORAGE_KEYS.USE_LOYALTY_POINTS,
|
CART_STORAGE_KEYS.USE_LOYALTY_POINTS,
|
||||||
false,
|
false,
|
||||||
@@ -435,7 +435,7 @@ const orderSlice = createSlice({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateOrderType(state, action: PayloadAction<string>) {
|
updateOrderType(state, action: PayloadAction<OrderType>) {
|
||||||
state.orderType = action.payload;
|
state.orderType = action.payload;
|
||||||
|
|
||||||
// Sync to localStorage
|
// Sync to localStorage
|
||||||
@@ -604,7 +604,7 @@ export const selectGrandTotal = (state: RootState) => {
|
|||||||
const taxAmount = selectTaxAmount(state);
|
const taxAmount = selectTaxAmount(state);
|
||||||
const subtotal = selectCartTotal(state);
|
const subtotal = selectCartTotal(state);
|
||||||
const deliveryFee =
|
const deliveryFee =
|
||||||
state.order.orderType != OrderType.DineIn
|
state.order.orderType !== OrderType.DineIn
|
||||||
? Number(state.order.restaurant?.delivery_fees) || 0
|
? Number(state.order.restaurant?.delivery_fees) || 0
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { useAppSelector } from "redux/hooks";
|
|||||||
import { colors, ProBlack2, ProGray1 } from "ThemeConstants";
|
import { colors, ProBlack2, ProGray1 } from "ThemeConstants";
|
||||||
import { AddressSummary } from "../checkout/components/AddressSummary";
|
import { AddressSummary } from "../checkout/components/AddressSummary";
|
||||||
import styles from "./address.module.css";
|
import styles from "./address.module.css";
|
||||||
|
import { OrderType } from "pages/checkout/hooks/types.ts";
|
||||||
|
|
||||||
export default function AddressPage() {
|
export default function AddressPage() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -165,7 +166,7 @@ export default function AddressPage() {
|
|||||||
to={`/${id}/menu?orderType=delivery`}
|
to={`/${id}/menu?orderType=delivery`}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
localStorage.setItem("orderType", "delivery");
|
localStorage.setItem("orderType", OrderType.Delivery);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import YouMightAlsoLike from "pages/cart/components/youMayLike/YouMightAlsoLike.
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useAppSelector } from "redux/hooks.ts";
|
import { useAppSelector } from "redux/hooks.ts";
|
||||||
import CartFooter from "./cartFooter/CartFooter";
|
import CartFooter from "./cartFooter/CartFooter";
|
||||||
|
import { OrderType } from "pages/checkout/hooks/types.ts";
|
||||||
|
|
||||||
interface CartDesktopLayoutProps {
|
interface CartDesktopLayoutProps {
|
||||||
form: FormInstance;
|
form: FormInstance;
|
||||||
@@ -177,11 +178,10 @@ export default function CartDesktopLayout({ form }: CartDesktopLayoutProps) {
|
|||||||
<CouponCard />
|
<CouponCard />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{orderType === "pickup" && <CarPlateCard />}
|
{orderType === OrderType.Pickup && <CarPlateCard />}
|
||||||
|
|
||||||
{(orderType === "delivery" || orderType === "pickup") && (
|
{(orderType === OrderType.Delivery ||
|
||||||
<TimeEstimateCard />
|
orderType === OrderType.Pickup) && <TimeEstimateCard />}
|
||||||
)}
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className={styles.desktopSidebarCard}
|
className={styles.desktopSidebarCard}
|
||||||
@@ -191,7 +191,7 @@ export default function CartDesktopLayout({ form }: CartDesktopLayoutProps) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Table Number */}
|
{/* Table Number */}
|
||||||
{orderType === "dine-in" && (
|
{orderType === OrderType.DineIn && (
|
||||||
<div
|
<div
|
||||||
className={styles.desktopSidebarCard}
|
className={styles.desktopSidebarCard}
|
||||||
style={{ "--animation-order": 3 } as React.CSSProperties}
|
style={{ "--animation-order": 3 } as React.CSSProperties}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import SpecialRequestCard from "pages/cart/components/specialRequest/SpecialRequ
|
|||||||
import TableNumberCard from "pages/cart/components/TableNumberCard.tsx";
|
import TableNumberCard from "pages/cart/components/TableNumberCard.tsx";
|
||||||
import TimeEstimateCard from "pages/cart/components/timeEstimate/TimeEstimateCard.tsx";
|
import TimeEstimateCard from "pages/cart/components/timeEstimate/TimeEstimateCard.tsx";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { OrderType } from "pages/checkout/hooks/types";
|
||||||
|
|
||||||
interface CartMobileTabletLayoutProps {
|
interface CartMobileTabletLayoutProps {
|
||||||
form: FormInstance;
|
form: FormInstance;
|
||||||
@@ -224,15 +225,14 @@ export default function CartMobileTabletLayout({
|
|||||||
<CouponCard />
|
<CouponCard />
|
||||||
|
|
||||||
{/* Car Plate*/}
|
{/* Car Plate*/}
|
||||||
{orderType === "pickup" && <CarPlateCard />}
|
{orderType === OrderType.Pickup && <CarPlateCard />}
|
||||||
|
|
||||||
{/* Estimate Time */}
|
{/* Estimate Time */}
|
||||||
{(orderType === "delivery" || orderType === "pickup") && (
|
{(orderType === OrderType.Delivery ||
|
||||||
<TimeEstimateCard />
|
orderType === OrderType.Pickup) && <TimeEstimateCard />}
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Collection Method */}
|
{/* Collection Method */}
|
||||||
{orderType === "pickup" && (
|
{orderType === OrderType.Pickup && (
|
||||||
<ProInputCard title={t("cart.collectionMethod")}>
|
<ProInputCard title={t("cart.collectionMethod")}>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="collectionMethod"
|
name="collectionMethod"
|
||||||
@@ -270,7 +270,7 @@ export default function CartMobileTabletLayout({
|
|||||||
<RewardWaiterCard />
|
<RewardWaiterCard />
|
||||||
|
|
||||||
{/* Table Number */}
|
{/* Table Number */}
|
||||||
{orderType === "dine-in" && <TableNumberCard />}
|
{orderType === OrderType.DineIn && <TableNumberCard />}
|
||||||
|
|
||||||
{/* Invoice Summary */}
|
{/* Invoice Summary */}
|
||||||
<OrderSummary />
|
<OrderSummary />
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { useCallback, useMemo, useState } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
||||||
import styles from "../../address/address.module.css";
|
import styles from "../../address/address.module.css";
|
||||||
|
import { OrderType } from "pages/checkout/hooks/types.ts";
|
||||||
|
|
||||||
interface LocationData {
|
interface LocationData {
|
||||||
lat: number;
|
lat: number;
|
||||||
@@ -19,7 +20,7 @@ export const AddressSummary = () => {
|
|||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const { location } = useAppSelector(selectCart);
|
const { location } = useAppSelector(selectCart);
|
||||||
const [isMapBottomSheetOpen, setIsMapBottomSheetOpen] = useState(false);
|
const [isMapBottomSheetOpen, setIsMapBottomSheetOpen] = useState(false);
|
||||||
const { orderType } = useAppSelector(selectCart) // Default to delivery for now
|
const { orderType } = useAppSelector(selectCart); // Default to delivery for now
|
||||||
|
|
||||||
const handleLocationSave = useCallback(
|
const handleLocationSave = useCallback(
|
||||||
(locationString: string) => {
|
(locationString: string) => {
|
||||||
@@ -46,7 +47,10 @@ export const AddressSummary = () => {
|
|||||||
[location],
|
[location],
|
||||||
);
|
);
|
||||||
|
|
||||||
const shouldRender = useMemo(() => orderType === "delivery", [orderType]);
|
const shouldRender = useMemo(
|
||||||
|
() => orderType === OrderType.Delivery,
|
||||||
|
[orderType],
|
||||||
|
);
|
||||||
|
|
||||||
if (!shouldRender) {
|
if (!shouldRender) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -7,11 +7,12 @@ import { useMemo } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useAppSelector } from "redux/hooks";
|
import { useAppSelector } from "redux/hooks";
|
||||||
import styles from "../../address/address.module.css";
|
import styles from "../../address/address.module.css";
|
||||||
|
import { OrderType } from "pages/checkout/hooks/types.ts";
|
||||||
|
|
||||||
export default function BriefMenu() {
|
export default function BriefMenu() {
|
||||||
const { tables, items } = useAppSelector(selectCart);
|
const { tables, items } = useAppSelector(selectCart);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { orderType } = useAppSelector(selectCart)
|
const { orderType } = useAppSelector(selectCart);
|
||||||
|
|
||||||
const menuItems = useMemo(
|
const menuItems = useMemo(
|
||||||
() =>
|
() =>
|
||||||
@@ -28,23 +29,20 @@ export default function BriefMenu() {
|
|||||||
<div>
|
<div>
|
||||||
<ProText className={styles.itemName}>{item.name}</ProText>
|
<ProText className={styles.itemName}>{item.name}</ProText>
|
||||||
<br />
|
<br />
|
||||||
<ArabicPrice
|
<ArabicPrice price={item.price} type="secondary" />
|
||||||
price={item.price}
|
|
||||||
type="secondary"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)),
|
)),
|
||||||
[items]
|
[items],
|
||||||
);
|
);
|
||||||
|
|
||||||
const cardTitle = useMemo(
|
const cardTitle = useMemo(
|
||||||
() =>
|
() =>
|
||||||
orderType === "dine-in"
|
orderType === OrderType.DineIn
|
||||||
? t("checkout.table") + " " + tables
|
? t("checkout.table") + " " + tables
|
||||||
: t("checkout.items"),
|
: t("checkout.items"),
|
||||||
[orderType, t, tables]
|
[orderType, t, tables],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ import { useNavigate, useParams } from "react-router-dom";
|
|||||||
import { useAppSelector } from "redux/hooks";
|
import { useAppSelector } from "redux/hooks";
|
||||||
import styles from "../../address/address.module.css";
|
import styles from "../../address/address.module.css";
|
||||||
import useOrder from "../hooks/useOrder";
|
import useOrder from "../hooks/useOrder";
|
||||||
|
import { OrderType } from "pages/checkout/hooks/types.ts";
|
||||||
|
|
||||||
export default function CheckoutButton({ form }: { form: FormInstance }) {
|
export default function CheckoutButton({ form }: { form: FormInstance }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { orderType } = useAppSelector(selectCart)
|
const { orderType } = useAppSelector(selectCart);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { handleCreateOrder } = useOrder();
|
const { handleCreateOrder } = useOrder();
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
@@ -28,7 +29,7 @@ export default function CheckoutButton({ form }: { form: FormInstance }) {
|
|||||||
}, [handleCreateOrder, form]);
|
}, [handleCreateOrder, form]);
|
||||||
|
|
||||||
const shouldShowSplitBill = useMemo(
|
const shouldShowSplitBill = useMemo(
|
||||||
() => orderType === "dine-in",
|
() => orderType === OrderType.DineIn,
|
||||||
[orderType],
|
[orderType],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { useCallback, useMemo, useState } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
||||||
import styles from "../../address/address.module.css";
|
import styles from "../../address/address.module.css";
|
||||||
|
import { OrderType } from "pages/checkout/hooks/types.ts";
|
||||||
|
|
||||||
export const GiftDetails = () => {
|
export const GiftDetails = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -34,7 +35,7 @@ export const GiftDetails = () => {
|
|||||||
console.error("Failed to parse location data:", error);
|
console.error("Failed to parse location data:", error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[dispatch]
|
[dispatch],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleOfficeBottomSheetOpen = useCallback(() => {
|
const handleOfficeBottomSheetOpen = useCallback(() => {
|
||||||
@@ -55,11 +56,11 @@ export const GiftDetails = () => {
|
|||||||
|
|
||||||
const buttonText = useMemo(
|
const buttonText = useMemo(
|
||||||
() => (giftDetails ? t("address.changeGift") : t("address.selectGift")),
|
() => (giftDetails ? t("address.changeGift") : t("address.selectGift")),
|
||||||
[giftDetails, t]
|
[giftDetails, t],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
orderType === "gift" && (
|
orderType === OrderType.Gift && (
|
||||||
<>
|
<>
|
||||||
<Card
|
<Card
|
||||||
title={t("address.giftDetails")}
|
title={t("address.giftDetails")}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { useCallback, useMemo, useState } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
||||||
import styles from "../../address/address.module.css";
|
import styles from "../../address/address.module.css";
|
||||||
|
import { OrderType } from "pages/checkout/hooks/types.ts";
|
||||||
|
|
||||||
export const OfficeDetails = () => {
|
export const OfficeDetails = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -20,7 +21,7 @@ export const OfficeDetails = () => {
|
|||||||
const { officeDetails } = useAppSelector(selectCart);
|
const { officeDetails } = useAppSelector(selectCart);
|
||||||
const [isOfficeBottomSheetOpen, setIsOfficeBottomSheetOpen] = useState(false);
|
const [isOfficeBottomSheetOpen, setIsOfficeBottomSheetOpen] = useState(false);
|
||||||
|
|
||||||
const { orderType } = useAppSelector(selectCart)
|
const { orderType } = useAppSelector(selectCart);
|
||||||
|
|
||||||
const handleOfficeDetailsSave = useCallback(
|
const handleOfficeDetailsSave = useCallback(
|
||||||
(officeDetailsData: OfficeDetailsType) => {
|
(officeDetailsData: OfficeDetailsType) => {
|
||||||
@@ -31,7 +32,7 @@ export const OfficeDetails = () => {
|
|||||||
console.error("Failed to parse location data:", error);
|
console.error("Failed to parse location data:", error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[dispatch]
|
[dispatch],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleOfficeBottomSheetOpen = useCallback(() => {
|
const handleOfficeBottomSheetOpen = useCallback(() => {
|
||||||
@@ -45,11 +46,11 @@ export const OfficeDetails = () => {
|
|||||||
const buttonText = useMemo(
|
const buttonText = useMemo(
|
||||||
() =>
|
() =>
|
||||||
officeDetails ? t("address.changeOffice") : t("address.selectOffice"),
|
officeDetails ? t("address.changeOffice") : t("address.selectOffice"),
|
||||||
[officeDetails, t]
|
[officeDetails, t],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
orderType === "office" && (
|
orderType === OrderType.ToOffice && (
|
||||||
<>
|
<>
|
||||||
<Card
|
<Card
|
||||||
title={t("address.officeDetails")}
|
title={t("address.officeDetails")}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { useCallback, useMemo, useState } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
||||||
import styles from "../../address/address.module.css";
|
import styles from "../../address/address.module.css";
|
||||||
|
import { OrderType } from "pages/checkout/hooks/types.ts";
|
||||||
|
|
||||||
export const RoomDetails = () => {
|
export const RoomDetails = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -20,7 +21,7 @@ export const RoomDetails = () => {
|
|||||||
const { roomDetails } = useAppSelector(selectCart);
|
const { roomDetails } = useAppSelector(selectCart);
|
||||||
const [isRoomBottomSheetOpen, setIsRoomBottomSheetOpen] = useState(false);
|
const [isRoomBottomSheetOpen, setIsRoomBottomSheetOpen] = useState(false);
|
||||||
|
|
||||||
const { orderType } = useAppSelector(selectCart)
|
const { orderType } = useAppSelector(selectCart);
|
||||||
|
|
||||||
const handleRoomDetailsSave = useCallback(
|
const handleRoomDetailsSave = useCallback(
|
||||||
(roomDetailsData: RoomDetailsType) => {
|
(roomDetailsData: RoomDetailsType) => {
|
||||||
@@ -31,7 +32,7 @@ export const RoomDetails = () => {
|
|||||||
console.error("Failed to parse location data:", error);
|
console.error("Failed to parse location data:", error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[dispatch]
|
[dispatch],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleRoomBottomSheetOpen = useCallback(() => {
|
const handleRoomBottomSheetOpen = useCallback(() => {
|
||||||
@@ -44,11 +45,11 @@ export const RoomDetails = () => {
|
|||||||
|
|
||||||
const buttonText = useMemo(
|
const buttonText = useMemo(
|
||||||
() => (roomDetails ? t("address.changeRoom") : t("address.selectRoom")),
|
() => (roomDetails ? t("address.changeRoom") : t("address.selectRoom")),
|
||||||
[roomDetails, t]
|
[roomDetails, t],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
orderType === "room" && (
|
orderType === OrderType.ToRoom && (
|
||||||
<>
|
<>
|
||||||
<Card
|
<Card
|
||||||
title={t("address.roomDetails")}
|
title={t("address.roomDetails")}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import ProPhoneInput from "components/ProPhoneInput";
|
|||||||
import { selectCart, updatePhone } from "features/order/orderSlice";
|
import { selectCart, updatePhone } from "features/order/orderSlice";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
||||||
|
import { OrderType } from "pages/checkout/hooks/types.ts";
|
||||||
|
|
||||||
export default function PhoneCard() {
|
export default function PhoneCard() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -10,7 +11,7 @@ export default function PhoneCard() {
|
|||||||
const { phone, orderType } = useAppSelector(selectCart);
|
const { phone, orderType } = useAppSelector(selectCart);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
orderType !== "gift" && (
|
orderType !== OrderType.Gift && (
|
||||||
<>
|
<>
|
||||||
<ProInputCard title={t("checkout.phoneNumber")}>
|
<ProInputCard title={t("checkout.phoneNumber")}>
|
||||||
<ProPhoneInput
|
<ProPhoneInput
|
||||||
|
|||||||
@@ -245,4 +245,5 @@ export enum OrderType {
|
|||||||
ScheduledOrder = "scheduled_order",
|
ScheduledOrder = "scheduled_order",
|
||||||
ToRoom = "room",
|
ToRoom = "room",
|
||||||
ToOffice = "office",
|
ToOffice = "office",
|
||||||
|
Booking = "booking",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
clearCart,
|
clearCart,
|
||||||
selectCart,
|
selectCart,
|
||||||
selectGrandTotal,
|
selectGrandTotal,
|
||||||
selectHighestPricedLoyaltyItem
|
selectHighestPricedLoyaltyItem,
|
||||||
} from "features/order/orderSlice";
|
} from "features/order/orderSlice";
|
||||||
import { useCallback } from "react";
|
import { useCallback } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@@ -12,6 +12,7 @@ import { useCreateOrderMutation } from "redux/api/others";
|
|||||||
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
||||||
import { PAYMENT_CONFIRMATION_URL } from "utils/constants";
|
import { PAYMENT_CONFIRMATION_URL } from "utils/constants";
|
||||||
import { Customer } from "../../otp/types";
|
import { Customer } from "../../otp/types";
|
||||||
|
import { OrderType } from "pages/checkout/hooks/types.ts";
|
||||||
|
|
||||||
export default function useOrder() {
|
export default function useOrder() {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
@@ -72,7 +73,7 @@ export default function useOrder() {
|
|||||||
use_loylaty: useLoyaltyPoints && highestLoyaltyItem ? 1 : 0,
|
use_loylaty: useLoyaltyPoints && highestLoyaltyItem ? 1 : 0,
|
||||||
useWallet: 0,
|
useWallet: 0,
|
||||||
tip,
|
tip,
|
||||||
...(orderType === "gift"
|
...(orderType === OrderType.Gift
|
||||||
? {
|
? {
|
||||||
receiverName: giftDetails?.receiverName,
|
receiverName: giftDetails?.receiverName,
|
||||||
receiverPhone: giftDetails?.receiverPhone,
|
receiverPhone: giftDetails?.receiverPhone,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import DownIcon from "components/Icons/DownIcon";
|
|||||||
import PickupIcon from "components/Icons/PickupIcon";
|
import PickupIcon from "components/Icons/PickupIcon";
|
||||||
import useBreakPoint from "hooks/useBreakPoint";
|
import useBreakPoint from "hooks/useBreakPoint";
|
||||||
import styles from "../menu.module.css";
|
import styles from "../menu.module.css";
|
||||||
|
import { OrderType } from "pages/checkout/hooks/types.ts";
|
||||||
|
|
||||||
interface ResponsiveServicesProps {
|
interface ResponsiveServicesProps {
|
||||||
orderType: string;
|
orderType: string;
|
||||||
@@ -18,18 +19,20 @@ interface ResponsiveServicesProps {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default function ResponsiveServices({
|
||||||
export default function ResponsiveServices({ orderType, translations }: ResponsiveServicesProps) {
|
orderType,
|
||||||
|
translations,
|
||||||
|
}: ResponsiveServicesProps) {
|
||||||
const { isMobile } = useBreakPoint();
|
const { isMobile } = useBreakPoint();
|
||||||
|
|
||||||
// Hide pickup service if screen width is less than 400px (insufficient for 3 services)
|
// Hide pickup service if screen width is less than 400px (insufficient for 3 services)
|
||||||
const shouldHidePickup = isMobile;
|
const shouldHidePickup = isMobile;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.services}>
|
<div className={styles.services}>
|
||||||
<Button
|
<Button
|
||||||
className={
|
className={
|
||||||
orderType == "dine-in"
|
orderType == OrderType.DineIn
|
||||||
? styles.activeServiceButton
|
? styles.activeServiceButton
|
||||||
: styles.serviceButton
|
: styles.serviceButton
|
||||||
}
|
}
|
||||||
@@ -41,11 +44,11 @@ export default function ResponsiveServices({ orderType, translations }: Responsi
|
|||||||
>
|
>
|
||||||
{translations.common.dineIn}
|
{translations.common.dineIn}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{!shouldHidePickup && (
|
{!shouldHidePickup && (
|
||||||
<Button
|
<Button
|
||||||
className={
|
className={
|
||||||
orderType == "pickup"
|
orderType == OrderType.Pickup
|
||||||
? styles.activeServiceButton
|
? styles.activeServiceButton
|
||||||
: styles.serviceButton
|
: styles.serviceButton
|
||||||
}
|
}
|
||||||
@@ -58,7 +61,7 @@ export default function ResponsiveServices({ orderType, translations }: Responsi
|
|||||||
{translations.common.pickup}
|
{translations.common.pickup}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className={
|
className={
|
||||||
orderType == "more"
|
orderType == "more"
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { Link, useParams } from "react-router-dom";
|
import { Link, useParams } from "react-router-dom";
|
||||||
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
||||||
import styles from "./restaurant.module.css";
|
import styles from "./restaurant.module.css";
|
||||||
|
import { OrderType } from "pages/checkout/hooks/types.ts";
|
||||||
|
|
||||||
interface RestaurantServicesProps {
|
interface RestaurantServicesProps {
|
||||||
dineIn?: boolean;
|
dineIn?: boolean;
|
||||||
@@ -43,7 +44,7 @@ export default function RestaurantServices({
|
|||||||
const services = [
|
const services = [
|
||||||
...((dineIn && [
|
...((dineIn && [
|
||||||
{
|
{
|
||||||
id: "dine-in",
|
id: OrderType.DineIn,
|
||||||
title: t("common.dineIn"),
|
title: t("common.dineIn"),
|
||||||
description: t("home.services.dineIn"),
|
description: t("home.services.dineIn"),
|
||||||
icon: (
|
icon: (
|
||||||
@@ -58,7 +59,7 @@ export default function RestaurantServices({
|
|||||||
[]),
|
[]),
|
||||||
...((pickup && [
|
...((pickup && [
|
||||||
{
|
{
|
||||||
id: "pickup",
|
id: OrderType.Pickup,
|
||||||
title: t("common.pickup"),
|
title: t("common.pickup"),
|
||||||
description: t("home.services.pickup"),
|
description: t("home.services.pickup"),
|
||||||
icon: (
|
icon: (
|
||||||
@@ -73,7 +74,7 @@ export default function RestaurantServices({
|
|||||||
[]),
|
[]),
|
||||||
...((gift && [
|
...((gift && [
|
||||||
{
|
{
|
||||||
id: "gift",
|
id: OrderType.Gift,
|
||||||
title: t("common.sendGift"),
|
title: t("common.sendGift"),
|
||||||
description: t("home.services.gift"),
|
description: t("home.services.gift"),
|
||||||
icon: (
|
icon: (
|
||||||
@@ -88,7 +89,7 @@ export default function RestaurantServices({
|
|||||||
[]),
|
[]),
|
||||||
...((toRoom && [
|
...((toRoom && [
|
||||||
{
|
{
|
||||||
id: "room",
|
id: OrderType.ToRoom,
|
||||||
title: t("common.roomService"),
|
title: t("common.roomService"),
|
||||||
description: t("home.services.room"),
|
description: t("home.services.room"),
|
||||||
icon: (
|
icon: (
|
||||||
@@ -101,7 +102,7 @@ export default function RestaurantServices({
|
|||||||
[]),
|
[]),
|
||||||
...((toOffice && [
|
...((toOffice && [
|
||||||
{
|
{
|
||||||
id: "office",
|
id: OrderType.ToOffice,
|
||||||
title: t("common.officeDelivery"),
|
title: t("common.officeDelivery"),
|
||||||
description: t("home.services.office"),
|
description: t("home.services.office"),
|
||||||
icon: (
|
icon: (
|
||||||
@@ -116,7 +117,7 @@ export default function RestaurantServices({
|
|||||||
[]),
|
[]),
|
||||||
...((is_booking_enabled && [
|
...((is_booking_enabled && [
|
||||||
{
|
{
|
||||||
id: "booking",
|
id: OrderType.Booking,
|
||||||
title: t("common.tableBooking"),
|
title: t("common.tableBooking"),
|
||||||
description: t("home.services.booking"),
|
description: t("home.services.booking"),
|
||||||
icon: (
|
icon: (
|
||||||
@@ -131,7 +132,7 @@ export default function RestaurantServices({
|
|||||||
[]),
|
[]),
|
||||||
...((delivery && [
|
...((delivery && [
|
||||||
{
|
{
|
||||||
id: "delivery",
|
id: OrderType.Delivery,
|
||||||
title: t("common.delivery"),
|
title: t("common.delivery"),
|
||||||
description: t("home.services.delivery"),
|
description: t("home.services.delivery"),
|
||||||
icon: (
|
icon: (
|
||||||
|
|||||||
Reference in New Issue
Block a user