Merge pull request #640 from Tria-plc/freight_feature/usermanagement

Freight feature/usermanagement
This commit is contained in:
marshal
2026-07-13 08:13:01 +03:00
committed by GitHub
120 changed files with 3798 additions and 1409 deletions

View File

@@ -24,9 +24,10 @@ export interface GlShipmentQuantities {
hazardousQuantity: number;
reeferQuantity: number;
}>;
/** Bulk: tons (or item count) + hazardous qty. */
/** Bulk: tons (or item count) + hazardous/reefer qty. */
bulkQuantity: number;
bulkHazardousQuantity: number;
bulkReeferQuantity: number;
}
/**
@@ -113,6 +114,30 @@ export function computeGlShipmentTotal(
amount: rate.unitPrice * qty,
});
}
if (contract.isHazardous && q.bulkHazardousQuantity > 0) {
const hz = rateFor((i) => i.conditionalOn === "is_hazardous");
if (hz) {
lines.push({
label: hz.label,
unitPrice: hz.unitPrice,
unit: hz.unit,
quantity: q.bulkHazardousQuantity,
amount: hz.unitPrice * q.bulkHazardousQuantity,
});
}
}
if (contract.isReefer && q.bulkReeferQuantity > 0) {
const rf = rateFor((i) => i.conditionalOn === "is_reefer");
if (rf) {
lines.push({
label: rf.label,
unitPrice: rf.unitPrice,
unit: rf.unit,
quantity: q.bulkReeferQuantity,
amount: rf.unitPrice * q.bulkReeferQuantity,
});
}
}
}
const total = lines.reduce((s, l) => s + l.amount, 0);

View File

@@ -137,8 +137,12 @@ export function AllocateBookingWizard({
enabled: opened,
}),
);
// Paginated {items, meta} list; the newest 100 schedules comfortably cover
// every DRAFT schedule the wizard can attach to.
const schedulesQuery = useQuery(
api.trainScheduling.scheduleList.queryOptions({ input: {} }),
api.trainScheduling.scheduleList.queryOptions({
input: { filters: { pageSize: 100 } },
}),
);
const routesQuery = useQuery(
api.routes.list.queryOptions({ input: { status: "AVAILABLE" } }),
@@ -163,7 +167,7 @@ export function AllocateBookingWizard({
const matchingSchedules = useMemo(
() =>
(schedulesQuery.data ?? []).filter(
(schedulesQuery.data?.items ?? []).filter(
(s: TrainScheduleListItem) =>
s.status === "DRAFT" &&
(!s.freightType || s.freightType === "MIXED" || s.freightType === bookingFreightType),

View File

@@ -1,4 +1,4 @@
import { useMemo, useState } from "react";
import { memo, useMemo, useState } from "react";
import {
Box,
Group,
@@ -267,7 +267,13 @@ function CapacityDivider({ used, max }: { used: number; max: number | null }) {
);
}
export function PriorityTrackingTab({ data, bookings }: Props) {
// Memoized: mounted in a keep-mounted Tabs panel, so it re-renders with every
// page render; both props keep their identity across unrelated page state
// (React Query structural sharing + the page's useMemo'd bookings).
export const PriorityTrackingTab = memo(function PriorityTrackingTab({
data,
bookings,
}: Props) {
const phase = data.windowPhase;
const isPayPhase = phase === "PAYMENT";
@@ -558,7 +564,7 @@ export function PriorityTrackingTab({ data, bookings }: Props) {
) : null}
</Stack>
);
}
});
/** Contextual banner describing the current window phase in plain language. */
function PhaseBanner({ phase }: { phase: string | null }) {