cart & checkout: apply validation based on required inputs in each service & add phone input in checkout page
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { colors } from "ThemeConstants.ts";
|
||||
import { Button, FormInstance } from "antd";
|
||||
import { Button, FormInstance, message } from "antd";
|
||||
import { selectCart } from "features/order/orderSlice.ts";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link, useNavigate, useParams } from "react-router-dom";
|
||||
@@ -17,15 +17,15 @@ export default function CartFooter({ form }: CartFooterProps) {
|
||||
const orderType = localStorage.getItem("orderType");
|
||||
const navigate = useNavigate();
|
||||
|
||||
// Check if checkout should be disabled
|
||||
const isCheckoutDisabled = items.length === 0;
|
||||
|
||||
const handleCheckoutClick = async () => {
|
||||
try {
|
||||
await form.validateFields();
|
||||
navigate(`/${id}/checkout`);
|
||||
} catch (error) {
|
||||
console.log("Form validation failed:", error);
|
||||
if (items.length === 0) message.warning(t("cart.pleaseAddItemsToCart"));
|
||||
else {
|
||||
try {
|
||||
await form.validateFields();
|
||||
navigate(`/${id}/checkout`);
|
||||
} catch (error) {
|
||||
console.log("Form validation failed:", error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -60,7 +60,6 @@ export default function CartFooter({ form }: CartFooterProps) {
|
||||
color: "white",
|
||||
width: "100%",
|
||||
}}
|
||||
disabled={isCheckoutDisabled}
|
||||
onClick={handleCheckoutClick}
|
||||
>
|
||||
{t("cart.checkout")}
|
||||
|
||||
Reference in New Issue
Block a user