pay flow: initial commit
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Badge, Button } from "antd";
|
||||
import CartIcon from "components/Icons/cart/CartIcon";
|
||||
import { selectCartItems } from "features/order/orderSlice";
|
||||
import { OrderType } from "pages/checkout/hooks/types";
|
||||
import { useCallback } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useAppSelector } from "redux/hooks";
|
||||
@@ -11,10 +12,17 @@ export function CartButton() {
|
||||
const { subdomain } = useParams();
|
||||
const navigate = useNavigate();
|
||||
const items = useAppSelector(selectCartItems);
|
||||
const { orderType } = useAppSelector((s) => s.order);
|
||||
|
||||
const onCartClick = useCallback(() => {
|
||||
navigate(`/${subdomain}/cart`);
|
||||
}, [navigate, subdomain]);
|
||||
console.log(orderType);
|
||||
|
||||
navigate(
|
||||
orderType === OrderType.Pay
|
||||
? `/${subdomain}/pay`
|
||||
: `/${subdomain}/menu?orderType=${orderType}`,
|
||||
);
|
||||
}, [navigate, subdomain, orderType]);
|
||||
|
||||
const totalItems = items.reduce((sum, item) => sum + item.quantity, 0);
|
||||
|
||||
@@ -26,7 +34,7 @@ export function CartButton() {
|
||||
right: !isRTL ? "auto" : "20px",
|
||||
left: !isRTL ? "20px" : "auto",
|
||||
}}
|
||||
className={'cart-button'}
|
||||
className={"cart-button"}
|
||||
>
|
||||
<Badge count={totalItems} size="default" className={styles.badge}>
|
||||
<Button
|
||||
|
||||
@@ -3,6 +3,7 @@ import CartIcon from "components/Icons/cart/CartIcon";
|
||||
import ProText from "components/ProText";
|
||||
import { selectCartItems } from "features/order/orderSlice";
|
||||
import useBreakPoint from "hooks/useBreakPoint";
|
||||
import { OrderType } from "pages/checkout/hooks/types";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link, useParams } from "react-router-dom";
|
||||
import { useAppSelector } from "redux/hooks";
|
||||
@@ -14,9 +15,11 @@ export function MenuFooter() {
|
||||
const { isMobile, isTablet } = useBreakPoint();
|
||||
const { t } = useTranslation();
|
||||
const { subdomain } = useParams();
|
||||
|
||||
const { orderType } = useAppSelector((s) => s.order);
|
||||
const totalItems = items.length;
|
||||
|
||||
console.log(orderType);
|
||||
|
||||
return (
|
||||
<>
|
||||
{(isMobile || isTablet) && (
|
||||
@@ -37,7 +40,11 @@ export function MenuFooter() {
|
||||
}}
|
||||
>
|
||||
<Link
|
||||
to={`/${subdomain}/cart`}
|
||||
to={
|
||||
orderType === OrderType.Pay
|
||||
? `/${subdomain}/pay`
|
||||
: `/${subdomain}/cart`
|
||||
}
|
||||
style={{
|
||||
width: "100%",
|
||||
padding: "0 16px",
|
||||
|
||||
Reference in New Issue
Block a user