main #9

Merged
Hemant.Vishwakarma merged 3 commits from main into testing 2026-04-22 12:15:34 +00:00
3 changed files with 30 additions and 33 deletions

View File

@@ -692,7 +692,8 @@ export default function Navbar({
label: 'My Profile',
icon: <User className="w-4 h-4" />,
action: () => {
navigate(citySelected ? `/${slugify(cityName)}/profile` : '/profile');
// navigate(citySelected ? `/${slugify(cityName)}/profile` : '/profile');
navigate(citySelected ? `/profile` : '/profile');
setActiveUserDropdown(false);
}
},

View File

@@ -23,9 +23,10 @@ export function PaymentCancelPage({
}: PaymentCancelPageProps) {
const navigate = useNavigate();
// ✅ Clear pending booking ID when user cancels
// ✅ Clear stored booking ID when user cancels
useEffect(() => {
localStorage.removeItem('pendingBookingId');
sessionStorage.removeItem('pendingBookingId');
}, []);
return (
@@ -64,12 +65,20 @@ export function PaymentCancelPage({
<p className="text-[#555] mt-2">
You cancelled the payment process. No charges have been made.
</p>
<button
onClick={() => navigate(-1)}
className="mt-6 px-6 py-3 bg-[#F95F62] text-white rounded-xl font-medium hover:bg-[#e8545a] transition"
>
Go Back & Try Again
</button>
<div className="mt-6 flex flex-col sm:flex-row gap-3 justify-center">
<button
onClick={() => navigate(-1)}
className="px-6 py-3 bg-[#F95F62] text-white rounded-xl font-medium hover:bg-[#e8545a] transition"
>
Go Back & Try Again
</button>
<button
onClick={onHomeClick}
className="px-6 py-3 bg-gray-200 text-[#2a2a2a] rounded-xl font-medium hover:bg-gray-300 transition"
>
Return to Home
</button>
</div>
</div>
</div>

View File

@@ -24,7 +24,6 @@ export function PaymentSuccessPage({
user,
}: PaymentSuccessPageProps) {
const [searchParams] = useSearchParams();
const sessionId = searchParams.get('session_id');
const [confirmPayment, { isLoading }] = useConfirmCardPaymentMutation();
const [status, setStatus] = useState<'loading' | 'success' | 'error'>('loading');
const [errorMsg, setErrorMsg] = useState<string>('');
@@ -32,55 +31,43 @@ export function PaymentSuccessPage({
useEffect(() => {
const confirm = async () => {
// Try multiple sources for bookingId
// Try multiple sources to get bookingId
let bookingId = localStorage.getItem('pendingBookingId');
if (!bookingId) {
bookingId = sessionStorage.getItem('pendingBookingId');
}
// Optional: if you have bookingId in URL query param (e.g., ?bookingId=123)
const urlBookingId = searchParams.get('bookingId');
if (!bookingId && urlBookingId) {
bookingId = urlBookingId;
}
if (!bookingId) bookingId = sessionStorage.getItem('pendingBookingId');
if (!bookingId) bookingId = searchParams.get('bookingId'); // URL query param
console.log('Retrieved bookingId:', bookingId);
console.log('SessionId from URL:', sessionId);
if (!bookingId) {
setStatus('error');
setErrorMsg(
'Missing booking information. Please contact support with your order reference. ' +
'Booking ID not found. Please contact support with your order details. ' +
'If you just completed payment, your order may still be processing.'
);
return;
}
if (!sessionId) {
setStatus('error');
setErrorMsg('Missing session ID. Please contact support.');
return;
}
try {
await confirmPayment({ bookingId, sessionId }).unwrap();
// ✅ Call confirm API with only bookingId
await confirmPayment(bookingId).unwrap();
setStatus('success');
toast.success('Payment confirmed! Your order is complete.');
// Clean up storage
localStorage.removeItem('pendingBookingId');
sessionStorage.removeItem('pendingBookingId');
} catch (err: any) {
console.error('Payment confirmation error:', err);
console.error('Confirmation error:', err);
setStatus('error');
setErrorMsg(err?.data?.message || 'Payment could not be confirmed. Please contact support.');
toast.error('Payment confirmation failed');
// Clean up storage to avoid infinite loops
setErrorMsg(err?.data?.message || 'Failed to confirm payment. Please contact support.');
toast.error('Confirmation failed');
// Clean up to avoid retry loops
localStorage.removeItem('pendingBookingId');
sessionStorage.removeItem('pendingBookingId');
}
};
confirm();
}, [sessionId, confirmPayment, searchParams]);
}, [confirmPayment, searchParams]);
return (
<div className="min-h-screen bg-[#fafafa] font-poppins">