Add contractKind field to BookingWindowRow and MyBookingWindow interfaces

This commit is contained in:
Marshal
2026-07-03 20:15:31 +00:00
parent ff9cb4e6cd
commit c3f06b6aa9
3 changed files with 10 additions and 3 deletions

View File

@@ -176,6 +176,7 @@ const DEFAULT_TRAIN_LIMITS: Required<TrainLimitConfig> = {
interface BookingWindowRow {
schedule_id: string;
contract_id: string | null;
contract_kind: string | null;
direction: string | null;
window_phase: string | null;
window_opens_at: Date | null;
@@ -3129,6 +3130,7 @@ export class TrainSchedulingService {
const rows: Array<BookingWindowRow> = await this.dataSource.query(
`SELECT DISTINCT ts.id AS schedule_id,
cr.contract_id AS contract_id,
c.contract_kind AS contract_kind,
ts.direction,
ts.window_phase,
ts.window_opens_at,
@@ -3149,7 +3151,6 @@ export class TrainSchedulingService {
ON c.id = cr.contract_id
AND c.company_id = $1
AND c.status IN ('CONTRACT_ACTIVE', 'FULLY_EXECUTED')
AND c.contract_kind = 'GENERAL'
AND c.deleted_at IS NULL
LEFT JOIN freight.yards oy ON oy.id = ts.origin_station_id
LEFT JOIN freight.yards dy ON dy.id = ts.destination_station_id
@@ -3173,6 +3174,7 @@ export class TrainSchedulingService {
const rows: Array<BookingWindowRow> = await this.dataSource.query(
`SELECT DISTINCT ts.id AS schedule_id,
cr.contract_id AS contract_id,
c.contract_kind AS contract_kind,
ts.direction,
ts.window_phase,
ts.window_opens_at,
@@ -3192,7 +3194,6 @@ export class TrainSchedulingService {
AND cr.deleted_at IS NULL
JOIN freight.contracts c
ON c.id = cr.contract_id
AND c.contract_kind = 'GENERAL'
AND c.deleted_at IS NULL
LEFT JOIN freight.yards oy ON oy.id = ts.origin_station_id
LEFT JOIN freight.yards dy ON dy.id = ts.destination_station_id
@@ -3211,6 +3212,7 @@ export class TrainSchedulingService {
return {
scheduleId: r.schedule_id,
contractId: r.contract_id,
contractKind: r.contract_kind,
direction: r.direction,
windowPhase: r.window_phase,
isOpenNow: r.window_phase === 'OPEN' && r.booking_window_status === 'OPEN',

View File

@@ -221,7 +221,10 @@ export const UpcomingWindowsSection = memo(function UpcomingWindowsSection({
<Group gap={8} wrap="nowrap" style={{ flexShrink: 0 }}>
<DirectionBadge direction={w.direction} />
<StatusBadge window={w} />
{w.isOpenNow && (
{/* ONE_TIME contracts book via their own single-shipment flow,
not window drawdown — show the window + countdown but no
"Book now" entry. */}
{w.isOpenNow && w.contractKind !== "ONE_TIME" && (
<Button
size="xs"
radius="md"

View File

@@ -55,6 +55,8 @@ export interface MyBookingWindow {
scheduleId: string;
/** Contract whose route this window belongs to, when the row carries it. */
contractId: string | null;
/** ONE_TIME contracts can't draw down against a window — button is hidden. */
contractKind: "ONE_TIME" | "GENERAL" | null;
direction: "IMPORT" | "EXPORT" | null;
windowPhase: string | null;
isOpenNow: boolean;