From 0dbba7f80eaac0e6db42f6cab467b282dd55f607 Mon Sep 17 00:00:00 2001 From: aryabenade Date: Sun, 26 Apr 2026 19:52:31 +0530 Subject: [PATCH 1/3] select the same card on checkout page which we select on the buy cards page Co-authored-by: Copilot --- src/pages/CheckoutPage.tsx | 14 ++++++++------ src/pages/PassesPage.tsx | 9 ++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/pages/CheckoutPage.tsx b/src/pages/CheckoutPage.tsx index b6b8a79..151a0e8 100644 --- a/src/pages/CheckoutPage.tsx +++ b/src/pages/CheckoutPage.tsx @@ -6,7 +6,7 @@ import { import Navbar from '../components/Navbar'; import { Footer } from '../components/Footer'; import { ImageWithFallback } from '../components/figma/ImageWithFallback'; -import { useNavigate } from 'react-router-dom'; +import { useLocation, useNavigate } from 'react-router-dom'; import { useAddCardToCartMutation, useGetCheckoutPageDataQuery } from '../Redux/services/cards.service'; import LoadingSpinner from '../components/LoadingSpinner'; import { toast } from 'sonner'; @@ -187,9 +187,9 @@ function CheckoutConfigCard({ if (bookingId) { navigate(`/payment/${bookingId}`) } else { - throw new Error(response?.error?.data?.message) + throw new Error(response?.error?.data?.message) } - } catch (error:any) { + } catch (error: any) { toast.error(error.message); } } @@ -307,6 +307,7 @@ export function CheckoutPage({ currentPage, }: any) { const navigate = useNavigate(); + const location = useLocation() // Default item (you can pass via props later) const baseUrl = import.meta.env.VITE_BASE_URL; @@ -320,11 +321,12 @@ export function CheckoutPage({ const flexiCard = checkoutPageData?.cards[0] ?? null const unlimitedCard = checkoutPageData?.cards[1] ?? null const attractions = checkoutPageData?.attractions ?? []; - - const [checkoutItem, setCheckoutItem] = useState(flexiCard); + + const selectedCard = location.state?.selectedCard === "selective_pass" ? flexiCard : unlimitedCard + const [checkoutItem, setCheckoutItem] = useState(selectedCard); useEffect(() => { - setCheckoutItem(flexiCard) + setCheckoutItem(selectedCard) }, [cards]) if (isLoading) { diff --git a/src/pages/PassesPage.tsx b/src/pages/PassesPage.tsx index 3396a39..2900536 100644 --- a/src/pages/PassesPage.tsx +++ b/src/pages/PassesPage.tsx @@ -166,11 +166,10 @@ export function PassesPage({ return () } - - const handleCheckoutClick = () => { + const handleCheckoutClick = (cardTypeName:string) => { console.log('Proceeding to checkout for user:', user); // Add your checkout logic here - navigate('/checkout'); + navigate('/checkout', { state: { selectedCard: cardTypeName } }); }; const handleSignInClick = () => { @@ -283,7 +282,7 @@ export function PassesPage({ ? "bg-primary hover:bg-primary/90 text-white hover:shadow-lg" : "bg-gray-400 hover:bg-gray-400 text-white hover:shadow-md" }`} - onClick={user ? handleCheckoutClick : handleSignInClick} + onClick={() => user ? handleCheckoutClick(cards[0]?.cardType?.cardTypeName) : handleSignInClick} disabled={selectedPass !== passTypes[0].id} > @@ -373,7 +372,7 @@ export function PassesPage({ }`} disabled={selectedPass !== passTypes[1].id} - onClick={user ? handleCheckoutClick : handleSignInClick} + onClick={() => user ? handleCheckoutClick(cards[1]?.cardType?.cardTypeName) : handleSignInClick} > {user ? 'PURCHASE NOW' : 'LOGIN TO BUY PASS'} -- 2.34.1 From 13780803ba96e045bb83836c4904d21bb9c9d08d Mon Sep 17 00:00:00 2001 From: aryabenade Date: Sun, 26 Apr 2026 23:43:33 +0530 Subject: [PATCH 2/3] add the ScrollToTop Component Co-authored-by: Copilot --- src/components/ScrollToTop.tsx | 12 ++++++++++++ src/main.tsx | 2 ++ 2 files changed, 14 insertions(+) create mode 100644 src/components/ScrollToTop.tsx diff --git a/src/components/ScrollToTop.tsx b/src/components/ScrollToTop.tsx new file mode 100644 index 0000000..bf31b9e --- /dev/null +++ b/src/components/ScrollToTop.tsx @@ -0,0 +1,12 @@ +import { useEffect } from "react"; +import { useLocation } from "react-router-dom"; + +export function ScrollToTop() { + const { pathname } = useLocation(); + + useEffect(() => { + window.scrollTo(0, 0); + }, [pathname]); + + return null; +} diff --git a/src/main.tsx b/src/main.tsx index cfff6d7..0133335 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -5,11 +5,13 @@ import "./index.css"; import { Provider } from "react-redux"; import { store } from "./Redux/Store"; import { Toaster } from "sonner"; +import { ScrollToTop } from "./components/ScrollToTop"; createRoot(document.getElementById("root")!).render( + -- 2.34.1 From 05f134fdbaed73b42c13005fa6346e3cf3527af5 Mon Sep 17 00:00:00 2001 From: aryabenade Date: Mon, 27 Apr 2026 11:22:54 +0530 Subject: [PATCH 3/3] change the padding of navbar --- src/components/Navbar.tsx | 2 +- src/pages/PassesPage.tsx | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 77e2b50..2e2351e 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -501,7 +501,7 @@ export default function Navbar({ >
) -- 2.34.1