@burdenoff/microfe-theglobalfuel 2026.704.1 → 2026.705.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node_modules/{.bun/clsx@2.1.1/node_modules/clsx → clsx}/dist/clsx.js +1 -1
- package/dist/node_modules/clsx/dist/clsx.js.map +1 -0
- package/dist/node_modules/{.bun/tailwind-merge@3.5.0/node_modules/tailwind-merge → tailwind-merge}/dist/bundle-mjs.js +212 -170
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js.map +1 -0
- package/dist/theglobalfuel/components/DataTable.js +37 -27
- package/dist/theglobalfuel/components/DataTable.js.map +1 -1
- package/dist/theglobalfuel/hooks/index.js +1 -0
- package/dist/theglobalfuel/hooks/useNotify.js +19 -0
- package/dist/theglobalfuel/hooks/useNotify.js.map +1 -0
- package/dist/theglobalfuel/hooks/useTheFiles.js +4 -1
- package/dist/theglobalfuel/hooks/useTheFiles.js.map +1 -1
- package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.js +59 -31
- package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.js.map +1 -1
- package/dist/theglobalfuel/pages/assets/AssetDetailPage.js +367 -321
- package/dist/theglobalfuel/pages/assets/AssetDetailPage.js.map +1 -1
- package/dist/theglobalfuel/pages/assets/AssetsPage.js +66 -54
- package/dist/theglobalfuel/pages/assets/AssetsPage.js.map +1 -1
- package/dist/theglobalfuel/pages/compliance/CompliancePage.js +346 -182
- package/dist/theglobalfuel/pages/compliance/CompliancePage.js.map +1 -1
- package/dist/theglobalfuel/pages/contracts/ContractDetailPage.js +418 -390
- package/dist/theglobalfuel/pages/contracts/ContractDetailPage.js.map +1 -1
- package/dist/theglobalfuel/pages/contracts/ContractsPage.js +238 -230
- package/dist/theglobalfuel/pages/contracts/ContractsPage.js.map +1 -1
- package/dist/theglobalfuel/pages/dashboard/DashboardPage.js +5 -3
- package/dist/theglobalfuel/pages/dashboard/DashboardPage.js.map +1 -1
- package/dist/theglobalfuel/pages/emissions/EmissionsPage.js +201 -177
- package/dist/theglobalfuel/pages/emissions/EmissionsPage.js.map +1 -1
- package/dist/theglobalfuel/pages/inventory/InventoryPage.js +271 -238
- package/dist/theglobalfuel/pages/inventory/InventoryPage.js.map +1 -1
- package/dist/theglobalfuel/pages/production/ProductionPage.js +185 -177
- package/dist/theglobalfuel/pages/production/ProductionPage.js.map +1 -1
- package/dist/theglobalfuel/pages/reserves/ReservesPage.js +160 -138
- package/dist/theglobalfuel/pages/reserves/ReservesPage.js.map +1 -1
- package/dist/theglobalfuel/pages/shipments/ShipmentsPage.js +250 -198
- package/dist/theglobalfuel/pages/shipments/ShipmentsPage.js.map +1 -1
- package/dist/theglobalfuel/utils/cn.js +2 -2
- package/dist/theglobalfuel/utils/formatters.js +6 -1
- package/dist/theglobalfuel/utils/formatters.js.map +1 -1
- package/dist/theglobalfuel/utils/transitions.js +70 -0
- package/dist/theglobalfuel/utils/transitions.js.map +1 -0
- package/package.json +1 -1
- package/dist/dev/main.d.ts +0 -2
- package/dist/dev/main.d.ts.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js.map +0 -1
- package/dist/node_modules/.bun/tailwind-merge@3.5.0/node_modules/tailwind-merge/dist/bundle-mjs.js.map +0 -1
- package/dist/theglobalfuel/TheGlobalFuelRoot.d.ts +0 -5
- package/dist/theglobalfuel/TheGlobalFuelRoot.d.ts.map +0 -1
- package/dist/theglobalfuel/TheGlobalFuelRoutes.d.ts +0 -4
- package/dist/theglobalfuel/TheGlobalFuelRoutes.d.ts.map +0 -1
- package/dist/theglobalfuel/components/DataTable.d.ts +0 -28
- package/dist/theglobalfuel/components/DataTable.d.ts.map +0 -1
- package/dist/theglobalfuel/components/EmptyState.d.ts +0 -18
- package/dist/theglobalfuel/components/EmptyState.d.ts.map +0 -1
- package/dist/theglobalfuel/components/EvidenceUpload.d.ts +0 -14
- package/dist/theglobalfuel/components/EvidenceUpload.d.ts.map +0 -1
- package/dist/theglobalfuel/components/FileLink.d.ts +0 -15
- package/dist/theglobalfuel/components/FileLink.d.ts.map +0 -1
- package/dist/theglobalfuel/components/FilterTabs.d.ts +0 -18
- package/dist/theglobalfuel/components/FilterTabs.d.ts.map +0 -1
- package/dist/theglobalfuel/components/MetricsCard.d.ts +0 -23
- package/dist/theglobalfuel/components/MetricsCard.d.ts.map +0 -1
- package/dist/theglobalfuel/components/MiniBar.d.ts +0 -16
- package/dist/theglobalfuel/components/MiniBar.d.ts.map +0 -1
- package/dist/theglobalfuel/components/PageLayout.d.ts +0 -16
- package/dist/theglobalfuel/components/PageLayout.d.ts.map +0 -1
- package/dist/theglobalfuel/components/Pagination.d.ts +0 -22
- package/dist/theglobalfuel/components/Pagination.d.ts.map +0 -1
- package/dist/theglobalfuel/components/StateViews.d.ts +0 -24
- package/dist/theglobalfuel/components/StateViews.d.ts.map +0 -1
- package/dist/theglobalfuel/components/StatusBadge.d.ts +0 -9
- package/dist/theglobalfuel/components/StatusBadge.d.ts.map +0 -1
- package/dist/theglobalfuel/components/Tabs.d.ts +0 -17
- package/dist/theglobalfuel/components/Tabs.d.ts.map +0 -1
- package/dist/theglobalfuel/components/TheDiscussion.d.ts +0 -18
- package/dist/theglobalfuel/components/TheDiscussion.d.ts.map +0 -1
- package/dist/theglobalfuel/components/TheTags.d.ts +0 -17
- package/dist/theglobalfuel/components/TheTags.d.ts.map +0 -1
- package/dist/theglobalfuel/components/index.d.ts +0 -19
- package/dist/theglobalfuel/components/index.d.ts.map +0 -1
- package/dist/theglobalfuel/context/TheGlobalFuelContext.d.ts +0 -16
- package/dist/theglobalfuel/context/TheGlobalFuelContext.d.ts.map +0 -1
- package/dist/theglobalfuel/context/index.d.ts +0 -6
- package/dist/theglobalfuel/context/index.d.ts.map +0 -1
- package/dist/theglobalfuel/hooks/index.d.ts +0 -10
- package/dist/theglobalfuel/hooks/index.d.ts.map +0 -1
- package/dist/theglobalfuel/hooks/useCursorPager.d.ts +0 -33
- package/dist/theglobalfuel/hooks/useCursorPager.d.ts.map +0 -1
- package/dist/theglobalfuel/hooks/useTheComments.d.ts +0 -36
- package/dist/theglobalfuel/hooks/useTheComments.d.ts.map +0 -1
- package/dist/theglobalfuel/hooks/useTheFiles.d.ts +0 -47
- package/dist/theglobalfuel/hooks/useTheFiles.d.ts.map +0 -1
- package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.d.ts +0 -75
- package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.d.ts.map +0 -1
- package/dist/theglobalfuel/hooks/useTheTags.d.ts +0 -44
- package/dist/theglobalfuel/hooks/useTheTags.d.ts.map +0 -1
- package/dist/theglobalfuel/index.d.ts +0 -9
- package/dist/theglobalfuel/index.d.ts.map +0 -1
- package/dist/theglobalfuel/pages/assets/AssetDetailPage.d.ts +0 -13
- package/dist/theglobalfuel/pages/assets/AssetDetailPage.d.ts.map +0 -1
- package/dist/theglobalfuel/pages/assets/AssetsPage.d.ts +0 -10
- package/dist/theglobalfuel/pages/assets/AssetsPage.d.ts.map +0 -1
- package/dist/theglobalfuel/pages/compliance/CompliancePage.d.ts +0 -11
- package/dist/theglobalfuel/pages/compliance/CompliancePage.d.ts.map +0 -1
- package/dist/theglobalfuel/pages/contracts/ContractDetailPage.d.ts +0 -9
- package/dist/theglobalfuel/pages/contracts/ContractDetailPage.d.ts.map +0 -1
- package/dist/theglobalfuel/pages/contracts/ContractsPage.d.ts +0 -8
- package/dist/theglobalfuel/pages/contracts/ContractsPage.d.ts.map +0 -1
- package/dist/theglobalfuel/pages/dashboard/DashboardPage.d.ts +0 -13
- package/dist/theglobalfuel/pages/dashboard/DashboardPage.d.ts.map +0 -1
- package/dist/theglobalfuel/pages/emissions/EmissionsPage.d.ts +0 -12
- package/dist/theglobalfuel/pages/emissions/EmissionsPage.d.ts.map +0 -1
- package/dist/theglobalfuel/pages/inventory/InventoryPage.d.ts +0 -11
- package/dist/theglobalfuel/pages/inventory/InventoryPage.d.ts.map +0 -1
- package/dist/theglobalfuel/pages/production/ProductionPage.d.ts +0 -11
- package/dist/theglobalfuel/pages/production/ProductionPage.d.ts.map +0 -1
- package/dist/theglobalfuel/pages/reserves/ReservesPage.d.ts +0 -10
- package/dist/theglobalfuel/pages/reserves/ReservesPage.d.ts.map +0 -1
- package/dist/theglobalfuel/pages/shipments/ShipmentsPage.d.ts +0 -10
- package/dist/theglobalfuel/pages/shipments/ShipmentsPage.d.ts.map +0 -1
- package/dist/theglobalfuel/types/index.d.ts +0 -376
- package/dist/theglobalfuel/types/index.d.ts.map +0 -1
- package/dist/theglobalfuel/utils/cn.d.ts +0 -4
- package/dist/theglobalfuel/utils/cn.d.ts.map +0 -1
- package/dist/theglobalfuel/utils/formatters.d.ts +0 -36
- package/dist/theglobalfuel/utils/formatters.d.ts.map +0 -1
- package/dist/theglobalfuel/utils/i18n.d.ts +0 -6
- package/dist/theglobalfuel/utils/i18n.d.ts.map +0 -1
- package/dist/theglobalfuel/utils/index.d.ts +0 -9
- package/dist/theglobalfuel/utils/index.d.ts.map +0 -1
- package/dist/theglobalfuel/utils/navigation.d.ts +0 -14
- package/dist/theglobalfuel/utils/navigation.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShipmentsPage.js","names":[],"sources":["../../../../src/theglobalfuel/pages/shipments/ShipmentsPage.tsx"],"sourcesContent":["/**\n * Shipments — schedule and track cargo movements against offtake contracts.\n * @module theglobalfuel/pages/shipments\n *\n * Reads `theListShipments` (plain array, filtered by contract + status) and\n * `theListContracts` (to resolve contract references + populate the picker);\n * writes `theScheduleShipment` and `theDeliverShipment`.\n */\n\nimport { useMemo, useState } from 'react';\nimport { Plus, Ship, CalendarClock, Truck, PackageCheck, ArrowRight } from 'lucide-react';\nimport {\n Button,\n Input,\n Label,\n Textarea,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n} from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../../components/PageLayout';\nimport { MetricsCard } from '../../components/MetricsCard';\nimport { StatusBadge } from '../../components/StatusBadge';\nimport { DataTable, type Column } from '../../components/DataTable';\nimport { FilterTabs, type FilterOption } from '../../components/FilterTabs';\nimport { LoadingView, ErrorView } from '../../components/StateViews';\nimport { EmptyState } from '../../components/EmptyState';\nimport { FileLink } from '../../components/FileLink';\nimport { EvidenceUpload } from '../../components/EvidenceUpload';\nimport {\n useTheShipments,\n useTheContracts,\n useTheScheduleShipment,\n useTheDeliverShipment,\n type UploadedTheFile,\n} from '../../hooks';\nimport { formatEnumLabel, formatDate, formatVolume } from '../../utils/formatters';\nimport type {\n TheShipment,\n TheShipmentStatus,\n TheTransportMode,\n TheUnit,\n TheOfftakeContract,\n} from '../../types';\n\nconst STATUS_FILTERS: Array<{ value: TheShipmentStatus | 'ALL'; label: string }> = [\n { value: 'ALL', label: 'All' },\n { value: 'SCHEDULED', label: 'Scheduled' },\n { value: 'LOADING', label: 'Loading' },\n { value: 'IN_TRANSIT', label: 'In transit' },\n { value: 'DELIVERED', label: 'Delivered' },\n { value: 'CANCELLED', label: 'Cancelled' },\n];\n\nconst TRANSPORT_MODES: TheTransportMode[] = [\n 'PIPELINE',\n 'TANKER',\n 'VESSEL_BULK',\n 'RAIL',\n 'TRUCK',\n 'GRID',\n];\n\nconst UNITS: TheUnit[] = ['BARRELS', 'CUBIC_METERS', 'TONNES', 'KILOGRAMS', 'MWH', 'GJ', 'MCF'];\n\ninterface ScheduleFormState {\n contractId: string;\n reference: string;\n mode: TheTransportMode;\n carrier: string;\n origin: string;\n destination: string;\n volume: string;\n unit: TheUnit;\n scheduledAt: string;\n notes: string;\n}\n\nconst EMPTY_FORM: ScheduleFormState = {\n contractId: '',\n reference: '',\n mode: 'TANKER',\n carrier: '',\n origin: '',\n destination: '',\n volume: '',\n unit: 'BARRELS',\n scheduledAt: '',\n notes: '',\n};\n\nexport function ShipmentsPage() {\n const [status, setStatus] = useState<TheShipmentStatus | 'ALL'>('ALL');\n const [contractId, setContractId] = useState<string | 'ALL'>('ALL');\n const [dialogOpen, setDialogOpen] = useState(false);\n const [form, setForm] = useState<ScheduleFormState>(EMPTY_FORM);\n const [doc, setDoc] = useState<UploadedTheFile | null>(null);\n const [formError, setFormError] = useState<string | null>(null);\n\n const scopedContractId = contractId === 'ALL' ? undefined : contractId;\n\n // Table query — respects both the contract scope and the status filter.\n const { data, isLoading, isError, refetch } = useTheShipments(\n scopedContractId,\n status === 'ALL' ? undefined : status\n );\n // Metrics query — same contract scope but ignores the status filter so the\n // header counts stay stable as the table is narrowed. When status is ALL both\n // queries share a react-query key and no extra request is made.\n const metricsQuery = useTheShipments(scopedContractId, undefined);\n\n // Contracts drive the picker + let us resolve a shipment's contract reference.\n const contractsQuery = useTheContracts({ pagination: { limit: 100 } });\n const contractItems = useMemo(\n () => contractsQuery.data?.items ?? [],\n [contractsQuery.data]\n );\n const contractMap = useMemo(() => {\n const map = new Map<string, TheOfftakeContract>();\n for (const c of contractItems) map.set(c.id, c);\n return map;\n }, [contractItems]);\n\n const scheduleShipment = useTheScheduleShipment();\n const deliverShipment = useTheDeliverShipment();\n\n const rows = useMemo(() => data ?? [], [data]);\n const metricsRows = useMemo(() => metricsQuery.data ?? [], [metricsQuery.data]);\n\n // ── Header metrics (derived from the contract-scoped, status-agnostic list) ──\n const scheduledCount = metricsRows.filter((s) => s.status === 'SCHEDULED').length;\n const inTransitCount = metricsRows.filter((s) => s.status === 'IN_TRANSIT').length;\n const deliveredCount = metricsRows.filter((s) => s.status === 'DELIVERED').length;\n\n const statusCounts = useMemo(() => {\n const counts: Record<string, number> = {};\n for (const s of metricsRows) counts[s.status] = (counts[s.status] ?? 0) + 1;\n return counts;\n }, [metricsRows]);\n\n const filterOptions: FilterOption<TheShipmentStatus | 'ALL'>[] = STATUS_FILTERS.map((opt) => ({\n value: opt.value,\n label: opt.label,\n count: opt.value === 'ALL' ? metricsRows.length : (statusCounts[opt.value] ?? 0),\n }));\n\n const resetForm = () => {\n setForm(EMPTY_FORM);\n setDoc(null);\n setFormError(null);\n };\n\n const handleSchedule = async () => {\n if (!form.contractId) {\n setFormError('Select the contract this shipment fulfils.');\n return;\n }\n if (!form.reference.trim()) {\n setFormError('A shipment reference is required.');\n return;\n }\n const volume = Number(form.volume);\n if (!form.volume || Number.isNaN(volume) || volume <= 0) {\n setFormError('Enter a volume greater than zero.');\n return;\n }\n setFormError(null);\n try {\n await scheduleShipment.mutateAsync({\n contractId: form.contractId,\n reference: form.reference.trim(),\n mode: form.mode,\n carrier: form.carrier.trim() || null,\n origin: form.origin.trim() || null,\n destination: form.destination.trim() || null,\n volume,\n unit: form.unit,\n scheduledAt: form.scheduledAt ? new Date(form.scheduledAt).toISOString() : null,\n documentFileId: doc?.fileId ?? null,\n notes: form.notes.trim() || null,\n });\n setDialogOpen(false);\n resetForm();\n } catch (err) {\n setFormError(err instanceof Error ? err.message : 'Failed to schedule shipment.');\n }\n };\n\n const columns: Column<TheShipment>[] = [\n {\n key: 'reference',\n header: 'Shipment',\n render: (s) => (\n <div className=\"min-w-0\">\n <p className=\"truncate font-semibold text-text-primary\">{s.reference}</p>\n <p className=\"truncate text-xs text-text-tertiary md:hidden\">{formatEnumLabel(s.mode)}</p>\n </div>\n ),\n },\n {\n key: 'contract',\n header: 'Contract',\n hideOnMobile: true,\n render: (s) => {\n const contract = contractMap.get(s.contractId);\n return contract ? (\n <div className=\"min-w-0\">\n <p className=\"truncate font-medium text-text-primary\">{contract.reference}</p>\n <p className=\"truncate text-xs text-text-tertiary\">{contract.counterparty}</p>\n </div>\n ) : (\n <span className=\"font-mono text-xs text-text-tertiary\">{s.contractId.slice(0, 8)}</span>\n );\n },\n },\n {\n key: 'mode',\n header: 'Mode',\n hideOnMobile: true,\n render: (s) => <span className=\"text-text-secondary\">{formatEnumLabel(s.mode)}</span>,\n },\n {\n key: 'status',\n header: 'Status',\n render: (s) => <StatusBadge status={s.status} />,\n },\n {\n key: 'route',\n header: 'Route',\n hideOnMobile: true,\n render: (s) => {\n const origin = s.origin?.trim();\n const destination = s.destination?.trim();\n if (!origin && !destination) return <span className=\"text-text-tertiary\">—</span>;\n return (\n <span className=\"inline-flex items-center gap-1.5 text-text-secondary\">\n <span className=\"truncate\">{origin ?? '—'}</span>\n <ArrowRight className=\"h-3.5 w-3.5 shrink-0 text-text-tertiary\" />\n <span className=\"truncate\">{destination ?? '—'}</span>\n </span>\n );\n },\n },\n {\n key: 'volume',\n header: 'Volume',\n align: 'right',\n sortValue: (s) => s.volume,\n render: (s) => (\n <span className=\"tabular-nums text-text-primary\">{formatVolume(s.volume, s.unit)}</span>\n ),\n },\n {\n key: 'scheduledAt',\n header: 'Scheduled',\n align: 'right',\n hideOnMobile: true,\n sortValue: (s) => s.scheduledAt ?? '',\n render: (s) => <span className=\"text-text-tertiary\">{formatDate(s.scheduledAt)}</span>,\n },\n {\n key: 'document',\n header: 'Document',\n hideOnMobile: true,\n render: (s) =>\n s.document?.id ? (\n <FileLink fileId={s.document.id} />\n ) : (\n <span className=\"text-text-tertiary\">—</span>\n ),\n },\n {\n key: 'action',\n header: '',\n align: 'right',\n render: (s) => {\n const done = s.status === 'DELIVERED' || s.status === 'CANCELLED';\n if (done) return <span className=\"text-text-tertiary\">—</span>;\n return (\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={deliverShipment.isPending}\n onClick={() => deliverShipment.mutate(s.id)}\n >\n <PackageCheck className=\"mr-1.5 h-4 w-4\" /> Mark delivered\n </Button>\n );\n },\n },\n ];\n\n const isFiltered = status !== 'ALL' || contractId !== 'ALL';\n\n return (\n <PageLayout\n title=\"Shipments\"\n description=\"Cargo movements delivering offtake contracts — pipelines, tankers, vessels, rail & grid.\"\n actions={\n <Button onClick={() => setDialogOpen(true)}>\n <Plus className=\"mr-1.5 h-4 w-4\" /> Schedule shipment\n </Button>\n }\n >\n {/* Header metrics — status mix within the current contract scope. */}\n <div className=\"mb-6 grid grid-cols-2 gap-4 lg:grid-cols-4\">\n <MetricsCard\n featured\n icon={<Ship className=\"h-5 w-5\" />}\n value={metricsRows.length}\n label=\"Total shipments\"\n />\n <MetricsCard\n icon={<CalendarClock className=\"h-5 w-5\" />}\n value={scheduledCount}\n label=\"Scheduled\"\n />\n <MetricsCard\n accent=\"warning\"\n icon={<Truck className=\"h-5 w-5\" />}\n value={inTransitCount}\n label=\"In transit\"\n />\n <MetricsCard\n accent=\"success\"\n icon={<PackageCheck className=\"h-5 w-5\" />}\n value={deliveredCount}\n label=\"Delivered\"\n />\n </div>\n\n <div className=\"mb-5 flex flex-wrap items-center gap-3\">\n <FilterTabs options={filterOptions} value={status} onChange={setStatus} />\n <Select value={contractId} onValueChange={(v) => setContractId(v as string | 'ALL')}>\n <SelectTrigger className=\"w-56\">\n <SelectValue placeholder=\"All contracts\" />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"ALL\">All contracts</SelectItem>\n {contractItems.map((c) => (\n <SelectItem key={c.id} value={c.id}>\n {c.reference} · {c.counterparty}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n {isLoading ? (\n <LoadingView label=\"Loading shipments…\" />\n ) : isError ? (\n <ErrorView message=\"Couldn't load shipments.\" onRetry={() => refetch()} />\n ) : rows.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n icon={<Ship className=\"h-10 w-10\" />}\n title={isFiltered ? 'No matching shipments' : 'No shipments yet'}\n description={\n isFiltered\n ? 'No shipments match these filters. Try a different status or contract.'\n : 'Schedule your first shipment to start tracking cargo against your offtake contracts.'\n }\n action={\n <Button onClick={() => setDialogOpen(true)}>\n <Plus className=\"mr-1.5 h-4 w-4\" /> Schedule shipment\n </Button>\n }\n />\n ) : (\n <DataTable\n columns={columns}\n rows={rows}\n rowKey={(s) => s.id}\n defaultSort={{ key: 'scheduledAt', dir: 'desc' }}\n />\n )}\n\n {/* Schedule shipment dialog */}\n <ResponsiveDialog\n open={dialogOpen}\n onOpenChange={(open) => {\n setDialogOpen(open);\n if (!open) resetForm();\n }}\n >\n <ResponsiveDialogContent>\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>Schedule shipment</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n Book a cargo movement against an offtake contract and track it to delivery.\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n <div className=\"grid gap-4 py-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipContract\">Contract *</Label>\n <Select\n value={form.contractId}\n onValueChange={(v) => {\n // Default the unit to the contract's unit for a sensible start.\n const contract = contractMap.get(v);\n setForm((prev) => ({\n ...prev,\n contractId: v,\n unit: contract?.unit ?? prev.unit,\n }));\n }}\n >\n <SelectTrigger id=\"shipContract\">\n <SelectValue placeholder=\"Select a contract\" />\n </SelectTrigger>\n <SelectContent>\n {contractItems.length === 0 ? (\n <SelectItem value=\"none\" disabled>\n No contracts available\n </SelectItem>\n ) : (\n contractItems.map((c) => (\n <SelectItem key={c.id} value={c.id}>\n {c.reference} · {c.counterparty}\n </SelectItem>\n ))\n )}\n </SelectContent>\n </Select>\n </div>\n\n <div className=\"grid gap-2 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipRef\">Reference *</Label>\n <Input\n id=\"shipRef\"\n value={form.reference}\n onChange={(e) => setForm({ ...form, reference: e.target.value })}\n placeholder=\"SHP-2026-0142\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipMode\">Mode</Label>\n <Select\n value={form.mode}\n onValueChange={(v) => setForm({ ...form, mode: v as TheTransportMode })}\n >\n <SelectTrigger id=\"shipMode\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {TRANSPORT_MODES.map((m) => (\n <SelectItem key={m} value={m}>\n {formatEnumLabel(m)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n </div>\n\n <div className=\"grid gap-2 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipOrigin\">Origin</Label>\n <Input\n id=\"shipOrigin\"\n value={form.origin}\n onChange={(e) => setForm({ ...form, origin: e.target.value })}\n placeholder=\"Ras Tanura Terminal\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipDest\">Destination</Label>\n <Input\n id=\"shipDest\"\n value={form.destination}\n onChange={(e) => setForm({ ...form, destination: e.target.value })}\n placeholder=\"Rotterdam\"\n />\n </div>\n </div>\n\n <div className=\"grid gap-2 sm:grid-cols-3\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipVolume\">Volume *</Label>\n <Input\n id=\"shipVolume\"\n type=\"number\"\n min=\"0\"\n step=\"any\"\n value={form.volume}\n onChange={(e) => setForm({ ...form, volume: e.target.value })}\n placeholder=\"500000\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipUnit\">Unit</Label>\n <Select\n value={form.unit}\n onValueChange={(v) => setForm({ ...form, unit: v as TheUnit })}\n >\n <SelectTrigger id=\"shipUnit\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {UNITS.map((u) => (\n <SelectItem key={u} value={u}>\n {formatEnumLabel(u)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipScheduled\">Scheduled date</Label>\n <Input\n id=\"shipScheduled\"\n type=\"date\"\n value={form.scheduledAt}\n onChange={(e) => setForm({ ...form, scheduledAt: e.target.value })}\n />\n </div>\n </div>\n\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipCarrier\">Carrier</Label>\n <Input\n id=\"shipCarrier\"\n value={form.carrier}\n onChange={(e) => setForm({ ...form, carrier: e.target.value })}\n placeholder=\"Frontline Ltd.\"\n />\n </div>\n\n <EvidenceUpload\n id=\"shipDocument\"\n label=\"Bill of lading (optional)\"\n value={doc}\n onChange={setDoc}\n hint=\"Attach the bill of lading or shipping document (PDF or image).\"\n />\n\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipNotes\">Notes</Label>\n <Textarea\n id=\"shipNotes\"\n value={form.notes}\n onChange={(e) => setForm({ ...form, notes: e.target.value })}\n placeholder=\"Optional context — laycan window, inspector, terms.\"\n rows={2}\n />\n </div>\n\n {formError && <p className=\"text-sm text-status-error-text\">{formError}</p>}\n </div>\n\n <ResponsiveDialogFooter>\n <Button variant=\"outline\" onClick={() => setDialogOpen(false)}>\n Cancel\n </Button>\n <Button onClick={handleSchedule} disabled={scheduleShipment.isPending}>\n {scheduleShipment.isPending ? 'Scheduling…' : 'Schedule shipment'}\n </Button>\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqDA,IAAM,KAA6E;CACjF;EAAE,OAAO;EAAO,OAAO;EAAO;CAC9B;EAAE,OAAO;EAAa,OAAO;EAAa;CAC1C;EAAE,OAAO;EAAW,OAAO;EAAW;CACtC;EAAE,OAAO;EAAc,OAAO;EAAc;CAC5C;EAAE,OAAO;EAAa,OAAO;EAAa;CAC1C;EAAE,OAAO;EAAa,OAAO;EAAa;CAC3C,EAEK,KAAsC;CAC1C;CACA;CACA;CACA;CACA;CACA;CACD,EAEK,IAAmB;CAAC;CAAW;CAAgB;CAAU;CAAa;CAAO;CAAM;CAAM,EAezF,IAAgC;CACpC,YAAY;CACZ,WAAW;CACX,MAAM;CACN,SAAS;CACT,QAAQ;CACR,aAAa;CACb,QAAQ;CACR,MAAM;CACN,aAAa;CACb,OAAO;CACR;AAED,SAAgB,IAAgB;CAC9B,IAAM,CAAC,GAAQ,KAAa,EAAoC,MAAM,EAChE,CAAC,GAAY,KAAiB,EAAyB,MAAM,EAC7D,CAAC,GAAY,KAAiB,EAAS,GAAM,EAC7C,CAAC,GAAM,KAAW,EAA4B,EAAW,EACzD,CAA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C,GAAD;WAAO,SAAQ;qBAAgB;WAAsB,CAAA,EACrD,kBAAC,GAAD;WACE,IAAG;WACH,MAAK;WACL,OAAO,EAAK;WACZ,WAAW,MAAM,EAAQ;YAAE,GAAG;YAAM,aAAa,EAAE,OAAO;YAAO,CAAC;WAClE,CAAA,CACE;;SACF;;OAEN,kBAAC,OAAD;QAAK,WAAU;kBAAf,CACE,kBAAC,GAAD;SAAO,SAAQ;mBAAc;SAAe,CAAA,EAC5C,kBAAC,GAAD;SACE,IAAG;SACH,OAAO,EAAK;SACZ,WAAW,MAAM,EAAQ;UAAE,GAAG;UAAM,SAAS,EAAE,OAAO;UAAO,CAAC;SAC9D,aAAY;SACZ,CAAA,CACE;;OAEN,kBAAC,IAAD;QACE,IAAG;QACH,OAAM;QACN,OAAO;QACP,UAAU;QACV,MAAK;QACL,CAAA;OAEF,kBAAC,OAAD;QAAK,WAAU;kBAAf,CACE,kBAAC,GAAD;SAAO,SAAQ;mBAAY;SAAa,CAAA,EACxC,kBAAC,IAAD;SACE,IAAG;SACH,OAAO,EAAK;SACZ,WAAW,MAAM,EAAQ;UAAE,GAAG;UAAM,OAAO,EAAE,OAAO;UAAO,CAAC;SAC5D,aAAY;SACZ,MAAM;SACN,CAAA,CACE;;OAEL,KAAa,kBAAC,KAAD;QAAG,WAAU;kBAAkC;QAAc,CAAA;OACvE;;KAEN,kBAAC,IAAD,EAAA,UAAA,CACE,kBAAC,GAAD;MAAQ,SAAQ;MAAU,eAAe,EAAc,GAAM;gBAAE;MAEtD,CAAA,EACT,kBAAC,GAAD;MAAQ,SAAS;MAAgB,UAAU,EAAiB;gBACzD,EAAiB,YAAY,gBAAgB;MACvC,CAAA,CACc,EAAA,CAAA;KACD,EAAA,CAAA;IACT,CAAA;GACR"}
|
|
1
|
+
{"version":3,"file":"ShipmentsPage.js","names":[],"sources":["../../../../src/theglobalfuel/pages/shipments/ShipmentsPage.tsx"],"sourcesContent":["/**\n * Shipments — schedule and track cargo movements against offtake contracts.\n * @module theglobalfuel/pages/shipments\n *\n * Reads `theListShipments` (a cursor connection — `{ items, pageInfo }`, filtered\n * by contract + status) and `theListContracts` (to resolve contract references +\n * populate the picker); writes `theScheduleShipment`, `theDeliverShipment` and\n * lifecycle transitions via `theTransitionShipment`.\n */\n\nimport { useMemo, useState } from 'react';\nimport { Plus, Ship, CalendarClock, Truck, PackageCheck, ArrowRight } from 'lucide-react';\nimport {\n Button,\n Input,\n Label,\n Textarea,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n} from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../../components/PageLayout';\nimport { MetricsCard } from '../../components/MetricsCard';\nimport { StatusBadge } from '../../components/StatusBadge';\nimport { DataTable, type Column } from '../../components/DataTable';\nimport { FilterTabs, type FilterOption } from '../../components/FilterTabs';\nimport { LoadingView, ErrorView } from '../../components/StateViews';\nimport { EmptyState } from '../../components/EmptyState';\nimport { FileLink } from '../../components/FileLink';\nimport { EvidenceUpload } from '../../components/EvidenceUpload';\nimport { Pagination } from '../../components/Pagination';\nimport {\n useNotify,\n useTheShipments,\n useTheContracts,\n useTheScheduleShipment,\n useTheDeliverShipment,\n useTheTransitionShipment,\n useCursorPager,\n type UploadedTheFile,\n} from '../../hooks';\nimport { formatEnumLabel, formatDate, formatVolume } from '../../utils/formatters';\nimport {\n toBackendDate,\n SHIPMENT_TRANSITIONS,\n SHIPMENT_DELIVERABLE_FROM,\n nextStatuses,\n} from '../../utils';\nimport type {\n TheShipment,\n TheShipmentStatus,\n TheTransportMode,\n TheUnit,\n TheOfftakeContract,\n} from '../../types';\n\nconst STATUS_FILTERS: Array<{ value: TheShipmentStatus | 'ALL'; label: string }> = [\n { value: 'ALL', label: 'All' },\n { value: 'SCHEDULED', label: 'Scheduled' },\n { value: 'LOADING', label: 'Loading' },\n { value: 'IN_TRANSIT', label: 'In transit' },\n { value: 'DELIVERED', label: 'Delivered' },\n { value: 'CANCELLED', label: 'Cancelled' },\n];\n\nconst TRANSPORT_MODES: TheTransportMode[] = [\n 'PIPELINE',\n 'TANKER',\n 'VESSEL_BULK',\n 'RAIL',\n 'TRUCK',\n 'GRID',\n];\n\nconst UNITS: TheUnit[] = ['BARRELS', 'CUBIC_METERS', 'TONNES', 'KILOGRAMS', 'MWH', 'GJ', 'MCF'];\n\nconst PAGE_SIZE = 25;\n\ninterface ScheduleFormState {\n contractId: string;\n reference: string;\n mode: TheTransportMode;\n carrier: string;\n origin: string;\n destination: string;\n volume: string;\n unit: TheUnit;\n scheduledAt: string;\n notes: string;\n}\n\nconst EMPTY_FORM: ScheduleFormState = {\n contractId: '',\n reference: '',\n mode: 'TANKER',\n carrier: '',\n origin: '',\n destination: '',\n volume: '',\n unit: 'BARRELS',\n scheduledAt: '',\n notes: '',\n};\n\nexport function ShipmentsPage() {\n const [status, setStatus] = useState<TheShipmentStatus | 'ALL'>('ALL');\n const [contractId, setContractId] = useState<string | 'ALL'>('ALL');\n const pager = useCursorPager();\n const [dialogOpen, setDialogOpen] = useState(false);\n const [form, setForm] = useState<ScheduleFormState>(EMPTY_FORM);\n const [doc, setDoc] = useState<UploadedTheFile | null>(null);\n const [formError, setFormError] = useState<string | null>(null);\n // Track the shipment whose transition is in flight so only that row's Select\n // disables (transitionShipment.isPending is shared across all rows).\n const [transitioningId, setTransitioningId] = useState<string | null>(null);\n\n const notify = useNotify();\n\n const scopedContractId = contractId === 'ALL' ? undefined : contractId;\n\n // Table query — respects both the contract scope and the status filter, and is\n // cursor-paginated to PAGE_SIZE.\n const { data, isLoading, isError, refetch } = useTheShipments(\n scopedContractId,\n status === 'ALL' ? undefined : status,\n { limit: PAGE_SIZE, cursor: pager.cursor }\n );\n // Metrics query — same contract scope but ignores the status filter so the\n // header counts stay stable as the table is narrowed. A broad limit keeps the\n // KPI status mix representative (the table itself is paginated to PAGE_SIZE).\n const metricsQuery = useTheShipments(scopedContractId, undefined, { limit: 200 });\n\n // Contracts drive the picker + let us resolve a shipment's contract reference.\n const contractsQuery = useTheContracts({ pagination: { limit: 100 } });\n const contractItems = useMemo(\n () => contractsQuery.data?.items ?? [],\n [contractsQuery.data]\n );\n const contractMap = useMemo(() => {\n const map = new Map<string, TheOfftakeContract>();\n for (const c of contractItems) map.set(c.id, c);\n return map;\n }, [contractItems]);\n\n const scheduleShipment = useTheScheduleShipment();\n const deliverShipment = useTheDeliverShipment();\n const transitionShipment = useTheTransitionShipment();\n\n const rows = useMemo(() => data?.items ?? [], [data]);\n const metricsRows = useMemo(() => metricsQuery.data?.items ?? [], [metricsQuery.data]);\n\n // ── Header metrics (derived from the contract-scoped, status-agnostic list) ──\n const scheduledCount = metricsRows.filter((s) => s.status === 'SCHEDULED').length;\n const inTransitCount = metricsRows.filter((s) => s.status === 'IN_TRANSIT').length;\n const deliveredCount = metricsRows.filter((s) => s.status === 'DELIVERED').length;\n\n const statusCounts = useMemo(() => {\n const counts: Record<string, number> = {};\n for (const s of metricsRows) counts[s.status] = (counts[s.status] ?? 0) + 1;\n return counts;\n }, [metricsRows]);\n\n const filterOptions: FilterOption<TheShipmentStatus | 'ALL'>[] = STATUS_FILTERS.map((opt) => ({\n value: opt.value,\n label: opt.label,\n count: opt.value === 'ALL' ? metricsRows.length : (statusCounts[opt.value] ?? 0),\n }));\n\n const resetForm = () => {\n setForm(EMPTY_FORM);\n setDoc(null);\n setFormError(null);\n };\n\n const handleSchedule = async () => {\n if (!form.contractId) {\n setFormError('Select the contract this shipment fulfils.');\n return;\n }\n if (!form.reference.trim()) {\n setFormError('A shipment reference is required.');\n return;\n }\n const volume = Number(form.volume);\n if (!form.volume || Number.isNaN(volume) || volume <= 0) {\n setFormError('Enter a volume greater than zero.');\n notify.error('Enter a volume greater than zero.');\n return;\n }\n setFormError(null);\n try {\n await scheduleShipment.mutateAsync({\n contractId: form.contractId,\n reference: form.reference.trim(),\n mode: form.mode,\n carrier: form.carrier.trim() || null,\n origin: form.origin.trim() || null,\n destination: form.destination.trim() || null,\n volume,\n unit: form.unit,\n scheduledAt: toBackendDate(form.scheduledAt) ?? null,\n documentFileId: doc?.fileId ?? null,\n notes: form.notes.trim() || null,\n });\n notify.success('Shipment scheduled');\n setDialogOpen(false);\n resetForm();\n } catch (err) {\n setFormError(err instanceof Error ? err.message : 'Failed to schedule shipment.');\n notify.fromError(err);\n }\n };\n\n const columns: Column<TheShipment>[] = [\n {\n key: 'reference',\n header: 'Shipment',\n render: (s) => (\n <div className=\"min-w-0\">\n <p className=\"truncate font-semibold text-text-primary\">{s.reference}</p>\n <p className=\"truncate text-xs text-text-tertiary md:hidden\">{formatEnumLabel(s.mode)}</p>\n </div>\n ),\n },\n {\n key: 'contract',\n header: 'Contract',\n hideOnMobile: true,\n render: (s) => {\n const contract = contractMap.get(s.contractId);\n return contract ? (\n <div className=\"min-w-0\">\n <p className=\"truncate font-medium text-text-primary\">{contract.reference}</p>\n <p className=\"truncate text-xs text-text-tertiary\">{contract.counterparty}</p>\n </div>\n ) : (\n <span className=\"font-mono text-xs text-text-tertiary\">{s.contractId.slice(0, 8)}</span>\n );\n },\n },\n {\n key: 'mode',\n header: 'Mode',\n hideOnMobile: true,\n render: (s) => <span className=\"text-text-secondary\">{formatEnumLabel(s.mode)}</span>,\n },\n {\n key: 'status',\n header: 'Status',\n render: (s) => <StatusBadge status={s.status} />,\n },\n {\n key: 'route',\n header: 'Route',\n hideOnMobile: true,\n render: (s) => {\n const origin = s.origin?.trim();\n const destination = s.destination?.trim();\n if (!origin && !destination) return <span className=\"text-text-tertiary\">—</span>;\n return (\n <span className=\"inline-flex items-center gap-1.5 text-text-secondary\">\n <span className=\"truncate\">{origin ?? '—'}</span>\n <ArrowRight className=\"h-3.5 w-3.5 shrink-0 text-text-tertiary\" />\n <span className=\"truncate\">{destination ?? '—'}</span>\n </span>\n );\n },\n },\n {\n key: 'volume',\n header: 'Volume',\n align: 'right',\n sortValue: (s) => s.volume,\n render: (s) => (\n <span className=\"tabular-nums text-text-primary\">{formatVolume(s.volume, s.unit)}</span>\n ),\n },\n {\n key: 'scheduledAt',\n header: 'Scheduled',\n align: 'right',\n hideOnMobile: true,\n sortValue: (s) => s.scheduledAt ?? '',\n render: (s) => <span className=\"text-text-tertiary\">{formatDate(s.scheduledAt)}</span>,\n },\n {\n key: 'document',\n header: 'Document',\n hideOnMobile: true,\n render: (s) =>\n s.document?.id ? (\n <FileLink fileId={s.document.id} />\n ) : (\n <span className=\"text-text-tertiary\">—</span>\n ),\n },\n {\n key: 'action',\n header: '',\n align: 'right',\n render: (s) => {\n // Lifecycle transitions reachable via theTransitionShipment (SCHEDULED →\n // LOADING → IN_TRANSIT → CANCELLED). DELIVERED is NOT offered here — it is\n // reached through \"Mark delivered\", which additionally rolls volume into\n // the contract. Terminal states (DELIVERED / CANCELLED) expose neither.\n const nexts = nextStatuses(SHIPMENT_TRANSITIONS, s.status);\n const canDeliver = SHIPMENT_DELIVERABLE_FROM.includes(s.status);\n const rowBusy = transitioningId === s.id;\n if (nexts.length === 0 && !canDeliver) {\n return <span className=\"text-text-tertiary\">—</span>;\n }\n return (\n <div className=\"flex items-center justify-end gap-2\">\n {nexts.length > 0 && (\n <Select\n value={s.status}\n disabled={rowBusy}\n onValueChange={(v) => {\n if (v === s.status) return;\n setTransitioningId(s.id);\n transitionShipment.mutate(\n { id: s.id, status: v as TheShipmentStatus },\n {\n onSuccess: () => notify.success('Shipment updated'),\n onError: (e) => notify.fromError(e),\n onSettled: () => setTransitioningId(null),\n }\n );\n }}\n >\n <SelectTrigger\n className=\"h-8 w-36\"\n aria-label={`Change status for shipment ${s.reference}`}\n >\n <SelectValue placeholder={formatEnumLabel(s.status)} />\n </SelectTrigger>\n <SelectContent>\n {nexts.map((st) => (\n <SelectItem key={st} value={st}>\n {formatEnumLabel(st)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n )}\n {canDeliver && (\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={deliverShipment.isPending || rowBusy}\n onClick={() =>\n deliverShipment.mutate(s.id, {\n onSuccess: () => notify.success('Shipment delivered'),\n onError: (e) => notify.fromError(e),\n })\n }\n >\n <PackageCheck className=\"mr-1.5 h-4 w-4\" /> Mark delivered\n </Button>\n )}\n </div>\n );\n },\n },\n ];\n\n const isFiltered = status !== 'ALL' || contractId !== 'ALL';\n\n return (\n <PageLayout\n title=\"Shipments\"\n description=\"Cargo movements delivering offtake contracts — pipelines, tankers, vessels, rail & grid.\"\n actions={\n <Button onClick={() => setDialogOpen(true)}>\n <Plus className=\"mr-1.5 h-4 w-4\" /> Schedule shipment\n </Button>\n }\n >\n {/* Header metrics — status mix within the current contract scope. */}\n <div className=\"mb-6 grid grid-cols-2 gap-4 lg:grid-cols-4\">\n <MetricsCard\n featured\n icon={<Ship className=\"h-5 w-5\" />}\n value={metricsRows.length}\n label=\"Total shipments\"\n />\n <MetricsCard\n icon={<CalendarClock className=\"h-5 w-5\" />}\n value={scheduledCount}\n label=\"Scheduled\"\n />\n <MetricsCard\n accent=\"warning\"\n icon={<Truck className=\"h-5 w-5\" />}\n value={inTransitCount}\n label=\"In transit\"\n />\n <MetricsCard\n accent=\"success\"\n icon={<PackageCheck className=\"h-5 w-5\" />}\n value={deliveredCount}\n label=\"Delivered\"\n />\n </div>\n\n <div className=\"mb-5 flex flex-wrap items-center gap-3\">\n <FilterTabs\n options={filterOptions}\n value={status}\n onChange={(v) => {\n setStatus(v);\n pager.reset();\n }}\n />\n <Select\n value={contractId}\n onValueChange={(v) => {\n setContractId(v as string | 'ALL');\n pager.reset();\n }}\n >\n <SelectTrigger className=\"w-56\" aria-label=\"Filter by contract\">\n <SelectValue placeholder=\"All contracts\" />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"ALL\">All contracts</SelectItem>\n {contractItems.map((c) => (\n <SelectItem key={c.id} value={c.id}>\n {c.reference} · {c.counterparty}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n {isLoading ? (\n <LoadingView label=\"Loading shipments…\" />\n ) : isError ? (\n <ErrorView message=\"Couldn't load shipments.\" onRetry={() => refetch()} />\n ) : rows.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n icon={<Ship className=\"h-10 w-10\" />}\n title={isFiltered ? 'No matching shipments' : 'No shipments yet'}\n description={\n isFiltered\n ? 'No shipments match these filters. Try a different status or contract.'\n : 'Schedule your first shipment to start tracking cargo against your offtake contracts.'\n }\n action={\n <Button onClick={() => setDialogOpen(true)}>\n <Plus className=\"mr-1.5 h-4 w-4\" /> Schedule shipment\n </Button>\n }\n />\n ) : (\n <>\n <DataTable\n columns={columns}\n rows={rows}\n rowKey={(s) => s.id}\n defaultSort={{ key: 'scheduledAt', dir: 'desc' }}\n />\n <Pagination\n page={pager.page}\n pageSize={PAGE_SIZE}\n itemCount={rows.length}\n hasMore={data?.pageInfo?.hasMore ?? false}\n onPageChange={(p) => pager.onPageChange(p, data?.pageInfo?.cursor)}\n />\n </>\n )}\n\n {/* Schedule shipment dialog */}\n <ResponsiveDialog\n open={dialogOpen}\n onOpenChange={(open) => {\n setDialogOpen(open);\n if (!open) resetForm();\n }}\n >\n <ResponsiveDialogContent>\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>Schedule shipment</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n Book a cargo movement against an offtake contract and track it to delivery.\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n <form\n onSubmit={(e) => {\n e.preventDefault();\n void handleSchedule();\n }}\n >\n <div className=\"grid gap-4 py-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipContract\">Contract *</Label>\n <Select\n value={form.contractId}\n onValueChange={(v) => {\n // Default the unit to the contract's unit for a sensible start.\n const contract = contractMap.get(v);\n setForm((prev) => ({\n ...prev,\n contractId: v,\n unit: contract?.unit ?? prev.unit,\n }));\n }}\n >\n <SelectTrigger id=\"shipContract\">\n <SelectValue placeholder=\"Select a contract\" />\n </SelectTrigger>\n <SelectContent>\n {contractItems.length === 0 ? (\n <SelectItem value=\"none\" disabled>\n No contracts available\n </SelectItem>\n ) : (\n contractItems.map((c) => (\n <SelectItem key={c.id} value={c.id}>\n {c.reference} · {c.counterparty}\n </SelectItem>\n ))\n )}\n </SelectContent>\n </Select>\n </div>\n\n <div className=\"grid gap-2 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipRef\">Reference *</Label>\n <Input\n id=\"shipRef\"\n value={form.reference}\n onChange={(e) => setForm({ ...form, reference: e.target.value })}\n placeholder=\"SHP-2026-0142\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipMode\">Mode</Label>\n <Select\n value={form.mode}\n onValueChange={(v) => setForm({ ...form, mode: v as TheTransportMode })}\n >\n <SelectTrigger id=\"shipMode\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {TRANSPORT_MODES.map((m) => (\n <SelectItem key={m} value={m}>\n {formatEnumLabel(m)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n </div>\n\n <div className=\"grid gap-2 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipOrigin\">Origin</Label>\n <Input\n id=\"shipOrigin\"\n value={form.origin}\n onChange={(e) => setForm({ ...form, origin: e.target.value })}\n placeholder=\"Ras Tanura Terminal\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipDest\">Destination</Label>\n <Input\n id=\"shipDest\"\n value={form.destination}\n onChange={(e) => setForm({ ...form, destination: e.target.value })}\n placeholder=\"Rotterdam\"\n />\n </div>\n </div>\n\n <div className=\"grid gap-2 sm:grid-cols-3\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipVolume\">Volume *</Label>\n <Input\n id=\"shipVolume\"\n type=\"number\"\n min=\"0\"\n step=\"any\"\n value={form.volume}\n onChange={(e) => setForm({ ...form, volume: e.target.value })}\n placeholder=\"500000\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipUnit\">Unit</Label>\n <Select\n value={form.unit}\n onValueChange={(v) => setForm({ ...form, unit: v as TheUnit })}\n >\n <SelectTrigger id=\"shipUnit\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {UNITS.map((u) => (\n <SelectItem key={u} value={u}>\n {formatEnumLabel(u)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipScheduled\">Scheduled date</Label>\n <Input\n id=\"shipScheduled\"\n type=\"date\"\n value={form.scheduledAt}\n onChange={(e) => setForm({ ...form, scheduledAt: e.target.value })}\n />\n </div>\n </div>\n\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipCarrier\">Carrier</Label>\n <Input\n id=\"shipCarrier\"\n value={form.carrier}\n onChange={(e) => setForm({ ...form, carrier: e.target.value })}\n placeholder=\"Frontline Ltd.\"\n />\n </div>\n\n <EvidenceUpload\n id=\"shipDocument\"\n label=\"Bill of lading (optional)\"\n value={doc}\n onChange={setDoc}\n hint=\"Attach the bill of lading or shipping document (PDF or image).\"\n />\n\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"shipNotes\">Notes</Label>\n <Textarea\n id=\"shipNotes\"\n value={form.notes}\n onChange={(e) => setForm({ ...form, notes: e.target.value })}\n placeholder=\"Optional context — laycan window, inspector, terms.\"\n rows={2}\n />\n </div>\n\n {formError && <p className=\"text-sm text-status-error-text\">{formError}</p>}\n </div>\n\n <ResponsiveDialogFooter>\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => {\n setDialogOpen(false);\n resetForm();\n }}\n >\n Cancel\n </Button>\n <Button type=\"submit\" disabled={scheduleShipment.isPending}>\n {scheduleShipment.isPending ? 'Scheduling…' : 'Schedule shipment'}\n </Button>\n </ResponsiveDialogFooter>\n </form>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n </PageLayout>\n );\n}\n"],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GAAD;SACE,IAAG;SACH,OAAO,EAAK;SACZ,WAAW,MAAM,EAAQ;UAAE,GAAG;UAAM,SAAS,EAAE,OAAO;UAAO,CAAC;SAC9D,aAAY;SACZ,CAAA,CACE;;OAEN,kBAAC,IAAD;QACE,IAAG;QACH,OAAM;QACN,OAAO;QACP,UAAU;QACV,MAAK;QACL,CAAA;OAEF,kBAAC,OAAD;QAAK,WAAU;kBAAf,CACE,kBAAC,GAAD;SAAO,SAAQ;mBAAY;SAAa,CAAA,EACxC,kBAAC,GAAD;SACE,IAAG;SACH,OAAO,EAAK;SACZ,WAAW,MAAM,EAAQ;UAAE,GAAG;UAAM,OAAO,EAAE,OAAO;UAAO,CAAC;SAC5D,aAAY;SACZ,MAAM;SACN,CAAA,CACE;;OAEL,KAAa,kBAAC,KAAD;QAAG,WAAU;kBAAkC;QAAc,CAAA;OACvE;SAEN,kBAAC,IAAD,EAAA,UAAA,CACE,kBAAC,GAAD;MACE,MAAK;MACL,SAAQ;MACR,eAAe;AAEb,OADA,EAAc,GAAM,EACpB,GAAW;;gBAEd;MAEQ,CAAA,EACT,kBAAC,GAAD;MAAQ,MAAK;MAAS,UAAU,EAAiB;gBAC9C,EAAiB,YAAY,gBAAgB;MACvC,CAAA,CACc,EAAA,CAAA,CAClB;OACiB,EAAA,CAAA;IACT,CAAA;GACR"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import e from "../../node_modules
|
|
2
|
-
import { twMerge as t } from "../../node_modules
|
|
1
|
+
import e from "../../node_modules/clsx/dist/clsx.js";
|
|
2
|
+
import { twMerge as t } from "../../node_modules/tailwind-merge/dist/bundle-mjs.js";
|
|
3
3
|
//#region src/theglobalfuel/utils/cn.ts
|
|
4
4
|
function n(...n) {
|
|
5
5
|
return t(e(n));
|
|
@@ -84,11 +84,16 @@ function p(e) {
|
|
|
84
84
|
return e == null || Number.isNaN(e) ? "—" : `${r(e, { maximumFractionDigits: 2 })} t CO₂e`;
|
|
85
85
|
}
|
|
86
86
|
function m(e) {
|
|
87
|
+
if (!e) return;
|
|
88
|
+
let t = /^\d{4}-\d{2}-\d{2}$/.test(e) ? e : e.slice(0, 10), n = /* @__PURE__ */ new Date(`${t}T12:00:00Z`);
|
|
89
|
+
return Number.isNaN(n.getTime()) ? void 0 : n.toISOString();
|
|
90
|
+
}
|
|
91
|
+
function h(e) {
|
|
87
92
|
if (!e) return !1;
|
|
88
93
|
let t = typeof e == "string" ? new Date(e) : e;
|
|
89
94
|
return Number.isNaN(t.getTime()) ? !1 : t.getTime() < Date.now();
|
|
90
95
|
}
|
|
91
96
|
//#endregion
|
|
92
|
-
export { o as formatCo2e, s as formatCoords, e as formatDate, t as formatDateTime, c as formatEnumLabel, f as formatMoney, r as formatNumber, a as formatPercent, i as formatQuantity, n as formatRelativeTime, p as formatTonnesCo2e, u as formatUnit, d as formatVolume,
|
|
97
|
+
export { o as formatCo2e, s as formatCoords, e as formatDate, t as formatDateTime, c as formatEnumLabel, f as formatMoney, r as formatNumber, a as formatPercent, i as formatQuantity, n as formatRelativeTime, p as formatTonnesCo2e, u as formatUnit, d as formatVolume, h as isExpired, m as toBackendDate };
|
|
93
98
|
|
|
94
99
|
//# sourceMappingURL=formatters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","names":[],"sources":["../../../src/theglobalfuel/utils/formatters.ts"],"sourcesContent":["/**\n * Formatting utilities for the TheGlobalFuel microfrontend\n * @module theglobalfuel/utils/formatters\n */\n\n/** Format a date string or Date into a human-readable date. */\nexport function formatDate(\n date: string | Date | null | undefined,\n options?: Partial<Intl.DateTimeFormatOptions>\n): string {\n if (!date) return '—';\n const d = typeof date === 'string' ? new Date(date) : date;\n if (Number.isNaN(d.getTime())) return '—';\n return new Intl.DateTimeFormat(undefined, {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n ...options,\n }).format(d);\n}\n\n/** Format a date-time into a date + time string. */\nexport function formatDateTime(\n date: string | Date | null | undefined,\n options?: Partial<Intl.DateTimeFormatOptions>\n): string {\n if (!date) return '—';\n const d = typeof date === 'string' ? new Date(date) : date;\n if (Number.isNaN(d.getTime())) return '—';\n return new Intl.DateTimeFormat(undefined, {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n hour: 'numeric',\n minute: '2-digit',\n ...options,\n }).format(d);\n}\n\n/** Format a date into a relative time string (e.g. \"2 hours ago\", \"in 3 days\"). */\nexport function formatRelativeTime(date: string | Date | null | undefined): string {\n if (!date) return '—';\n const d = typeof date === 'string' ? new Date(date) : date;\n if (Number.isNaN(d.getTime())) return '—';\n\n const now = new Date();\n const diffMs = d.getTime() - now.getTime();\n const future = diffMs >= 0;\n const absSeconds = Math.floor(Math.abs(diffMs) / 1000);\n const minutes = Math.floor(absSeconds / 60);\n const hours = Math.floor(minutes / 60);\n const days = Math.floor(hours / 24);\n const weeks = Math.floor(days / 7);\n const months = Math.floor(days / 30);\n const years = Math.floor(days / 365);\n\n const phrase = (value: number, unit: string): string => {\n const label = `${value} ${unit}${value !== 1 ? 's' : ''}`;\n return future ? `in ${label}` : `${label} ago`;\n };\n\n if (absSeconds < 60) return future ? 'soon' : 'just now';\n if (minutes < 60) return phrase(minutes, 'min');\n if (hours < 24) return phrase(hours, 'hour');\n if (days < 7) return phrase(days, 'day');\n if (weeks < 4) return phrase(weeks, 'week');\n if (months < 12) return phrase(months, 'month');\n return phrase(years, 'year');\n}\n\n/** Format a number with locale grouping. */\nexport function formatNumber(\n value: number | null | undefined,\n options?: Partial<Intl.NumberFormatOptions>\n): string {\n if (value == null || Number.isNaN(value)) return '—';\n return new Intl.NumberFormat(undefined, options).format(value);\n}\n\n/** Format a quantity with an optional unit suffix (e.g. \"1,200 kg\"). */\nexport function formatQuantity(value: number | null | undefined, unit?: string | null): string {\n if (value == null || Number.isNaN(value)) return '—';\n const num = formatNumber(value, { maximumFractionDigits: 2 });\n return unit ? `${num} ${unit}` : num;\n}\n\n/** Format a percentage (0–100) into a rounded \"%\" string. */\nexport function formatPercent(value: number | null | undefined, fractionDigits = 0): string {\n if (value == null || Number.isNaN(value)) return '—';\n return `${value.toFixed(fractionDigits)}%`;\n}\n\n/**\n * Format a mass of CO2e (kg) into a compact, human-scaled string:\n * < 1,000 kg → \"kg CO₂e\"; ≥ 1,000 kg → \"t CO₂e\" (tonnes).\n */\nexport function formatCo2e(kg: number | null | undefined): string {\n if (kg == null || Number.isNaN(kg)) return '—';\n if (Math.abs(kg) >= 1000) {\n return `${formatNumber(kg / 1000, { maximumFractionDigits: 2 })} t CO₂e`;\n }\n return `${formatNumber(kg, { maximumFractionDigits: 1 })} kg CO₂e`;\n}\n\n/** Format coordinates into a compact \"lat, lng\" string. */\nexport function formatCoords(\n lat: number | null | undefined,\n lng: number | null | undefined\n): string {\n if (lat == null || lng == null) return '—';\n return `${lat.toFixed(4)}, ${lng.toFixed(4)}`;\n}\n\n/** Turn an ENUM_LIKE_TOKEN into a human \"Enum Like Token\" label. */\nexport function formatEnumLabel(value: string | null | undefined): string {\n if (!value) return '—';\n return value\n .toLowerCase()\n .replace(/_/g, ' ')\n .replace(/\\b\\w/g, (char) => char.toUpperCase());\n}\n\n/** Compact symbol for a `TheUnit` value (e.g. BARRELS → \"bbl\"). */\nconst UNIT_SYMBOL: Record<string, string> = {\n BARRELS: 'bbl',\n CUBIC_METERS: 'm³',\n TONNES: 't',\n KILOGRAMS: 'kg',\n MWH: 'MWh',\n GJ: 'GJ',\n MCF: 'Mcf',\n};\n\n/** Short unit symbol for a `TheUnit` token; falls back to a humanized label. */\nexport function formatUnit(unit: string | null | undefined): string {\n if (!unit) return '';\n return UNIT_SYMBOL[unit] ?? formatEnumLabel(unit);\n}\n\n/** Format a volume/quantity with its unit symbol (e.g. \"1,200 bbl\"). */\nexport function formatVolume(value: number | null | undefined, unit?: string | null): string {\n if (value == null || Number.isNaN(value)) return '—';\n const num = formatNumber(value, { maximumFractionDigits: 2 });\n const sym = formatUnit(unit);\n return sym ? `${num} ${sym}` : num;\n}\n\n/** Format a monetary amount with an ISO currency code (e.g. \"$1,250.00\"). */\nexport function formatMoney(\n value: number | null | undefined,\n currency: string | null | undefined = 'USD'\n): string {\n if (value == null || Number.isNaN(value)) return '—';\n try {\n return new Intl.NumberFormat(undefined, {\n style: 'currency',\n currency: currency || 'USD',\n maximumFractionDigits: 2,\n }).format(value);\n } catch {\n return `${formatNumber(value, { maximumFractionDigits: 2 })} ${currency ?? ''}`.trim();\n }\n}\n\n/** Format a mass already expressed in tonnes CO₂e (e.g. \"1,250 t CO₂e\"). */\nexport function formatTonnesCo2e(tonnes: number | null | undefined): string {\n if (tonnes == null || Number.isNaN(tonnes)) return '—';\n return `${formatNumber(tonnes, { maximumFractionDigits: 2 })} t CO₂e`;\n}\n\n/** Whether a date is in the past (used for permit/cert expiry flags). */\nexport function isExpired(date: string | Date | null | undefined): boolean {\n if (!date) return false;\n const d = typeof date === 'string' ? new Date(date) : date;\n if (Number.isNaN(d.getTime())) return false;\n return d.getTime() < Date.now();\n}\n"],"mappings":";AAMA,SAAgB,EACd,GACA,GACQ;AACR,KAAI,CAAC,EAAM,QAAO;CAClB,IAAM,IAAI,OAAO,KAAS,WAAW,IAAI,KAAK,EAAK,GAAG;AAEtD,QADI,OAAO,MAAM,EAAE,SAAS,CAAC,GAAS,MAC/B,IAAI,KAAK,eAAe,KAAA,GAAW;EACxC,KAAK;EACL,OAAO;EACP,MAAM;EACN,GAAG;EACJ,CAAC,CAAC,OAAO,EAAE;;AAId,SAAgB,EACd,GACA,GACQ;AACR,KAAI,CAAC,EAAM,QAAO;CAClB,IAAM,IAAI,OAAO,KAAS,WAAW,IAAI,KAAK,EAAK,GAAG;AAEtD,QADI,OAAO,MAAM,EAAE,SAAS,CAAC,GAAS,MAC/B,IAAI,KAAK,eAAe,KAAA,GAAW;EACxC,KAAK;EACL,OAAO;EACP,MAAM;EACN,MAAM;EACN,QAAQ;EACR,GAAG;EACJ,CAAC,CAAC,OAAO,EAAE;;AAId,SAAgB,EAAmB,GAAgD;AACjF,KAAI,CAAC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AO,GAAG,EAAa,GAAO,EAAE,uBAAuB,GAAG,CAAC,CAAC,GAAG,KAAY,KAAK,MAAM;;;AAK1F,SAAgB,EAAiB,GAA2C;AAE1E,QADI,KAAU,QAAQ,OAAO,MAAM,EAAO,GAAS,MAC5C,GAAG,EAAa,GAAQ,EAAE,uBAAuB,GAAG,CAAC,CAAC;;AAI/D,SAAgB,EAAU,GAAiD;AACzE,KAAI,CAAC,EAAM,QAAO;CAClB,IAAM,IAAI,OAAO,KAAS,WAAW,IAAI,KAAK,EAAK,GAAG;AAEtD,QADI,OAAO,MAAM,EAAE,SAAS,CAAC,GAAS,KAC/B,EAAE,SAAS,GAAG,KAAK,KAAK"}
|
|
1
|
+
{"version":3,"file":"formatters.js","names":[],"sources":["../../../src/theglobalfuel/utils/formatters.ts"],"sourcesContent":["/**\n * Formatting utilities for the TheGlobalFuel microfrontend\n * @module theglobalfuel/utils/formatters\n */\n\n/** Format a date string or Date into a human-readable date. */\nexport function formatDate(\n date: string | Date | null | undefined,\n options?: Partial<Intl.DateTimeFormatOptions>\n): string {\n if (!date) return '—';\n const d = typeof date === 'string' ? new Date(date) : date;\n if (Number.isNaN(d.getTime())) return '—';\n return new Intl.DateTimeFormat(undefined, {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n ...options,\n }).format(d);\n}\n\n/** Format a date-time into a date + time string. */\nexport function formatDateTime(\n date: string | Date | null | undefined,\n options?: Partial<Intl.DateTimeFormatOptions>\n): string {\n if (!date) return '—';\n const d = typeof date === 'string' ? new Date(date) : date;\n if (Number.isNaN(d.getTime())) return '—';\n return new Intl.DateTimeFormat(undefined, {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n hour: 'numeric',\n minute: '2-digit',\n ...options,\n }).format(d);\n}\n\n/** Format a date into a relative time string (e.g. \"2 hours ago\", \"in 3 days\"). */\nexport function formatRelativeTime(date: string | Date | null | undefined): string {\n if (!date) return '—';\n const d = typeof date === 'string' ? new Date(date) : date;\n if (Number.isNaN(d.getTime())) return '—';\n\n const now = new Date();\n const diffMs = d.getTime() - now.getTime();\n const future = diffMs >= 0;\n const absSeconds = Math.floor(Math.abs(diffMs) / 1000);\n const minutes = Math.floor(absSeconds / 60);\n const hours = Math.floor(minutes / 60);\n const days = Math.floor(hours / 24);\n const weeks = Math.floor(days / 7);\n const months = Math.floor(days / 30);\n const years = Math.floor(days / 365);\n\n const phrase = (value: number, unit: string): string => {\n const label = `${value} ${unit}${value !== 1 ? 's' : ''}`;\n return future ? `in ${label}` : `${label} ago`;\n };\n\n if (absSeconds < 60) return future ? 'soon' : 'just now';\n if (minutes < 60) return phrase(minutes, 'min');\n if (hours < 24) return phrase(hours, 'hour');\n if (days < 7) return phrase(days, 'day');\n if (weeks < 4) return phrase(weeks, 'week');\n if (months < 12) return phrase(months, 'month');\n return phrase(years, 'year');\n}\n\n/** Format a number with locale grouping. */\nexport function formatNumber(\n value: number | null | undefined,\n options?: Partial<Intl.NumberFormatOptions>\n): string {\n if (value == null || Number.isNaN(value)) return '—';\n return new Intl.NumberFormat(undefined, options).format(value);\n}\n\n/** Format a quantity with an optional unit suffix (e.g. \"1,200 kg\"). */\nexport function formatQuantity(value: number | null | undefined, unit?: string | null): string {\n if (value == null || Number.isNaN(value)) return '—';\n const num = formatNumber(value, { maximumFractionDigits: 2 });\n return unit ? `${num} ${unit}` : num;\n}\n\n/** Format a percentage (0–100) into a rounded \"%\" string. */\nexport function formatPercent(value: number | null | undefined, fractionDigits = 0): string {\n if (value == null || Number.isNaN(value)) return '—';\n return `${value.toFixed(fractionDigits)}%`;\n}\n\n/**\n * Format a mass of CO2e (kg) into a compact, human-scaled string:\n * < 1,000 kg → \"kg CO₂e\"; ≥ 1,000 kg → \"t CO₂e\" (tonnes).\n */\nexport function formatCo2e(kg: number | null | undefined): string {\n if (kg == null || Number.isNaN(kg)) return '—';\n if (Math.abs(kg) >= 1000) {\n return `${formatNumber(kg / 1000, { maximumFractionDigits: 2 })} t CO₂e`;\n }\n return `${formatNumber(kg, { maximumFractionDigits: 1 })} kg CO₂e`;\n}\n\n/** Format coordinates into a compact \"lat, lng\" string. */\nexport function formatCoords(\n lat: number | null | undefined,\n lng: number | null | undefined\n): string {\n if (lat == null || lng == null) return '—';\n return `${lat.toFixed(4)}, ${lng.toFixed(4)}`;\n}\n\n/** Turn an ENUM_LIKE_TOKEN into a human \"Enum Like Token\" label. */\nexport function formatEnumLabel(value: string | null | undefined): string {\n if (!value) return '—';\n return value\n .toLowerCase()\n .replace(/_/g, ' ')\n .replace(/\\b\\w/g, (char) => char.toUpperCase());\n}\n\n/** Compact symbol for a `TheUnit` value (e.g. BARRELS → \"bbl\"). */\nconst UNIT_SYMBOL: Record<string, string> = {\n BARRELS: 'bbl',\n CUBIC_METERS: 'm³',\n TONNES: 't',\n KILOGRAMS: 'kg',\n MWH: 'MWh',\n GJ: 'GJ',\n MCF: 'Mcf',\n};\n\n/** Short unit symbol for a `TheUnit` token; falls back to a humanized label. */\nexport function formatUnit(unit: string | null | undefined): string {\n if (!unit) return '';\n return UNIT_SYMBOL[unit] ?? formatEnumLabel(unit);\n}\n\n/** Format a volume/quantity with its unit symbol (e.g. \"1,200 bbl\"). */\nexport function formatVolume(value: number | null | undefined, unit?: string | null): string {\n if (value == null || Number.isNaN(value)) return '—';\n const num = formatNumber(value, { maximumFractionDigits: 2 });\n const sym = formatUnit(unit);\n return sym ? `${num} ${sym}` : num;\n}\n\n/** Format a monetary amount with an ISO currency code (e.g. \"$1,250.00\"). */\nexport function formatMoney(\n value: number | null | undefined,\n currency: string | null | undefined = 'USD'\n): string {\n if (value == null || Number.isNaN(value)) return '—';\n try {\n return new Intl.NumberFormat(undefined, {\n style: 'currency',\n currency: currency || 'USD',\n maximumFractionDigits: 2,\n }).format(value);\n } catch {\n return `${formatNumber(value, { maximumFractionDigits: 2 })} ${currency ?? ''}`.trim();\n }\n}\n\n/** Format a mass already expressed in tonnes CO₂e (e.g. \"1,250 t CO₂e\"). */\nexport function formatTonnesCo2e(tonnes: number | null | undefined): string {\n if (tonnes == null || Number.isNaN(tonnes)) return '—';\n return `${formatNumber(tonnes, { maximumFractionDigits: 2 })} t CO₂e`;\n}\n\n/**\n * Serialize a date-only `<input type=\"date\">` value (YYYY-MM-DD) to an ISO\n * timestamp anchored at NOON UTC. Anchoring at noon (not midnight) means the\n * calendar day is preserved in every timezone — `new Date('2026-06-30')` is UTC\n * midnight and renders as June 29 in any negative-offset zone. Returns undefined\n * for empty/invalid input so the field is omitted from the mutation.\n */\nexport function toBackendDate(value: string | null | undefined): string | undefined {\n if (!value) return undefined;\n const ymd = /^\\d{4}-\\d{2}-\\d{2}$/.test(value) ? value : value.slice(0, 10);\n const d = new Date(`${ymd}T12:00:00Z`);\n return Number.isNaN(d.getTime()) ? undefined : d.toISOString();\n}\n\n/** Whether a date is in the past (used for permit/cert expiry flags). */\nexport function isExpired(date: string | Date | null | undefined): boolean {\n if (!date) return false;\n const d = typeof date === 'string' ? new Date(date) : date;\n if (Number.isNaN(d.getTime())) return false;\n return d.getTime() < Date.now();\n}\n"],"mappings":";AAMA,SAAgB,EACd,GACA,GACQ;AACR,KAAI,CAAC,EAAM,QAAO;CAClB,IAAM,IAAI,OAAO,KAAS,WAAW,IAAI,KAAK,EAAK,GAAG;AAEtD,QADI,OAAO,MAAM,EAAE,SAAS,CAAC,GAAS,MAC/B,IAAI,KAAK,eAAe,KAAA,GAAW;EACxC,KAAK;EACL,OAAO;EACP,MAAM;EACN,GAAG;EACJ,CAAC,CAAC,OAAO,EAAE;;AAId,SAAgB,EACd,GACA,GACQ;AACR,KAAI,CAAC,EAAM,QAAO;CAClB,IAAM,IAAI,OAAO,KAAS,WAAW,IAAI,KAAK,EAAK,GAAG;AAEtD,QADI,OAAO,MAAM,EAAE,SAAS,CAAC,GAAS,MAC/B,IAAI,KAAK,eAAe,KAAA,GAAW;EACxC,KAAK;EACL,OAAO;EACP,MAAM;EACN,MAAM;EACN,QAAQ;EACR,GAAG;EACJ,CAAC,CAAC,OAAO,EAAE;;AAId,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B,CAAC,CAAC,OAAO,EAAM;SACV;AACN,SAAO,GAAG,EAAa,GAAO,EAAE,uBAAuB,GAAG,CAAC,CAAC,GAAG,KAAY,KAAK,MAAM;;;AAK1F,SAAgB,EAAiB,GAA2C;AAE1E,QADI,KAAU,QAAQ,OAAO,MAAM,EAAO,GAAS,MAC5C,GAAG,EAAa,GAAQ,EAAE,uBAAuB,GAAG,CAAC,CAAC;;AAU/D,SAAgB,EAAc,GAAsD;AAClF,KAAI,CAAC,EAAO;CACZ,IAAM,IAAM,sBAAsB,KAAK,EAAM,GAAG,IAAQ,EAAM,MAAM,GAAG,GAAG,EACpE,oBAAI,IAAI,KAAK,GAAG,EAAI,YAAY;AACtC,QAAO,OAAO,MAAM,EAAE,SAAS,CAAC,GAAG,KAAA,IAAY,EAAE,aAAa;;AAIhE,SAAgB,EAAU,GAAiD;AACzE,KAAI,CAAC,EAAM,QAAO;CAClB,IAAM,IAAI,OAAO,KAAS,WAAW,IAAI,KAAK,EAAK,GAAG;AAEtD,QADI,OAAO,MAAM,EAAE,SAAS,CAAC,GAAS,KAC/B,EAAE,SAAS,GAAG,KAAK,KAAK"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
//#region src/theglobalfuel/utils/transitions.ts
|
|
2
|
+
var e = {
|
|
3
|
+
EXPLORATION: ["APPRAISAL", "DECOMMISSIONING"],
|
|
4
|
+
APPRAISAL: ["DEVELOPMENT", "DECOMMISSIONING"],
|
|
5
|
+
DEVELOPMENT: ["PRODUCING", "DECOMMISSIONING"],
|
|
6
|
+
PRODUCING: ["SUSPENDED", "DECOMMISSIONING"],
|
|
7
|
+
SUSPENDED: ["PRODUCING", "DECOMMISSIONING"],
|
|
8
|
+
DECOMMISSIONING: ["RETIRED"],
|
|
9
|
+
RETIRED: []
|
|
10
|
+
}, t = {
|
|
11
|
+
DRAFT: ["NEGOTIATION", "TERMINATED"],
|
|
12
|
+
NEGOTIATION: [
|
|
13
|
+
"SIGNED",
|
|
14
|
+
"DRAFT",
|
|
15
|
+
"TERMINATED"
|
|
16
|
+
],
|
|
17
|
+
SIGNED: ["ACTIVE", "TERMINATED"],
|
|
18
|
+
ACTIVE: [
|
|
19
|
+
"SUSPENDED",
|
|
20
|
+
"COMPLETED",
|
|
21
|
+
"TERMINATED"
|
|
22
|
+
],
|
|
23
|
+
SUSPENDED: ["ACTIVE", "TERMINATED"],
|
|
24
|
+
COMPLETED: [],
|
|
25
|
+
TERMINATED: []
|
|
26
|
+
}, n = {
|
|
27
|
+
PENDING: ["SUBMITTED"],
|
|
28
|
+
SUBMITTED: ["APPROVED", "REJECTED"],
|
|
29
|
+
APPROVED: ["EXPIRED", "REVOKED"],
|
|
30
|
+
REJECTED: ["SUBMITTED"],
|
|
31
|
+
EXPIRED: ["SUBMITTED"],
|
|
32
|
+
REVOKED: []
|
|
33
|
+
}, r = {
|
|
34
|
+
AVAILABLE: [
|
|
35
|
+
"RESERVED",
|
|
36
|
+
"IN_TRANSIT",
|
|
37
|
+
"CONSUMED",
|
|
38
|
+
"WRITTEN_OFF"
|
|
39
|
+
],
|
|
40
|
+
RESERVED: [
|
|
41
|
+
"AVAILABLE",
|
|
42
|
+
"IN_TRANSIT",
|
|
43
|
+
"CONSUMED",
|
|
44
|
+
"WRITTEN_OFF"
|
|
45
|
+
],
|
|
46
|
+
IN_TRANSIT: [
|
|
47
|
+
"AVAILABLE",
|
|
48
|
+
"CONSUMED",
|
|
49
|
+
"WRITTEN_OFF"
|
|
50
|
+
],
|
|
51
|
+
CONSUMED: [],
|
|
52
|
+
WRITTEN_OFF: []
|
|
53
|
+
}, i = {
|
|
54
|
+
SCHEDULED: ["LOADING", "CANCELLED"],
|
|
55
|
+
LOADING: ["IN_TRANSIT", "CANCELLED"],
|
|
56
|
+
IN_TRANSIT: ["CANCELLED"],
|
|
57
|
+
DELIVERED: [],
|
|
58
|
+
CANCELLED: []
|
|
59
|
+
}, a = [
|
|
60
|
+
"SCHEDULED",
|
|
61
|
+
"LOADING",
|
|
62
|
+
"IN_TRANSIT"
|
|
63
|
+
];
|
|
64
|
+
function o(e, t) {
|
|
65
|
+
return e[t] ?? [];
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { e as ASSET_TRANSITIONS, n as COMPLIANCE_TRANSITIONS, t as CONTRACT_TRANSITIONS, r as INVENTORY_TRANSITIONS, a as SHIPMENT_DELIVERABLE_FROM, i as SHIPMENT_TRANSITIONS, o as nextStatuses };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=transitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transitions.js","names":[],"sources":["../../../src/theglobalfuel/utils/transitions.ts"],"sourcesContent":["/**\n * Lifecycle state machines — MIRROR of the wspace-theglobalfuel-svc service\n * transition maps (registry/commerce/sustainability). Used to offer ONLY the\n * legal next states in the UI transition Selects, so a user can never pick a\n * transition the backend rejects (which previously failed silently / errored).\n *\n * Keep these in exact sync with the svc: registry.service.ts ASSET_TRANSITIONS,\n * commerce.service.ts CONTRACT_TRANSITIONS / SHIPMENT_TRANSITIONS /\n * INVENTORY_TRANSITIONS, sustainability.service.ts COMPLIANCE_TRANSITIONS.\n *\n * @module theglobalfuel/utils/transitions\n */\n\nimport type {\n TheAssetStatus,\n TheContractStatus,\n TheComplianceStatus,\n TheInventoryStatus,\n TheShipmentStatus,\n} from '../types';\n\nexport const ASSET_TRANSITIONS: Record<TheAssetStatus, readonly TheAssetStatus[]> = {\n EXPLORATION: ['APPRAISAL', 'DECOMMISSIONING'],\n APPRAISAL: ['DEVELOPMENT', 'DECOMMISSIONING'],\n DEVELOPMENT: ['PRODUCING', 'DECOMMISSIONING'],\n PRODUCING: ['SUSPENDED', 'DECOMMISSIONING'],\n SUSPENDED: ['PRODUCING', 'DECOMMISSIONING'],\n DECOMMISSIONING: ['RETIRED'],\n RETIRED: [],\n};\n\nexport const CONTRACT_TRANSITIONS: Record<TheContractStatus, readonly TheContractStatus[]> = {\n DRAFT: ['NEGOTIATION', 'TERMINATED'],\n NEGOTIATION: ['SIGNED', 'DRAFT', 'TERMINATED'],\n SIGNED: ['ACTIVE', 'TERMINATED'],\n ACTIVE: ['SUSPENDED', 'COMPLETED', 'TERMINATED'],\n SUSPENDED: ['ACTIVE', 'TERMINATED'],\n COMPLETED: [],\n TERMINATED: [],\n};\n\nexport const COMPLIANCE_TRANSITIONS: Record<TheComplianceStatus, readonly TheComplianceStatus[]> = {\n PENDING: ['SUBMITTED'],\n SUBMITTED: ['APPROVED', 'REJECTED'],\n APPROVED: ['EXPIRED', 'REVOKED'],\n REJECTED: ['SUBMITTED'],\n EXPIRED: ['SUBMITTED'],\n REVOKED: [],\n};\n\nexport const INVENTORY_TRANSITIONS: Record<TheInventoryStatus, readonly TheInventoryStatus[]> = {\n AVAILABLE: ['RESERVED', 'IN_TRANSIT', 'CONSUMED', 'WRITTEN_OFF'],\n RESERVED: ['AVAILABLE', 'IN_TRANSIT', 'CONSUMED', 'WRITTEN_OFF'],\n IN_TRANSIT: ['AVAILABLE', 'CONSUMED', 'WRITTEN_OFF'],\n CONSUMED: [],\n WRITTEN_OFF: [],\n};\n\n/**\n * Shipment transitions reachable via `theTransitionShipment`. Note DELIVERED is\n * NOT offered here — it is reached through the \"Mark delivered\" action\n * (`theDeliverShipment`), which additionally rolls volume into the contract.\n */\nexport const SHIPMENT_TRANSITIONS: Record<TheShipmentStatus, readonly TheShipmentStatus[]> = {\n SCHEDULED: ['LOADING', 'CANCELLED'],\n LOADING: ['IN_TRANSIT', 'CANCELLED'],\n IN_TRANSIT: ['CANCELLED'],\n DELIVERED: [],\n CANCELLED: [],\n};\n\n/** Statuses a shipment can be marked DELIVERED from (via theDeliverShipment). */\nexport const SHIPMENT_DELIVERABLE_FROM: readonly TheShipmentStatus[] = [\n 'SCHEDULED',\n 'LOADING',\n 'IN_TRANSIT',\n];\n\n/** Legal next states for `current`, or [] if terminal/unknown. */\nexport function nextStatuses<T extends string>(\n map: Record<string, readonly T[]>,\n current: string\n): readonly T[] {\n return map[current] ?? [];\n}\n"],"mappings":";AAqBA,IAAa,IAAuE;CAClF,aAAa,CAAC,aAAa,kBAAkB;CAC7C,WAAW,CAAC,eAAe,kBAAkB;CAC7C,aAAa,CAAC,aAAa,kBAAkB;CAC7C,WAAW,CAAC,aAAa,kBAAkB;CAC3C,WAAW,CAAC,aAAa,kBAAkB;CAC3C,iBAAiB,CAAC,UAAU;CAC5B,SAAS,EAAE;CACZ,EAEY,IAAgF;CAC3F,OAAO,CAAC,eAAe,aAAa;CACpC,aAAa;EAAC;EAAU;EAAS;EAAa;CAC9C,QAAQ,CAAC,UAAU,aAAa;CAChC,QAAQ;EAAC;EAAa;EAAa;EAAa;CAChD,WAAW,CAAC,UAAU,aAAa;CACnC,WAAW,EAAE;CACb,YAAY,EAAE;CACf,EAEY,IAAsF;CACjG,SAAS,CAAC,YAAY;CACtB,WAAW,CAAC,YAAY,WAAW;CACnC,UAAU,CAAC,WAAW,UAAU;CAChC,UAAU,CAAC,YAAY;CACvB,SAAS,CAAC,YAAY;CACtB,SAAS,EAAE;CACZ,EAEY,IAAmF;CAC9F,WAAW;EAAC;EAAY;EAAc;EAAY;EAAc;CAChE,UAAU;EAAC;EAAa;EAAc;EAAY;EAAc;CAChE,YAAY;EAAC;EAAa;EAAY;EAAc;CACpD,UAAU,EAAE;CACZ,aAAa,EAAE;CAChB,EAOY,IAAgF;CAC3F,WAAW,CAAC,WAAW,YAAY;CACnC,SAAS,CAAC,cAAc,YAAY;CACpC,YAAY,CAAC,YAAY;CACzB,WAAW,EAAE;CACb,WAAW,EAAE;CACd,EAGY,IAA0D;CACrE;CACA;CACA;CACD;AAGD,SAAgB,EACd,GACA,GACc;AACd,QAAO,EAAI,MAAY,EAAE"}
|
package/package.json
CHANGED
package/dist/dev/main.d.ts
DELETED
package/dist/dev/main.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/dev/main.tsx"],"names":[],"mappings":"AAIA,OAAO,cAAc,CAAC"}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clsx.js","names":[],"sources":["../../../../../../../../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs"],"sourcesContent":["function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;"],"x_google_ignoreList":[0],"mappings":";AAAA,SAAS,EAAE,GAAE;CAAC,IAAI,GAAE,GAAE,IAAE;AAAG,KAAa,OAAO,KAAjB,YAA8B,OAAO,KAAjB,SAAmB,MAAG;UAAoB,OAAO,KAAjB,SAAmB,KAAG,MAAM,QAAQ,EAAE,EAAC;EAAC,IAAI,IAAE,EAAE;AAAO,OAAI,IAAE,GAAE,IAAE,GAAE,IAAI,GAAE,OAAK,IAAE,EAAE,EAAE,GAAG,MAAI,MAAI,KAAG,MAAK,KAAG;OAAQ,MAAI,KAAK,EAAE,GAAE,OAAK,MAAI,KAAG,MAAK,KAAG;AAAG,QAAO;;AAAE,SAAgB,IAAM;AAAC,MAAI,IAAI,GAAE,GAAE,IAAE,GAAE,IAAE,IAAG,IAAE,UAAU,QAAO,IAAE,GAAE,IAAI,EAAC,IAAE,UAAU,QAAM,IAAE,EAAE,EAAE,MAAI,MAAI,KAAG,MAAK,KAAG;AAAG,QAAO"}
|