fix(warehouse): disable Receive-At-Warehouse once booking is received

The Warehouse Information card kept the receive button active after the booking
already had an inventory record. Disable it (relabel "Received At Warehouse",
add a tooltip) when an inventory item exists.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hagernesh
2026-07-15 07:49:28 +00:00
parent b71a53c4a9
commit fd4c4d630f

View File

@@ -1,5 +1,5 @@
import { useState } from 'react';
import { Badge, Button, Card, Divider, Group, Stack, Text } from '@mantine/core';
import { Badge, Button, Card, Divider, Group, Stack, Text, Tooltip } from '@mantine/core';
import { PackagePlus, Train as TrainIcon, Warehouse as WarehouseIcon } from 'lucide-react';
import { useQuery } from '@tanstack/react-query';
@@ -126,14 +126,24 @@ export function WarehouseInfoCard({ bookingId, bookingReference }: WarehouseInfo
</>
)}
<Button
variant="light"
leftSection={<PackagePlus size={16} />}
onClick={() => setModalOpen(true)}
fullWidth
<Tooltip
label="This booking is already received at the warehouse"
disabled={!latest}
withArrow
>
Receive At Warehouse
</Button>
{/* span wrapper so the tooltip still fires on the disabled button */}
<span style={{ display: 'block' }}>
<Button
variant="light"
leftSection={<PackagePlus size={16} />}
onClick={() => setModalOpen(true)}
fullWidth
disabled={Boolean(latest)}
>
{latest ? 'Received At Warehouse' : 'Receive At Warehouse'}
</Button>
</span>
</Tooltip>
</Stack>
<ReceiveInventoryModal