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

View File

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

View File

@@ -1,17 +1,34 @@
import { updateRestaurant } from "features/order/orderSlice";
import { useEffect } from "react";
import { updateRestaurant, clearCart } from "features/order/orderSlice";
import { useEffect, useRef } from "react";
import { useAppDispatch } from "redux/hooks";
import { RestaurantDetails } from "utils/types/appTypes";
/**
* Custom hook to automatically load restaurant into Redux store
* when restaurant data is available
* Clears the cart when the restaurant (subdomain) changes
*/
export const useRestaurant = (restaurant: RestaurantDetails | undefined) => {
const dispatch = useAppDispatch();
const previousRestaurantIdRef = useRef<string | null>(null);
useEffect(() => {
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));
}
}, [restaurant, dispatch]);

View File

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

View File

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

View File

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