) {
+ state.giftType = action.payload;
+ },
},
});
@@ -720,6 +728,7 @@ export const {
updateOrder,
updateSplitBillAmount,
updateCustomerName,
+ updateGiftType,
} = orderSlice.actions;
// Tax calculation helper functions
diff --git a/src/pages/EGiftCards/EGiftCards.module.css b/src/pages/EGiftCards/EGiftCards.module.css
new file mode 100644
index 0000000..e69de29
diff --git a/src/pages/EGiftCards/EGiftCards.tsx b/src/pages/EGiftCards/EGiftCards.tsx
new file mode 100644
index 0000000..6d4ad8a
--- /dev/null
+++ b/src/pages/EGiftCards/EGiftCards.tsx
@@ -0,0 +1,24 @@
+import { Layout, Spin } from "antd";
+import PaymentMethods from "components/PaymentMethods/PaymentMethods";
+import ProHeader from "components/ProHeader/ProHeader";
+import { useTranslation } from "react-i18next";
+import styles from "../address/address.module.css";
+import ECardButton from "./components/ECardButton";
+import { useGetEGiftCardsQuery } from "redux/api/others";
+import ECardList from "./components/ECardList";
+
+export default function EGiftCardsPage() {
+ const { t } = useTranslation();
+ const { data: eGiftCards, isLoading } = useGetEGiftCardsQuery();
+
+ return (
+
+ {t("checkout.title")}
+
+
+ {isLoading ? : }
+
+
+
+ );
+}
diff --git a/src/pages/EGiftCards/components/ECardButton.tsx b/src/pages/EGiftCards/components/ECardButton.tsx
new file mode 100644
index 0000000..40a2ee5
--- /dev/null
+++ b/src/pages/EGiftCards/components/ECardButton.tsx
@@ -0,0 +1,37 @@
+import { Button, Layout, message } from "antd";
+import { useTranslation } from "react-i18next";
+import styles from "../../address/address.module.css";
+import { useCallback } from "react";
+import { useNavigate, useParams } from "react-router-dom";
+import { selectCart } from "features/order/orderSlice";
+import { useAppSelector } from "redux/hooks";
+
+export default function ECardButton() {
+ const { t } = useTranslation();
+ const { subdomain } = useParams();
+ const navigate = useNavigate();
+ const { giftDetails } = useAppSelector(selectCart);
+
+ const handleSelectCard = useCallback(() => {
+ if (giftDetails?.cardId) {
+ navigate(`/${subdomain}/cardDetails/${giftDetails?.cardId}`);
+ } else {
+ message.error(t("gift.pleaseSelectCard"));
+ }
+ }, [navigate, subdomain, giftDetails?.cardId]);
+
+ return (
+ <>
+
+
+
+ >
+ );
+}
diff --git a/src/pages/EGiftCards/components/ECardList.tsx b/src/pages/EGiftCards/components/ECardList.tsx
new file mode 100644
index 0000000..ca5b586
--- /dev/null
+++ b/src/pages/EGiftCards/components/ECardList.tsx
@@ -0,0 +1,14 @@
+import { Card, Image } from "antd";
+import { EGiftCard } from "../type";
+
+export default function ECardList({ eGiftCards }: { eGiftCards: EGiftCard[] }) {
+ return (
+ <>
+ {eGiftCards.map((card: EGiftCard) => (
+
+
+
+ ))}
+ >
+ );
+}
diff --git a/src/pages/EGiftCards/type.ts b/src/pages/EGiftCards/type.ts
new file mode 100644
index 0000000..a8adbad
--- /dev/null
+++ b/src/pages/EGiftCards/type.ts
@@ -0,0 +1,9 @@
+export interface EGiftCard {
+ id: number;
+ image: string;
+ restorant_id: number | null;
+ is_available: number;
+ created_at: string;
+ updated_at: string;
+ imageURL: string;
+}
diff --git a/src/pages/cart/components/cartFooter/CartFooter.tsx b/src/pages/cart/components/cartFooter/CartFooter.tsx
index 8f4fa8b..7387f67 100644
--- a/src/pages/cart/components/cartFooter/CartFooter.tsx
+++ b/src/pages/cart/components/cartFooter/CartFooter.tsx
@@ -5,6 +5,7 @@ import { useTranslation } from "react-i18next";
import { Link, useNavigate, useParams } from "react-router-dom";
import { useAppSelector } from "redux/hooks.ts";
import styles from "./footer.module.css";
+import { OrderType } from "pages/checkout/hooks/types";
interface CartFooterProps {
form: FormInstance;
@@ -63,7 +64,9 @@ export default function CartFooter({ form }: CartFooterProps) {
}}
onClick={handleCheckoutClick}
>
- {t("cart.checkout")}
+ {orderType === OrderType.Gift
+ ? t("cart.continueToGiftDetails")
+ : t("cart.checkout")}
);
diff --git a/src/pages/restaurant/RestaurantServices.tsx b/src/pages/restaurant/RestaurantServices.tsx
index 1624b92..66c0f72 100644
--- a/src/pages/restaurant/RestaurantServices.tsx
+++ b/src/pages/restaurant/RestaurantServices.tsx
@@ -1,4 +1,3 @@
-import { ScheduleFilled } from "@ant-design/icons";
import { Card } from "antd";
import BackIcon from "components/Icons/BackIcon";
import DeliveryIcon from "components/Icons/DeliveryIcon";
@@ -11,21 +10,26 @@ import ToRoomIcon from "components/Icons/ToRoomIcon";
import { updateOrderType } from "features/order/orderSlice";
import { OrderType } from "pages/checkout/hooks/types.ts";
import { useTranslation } from "react-i18next";
-import { Link, useParams } from "react-router-dom";
+import { Link, useNavigate, useParams } from "react-router-dom";
import { useGetRestaurantDetailsQuery } from "redux/api/others";
import { useAppDispatch, useAppSelector } from "redux/hooks";
import styles from "./restaurant.module.css";
import ScheduleOrderIcon from "components/Icons/ScheduleOrderIcon";
import ProText from "components/ProText";
+import { GiftTypeBottomSheet } from "components/CustomBottomSheet/GiftTypeBottomSheet";
+import { useState } from "react";
export default function RestaurantServices() {
const { t } = useTranslation();
const { isRTL } = useAppSelector((state) => state.locale);
const { subdomain } = useParams();
+ const navigate = useNavigate();
const dispatch = useAppDispatch();
const { data: restaurant } = useGetRestaurantDetailsQuery(subdomain, {
skip: !subdomain,
});
+ const [isGiftTypeBottomSheetOpen, setIsGiftTypeBottomSheetOpen] =
+ useState(false);
const {
dineIn,
@@ -188,12 +192,19 @@ export default function RestaurantServices() {
return (
{services?.map((s) => {
+ const isGift = s?.id === OrderType.Gift;
return (
{
- dispatch(updateOrderType(s?.id));
+ onClick={(e) => {
+ if (isGift) {
+ e.preventDefault();
+ dispatch(updateOrderType(s?.id));
+ setIsGiftTypeBottomSheetOpen(true);
+ } else {
+ dispatch(updateOrderType(s?.id));
+ }
}}
style={{
width: "100%",
@@ -225,7 +236,7 @@ export default function RestaurantServices() {
lineHeight: "140%",
letterSpacing: "0%",
verticalAlign: "middle",
- color: "#434E5C"
+ color: "#434E5C",
}}
>
{s?.title}
@@ -242,6 +253,14 @@ export default function RestaurantServices() {
);
})}
+ setIsGiftTypeBottomSheetOpen(false)}
+ onSave={() => {
+ setIsGiftTypeBottomSheetOpen(false);
+ navigate(`/${subdomain}/menu?orderType=${OrderType.Gift}`);
+ }}
+ />
);
}
diff --git a/src/pages/restaurant/restaurant.module.css b/src/pages/restaurant/restaurant.module.css
index 07f45ab..d5f0afc 100644
--- a/src/pages/restaurant/restaurant.module.css
+++ b/src/pages/restaurant/restaurant.module.css
@@ -145,7 +145,7 @@
display: grid;
gap: 16px;
padding: 0 1rem;
- margin: 10px 0;
+ margin: 24px 0 10px 0;
}
}
diff --git a/src/redux/api/others.ts b/src/redux/api/others.ts
index 34a6b0b..7006a3f 100644
--- a/src/redux/api/others.ts
+++ b/src/redux/api/others.ts
@@ -9,6 +9,7 @@ import {
RESTAURANT_DETAILS_URL,
TABLES_URL,
USER_DETAILS_URL,
+ EGIFT_CARDS_URL,
} from "utils/constants";
import { OrderDetails } from "pages/checkout/hooks/types";
@@ -19,6 +20,7 @@ import {
UserType,
} from "utils/types/appTypes";
import { baseApi } from "./apiSlice";
+import { EGiftCard } from "pages/EGiftCards/type";
export const branchApi = baseApi.injectEndpoints({
endpoints: (builder) => ({
@@ -31,7 +33,7 @@ export const branchApi = baseApi.injectEndpoints({
},
}),
transformResponse: (response: any) => {
- return response?.result?.restaurants?.[0]
+ return response?.result?.restaurants?.[0];
},
providesTags: ["Restaurant"],
}),
@@ -160,6 +162,15 @@ export const branchApi = baseApi.injectEndpoints({
}),
invalidatesTags: ["Orders", "Restaurant"],
}),
+ getEGiftCards: builder.query({
+ query: () => ({
+ url: EGIFT_CARDS_URL,
+ method: "GET",
+ }),
+ transformResponse: (response: any) => {
+ return response.result;
+ },
+ }),
}),
});
export const {
@@ -173,4 +184,5 @@ export const {
useGetDiscountMutation,
useRateOrderMutation,
useGetUserDetailsQuery,
+ useGetEGiftCardsQuery,
} = branchApi;
diff --git a/src/utils/constants.ts b/src/utils/constants.ts
index 44d7745..e18dd34 100644
--- a/src/utils/constants.ts
+++ b/src/utils/constants.ts
@@ -108,3 +108,4 @@ export const SEND_OTP_URL = `${API_BASE_URL}sendOtp`;
export const CONFIRM_OTP_URL = `${API_BASE_URL}confirmOtp`;
export const PAYMENT_CONFIRMATION_URL = `https://menu.fascano.com/payment/confirmation`;
export const DISCOUNT_URL = `${BASE_URL}getDiscount`;
+export const EGIFT_CARDS_URL = `${BASE_URL}gift/cards`;
\ No newline at end of file