mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 12:18:11 +00:00
Fix price on voucher
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import { Suspense, useState } from 'react';
|
||||
import { Suspense, useEffect, useState } from 'react';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import { Download, Eye, Trash2, AlertCircle, Send, CheckCircle, XCircle, RotateCcw, X } from 'lucide-react';
|
||||
import DataTable from '@/components/ui/DataTable';
|
||||
import Badge from '@/components/ui/Badge';
|
||||
@@ -56,18 +56,28 @@ const SectionHeader = ({ title }: { title: string }) => (
|
||||
);
|
||||
|
||||
function PaymentsPageContent() {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
// A link can pre-filter this page — the dashboard's Revenue card links here with
|
||||
// status=SUCCEEDED&bookingStatus=CONFIRMED,BOARDED so "view payments" shows exactly the
|
||||
// payments that make up that revenue figure, not every payment attempt.
|
||||
const initialBookingStatus = searchParams.get('bookingStatus') ?? '';
|
||||
const [pageTab, setPageTab] = useState<PageTab>('payments');
|
||||
const [filters, setFilters] = useState({
|
||||
search: '',
|
||||
status: searchParams.get('status') ?? '',
|
||||
method: '',
|
||||
bookingStatus: initialBookingStatus,
|
||||
bookingStatus: searchParams.get('bookingStatus') ?? '',
|
||||
});
|
||||
|
||||
// useState's initializer only runs on first mount — if this page was already mounted from
|
||||
// an earlier visit (e.g. the sidebar link), Next's client-side navigation to a new
|
||||
// ?status=...&bookingStatus=... URL does NOT remount the component, so the filters above
|
||||
// would silently keep whatever was set before. Re-sync whenever the URL itself changes.
|
||||
useEffect(() => {
|
||||
const status = searchParams.get('status') ?? '';
|
||||
const bookingStatus = searchParams.get('bookingStatus') ?? '';
|
||||
setFilters((f) => (f.status === status && f.bookingStatus === bookingStatus ? f : { ...f, status, bookingStatus }));
|
||||
}, [searchParams]);
|
||||
const [selectedPayment, setSelectedPayment] = useState<any>(null);
|
||||
const [deleteConfirmOpen, setDeleteConfirmOpen] = useState(false);
|
||||
const [paymentToDelete, setPaymentToDelete] = useState<any>(null);
|
||||
@@ -319,7 +329,7 @@ function PaymentsPageContent() {
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setFilters({ ...filters, status: '', bookingStatus: '' })}
|
||||
onClick={() => { setFilters({ ...filters, status: '', bookingStatus: '' }); router.replace('/payments'); }}
|
||||
className="flex items-center gap-1 font-medium hover:underline shrink-0 ml-3"
|
||||
>
|
||||
<X className="w-3.5 h-3.5" /> Clear
|
||||
|
||||
Reference in New Issue
Block a user