mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 17:38:12 +00:00
booking operations and trains scheduling also allocations
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
import { ArrowRight, Package, Train } from "lucide-react";
|
||||
import {
|
||||
Badge,
|
||||
Button,
|
||||
Group,
|
||||
Paper,
|
||||
Stack,
|
||||
Tabs,
|
||||
Text,
|
||||
} from "@mantine/core";
|
||||
|
||||
import type { EligibleContainerBooking, FreightType } from "@/types/trainScheduling";
|
||||
|
||||
import { EligibleBookingsPanel } from "./EligibleBookingsPanel";
|
||||
|
||||
export type AssignedBookingRow = {
|
||||
id: string;
|
||||
reference: string;
|
||||
weightTons?: number;
|
||||
};
|
||||
|
||||
export function ScheduleBookingsStep({
|
||||
assignedBookings,
|
||||
eligibleItems,
|
||||
eligibleLoading,
|
||||
selectedIds,
|
||||
onSelectionChange,
|
||||
assignedIds,
|
||||
freightType,
|
||||
canRemove,
|
||||
onRemove,
|
||||
}: {
|
||||
assignedBookings: AssignedBookingRow[];
|
||||
eligibleItems: EligibleContainerBooking[];
|
||||
eligibleLoading?: boolean;
|
||||
selectedIds: string[];
|
||||
onSelectionChange: (ids: string[]) => void;
|
||||
assignedIds?: string[];
|
||||
freightType?: FreightType;
|
||||
canRemove?: boolean;
|
||||
onRemove?: (bookingId: string) => void;
|
||||
}) {
|
||||
return (
|
||||
<Paper p="md" radius="xl" withBorder>
|
||||
<Tabs defaultValue={assignedBookings.length ? "on-train" : "add"} radius="lg" variant="pills">
|
||||
<Tabs.List mb="md">
|
||||
<Tabs.Tab
|
||||
value="on-train"
|
||||
leftSection={<Train size={14} />}
|
||||
rightSection={
|
||||
assignedBookings.length ? (
|
||||
<Badge size="xs" variant="light" color="teal" circle>
|
||||
{assignedBookings.length}
|
||||
</Badge>
|
||||
) : undefined
|
||||
}
|
||||
>
|
||||
On this train
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab value="add" leftSection={<Package size={14} />}>
|
||||
Add bookings
|
||||
</Tabs.Tab>
|
||||
</Tabs.List>
|
||||
|
||||
<Tabs.Panel value="on-train">
|
||||
{assignedBookings.length ? (
|
||||
<Stack gap="sm">
|
||||
{assignedBookings.map((booking) => (
|
||||
<Group
|
||||
key={booking.id}
|
||||
justify="space-between"
|
||||
p="sm"
|
||||
style={{
|
||||
border: "1px solid var(--mantine-color-gray-3)",
|
||||
borderRadius: 10,
|
||||
background: "var(--mantine-color-teal-0)",
|
||||
}}
|
||||
>
|
||||
<Stack gap={4}>
|
||||
<Group gap="xs">
|
||||
<Text fw={600} size="sm">
|
||||
{booking.reference}
|
||||
</Text>
|
||||
{booking.weightTons != null ? (
|
||||
<Badge variant="outline" size="xs">
|
||||
{booking.weightTons}T
|
||||
</Badge>
|
||||
) : null}
|
||||
</Group>
|
||||
<Group gap={6}>
|
||||
<Text size="xs" c="dimmed">
|
||||
Assigned to this consist
|
||||
</Text>
|
||||
<ArrowRight size={12} />
|
||||
<Text size="xs" c="teal">
|
||||
Ready for wagon plan
|
||||
</Text>
|
||||
</Group>
|
||||
</Stack>
|
||||
{canRemove && onRemove ? (
|
||||
<Button
|
||||
variant="subtle"
|
||||
color="red"
|
||||
size="compact-xs"
|
||||
onClick={() => onRemove(booking.id)}
|
||||
>
|
||||
Remove
|
||||
</Button>
|
||||
) : null}
|
||||
</Group>
|
||||
))}
|
||||
</Stack>
|
||||
) : (
|
||||
<Text size="sm" c="dimmed" ta="center" py="lg">
|
||||
No bookings on this train yet. Use the Add bookings tab to select eligible cargo.
|
||||
</Text>
|
||||
)}
|
||||
</Tabs.Panel>
|
||||
|
||||
<Tabs.Panel value="add">
|
||||
<EligibleBookingsPanel
|
||||
items={eligibleItems}
|
||||
isLoading={eligibleLoading}
|
||||
selectedIds={selectedIds}
|
||||
onSelectionChange={onSelectionChange}
|
||||
assignedIds={assignedIds}
|
||||
freightType={freightType}
|
||||
/>
|
||||
</Tabs.Panel>
|
||||
</Tabs>
|
||||
</Paper>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user