import { Divider, Image } from "antd"; import ProInputCard from "components/ProInputCard/ProInputCard"; import ProText from "components/ProText"; import { selectCart } from "features/order/orderSlice"; import { EGiftCard } from "pages/CardDetails/type"; import { useTranslation } from "react-i18next"; import { useGetEGiftCardsQuery } from "redux/api/others"; import { useAppSelector } from "redux/hooks"; import styles from "./GiftDetails.module.css"; import { useNavigate, useParams } from "react-router-dom"; import InvoiceIcon from "components/Icons/order/InvoiceIcon"; import BackIcon from "components/Icons/BackIcon"; import NextIcon from "components/Icons/NextIcon"; import { useMemo, useState } from "react"; import CardAmountIcon from "components/Icons/CardAmountIcon"; import ArabicPrice from "components/ArabicPrice"; import { GiftAmountBottomSheet } from "pages/CardDetails/components/GiftAmountBottomSheet"; import { GiftType } from "components/CustomBottomSheet/GiftTypeBottomSheet"; export function GiftCard() { const { t } = useTranslation(); const { giftDetails, items } = useAppSelector(selectCart); const { data: cards } = useGetEGiftCardsQuery(); const currentCard = cards?.find( (card: EGiftCard) => card.id == giftDetails?.cardId, ); const navigate = useNavigate(); const { subdomain } = useParams(); const { isRTL } = useAppSelector((state) => state.locale); const totalItems = useMemo(() => { return items.length || 0; }, [items]); const [isGiftAmountBottomSheetOpen, setIsGiftAmountBottomSheetOpen] = useState(false); console.log(giftDetails?.giftType); return ( <>
{ navigate(`/${subdomain}/card-details`); }} >
{t("checkout.giftSummary")} {t("checkout.holdayGiftCard")} - {t("checkout.messageIncluded")}
{t("checkout.to")} : {giftDetails?.receiverName}
{isRTL ? : }
{(giftDetails?.giftType === GiftType.Vouchers || giftDetails?.giftType === GiftType.ItemsAndVouchers) && ( <>
{ setIsGiftAmountBottomSheetOpen(true); }} >
{t("checkout.cardBalance")}
{isRTL ? : }
{giftDetails?.giftType === GiftType.ItemsAndVouchers && ( )} )} {(giftDetails?.giftType === GiftType.Items || giftDetails?.giftType === GiftType.ItemsAndVouchers) && (
{ navigate(`/${subdomain}/cart`); }} > {t("checkout.viewOrder")} ( {totalItems} {t("cart.items")} ) {isRTL ? : }
)}
setIsGiftAmountBottomSheetOpen(false)} /> ); }