updates
This commit is contained in:
@@ -31,10 +31,12 @@ import {
|
||||
import { confirmBankTransfer } from
|
||||
'../../services/api/paymentService';
|
||||
import Loading from '../../components/common/Loading';
|
||||
import { useFormatCurrency } from '../../hooks/useFormatCurrency';
|
||||
|
||||
const BookingSuccessPage: React.FC = () => {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const { formatCurrency } = useFormatCurrency();
|
||||
|
||||
const [booking, setBooking] = useState<Booking | null>(
|
||||
null
|
||||
@@ -72,6 +74,21 @@ const BookingSuccessPage: React.FC = () => {
|
||||
const bookingData = response.data.booking;
|
||||
setBooking(bookingData);
|
||||
|
||||
// Check for pending Stripe payment
|
||||
if (bookingData.payment_method === 'stripe' && bookingData.payments) {
|
||||
const pendingStripePayment = bookingData.payments.find(
|
||||
(p: any) =>
|
||||
p.payment_method === 'stripe' &&
|
||||
p.payment_status === 'pending'
|
||||
);
|
||||
|
||||
if (pendingStripePayment) {
|
||||
// Redirect to payment page for Stripe payment
|
||||
navigate(`/payment/${bookingId}`, { replace: true });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Redirect to deposit payment page if required and not yet paid
|
||||
if (
|
||||
bookingData.requires_deposit &&
|
||||
@@ -106,12 +123,7 @@ const BookingSuccessPage: React.FC = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const formatPrice = (price: number) => {
|
||||
return new Intl.NumberFormat('de-DE', {
|
||||
style: 'currency',
|
||||
currency: 'EUR',
|
||||
}).format(price);
|
||||
};
|
||||
const formatPrice = (price: number) => formatCurrency(price);
|
||||
|
||||
const getStatusColor = (status: string) => {
|
||||
switch (status) {
|
||||
@@ -369,9 +381,13 @@ const BookingSuccessPage: React.FC = () => {
|
||||
{roomType && (
|
||||
<div className="border-b pb-4">
|
||||
<div className="flex items-start gap-4">
|
||||
{roomType.images?.[0] && (
|
||||
{((room?.images && room.images.length > 0)
|
||||
? room.images[0]
|
||||
: roomType.images?.[0]) && (
|
||||
<img
|
||||
src={roomType.images[0]}
|
||||
src={(room?.images && room.images.length > 0)
|
||||
? room.images[0]
|
||||
: (roomType.images?.[0] || '')}
|
||||
alt={roomType.name}
|
||||
className="w-24 h-24 object-cover
|
||||
rounded-lg"
|
||||
@@ -395,7 +411,7 @@ const BookingSuccessPage: React.FC = () => {
|
||||
<p className="text-indigo-600
|
||||
font-semibold mt-1"
|
||||
>
|
||||
{formatPrice(roomType.base_price)}/night
|
||||
{formatPrice(room?.price || roomType.base_price)}/night
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user