mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 12:00:59 +00:00
Informational updates
This commit is contained in:
@@ -234,7 +234,7 @@ function DashboardPageContent() {
|
||||
)}
|
||||
|
||||
{/* Stat cards */}
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<StatCard
|
||||
icon={
|
||||
<BookOpen className="h-4 w-4 text-blue-600 dark:text-blue-400" />
|
||||
@@ -257,7 +257,28 @@ function DashboardPageContent() {
|
||||
},
|
||||
]}
|
||||
/>
|
||||
{/* Tickets card hidden temporarily */}
|
||||
<StatCard
|
||||
icon={
|
||||
<Ticket className="h-4 w-4 text-emerald-600 dark:text-emerald-400" />
|
||||
}
|
||||
iconBg="bg-emerald-100 dark:bg-emerald-900/30"
|
||||
label="Tickets"
|
||||
total={stats?.totalTickets ?? 0}
|
||||
loading={statsLoading}
|
||||
href="/tickets"
|
||||
rows={[
|
||||
{
|
||||
label: "Regular",
|
||||
value: stats?.totalNormalTickets ?? 0,
|
||||
href: "/tickets",
|
||||
},
|
||||
{
|
||||
label: "Package",
|
||||
value: stats?.totalPackageTickets ?? 0,
|
||||
href: "/tickets",
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
||||
{/* Revenue card */}
|
||||
<div className="card flex flex-col gap-3">
|
||||
|
||||
@@ -10,7 +10,7 @@ import ActionButton from '@/components/ui/ActionButton';
|
||||
import ConfirmDialog from '@/components/ui/ConfirmDialog';
|
||||
import Modal from '@/components/ui/Modal';
|
||||
import Image from 'next/image';
|
||||
import { ticketsApi, apiClient, stationsApi, excessBaggageApi } from '@/lib/api';
|
||||
import { ticketsApi, apiClient, stationsApi, excessBaggageApi, bookingsApi } from '@/lib/api';
|
||||
import Pagination from '@/components/ui/Pagination';
|
||||
import { formatDateTime, formatCurrency, formatDateTimeShort } from '@/lib/utils';
|
||||
import { useAuthStore } from '@/lib/auth-store';
|
||||
@@ -100,10 +100,21 @@ export default function TicketsPage() {
|
||||
|
||||
const [generateMissingResult, setGenerateMissingResult] = useState<any>(null);
|
||||
|
||||
const { data: hasMissingTickets } = useQuery({
|
||||
queryKey: ['bookings-missing-tickets'],
|
||||
queryFn: async () => {
|
||||
const res = await bookingsApi.getAll({ status: 'CONFIRMED', paymentStatus: 'SUCCEEDED', take: 50 });
|
||||
const items: any[] = (res as any)?.items ?? (Array.isArray(res) ? res : []);
|
||||
return items.some((b: any) => !b.tickets?.length);
|
||||
},
|
||||
refetchInterval: 30_000,
|
||||
});
|
||||
|
||||
const generateMissingMutation = useMutation({
|
||||
mutationFn: () => ticketsApi.generateMissing(),
|
||||
onSuccess: (result: any) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['tickets'] });
|
||||
queryClient.invalidateQueries({ queryKey: ['bookings-missing-tickets'] });
|
||||
setGenerateMissingResult(result);
|
||||
setSuccessMessage(`Generated ${result.generated} ticket(s) for ${result.processed} booking(s)${result.failed ? ` (${result.failed} failed)` : ''}`);
|
||||
setTimeout(() => setSuccessMessage(''), 6000);
|
||||
@@ -562,14 +573,16 @@ export default function TicketsPage() {
|
||||
<p className="text-muted-foreground">Manage tickets and validations</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<ActionButton
|
||||
icon={Download}
|
||||
variant="secondary"
|
||||
loading={generateMissingMutation.isPending}
|
||||
onClick={() => generateMissingMutation.mutate()}
|
||||
>
|
||||
Generate Missing
|
||||
</ActionButton>
|
||||
{hasMissingTickets && (
|
||||
<ActionButton
|
||||
icon={Download}
|
||||
variant="secondary"
|
||||
loading={generateMissingMutation.isPending}
|
||||
onClick={() => generateMissingMutation.mutate()}
|
||||
>
|
||||
Generate Missing
|
||||
</ActionButton>
|
||||
)}
|
||||
<ActionButton icon={Download} variant="export" onClick={() => setExportModalOpen(true)}>Export</ActionButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -128,6 +128,7 @@ function BookingDetailContent() {
|
||||
) {
|
||||
apiClient.post(`/tickets/generate/${booking.id}`, {}).then(() => refetch()).catch(() => {});
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [booking?.id, booking?.status, booking?.tickets?.length]);
|
||||
|
||||
const { data: paymentMethods } = useQuery<any[]>({
|
||||
@@ -151,6 +152,7 @@ function BookingDetailContent() {
|
||||
if (intentStatus?.status === "SUCCEEDED") {
|
||||
refetch();
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [intentStatus?.status]);
|
||||
|
||||
const selectedPaymentMethod =
|
||||
|
||||
@@ -974,9 +974,6 @@ const adultPassengerCount = searchCriteria?.adultCount ?? passengers.filter(p =>
|
||||
{(p as any).outboundCoachNumber && <span className="text-gray-500 dark:text-gray-400">{(p as any).outboundCoachNumber} — </span>}
|
||||
{(p as any).outboundSeatId ? (seatDetails[`outbound-${(p as any).outboundSeatId}`] || 'Loading...') : (isPkgFreeChild(i) || (!packageId && isChild(p) && isFirstChild(passengers, i)) ? '—' : 'Auto-assign')}
|
||||
</p>
|
||||
{(p as any).outboundSeatId && (
|
||||
<p className="text-[10px] text-gray-400 dark:text-gray-500 mt-0.5">{formatSeatClass(outboundSchedule)}</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="bg-gray-50 dark:bg-gray-800 rounded-lg px-3 py-2 text-right">
|
||||
<p className="text-xs text-gray-500 dark:text-gray-400">Return</p>
|
||||
@@ -984,9 +981,6 @@ const adultPassengerCount = searchCriteria?.adultCount ?? passengers.filter(p =>
|
||||
{(p as any).inboundCoachNumber && <span className="text-gray-500 dark:text-gray-400">{(p as any).inboundCoachNumber} — </span>}
|
||||
{(p as any).inboundSeatId ? (seatDetails[`inbound-${(p as any).inboundSeatId}`] || 'Loading...') : (isPkgFreeChild(i) || (!packageId && isChild(p) && isFirstChild(passengers, i)) ? '—' : 'Auto-assign')}
|
||||
</p>
|
||||
{(p as any).inboundSeatId && (
|
||||
<p className="text-[10px] text-gray-400 dark:text-gray-500 mt-0.5">{formatSeatClass(inboundSchedule)}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
@@ -996,9 +990,6 @@ const adultPassengerCount = searchCriteria?.adultCount ?? passengers.filter(p =>
|
||||
{p.coachNumber && <span className="text-gray-500 dark:text-gray-400">{p.coachNumber} — </span>}
|
||||
{p.seatId ? (seatDetails[p.seatId] || 'Loading...') : (isPkgFreeChild(i) || (!packageId && isChild(p) && isFirstChild(passengers, i)) ? '—' : 'Auto-assign')}
|
||||
</p>
|
||||
{p.seatId && (
|
||||
<p className="text-[10px] text-gray-400 dark:text-gray-500 mt-0.5">{formatSeatClass(selectedSchedule)}</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -783,7 +783,7 @@ export default function PackageDetailPage() {
|
||||
<Users className="w-5 h-5 text-primary mx-auto mb-1" />
|
||||
<p className="text-[10px] text-gray-400 uppercase tracking-wide">Available</p>
|
||||
<p className={`text-xs font-bold mt-0.5 ${availableSeats <= 20 ? "text-orange-500" : "text-gray-800 dark:text-white"}`}>
|
||||
{availableSeats} seats
|
||||
{pkg.priceTiers.filter((t) => t.availableSeats > 0).length} classes
|
||||
</p>
|
||||
</div>
|
||||
<div className="bg-white dark:bg-gray-900 rounded-xl p-4 border border-gray-100 dark:border-gray-800 text-center">
|
||||
|
||||
Reference in New Issue
Block a user