mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
Merge pull request #74 from Tria-plc/alpha
Remove old files and fix data assignment in passenger dashboard
This commit is contained in:
@@ -20,15 +20,14 @@ export default function DashboardPage() {
|
||||
queryFn: () => dashboardApi.getRevenueChart(30),
|
||||
});
|
||||
|
||||
const { data: recentBookingsData, isLoading: bookingsLoading } = useQuery({
|
||||
const { data: recentBookingsData, isLoading: bookingsLoading } = useQuery<any>({
|
||||
queryKey: ['recent-bookings'],
|
||||
queryFn: () => dashboardApi.getRecentBookings(10),
|
||||
});
|
||||
|
||||
const recentBookings = Array.isArray(recentBookingsData)
|
||||
? recentBookingsData
|
||||
: recentBookingsData?.items || recentBookingsData?.data || [];
|
||||
: recentBookingsData?.items || recentBookingsData?.data || [];
|
||||
: recentBookingsData?.items || recentBookingsData?.data || [];
|
||||
|
||||
const columns = [
|
||||
{ key: 'reference', label: 'Reference', render: (item: any) => item.bookingRef || item.reference },
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
const DashboardPage = () => (
|
||||
<div className="flex flex-col gap-4">
|
||||
<h1 className="text-2xl font-semibold text-gray-900">
|
||||
Passenger Dashboard
|
||||
</h1>
|
||||
<p className="text-sm text-gray-600">
|
||||
Daily ridership, ticket sales, occupancy by class, and schedule status go
|
||||
here.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
|
||||
export default DashboardPage;
|
||||
@@ -1,10 +0,0 @@
|
||||
const PassengersPage = () => (
|
||||
<div className="flex flex-col gap-4">
|
||||
<h1 className="text-2xl font-semibold text-gray-900">Passengers</h1>
|
||||
<p className="text-sm text-gray-600">
|
||||
Passenger directory. Connect to <code>/passengers</code> when ready.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
|
||||
export default PassengersPage;
|
||||
@@ -1,36 +0,0 @@
|
||||
import { useParams } from "react-router-dom";
|
||||
|
||||
import { useSchedule } from "@/hooks/useSchedules";
|
||||
|
||||
const ScheduleDetailPage = () => {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const { data, isLoading } = useSchedule(id ?? "");
|
||||
|
||||
if (isLoading) return <div className="text-sm text-gray-500">Loading…</div>;
|
||||
if (!data)
|
||||
return <div className="text-sm text-red-600">Schedule not found.</div>;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<h1 className="text-2xl font-semibold text-gray-900">
|
||||
Schedule {data.trainCode}
|
||||
</h1>
|
||||
<dl className="grid grid-cols-2 gap-2 text-sm">
|
||||
<dt className="text-gray-500">Status</dt>
|
||||
<dd className="text-gray-900">{data.status}</dd>
|
||||
<dt className="text-gray-500">Departure</dt>
|
||||
<dd className="text-gray-900">
|
||||
{new Date(data.departureTime).toLocaleString()}
|
||||
</dd>
|
||||
<dt className="text-gray-500">Arrival</dt>
|
||||
<dd className="text-gray-900">
|
||||
{new Date(data.arrivalTime).toLocaleString()}
|
||||
</dd>
|
||||
<dt className="text-gray-500">Base price</dt>
|
||||
<dd className="text-gray-900">{data.basePrice.toFixed(2)}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ScheduleDetailPage;
|
||||
@@ -1,20 +0,0 @@
|
||||
import ScheduleTable from "../../components/schedules/ScheduleTable";
|
||||
import { useSchedules } from "../../hooks/useSchedules";
|
||||
|
||||
const SchedulesPage = () => {
|
||||
const { data, isLoading } = useSchedules();
|
||||
const items = data ?? [];
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<h1 className="text-2xl font-semibold text-gray-900">Schedules</h1>
|
||||
{isLoading ? (
|
||||
<div className="text-sm text-gray-500">Loading…</div>
|
||||
) : (
|
||||
<ScheduleTable schedules={items} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SchedulesPage;
|
||||
@@ -1,32 +0,0 @@
|
||||
import { Table, type TableColumn } from "@edr/ui-common";
|
||||
import type { Passenger } from "@edr/types";
|
||||
|
||||
import { useStations } from "../../hooks/useStations";
|
||||
|
||||
const columns: TableColumn<Passenger.IStation>[] = [
|
||||
{ key: "code", header: "Code" },
|
||||
{ key: "name", header: "Name" },
|
||||
{ key: "city", header: "City" },
|
||||
{ key: "country", header: "Country" },
|
||||
];
|
||||
|
||||
const StationsPage = () => {
|
||||
const { data, isLoading } = useStations();
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<h1 className="text-2xl font-semibold text-gray-900">Stations</h1>
|
||||
{isLoading ? (
|
||||
<div className="text-sm text-gray-500">Loading…</div>
|
||||
) : (
|
||||
<Table
|
||||
columns={columns}
|
||||
data={data ?? []}
|
||||
rowKey={(row) => row.id}
|
||||
emptyMessage="No stations"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default StationsPage;
|
||||
@@ -1,32 +0,0 @@
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
import TicketForm from "../../components/tickets/TicketForm";
|
||||
import { ticketsService } from "../../services/tickets.service";
|
||||
|
||||
const BookTicketPage = () => {
|
||||
const navigate = useNavigate();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: ticketsService.create,
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["tickets"] });
|
||||
navigate("/tickets");
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="max-w-lg">
|
||||
<h1 className="mb-4 text-2xl font-semibold text-gray-900">
|
||||
Issue ticket
|
||||
</h1>
|
||||
<TicketForm
|
||||
onSubmit={mutation.mutate}
|
||||
isSubmitting={mutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default BookTicketPage;
|
||||
@@ -1,38 +0,0 @@
|
||||
import { useParams } from "react-router-dom";
|
||||
|
||||
import { useTicket } from "../../hooks/useTickets";
|
||||
|
||||
const TicketDetailPage = () => {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const { data, isLoading } = useTicket(id ?? "");
|
||||
|
||||
if (isLoading) return <div className="text-sm text-gray-500">Loading…</div>;
|
||||
if (!data)
|
||||
return <div className="text-sm text-red-600">Ticket not found.</div>;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<h1 className="text-2xl font-semibold text-gray-900">
|
||||
Ticket {data.reference}
|
||||
</h1>
|
||||
<dl className="grid grid-cols-2 gap-2 text-sm">
|
||||
<dt className="text-gray-500">Passenger ID</dt>
|
||||
<dd className="text-gray-900">{data.passengerId}</dd>
|
||||
<dt className="text-gray-500">Schedule ID</dt>
|
||||
<dd className="text-gray-900">{data.scheduleId}</dd>
|
||||
<dt className="text-gray-500">Seat ID</dt>
|
||||
<dd className="text-gray-900">{data.seatId}</dd>
|
||||
<dt className="text-gray-500">Status</dt>
|
||||
<dd className="text-gray-900">{data.status}</dd>
|
||||
<dt className="text-gray-500">Issued</dt>
|
||||
<dd className="text-gray-900">
|
||||
{new Date(data.issuedAt).toLocaleString()}
|
||||
</dd>
|
||||
<dt className="text-gray-500">Price paid</dt>
|
||||
<dd className="text-gray-900">{data.pricePaid.toFixed(2)}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TicketDetailPage;
|
||||
@@ -1,28 +0,0 @@
|
||||
import { Link } from "react-router-dom";
|
||||
import { Button } from "@edr/ui-common";
|
||||
|
||||
import TicketTable from "../../components/tickets/TicketTable";
|
||||
import { useTickets } from "../../hooks/useTickets";
|
||||
|
||||
const TicketsPage = () => {
|
||||
const { data, isLoading } = useTickets();
|
||||
const items = data?.items ?? [];
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-2xl font-semibold text-gray-900">Tickets</h1>
|
||||
<Link to="/tickets/new">
|
||||
<Button>Issue ticket</Button>
|
||||
</Link>
|
||||
</div>
|
||||
{isLoading ? (
|
||||
<div className="text-sm text-gray-500">Loading…</div>
|
||||
) : (
|
||||
<TicketTable tickets={items} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TicketsPage;
|
||||
Reference in New Issue
Block a user