mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
Merge pull request #73 from Tria-plc/alpha
Removed old folders and files from passenger web apps
This commit is contained in:
@@ -28,6 +28,7 @@ export default function DashboardPage() {
|
||||
const recentBookings = Array.isArray(recentBookingsData)
|
||||
? recentBookingsData
|
||||
: recentBookingsData?.items || recentBookingsData?.data || [];
|
||||
: recentBookingsData?.items || recentBookingsData?.data || [];
|
||||
|
||||
const columns = [
|
||||
{ key: 'reference', label: 'Reference', render: (item: any) => item.bookingRef || item.reference },
|
||||
@@ -49,7 +50,7 @@ export default function DashboardPage() {
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold text-foreground">Dashboard</h1>
|
||||
<p className="text-muted-foreground mt-1">Welcome back! Here's what's happening today.</p>
|
||||
<p className="text-muted-foreground mt-1">Hello, welcome back! Here's what's happening today.</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-4">
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,86 +0,0 @@
|
||||
import { FormEvent, useState } from "react";
|
||||
import { Button, FormField } from "@edr/ui-common";
|
||||
|
||||
export interface ScheduleFormPayload {
|
||||
trainCode: string;
|
||||
originStationId: string;
|
||||
destinationStationId: string;
|
||||
departureTime: string;
|
||||
arrivalTime: string;
|
||||
basePrice: number;
|
||||
}
|
||||
|
||||
export interface ScheduleFormProps {
|
||||
onSubmit: (payload: ScheduleFormPayload) => void;
|
||||
isSubmitting?: boolean;
|
||||
}
|
||||
|
||||
const ScheduleForm = ({ onSubmit, isSubmitting }: ScheduleFormProps) => {
|
||||
const [trainCode, setTrainCode] = useState("");
|
||||
const [originStationId, setOriginStationId] = useState("");
|
||||
const [destinationStationId, setDestinationStationId] = useState("");
|
||||
const [departureTime, setDepartureTime] = useState("");
|
||||
const [arrivalTime, setArrivalTime] = useState("");
|
||||
const [basePrice, setBasePrice] = useState("0");
|
||||
|
||||
const handleSubmit = (event: FormEvent<HTMLFormElement>) => {
|
||||
event.preventDefault();
|
||||
onSubmit({
|
||||
trainCode,
|
||||
originStationId,
|
||||
destinationStationId,
|
||||
departureTime,
|
||||
arrivalTime,
|
||||
basePrice: Number(basePrice),
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit} className="flex flex-col gap-3">
|
||||
<FormField
|
||||
label="Train code"
|
||||
value={trainCode}
|
||||
onChange={(e) => setTrainCode(e.target.value)}
|
||||
required
|
||||
/>
|
||||
<FormField
|
||||
label="Origin station ID"
|
||||
value={originStationId}
|
||||
onChange={(e) => setOriginStationId(e.target.value)}
|
||||
required
|
||||
/>
|
||||
<FormField
|
||||
label="Destination station ID"
|
||||
value={destinationStationId}
|
||||
onChange={(e) => setDestinationStationId(e.target.value)}
|
||||
required
|
||||
/>
|
||||
<FormField
|
||||
label="Departure"
|
||||
type="datetime-local"
|
||||
value={departureTime}
|
||||
onChange={(e) => setDepartureTime(e.target.value)}
|
||||
required
|
||||
/>
|
||||
<FormField
|
||||
label="Arrival"
|
||||
type="datetime-local"
|
||||
value={arrivalTime}
|
||||
onChange={(e) => setArrivalTime(e.target.value)}
|
||||
required
|
||||
/>
|
||||
<FormField
|
||||
label="Base price"
|
||||
type="number"
|
||||
value={basePrice}
|
||||
onChange={(e) => setBasePrice(e.target.value)}
|
||||
min="0"
|
||||
/>
|
||||
<Button type="submit" isLoading={isSubmitting}>
|
||||
Publish schedule
|
||||
</Button>
|
||||
</form>
|
||||
);
|
||||
};
|
||||
|
||||
export default ScheduleForm;
|
||||
@@ -1,37 +0,0 @@
|
||||
import type { Passenger } from "@edr/types";
|
||||
import { Table, type TableColumn } from "@edr/ui-common";
|
||||
|
||||
export interface ScheduleTableProps {
|
||||
schedules: Passenger.ISchedule[];
|
||||
}
|
||||
|
||||
const columns: TableColumn<Passenger.ISchedule>[] = [
|
||||
{ key: "trainCode", header: "Train" },
|
||||
{ key: "status", header: "Status" },
|
||||
{
|
||||
key: "departureTime",
|
||||
header: "Departure",
|
||||
render: (row) => new Date(row.departureTime).toLocaleString(),
|
||||
},
|
||||
{
|
||||
key: "arrivalTime",
|
||||
header: "Arrival",
|
||||
render: (row) => new Date(row.arrivalTime).toLocaleString(),
|
||||
},
|
||||
{
|
||||
key: "basePrice",
|
||||
header: "Base price",
|
||||
render: (row) => row.basePrice.toFixed(2),
|
||||
},
|
||||
];
|
||||
|
||||
const ScheduleTable = ({ schedules }: ScheduleTableProps) => (
|
||||
<Table
|
||||
columns={columns}
|
||||
data={schedules}
|
||||
rowKey={(row) => row.id}
|
||||
emptyMessage="No schedules yet"
|
||||
/>
|
||||
);
|
||||
|
||||
export default ScheduleTable;
|
||||
@@ -1,42 +0,0 @@
|
||||
import clsx from "clsx";
|
||||
import type { Passenger } from "@edr/types";
|
||||
|
||||
export interface SeatSelectorProps {
|
||||
seats: Passenger.ISeat[];
|
||||
selectedSeatId?: string;
|
||||
onSelect: (seatId: string) => void;
|
||||
}
|
||||
|
||||
const SeatSelector = ({
|
||||
seats,
|
||||
selectedSeatId,
|
||||
onSelect,
|
||||
}: SeatSelectorProps) => (
|
||||
<div className="grid grid-cols-4 gap-2">
|
||||
{seats.map((seat) => {
|
||||
const isAvailable = seat.status === "AVAILABLE";
|
||||
const isSelected = seat.id === selectedSeatId;
|
||||
return (
|
||||
<button
|
||||
key={seat.id}
|
||||
type="button"
|
||||
disabled={!isAvailable}
|
||||
onClick={() => onSelect(seat.id)}
|
||||
className={clsx(
|
||||
"w-12 h-12 rounded flex items-center justify-center text-xs font-semibold transition-all",
|
||||
isSelected
|
||||
? "bg-primary text-white shadow-md scale-105"
|
||||
: isAvailable
|
||||
? "bg-green-100 hover:bg-green-200 text-green-800 hover:shadow-md"
|
||||
: "cursor-not-allowed bg-gray-200 text-gray-500 opacity-60",
|
||||
)}
|
||||
title={`Seat ${seat.seatNumber} - ${seat.status}`}
|
||||
>
|
||||
{seat.seatNumber}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
|
||||
export default SeatSelector;
|
||||
@@ -1,70 +0,0 @@
|
||||
import { FormEvent, useState } from "react";
|
||||
import { Button, FormField } from "@edr/ui-common";
|
||||
|
||||
import type { CreateTicketPayload } from "../../services/tickets.service";
|
||||
|
||||
export interface TicketFormProps {
|
||||
onSubmit: (payload: CreateTicketPayload) => void;
|
||||
isSubmitting?: boolean;
|
||||
}
|
||||
|
||||
const TicketForm = ({ onSubmit, isSubmitting }: TicketFormProps) => {
|
||||
const [reference, setReference] = useState("");
|
||||
const [passengerId, setPassengerId] = useState("");
|
||||
const [scheduleId, setScheduleId] = useState("");
|
||||
const [seatId, setSeatId] = useState("");
|
||||
const [pricePaid, setPricePaid] = useState("0");
|
||||
|
||||
const handleSubmit = (event: FormEvent<HTMLFormElement>) => {
|
||||
event.preventDefault();
|
||||
onSubmit({
|
||||
reference,
|
||||
passengerId,
|
||||
scheduleId,
|
||||
seatId,
|
||||
pricePaid: Number(pricePaid),
|
||||
issuedAt: new Date().toISOString(),
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit} className="flex flex-col gap-3">
|
||||
<FormField
|
||||
label="Reference"
|
||||
value={reference}
|
||||
onChange={(e) => setReference(e.target.value)}
|
||||
required
|
||||
/>
|
||||
<FormField
|
||||
label="Passenger ID"
|
||||
value={passengerId}
|
||||
onChange={(e) => setPassengerId(e.target.value)}
|
||||
required
|
||||
/>
|
||||
<FormField
|
||||
label="Schedule ID"
|
||||
value={scheduleId}
|
||||
onChange={(e) => setScheduleId(e.target.value)}
|
||||
required
|
||||
/>
|
||||
<FormField
|
||||
label="Seat ID"
|
||||
value={seatId}
|
||||
onChange={(e) => setSeatId(e.target.value)}
|
||||
required
|
||||
/>
|
||||
<FormField
|
||||
label="Price paid"
|
||||
type="number"
|
||||
value={pricePaid}
|
||||
onChange={(e) => setPricePaid(e.target.value)}
|
||||
min="0"
|
||||
/>
|
||||
<Button type="submit" isLoading={isSubmitting}>
|
||||
Issue ticket
|
||||
</Button>
|
||||
</form>
|
||||
);
|
||||
};
|
||||
|
||||
export default TicketForm;
|
||||
@@ -1,33 +0,0 @@
|
||||
import type { Passenger } from "@edr/types";
|
||||
import { Table, type TableColumn } from "@edr/ui-common";
|
||||
|
||||
export interface TicketTableProps {
|
||||
tickets: Passenger.ITicket[];
|
||||
}
|
||||
|
||||
const columns: TableColumn<Passenger.ITicket>[] = [
|
||||
{ key: "reference", header: "Reference" },
|
||||
{ key: "passengerId", header: "Passenger" },
|
||||
{ key: "status", header: "Status" },
|
||||
{
|
||||
key: "issuedAt",
|
||||
header: "Issued",
|
||||
render: (row) => new Date(row.issuedAt).toLocaleString(),
|
||||
},
|
||||
{
|
||||
key: "pricePaid",
|
||||
header: "Price",
|
||||
render: (row) => row.pricePaid.toFixed(2),
|
||||
},
|
||||
];
|
||||
|
||||
const TicketTable = ({ tickets }: TicketTableProps) => (
|
||||
<Table
|
||||
columns={columns}
|
||||
data={tickets}
|
||||
rowKey={(row) => row.id}
|
||||
emptyMessage="No tickets yet"
|
||||
/>
|
||||
);
|
||||
|
||||
export default TicketTable;
|
||||
@@ -1,16 +0,0 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { schedulesService } from "../services/schedules.service";
|
||||
|
||||
export const useSchedules = () =>
|
||||
useQuery({
|
||||
queryKey: ["schedules"],
|
||||
queryFn: schedulesService.list,
|
||||
});
|
||||
|
||||
export const useSchedule = (id: string) =>
|
||||
useQuery({
|
||||
queryKey: ["schedules", id],
|
||||
queryFn: () => schedulesService.get(id),
|
||||
enabled: Boolean(id),
|
||||
});
|
||||
@@ -1,9 +0,0 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { stationsService } from "../services/stations.service";
|
||||
|
||||
export const useStations = () =>
|
||||
useQuery({
|
||||
queryKey: ["stations"],
|
||||
queryFn: stationsService.list,
|
||||
});
|
||||
@@ -1,16 +0,0 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { ticketsService } from "../services/tickets.service";
|
||||
|
||||
export const useTickets = () =>
|
||||
useQuery({
|
||||
queryKey: ["tickets"],
|
||||
queryFn: ticketsService.list,
|
||||
});
|
||||
|
||||
export const useTicket = (id: string) =>
|
||||
useQuery({
|
||||
queryKey: ["tickets", id],
|
||||
queryFn: () => ticketsService.get(id),
|
||||
enabled: Boolean(id),
|
||||
});
|
||||
@@ -1,14 +0,0 @@
|
||||
import type { Passenger } from "@edr/types";
|
||||
|
||||
import { api } from "../utils/api";
|
||||
|
||||
export const schedulesService = {
|
||||
list: async (): Promise<Passenger.ISchedule[]> => {
|
||||
const { data } = await api.get("/schedules");
|
||||
return data.data;
|
||||
},
|
||||
get: async (id: string): Promise<Passenger.ISchedule> => {
|
||||
const { data } = await api.get(`/schedules/${id}`);
|
||||
return data.data;
|
||||
},
|
||||
};
|
||||
@@ -1,14 +0,0 @@
|
||||
// import type { IStation } from "../types";
|
||||
import { api } from "../utils/api";
|
||||
import type { Passenger } from "@edr/types";
|
||||
|
||||
export const stationsService = {
|
||||
list: async (): Promise<Passenger.IStation[]> => {
|
||||
const { data } = await api.get("/stations");
|
||||
return data.data;
|
||||
},
|
||||
get: async (id: string): Promise<Passenger.IStation> => {
|
||||
const { data } = await api.get(`/stations/${id}`);
|
||||
return data.data;
|
||||
},
|
||||
};
|
||||
@@ -1,30 +0,0 @@
|
||||
import type { Passenger, PaginatedResponse } from "@edr/types";
|
||||
|
||||
import { api } from "../utils/api";
|
||||
|
||||
export interface CreateTicketPayload {
|
||||
reference: string;
|
||||
passengerId: string;
|
||||
scheduleId: string;
|
||||
seatId: string;
|
||||
pricePaid: number;
|
||||
issuedAt: string;
|
||||
}
|
||||
|
||||
export const ticketsService = {
|
||||
list: async (): Promise<PaginatedResponse<Passenger.ITicket>> => {
|
||||
const { data } = await api.get("/tickets");
|
||||
return data.data;
|
||||
},
|
||||
get: async (id: string): Promise<Passenger.ITicket> => {
|
||||
const { data } = await api.get(`/tickets/${id}`);
|
||||
return data.data;
|
||||
},
|
||||
create: async (payload: CreateTicketPayload): Promise<Passenger.ITicket> => {
|
||||
const { data } = await api.post("/tickets", payload);
|
||||
return data.data;
|
||||
},
|
||||
cancel: async (id: string): Promise<void> => {
|
||||
await api.delete(`/tickets/${id}`);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user