preserve cart & checkout elment on refersh

This commit is contained in:
2025-12-31 16:23:37 +03:00
parent 71e1d71c96
commit 2416b37069
9 changed files with 46 additions and 34 deletions

View File

@@ -5,7 +5,7 @@ import PaymentMethods from "components/PaymentMethods/PaymentMethods";
import ProHeader from "components/ProHeader/ProHeader";
import { selectCart, updateCollectionMethod } from "features/order/orderSlice";
import { useTranslation } from "react-i18next";
import { useAppSelector } from "redux/hooks";
import { useAppDispatch, useAppSelector } from "redux/hooks";
import styles from "../address/address.module.css";
import { AddressSummary } from "./components/AddressSummary";
import CheckoutButton from "./components/CheckoutButton";
@@ -19,13 +19,18 @@ import BriefMenuCard from "./components/BriefMenuCard";
import CustomerInformationCard from "./components/CustomerInformationCard";
import Ads1 from "components/Ads/Ads1";
import TimeEstimateCard from "pages/cart/components/timeEstimate/TimeEstimateCard";
import { useEffect } from "react";
export default function CheckoutPage() {
const { t } = useTranslation();
const [form] = Form.useForm();
const { phone, order, orderType, collectionMethod } =
const { phone, order, orderType, collectionMethod, coupon } =
useAppSelector(selectCart);
const { token } = useAppSelector((state) => state.auth);
const dispatch = useAppDispatch();
useEffect(() => {
form.setFieldsValue({ coupon, collectionMethod });
}, [form, phone]);
return (
<>
@@ -93,9 +98,9 @@ export default function CheckoutPage() {
value={collectionMethod}
onRatioClick={(value) => {
if (value === "cod") {
updateCollectionMethod(value);
dispatch(updateCollectionMethod(value));
} else {
updateCollectionMethod(value);
dispatch(updateCollectionMethod(value));
}
}}
/>