This commit is contained in:
2026-01-14 21:30:32 +03:00
parent 3a72b8e933
commit ce68b8b978
6 changed files with 52 additions and 30 deletions

View File

@@ -6,7 +6,7 @@ import CancelPopupIcon from "components/Icons/CancelPopupIcon";
import NextIcon from "components/Icons/NextIcon"; import NextIcon from "components/Icons/NextIcon";
import { useState } from "react"; import { useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useParams } from "react-router-dom"; import { useNavigate, useParams } from "react-router-dom";
import { useCancelOrderMutation } from "redux/api/others"; import { useCancelOrderMutation } from "redux/api/others";
import { useAppSelector } from "redux/hooks"; import { useAppSelector } from "redux/hooks";
import { ProBottomSheet } from "../ProBottomSheet/ProBottomSheet"; import { ProBottomSheet } from "../ProBottomSheet/ProBottomSheet";
@@ -18,7 +18,8 @@ export function CancelOrderBottomSheet() {
const { t } = useTranslation(); const { t } = useTranslation();
const [isOpen, setIsOpen] = useState(false); const [isOpen, setIsOpen] = useState(false);
const { isRTL } = useAppSelector((state) => state.locale); const { isRTL } = useAppSelector((state) => state.locale);
const { orderId } = useParams(); const { orderId, subdomain } = useParams();
const navigate = useNavigate();
const [cancelOrder] = useCancelOrderMutation(); const [cancelOrder] = useCancelOrderMutation();
@@ -31,6 +32,7 @@ export function CancelOrderBottomSheet() {
message.error(res.error.data.message); message.error(res.error.data.message);
} else { } else {
message.success(res.data.message); message.success(res.data.message);
navigate(`/${subdomain}`);
} }
}); });
}; };

View File

