import { Center, Loader, Text, Timeline } from '@mantine/core'; import { ArrowRightLeft, ClipboardCheck, PackageCheck, PackagePlus, Send, Truck, Warehouse, } from 'lucide-react'; import { useQuery } from '@tanstack/react-query'; import { api } from '@/services/api'; import type { ActivityType } from '@/types/warehouse'; import { formatDate, humanizeEnum } from './options'; const activityIcon: Record = { INVENTORY_RECEIVED: , INVENTORY_STORED: , INVENTORY_MOVED: , INVENTORY_RESERVED: , READY_FOR_LOADING: , INVENTORY_LOADED: , INVENTORY_DISPATCHED: , }; export function ActivityTimeline({ inventoryId }: { inventoryId: string }) { const { data, isLoading } = useQuery( api.warehouses.activity.queryOptions({ input: { id: inventoryId }, enabled: Boolean(inventoryId), }), ); const items = data ?? []; if (isLoading) { return (
); } if (items.length === 0) { return ( No activity recorded yet. ); } return ( {items.map((log) => ( {log.description && ( {log.description} )} {log.performedBy ?? 'system'} ยท {formatDate(log.createdAt)} ))} ); }