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 { 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 { PackagePlus, Train as TrainIcon, Warehouse as WarehouseIcon } from 'lucide-react';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
@@ -126,14 +126,24 @@ export function WarehouseInfoCard({ bookingId, bookingReference }: WarehouseInfo
</> </>
)} )}
<Button <Tooltip
variant="light" label="This booking is already received at the warehouse"
leftSection={<PackagePlus size={16} />} disabled={!latest}
onClick={() => setModalOpen(true)} withArrow
fullWidth
> >
Receive At Warehouse {/* span wrapper so the tooltip still fires on the disabled button */}
</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> </Stack>
<ReceiveInventoryModal <ReceiveInventoryModal