@@ -8,6 +8,7 @@ interface InputCardProps {
name: string; name: string;
placeholder: string; placeholder: string;
value: string; value: string;
required?: boolean;
} }
export default function InputCard({ export default function InputCard({
@@ -15,6 +16,7 @@ export default function InputCard({
name, name,
placeholder, placeholder,
value, value,
required = false,
}: InputCardProps) { }: InputCardProps) {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
@@ -24,9 +26,8 @@ export default function InputCard({
<> <>
<ProInputCard title={title} dividerStyle={{ margin: "5px 0 0 0" }}> <ProInputCard title={title} dividerStyle={{ margin: "5px 0 0 0" }}>
<Form.Item <Form.Item
label={title}
name={name} name={name}
style={{ position: "relative", top: -5 }} rules={[{ required }]}
> >
<Input <Input
placeholder={placeholder} placeholder={placeholder}

View File

@@ -1,17 +1,34 @@
import { updateRestaurant } from "features/order/orderSlice"; import { updateRestaurant, clearCart } from "features/order/orderSlice";
import { useEffect } from "react"; import { useEffect, useRef } from "react";
import { useAppDispatch } from "redux/hooks"; import { useAppDispatch } from "redux/hooks";
import { RestaurantDetails } from "utils/types/appTypes"; import { RestaurantDetails } from "utils/types/appTypes";
/** /**
* Custom hook to automatically load restaurant into Redux store * Custom hook to automatically load restaurant into Redux store
* when restaurant data is available * when restaurant data is available
* Clears the cart when the restaurant (subdomain) changes
*/ */
export const useRestaurant = (restaurant: RestaurantDetails | undefined) => { export const useRestaurant = (restaurant: RestaurantDetails | undefined) => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const previousRestaurantIdRef = useRef<string | null>(null);
useEffect(() => { useEffect(() => {
if (restaurant) { if (restaurant) {
const currentRestaurantId = restaurant.restautantId;
// Check if restaurant has changed
if (
previousRestaurantIdRef.current !== null &&
previousRestaurantIdRef.current !== currentRestaurantId
) {
// Restaurant changed, clear the cart
dispatch(clearCart());
}
// Update the previous restaurant ID
previousRestaurantIdRef.current = currentRestaurantId;
// Update restaurant in store
dispatch(updateRestaurant(restaurant)); dispatch(updateRestaurant(restaurant));
} }
}, [restaurant, dispatch]); }, [restaurant, dispatch]);

View File

@@ -143,7 +143,7 @@ export default function CartMobileTabletLayout({
</Card> </Card>
</div> </div>
<YouMightAlsoLike /> {/* <YouMightAlsoLike /> */}
<SpecialRequestCard /> <SpecialRequestCard />

View File

@@ -70,6 +70,7 @@ export default function CheckoutPage() {
name="roomNumber" name="roomNumber"
placeholder={t("address.roomNo")} placeholder={t("address.roomNo")}
value={order?.roomNumber} value={order?.roomNumber}
required
/> />
)} )}
{orderType === OrderType.ToOffice && ( {orderType === OrderType.ToOffice && (
@@ -78,6 +79,7 @@ export default function CheckoutPage() {
name="officeNumber" name="officeNumber"
placeholder={t("address.officeNo")} placeholder={t("address.officeNo")}
value={order?.officeNumber} value={order?.officeNumber}
required
/> />
)} )}
{orderType === OrderType.Redeem && <VoucherSummary />} {orderType === OrderType.Redeem && <VoucherSummary />}
@@ -91,7 +93,7 @@ export default function CheckoutPage() {
)} )}
{/* Collection Method */} {/* Collection Method */}
{orderType === OrderType.Pickup && ( {/* {orderType === OrderType.Pickup && (
<ProInputCard title={t("cart.collectionMethod")}> <ProInputCard title={t("cart.collectionMethod")}>
<Form.Item <Form.Item
name="collectionMethod" name="collectionMethod"
@@ -123,7 +125,7 @@ export default function CheckoutPage() {
/> />
</Form.Item> </Form.Item>
</ProInputCard> </ProInputCard>
)} )} */}
{/* Reward Your Waiter */} {/* Reward Your Waiter */}
{/* {orderType !== OrderType.Redeem && orderType !== OrderType.Gift && ( {/* {orderType !== OrderType.Redeem && orderType !== OrderType.Gift && (
@@ -133,7 +135,7 @@ export default function CheckoutPage() {
<EarnLoyaltyPointsCard /> <EarnLoyaltyPointsCard />
)} )}
<BriefMenuCard /> <BriefMenuCard />
<Ads1 /> {/* <Ads1 /> */}
<OrderSummary /> <OrderSummary />
</Layout.Content> </Layout.Content>

View File

@@ -450,7 +450,7 @@ export default function OrderPage() {
)} )}
</Card> </Card>
<Ads2 /> {/* <Ads2 /> */}
{/* <ProInputCard {/* <ProInputCard
title={ title={
@@ -506,7 +506,7 @@ export default function OrderPage() {
<PaymentDetails order={orderDetails?.order} /> <PaymentDetails order={orderDetails?.order} />
{/* inviteToBill */} {/* inviteToBill */}
{!hasClosedStatus && ( {/* {!hasClosedStatus && (
<ProInputCard <ProInputCard
title={ title={
<> <>
@@ -622,7 +622,7 @@ export default function OrderPage() {
</ProText> </ProText>
</Button> </Button>
</ProInputCard> </ProInputCard>
)} )} */}
<QRBottomSheet isOpen={isOpen} onClose={() => setIsOpen(false)} /> <QRBottomSheet isOpen={isOpen} onClose={() => setIsOpen(false)} />
@@ -671,25 +671,25 @@ export default function OrderPage() {
onClose={() => setIsRateOrderOpen(false)} onClose={() => setIsRateOrderOpen(false)}
/> />
{!hasClosedStatus || {(!hasClosedStatus && !hasCanceledByCustomerStatus) && (
(hasCanceledByCustomerStatus && <CancelOrderBottomSheet />)} <CancelOrderBottomSheet />
)}
</Layout.Content> </Layout.Content>
{hasClosedStatus || {(hasClosedStatus || hasCanceledByCustomerStatus) && (
(hasCanceledByCustomerStatus && ( <Layout.Footer className={styles.checkoutButtonContainer}>
<Layout.Footer className={styles.checkoutButtonContainer}> <Button
<Button type="primary"
type="primary" shape="round"
shape="round" className={styles.checkoutButton}
className={styles.checkoutButton} onClick={() => {
onClick={() => { navigate(`/${restaurant?.subdomain}/menu`);
navigate(`/${restaurant?.subdomain}/menu`); }}
}} >
> {t("order.newOrder")}
{t("order.newOrder")} </Button>
</Button> </Layout.Footer>
</Layout.Footer> )}
))}
</Layout> </Layout>
<SplitBillParticipantsBottomSheet <SplitBillParticipantsBottomSheet
isOpen={isSplitBillParticipantsBottomSheetOpen} isOpen={isSplitBillParticipantsBottomSheetOpen}