@freighttech/shipment-tracking 0.6.0
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/LICENSE +21 -0
- package/NOTICE +25 -0
- package/dist/generated/entities/bic_config/index.js +21 -0
- package/dist/generated/entities/bic_config/index.js.map +7 -0
- package/dist/generated/entities/carrier_config/index.js +27 -0
- package/dist/generated/entities/carrier_config/index.js.map +7 -0
- package/dist/generated/entities/location_override/index.js +33 -0
- package/dist/generated/entities/location_override/index.js.map +7 -0
- package/dist/generated/entities/shipment/index.js +73 -0
- package/dist/generated/entities/shipment/index.js.map +7 -0
- package/dist/generated/entities/ships_go_config/index.js +31 -0
- package/dist/generated/entities/ships_go_config/index.js.map +7 -0
- package/dist/generated/entities/tracking_event/index.js +101 -0
- package/dist/generated/entities/tracking_event/index.js.map +7 -0
- package/dist/generated/entities/tracking_job/index.js +47 -0
- package/dist/generated/entities/tracking_job/index.js.map +7 -0
- package/dist/generated/entities/webhook/index.js +25 -0
- package/dist/generated/entities/webhook/index.js.map +7 -0
- package/dist/generated/entities/webhook_delivery/index.js +25 -0
- package/dist/generated/entities/webhook_delivery/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +21 -0
- package/dist/generated/entities.ids.generated.js.map +7 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +7 -0
- package/dist/modules/shipment_tracking/acl.js +22 -0
- package/dist/modules/shipment_tracking/acl.js.map +7 -0
- package/dist/modules/shipment_tracking/api/bic-configs/route.js +176 -0
- package/dist/modules/shipment_tracking/api/bic-configs/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/bic-configs/test/route.js +95 -0
- package/dist/modules/shipment_tracking/api/bic-configs/test/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/cargo-events/route.js +93 -0
- package/dist/modules/shipment_tracking/api/cargo-events/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/carrier-configs/route.js +139 -0
- package/dist/modules/shipment_tracking/api/carrier-configs/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/dashboard/ships-map/route.js +177 -0
- package/dist/modules/shipment_tracking/api/dashboard/ships-map/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/location-overrides/route.js +179 -0
- package/dist/modules/shipment_tracking/api/location-overrides/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/openapi.js +27 -0
- package/dist/modules/shipment_tracking/api/openapi.js.map +7 -0
- package/dist/modules/shipment_tracking/api/shipments/route.js +192 -0
- package/dist/modules/shipment_tracking/api/shipments/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/shipsgo-configs/route.js +185 -0
- package/dist/modules/shipment_tracking/api/shipsgo-configs/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/tracking-jobs/route.js +144 -0
- package/dist/modules/shipment_tracking/api/tracking-jobs/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/tracking-jobs/sync/route.js +107 -0
- package/dist/modules/shipment_tracking/api/tracking-jobs/sync/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/utils.js +12 -0
- package/dist/modules/shipment_tracking/api/utils.js.map +7 -0
- package/dist/modules/shipment_tracking/api/webhooks/deliveries/route.js +76 -0
- package/dist/modules/shipment_tracking/api/webhooks/deliveries/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/webhooks/route.js +135 -0
- package/dist/modules/shipment_tracking/api/webhooks/route.js.map +7 -0
- package/dist/modules/shipment_tracking/api/webhooks/test/route.js +71 -0
- package/dist/modules/shipment_tracking/api/webhooks/test/route.js.map +7 -0
- package/dist/modules/shipment_tracking/assets/carriers/cma_cgm.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/cosco.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/evergreen.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/hapag_lloyd.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/maersk.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/msc.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/one.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/oocl.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/yang_ming.png +0 -0
- package/dist/modules/shipment_tracking/assets/carriers/zim.png +0 -0
- package/dist/modules/shipment_tracking/assets/index.js +52 -0
- package/dist/modules/shipment_tracking/assets/index.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/carrier-configs/page.js +621 -0
- package/dist/modules/shipment_tracking/backend/carrier-configs/page.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/carrier-configs/page.meta.js +19 -0
- package/dist/modules/shipment_tracking/backend/carrier-configs/page.meta.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/location-overrides/page.js +198 -0
- package/dist/modules/shipment_tracking/backend/location-overrides/page.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/location-overrides/page.meta.js +19 -0
- package/dist/modules/shipment_tracking/backend/location-overrides/page.meta.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/shipment-tracking/page.js +279 -0
- package/dist/modules/shipment_tracking/backend/shipment-tracking/page.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/shipment-tracking/page.meta.js +19 -0
- package/dist/modules/shipment_tracking/backend/shipment-tracking/page.meta.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/tracking-jobs/page.js +10 -0
- package/dist/modules/shipment_tracking/backend/tracking-jobs/page.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/tracking-jobs/page.meta.js +19 -0
- package/dist/modules/shipment_tracking/backend/tracking-jobs/page.meta.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/webhooks/page.js +198 -0
- package/dist/modules/shipment_tracking/backend/webhooks/page.js.map +7 -0
- package/dist/modules/shipment_tracking/backend/webhooks/page.meta.js +19 -0
- package/dist/modules/shipment_tracking/backend/webhooks/page.meta.js.map +7 -0
- package/dist/modules/shipment_tracking/ce.js +52 -0
- package/dist/modules/shipment_tracking/ce.js.map +7 -0
- package/dist/modules/shipment_tracking/cli.js +229 -0
- package/dist/modules/shipment_tracking/cli.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/bic-configs.js +66 -0
- package/dist/modules/shipment_tracking/commands/bic-configs.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/carrier-configs.js +65 -0
- package/dist/modules/shipment_tracking/commands/carrier-configs.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/index.js +9 -0
- package/dist/modules/shipment_tracking/commands/index.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/location-overrides.js +93 -0
- package/dist/modules/shipment_tracking/commands/location-overrides.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/shipments.js +200 -0
- package/dist/modules/shipment_tracking/commands/shipments.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/shipsgo-configs.js +75 -0
- package/dist/modules/shipment_tracking/commands/shipsgo-configs.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/tracking-jobs.js +120 -0
- package/dist/modules/shipment_tracking/commands/tracking-jobs.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/tracking.js +140 -0
- package/dist/modules/shipment_tracking/commands/tracking.js.map +7 -0
- package/dist/modules/shipment_tracking/commands/webhooks.js +115 -0
- package/dist/modules/shipment_tracking/commands/webhooks.js.map +7 -0
- package/dist/modules/shipment_tracking/components/CombinedTimestampCell.js +168 -0
- package/dist/modules/shipment_tracking/components/CombinedTimestampCell.js.map +7 -0
- package/dist/modules/shipment_tracking/components/FacilityLocationInput.js +202 -0
- package/dist/modules/shipment_tracking/components/FacilityLocationInput.js.map +7 -0
- package/dist/modules/shipment_tracking/components/LocationOverrideDrawer.js +501 -0
- package/dist/modules/shipment_tracking/components/LocationOverrideDrawer.js.map +7 -0
- package/dist/modules/shipment_tracking/components/ShipmentDetailsDrawer.js +818 -0
- package/dist/modules/shipment_tracking/components/ShipmentDetailsDrawer.js.map +7 -0
- package/dist/modules/shipment_tracking/components/ShipmentDrawer.js +404 -0
- package/dist/modules/shipment_tracking/components/ShipmentDrawer.js.map +7 -0
- package/dist/modules/shipment_tracking/components/ShipsGoConfigSection.js +200 -0
- package/dist/modules/shipment_tracking/components/ShipsGoConfigSection.js.map +7 -0
- package/dist/modules/shipment_tracking/components/TimestampCell.js +108 -0
- package/dist/modules/shipment_tracking/components/TimestampCell.js.map +7 -0
- package/dist/modules/shipment_tracking/components/TrackingJobDrawer.js +343 -0
- package/dist/modules/shipment_tracking/components/TrackingJobDrawer.js.map +7 -0
- package/dist/modules/shipment_tracking/components/VesselTrackingMap.js +496 -0
- package/dist/modules/shipment_tracking/components/VesselTrackingMap.js.map +7 -0
- package/dist/modules/shipment_tracking/components/WebhookDrawer.js +332 -0
- package/dist/modules/shipment_tracking/components/WebhookDrawer.js.map +7 -0
- package/dist/modules/shipment_tracking/data/entities.js +686 -0
- package/dist/modules/shipment_tracking/data/entities.js.map +7 -0
- package/dist/modules/shipment_tracking/data/validators.js +434 -0
- package/dist/modules/shipment_tracking/data/validators.js.map +7 -0
- package/dist/modules/shipment_tracking/di.js +60 -0
- package/dist/modules/shipment_tracking/di.js.map +7 -0
- package/dist/modules/shipment_tracking/encryption.js +12 -0
- package/dist/modules/shipment_tracking/encryption.js.map +7 -0
- package/dist/modules/shipment_tracking/events.js +87 -0
- package/dist/modules/shipment_tracking/events.js.map +7 -0
- package/dist/modules/shipment_tracking/hooks/useVesselTracking.js +137 -0
- package/dist/modules/shipment_tracking/hooks/useVesselTracking.js.map +7 -0
- package/dist/modules/shipment_tracking/i18n/de.json +327 -0
- package/dist/modules/shipment_tracking/i18n/en.json +327 -0
- package/dist/modules/shipment_tracking/i18n/es.json +327 -0
- package/dist/modules/shipment_tracking/i18n/pl.json +327 -0
- package/dist/modules/shipment_tracking/index.js +15 -0
- package/dist/modules/shipment_tracking/index.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/cma-cgm.js +66 -0
- package/dist/modules/shipment_tracking/lib/adapters/cma-cgm.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/cosco-types.js +1 -0
- package/dist/modules/shipment_tracking/lib/adapters/cosco-types.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/cosco.js +236 -0
- package/dist/modules/shipment_tracking/lib/adapters/cosco.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/evergreen.js +87 -0
- package/dist/modules/shipment_tracking/lib/adapters/evergreen.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/hapag-lloyd.js +68 -0
- package/dist/modules/shipment_tracking/lib/adapters/hapag-lloyd.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/index.js +20 -0
- package/dist/modules/shipment_tracking/lib/adapters/index.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/maersk.js +84 -0
- package/dist/modules/shipment_tracking/lib/adapters/maersk.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/msc.js +170 -0
- package/dist/modules/shipment_tracking/lib/adapters/msc.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/adapters/zim.js +85 -0
- package/dist/modules/shipment_tracking/lib/adapters/zim.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/audit-helpers.js +20 -0
- package/dist/modules/shipment_tracking/lib/audit-helpers.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/auth/base64url.js +8 -0
- package/dist/modules/shipment_tracking/lib/auth/base64url.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/auth/oauth-client.js +38 -0
- package/dist/modules/shipment_tracking/lib/auth/oauth-client.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/background.js +15 -0
- package/dist/modules/shipment_tracking/lib/background.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/bic-api-client.js +106 -0
- package/dist/modules/shipment_tracking/lib/bic-api-client.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/carrier-adapter.js +17 -0
- package/dist/modules/shipment_tracking/lib/carrier-adapter.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/current-vessel.js +149 -0
- package/dist/modules/shipment_tracking/lib/current-vessel.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/dcsa-event-mapping.js +124 -0
- package/dist/modules/shipment_tracking/lib/dcsa-event-mapping.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/dcsa-event-parser.js +112 -0
- package/dist/modules/shipment_tracking/lib/dcsa-event-parser.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/dcsa-params.js +16 -0
- package/dist/modules/shipment_tracking/lib/dcsa-params.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/empty-return.js +48 -0
- package/dist/modules/shipment_tracking/lib/empty-return.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/location-overrides.js +85 -0
- package/dist/modules/shipment_tracking/lib/location-overrides.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/location-types.js +59 -0
- package/dist/modules/shipment_tracking/lib/location-types.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/logger.js +113 -0
- package/dist/modules/shipment_tracking/lib/logger.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/poi-event-processor.js +183 -0
- package/dist/modules/shipment_tracking/lib/poi-event-processor.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/poi-nats-config.js +52 -0
- package/dist/modules/shipment_tracking/lib/poi-nats-config.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/poi-types.js +43 -0
- package/dist/modules/shipment_tracking/lib/poi-types.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/rate-limiter.js +31 -0
- package/dist/modules/shipment_tracking/lib/rate-limiter.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/route-extraction.js +187 -0
- package/dist/modules/shipment_tracking/lib/route-extraction.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/route-inference.js +106 -0
- package/dist/modules/shipment_tracking/lib/route-inference.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/schedule-generator.js +63 -0
- package/dist/modules/shipment_tracking/lib/schedule-generator.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/shipsgo-client.js +143 -0
- package/dist/modules/shipment_tracking/lib/shipsgo-client.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/shipsgo-mapper.js +204 -0
- package/dist/modules/shipment_tracking/lib/shipsgo-mapper.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/status-machine.js +131 -0
- package/dist/modules/shipment_tracking/lib/status-machine.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/time-extraction.js +41 -0
- package/dist/modules/shipment_tracking/lib/time-extraction.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/timestamp-utils.js +100 -0
- package/dist/modules/shipment_tracking/lib/timestamp-utils.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/vessel-api.js +111 -0
- package/dist/modules/shipment_tracking/lib/vessel-api.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/vessel-cache.js +50 -0
- package/dist/modules/shipment_tracking/lib/vessel-cache.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/vessel-extraction.js +13 -0
- package/dist/modules/shipment_tracking/lib/vessel-extraction.js.map +7 -0
- package/dist/modules/shipment_tracking/lib/webhook-dispatcher.js +62 -0
- package/dist/modules/shipment_tracking/lib/webhook-dispatcher.js.map +7 -0
- package/dist/modules/shipment_tracking/migrations/Migration20260422161208_shipment_tracking.js +48 -0
- package/dist/modules/shipment_tracking/migrations/Migration20260422161208_shipment_tracking.js.map +7 -0
- package/dist/modules/shipment_tracking/migrations/Migration20260529120000_shipment_tracking_poi_region_names.js +15 -0
- package/dist/modules/shipment_tracking/migrations/Migration20260529120000_shipment_tracking_poi_region_names.js.map +7 -0
- package/dist/modules/shipment_tracking/migrations/Migration20260821120000_shipment_tracking_shipsgo.js +47 -0
- package/dist/modules/shipment_tracking/migrations/Migration20260821120000_shipment_tracking_shipsgo.js.map +7 -0
- package/dist/modules/shipment_tracking/notifications.js +145 -0
- package/dist/modules/shipment_tracking/notifications.js.map +7 -0
- package/dist/modules/shipment_tracking/services/carrierRegistry.js +24 -0
- package/dist/modules/shipment_tracking/services/carrierRegistry.js.map +7 -0
- package/dist/modules/shipment_tracking/services/poiNatsService.js +397 -0
- package/dist/modules/shipment_tracking/services/poiNatsService.js.map +7 -0
- package/dist/modules/shipment_tracking/services/shipsGoProvider.js +163 -0
- package/dist/modules/shipment_tracking/services/shipsGoProvider.js.map +7 -0
- package/dist/modules/shipment_tracking/services/trackingService.js +1283 -0
- package/dist/modules/shipment_tracking/services/trackingService.js.map +7 -0
- package/dist/modules/shipment_tracking/services/webhookService.js +263 -0
- package/dist/modules/shipment_tracking/services/webhookService.js.map +7 -0
- package/dist/modules/shipment_tracking/setup.js +72 -0
- package/dist/modules/shipment_tracking/setup.js.map +7 -0
- package/dist/modules/shipment_tracking/subscribers/cargo-event-created.js +60 -0
- package/dist/modules/shipment_tracking/subscribers/cargo-event-created.js.map +7 -0
- package/dist/modules/shipment_tracking/subscribers/dcsa-event-webhook-dispatch.js +58 -0
- package/dist/modules/shipment_tracking/subscribers/dcsa-event-webhook-dispatch.js.map +7 -0
- package/dist/modules/shipment_tracking/subscribers/poi-event-notification.js +82 -0
- package/dist/modules/shipment_tracking/subscribers/poi-event-notification.js.map +7 -0
- package/dist/modules/shipment_tracking/subscribers/poi-event-webhook-dispatch.js +53 -0
- package/dist/modules/shipment_tracking/subscribers/poi-event-webhook-dispatch.js.map +7 -0
- package/dist/modules/shipment_tracking/subscribers/shipment-status-changed.js +28 -0
- package/dist/modules/shipment_tracking/subscribers/shipment-status-changed.js.map +7 -0
- package/dist/modules/shipment_tracking/subscribers/terminal-event-ingest.js +67 -0
- package/dist/modules/shipment_tracking/subscribers/terminal-event-ingest.js.map +7 -0
- package/dist/modules/shipment_tracking/subscribers/tracking-job-initial-poll.js +30 -0
- package/dist/modules/shipment_tracking/subscribers/tracking-job-initial-poll.js.map +7 -0
- package/dist/modules/shipment_tracking/subscribers/tracking-job-webhook-dispatch.js +19 -0
- package/dist/modules/shipment_tracking/subscribers/tracking-job-webhook-dispatch.js.map +7 -0
- package/dist/modules/shipment_tracking/tables/index.js +6 -0
- package/dist/modules/shipment_tracking/tables/index.js.map +7 -0
- package/dist/modules/shipment_tracking/tables/tracking_job/table.client.js +284 -0
- package/dist/modules/shipment_tracking/tables/tracking_job/table.client.js.map +7 -0
- package/dist/modules/shipment_tracking/tables/tracking_job/table.js +36 -0
- package/dist/modules/shipment_tracking/tables/tracking_job/table.js.map +7 -0
- package/dist/modules/shipment_tracking/widgets/dashboard/ships-map/config.js +25 -0
- package/dist/modules/shipment_tracking/widgets/dashboard/ships-map/config.js.map +7 -0
- package/dist/modules/shipment_tracking/widgets/dashboard/ships-map/widget.client.js +355 -0
- package/dist/modules/shipment_tracking/widgets/dashboard/ships-map/widget.client.js.map +7 -0
- package/dist/modules/shipment_tracking/widgets/dashboard/ships-map/widget.js +26 -0
- package/dist/modules/shipment_tracking/widgets/dashboard/ships-map/widget.js.map +7 -0
- package/dist/types/assets.d.js +1 -0
- package/dist/types/assets.d.js.map +7 -0
- package/generated/entities/bic_config/index.ts +20 -0
- package/generated/entities/carrier_config/index.ts +23 -0
- package/generated/entities/location_override/index.ts +26 -0
- package/generated/entities/shipment/index.ts +46 -0
- package/generated/entities/ships_go_config/index.ts +25 -0
- package/generated/entities/tracking_event/index.ts +60 -0
- package/generated/entities/tracking_job/index.ts +33 -0
- package/generated/entities/webhook/index.ts +22 -0
- package/generated/entities/webhook_delivery/index.ts +22 -0
- package/generated/entities.ids.generated.ts +47 -0
- package/package.json +81 -0
- package/src/index.ts +39 -0
- package/src/modules/shipment_tracking/__integration__/TC-TRACK-410-shipsgo-config-api.spec.ts +133 -0
- package/src/modules/shipment_tracking/__integration__/meta.ts +4 -0
- package/src/modules/shipment_tracking/__tests__/empty-return-stop.test.ts +231 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/hapag-lloyd-transship-container.json +702 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/index.ts +434 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/maersk-multi-transship-completed.json +1518 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/maersk-transship-intransit.json +558 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/msc-direct.json +222 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/msc-multi-transship-completed.json +974 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/msc-multi.json +4846 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/msc-transship.json +409 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/poi-events.json +240 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/synthetic/index.ts +138 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/synthetic-eta-updates.json +288 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/synthetic-route-inference.json +201 -0
- package/src/modules/shipment_tracking/__tests__/fixtures/synthetic-voyage-progression.json +410 -0
- package/src/modules/shipment_tracking/__tests__/shipsgo-air-mapper.test.ts +157 -0
- package/src/modules/shipment_tracking/__tests__/shipsgo-client.test.ts +155 -0
- package/src/modules/shipment_tracking/__tests__/shipsgo-mapper.test.ts +201 -0
- package/src/modules/shipment_tracking/__tests__/shipsgo-poll.test.ts +357 -0
- package/src/modules/shipment_tracking/__tests__/shipsgo-provider.test.ts +364 -0
- package/src/modules/shipment_tracking/__tests__/trackingService.integration.test.ts +2248 -0
- package/src/modules/shipment_tracking/__tests__/webhookPayload.test.ts +151 -0
- package/src/modules/shipment_tracking/acl.ts +18 -0
- package/src/modules/shipment_tracking/api/bic-configs/route.ts +206 -0
- package/src/modules/shipment_tracking/api/bic-configs/test/route.ts +108 -0
- package/src/modules/shipment_tracking/api/cargo-events/route.ts +101 -0
- package/src/modules/shipment_tracking/api/carrier-configs/route.ts +142 -0
- package/src/modules/shipment_tracking/api/dashboard/ships-map/route.ts +246 -0
- package/src/modules/shipment_tracking/api/location-overrides/route.ts +185 -0
- package/src/modules/shipment_tracking/api/openapi.ts +28 -0
- package/src/modules/shipment_tracking/api/shipments/route.ts +197 -0
- package/src/modules/shipment_tracking/api/shipsgo-configs/route.ts +215 -0
- package/src/modules/shipment_tracking/api/tracking-jobs/route.ts +149 -0
- package/src/modules/shipment_tracking/api/tracking-jobs/sync/route.ts +116 -0
- package/src/modules/shipment_tracking/api/utils.ts +10 -0
- package/src/modules/shipment_tracking/api/webhooks/deliveries/route.ts +82 -0
- package/src/modules/shipment_tracking/api/webhooks/route.ts +138 -0
- package/src/modules/shipment_tracking/api/webhooks/test/route.ts +84 -0
- package/src/modules/shipment_tracking/assets/carriers/cma_cgm.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/cosco.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/evergreen.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/hapag_lloyd.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/maersk.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/msc.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/one.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/oocl.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/yang_ming.png +0 -0
- package/src/modules/shipment_tracking/assets/carriers/zim.png +0 -0
- package/src/modules/shipment_tracking/assets/index.ts +66 -0
- package/src/modules/shipment_tracking/backend/carrier-configs/page.meta.ts +16 -0
- package/src/modules/shipment_tracking/backend/carrier-configs/page.tsx +782 -0
- package/src/modules/shipment_tracking/backend/location-overrides/page.meta.ts +16 -0
- package/src/modules/shipment_tracking/backend/location-overrides/page.tsx +241 -0
- package/src/modules/shipment_tracking/backend/shipment-tracking/page.meta.ts +16 -0
- package/src/modules/shipment_tracking/backend/shipment-tracking/page.tsx +340 -0
- package/src/modules/shipment_tracking/backend/tracking-jobs/page.meta.ts +16 -0
- package/src/modules/shipment_tracking/backend/tracking-jobs/page.tsx +16 -0
- package/src/modules/shipment_tracking/backend/webhooks/page.meta.ts +16 -0
- package/src/modules/shipment_tracking/backend/webhooks/page.tsx +228 -0
- package/src/modules/shipment_tracking/ce.ts +48 -0
- package/src/modules/shipment_tracking/cli.ts +321 -0
- package/src/modules/shipment_tracking/commands/bic-configs.ts +94 -0
- package/src/modules/shipment_tracking/commands/carrier-configs.ts +89 -0
- package/src/modules/shipment_tracking/commands/index.ts +8 -0
- package/src/modules/shipment_tracking/commands/location-overrides.ts +119 -0
- package/src/modules/shipment_tracking/commands/shipments.ts +247 -0
- package/src/modules/shipment_tracking/commands/shipsgo-configs.ts +101 -0
- package/src/modules/shipment_tracking/commands/tracking-jobs.ts +158 -0
- package/src/modules/shipment_tracking/commands/tracking.ts +230 -0
- package/src/modules/shipment_tracking/commands/webhooks.ts +159 -0
- package/src/modules/shipment_tracking/components/CombinedTimestampCell.tsx +236 -0
- package/src/modules/shipment_tracking/components/FacilityLocationInput.tsx +235 -0
- package/src/modules/shipment_tracking/components/LocationOverrideDrawer.tsx +586 -0
- package/src/modules/shipment_tracking/components/ShipmentDetailsDrawer.tsx +1364 -0
- package/src/modules/shipment_tracking/components/ShipmentDrawer.tsx +498 -0
- package/src/modules/shipment_tracking/components/ShipsGoConfigSection.tsx +266 -0
- package/src/modules/shipment_tracking/components/TimestampCell.tsx +146 -0
- package/src/modules/shipment_tracking/components/TrackingJobDrawer.tsx +467 -0
- package/src/modules/shipment_tracking/components/VesselTrackingMap.tsx +761 -0
- package/src/modules/shipment_tracking/components/WebhookDrawer.tsx +434 -0
- package/src/modules/shipment_tracking/data/entities.ts +748 -0
- package/src/modules/shipment_tracking/data/validators.ts +523 -0
- package/src/modules/shipment_tracking/di.ts +73 -0
- package/src/modules/shipment_tracking/encryption.ts +17 -0
- package/src/modules/shipment_tracking/events.ts +122 -0
- package/src/modules/shipment_tracking/hooks/useVesselTracking.ts +297 -0
- package/src/modules/shipment_tracking/i18n/de.json +327 -0
- package/src/modules/shipment_tracking/i18n/en.json +327 -0
- package/src/modules/shipment_tracking/i18n/es.json +327 -0
- package/src/modules/shipment_tracking/i18n/pl.json +327 -0
- package/src/modules/shipment_tracking/index.ts +13 -0
- package/src/modules/shipment_tracking/lib/__tests__/dcsa-event-mapping.test.ts +385 -0
- package/src/modules/shipment_tracking/lib/__tests__/dcsa-event-parser.test.ts +398 -0
- package/src/modules/shipment_tracking/lib/__tests__/empty-return.test.ts +174 -0
- package/src/modules/shipment_tracking/lib/__tests__/poi-event-processor.test.ts +699 -0
- package/src/modules/shipment_tracking/lib/__tests__/route-inference.test.ts +402 -0
- package/src/modules/shipment_tracking/lib/__tests__/status-machine.test.ts +447 -0
- package/src/modules/shipment_tracking/lib/__tests__/time-extraction.test.ts +331 -0
- package/src/modules/shipment_tracking/lib/__tests__/timestamp-utils.test.ts +260 -0
- package/src/modules/shipment_tracking/lib/__tests__/vessel-api.test.ts +125 -0
- package/src/modules/shipment_tracking/lib/__tests__/vessel-extraction.test.ts +108 -0
- package/src/modules/shipment_tracking/lib/adapters/cma-cgm.ts +84 -0
- package/src/modules/shipment_tracking/lib/adapters/cosco-types.ts +145 -0
- package/src/modules/shipment_tracking/lib/adapters/cosco.ts +314 -0
- package/src/modules/shipment_tracking/lib/adapters/evergreen.ts +107 -0
- package/src/modules/shipment_tracking/lib/adapters/hapag-lloyd.ts +88 -0
- package/src/modules/shipment_tracking/lib/adapters/index.ts +18 -0
- package/src/modules/shipment_tracking/lib/adapters/maersk.ts +104 -0
- package/src/modules/shipment_tracking/lib/adapters/msc.ts +223 -0
- package/src/modules/shipment_tracking/lib/adapters/zim.ts +106 -0
- package/src/modules/shipment_tracking/lib/audit-helpers.ts +29 -0
- package/src/modules/shipment_tracking/lib/auth/base64url.ts +4 -0
- package/src/modules/shipment_tracking/lib/auth/oauth-client.ts +53 -0
- package/src/modules/shipment_tracking/lib/background.ts +24 -0
- package/src/modules/shipment_tracking/lib/bic-api-client.ts +199 -0
- package/src/modules/shipment_tracking/lib/carrier-adapter.ts +136 -0
- package/src/modules/shipment_tracking/lib/current-vessel.ts +274 -0
- package/src/modules/shipment_tracking/lib/dcsa-event-mapping.ts +202 -0
- package/src/modules/shipment_tracking/lib/dcsa-event-parser.ts +163 -0
- package/src/modules/shipment_tracking/lib/dcsa-params.ts +14 -0
- package/src/modules/shipment_tracking/lib/empty-return.ts +122 -0
- package/src/modules/shipment_tracking/lib/location-overrides.ts +150 -0
- package/src/modules/shipment_tracking/lib/location-types.ts +154 -0
- package/src/modules/shipment_tracking/lib/logger.ts +195 -0
- package/src/modules/shipment_tracking/lib/poi-event-processor.ts +302 -0
- package/src/modules/shipment_tracking/lib/poi-nats-config.ts +134 -0
- package/src/modules/shipment_tracking/lib/poi-types.ts +198 -0
- package/src/modules/shipment_tracking/lib/rate-limiter.ts +58 -0
- package/src/modules/shipment_tracking/lib/route-extraction.ts +439 -0
- package/src/modules/shipment_tracking/lib/route-inference.ts +238 -0
- package/src/modules/shipment_tracking/lib/schedule-generator.ts +92 -0
- package/src/modules/shipment_tracking/lib/shipsgo-client.ts +350 -0
- package/src/modules/shipment_tracking/lib/shipsgo-mapper.ts +296 -0
- package/src/modules/shipment_tracking/lib/status-machine.ts +230 -0
- package/src/modules/shipment_tracking/lib/time-extraction.ts +85 -0
- package/src/modules/shipment_tracking/lib/timestamp-utils.ts +244 -0
- package/src/modules/shipment_tracking/lib/vessel-api.ts +299 -0
- package/src/modules/shipment_tracking/lib/vessel-cache.ts +102 -0
- package/src/modules/shipment_tracking/lib/vessel-extraction.ts +39 -0
- package/src/modules/shipment_tracking/lib/webhook-dispatcher.ts +93 -0
- package/src/modules/shipment_tracking/migrations/.snapshot-open-mercato.json +2914 -0
- package/src/modules/shipment_tracking/migrations/Migration20260422161208_shipment_tracking.ts +60 -0
- package/src/modules/shipment_tracking/migrations/Migration20260529120000_shipment_tracking_poi_region_names.ts +22 -0
- package/src/modules/shipment_tracking/migrations/Migration20260821120000_shipment_tracking_shipsgo.ts +65 -0
- package/src/modules/shipment_tracking/notifications.ts +151 -0
- package/src/modules/shipment_tracking/services/carrierRegistry.ts +29 -0
- package/src/modules/shipment_tracking/services/poiNatsService.ts +526 -0
- package/src/modules/shipment_tracking/services/shipsGoProvider.ts +231 -0
- package/src/modules/shipment_tracking/services/trackingService.ts +1777 -0
- package/src/modules/shipment_tracking/services/webhookService.ts +347 -0
- package/src/modules/shipment_tracking/setup.ts +99 -0
- package/src/modules/shipment_tracking/subscribers/__tests__/terminal-event-ingest.test.ts +141 -0
- package/src/modules/shipment_tracking/subscribers/cargo-event-created.ts +115 -0
- package/src/modules/shipment_tracking/subscribers/dcsa-event-webhook-dispatch.ts +115 -0
- package/src/modules/shipment_tracking/subscribers/poi-event-notification.ts +144 -0
- package/src/modules/shipment_tracking/subscribers/poi-event-webhook-dispatch.ts +94 -0
- package/src/modules/shipment_tracking/subscribers/shipment-status-changed.ts +41 -0
- package/src/modules/shipment_tracking/subscribers/terminal-event-ingest.ts +109 -0
- package/src/modules/shipment_tracking/subscribers/tracking-job-initial-poll.ts +53 -0
- package/src/modules/shipment_tracking/subscribers/tracking-job-webhook-dispatch.ts +50 -0
- package/src/modules/shipment_tracking/tables/index.ts +4 -0
- package/src/modules/shipment_tracking/tables/tracking_job/table.client.tsx +337 -0
- package/src/modules/shipment_tracking/tables/tracking_job/table.ts +34 -0
- package/src/modules/shipment_tracking/widgets/dashboard/ships-map/config.ts +32 -0
- package/src/modules/shipment_tracking/widgets/dashboard/ships-map/widget.client.tsx +448 -0
- package/src/modules/shipment_tracking/widgets/dashboard/ships-map/widget.ts +25 -0
- package/src/types/assets.d.ts +5 -0
|
@@ -0,0 +1,782 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { useCallback, useMemo, useState } from 'react'
|
|
5
|
+
import { Page, PageBody } from '@freighttech/ui/backend/Page'
|
|
6
|
+
import { BooleanIcon } from '@freighttech/ui/backend/ValueIcons'
|
|
7
|
+
import {
|
|
8
|
+
DynamicTable,
|
|
9
|
+
TableSkeleton,
|
|
10
|
+
useDynamicTablePage,
|
|
11
|
+
} from '@freighttech/ui/backend/dynamic-table'
|
|
12
|
+
import type { ColumnDef, ContextMenuAction } from '@freighttech/ui/backend/dynamic-table'
|
|
13
|
+
import { apiCallOrThrow } from '@freighttech/ui/backend/utils/apiCall'
|
|
14
|
+
import { flash } from '@freighttech/ui/backend/FlashMessages'
|
|
15
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
16
|
+
import {
|
|
17
|
+
Dialog,
|
|
18
|
+
DialogContent,
|
|
19
|
+
DialogHeader,
|
|
20
|
+
DialogTitle,
|
|
21
|
+
DialogFooter,
|
|
22
|
+
} from '@freighttech/ui/primitives/dialog'
|
|
23
|
+
import { Button } from '@freighttech/ui/primitives/button'
|
|
24
|
+
import { Button as ButtonV2 } from '@freighttech/ui/primitives-v2'
|
|
25
|
+
import { Input } from '@freighttech/ui/primitives/input'
|
|
26
|
+
import { Label } from '@freighttech/ui/primitives/label'
|
|
27
|
+
import { Checkbox } from '@freighttech/ui/primitives/checkbox'
|
|
28
|
+
import { Textarea } from '@freighttech/ui/primitives/textarea'
|
|
29
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@freighttech/ui/primitives/card'
|
|
30
|
+
import { Badge } from '@freighttech/ui/primitives/badge'
|
|
31
|
+
import { Loader2, CheckCircle2, XCircle, Shield, Plus } from 'lucide-react'
|
|
32
|
+
import { ShipsGoConfigSection } from '../../components/ShipsGoConfigSection'
|
|
33
|
+
|
|
34
|
+
// ─── Carrier Config Types ────────────────────────────────────
|
|
35
|
+
|
|
36
|
+
type CarrierConfigRow = {
|
|
37
|
+
id: string
|
|
38
|
+
carrierCode: string
|
|
39
|
+
apiEndpoint: string | null
|
|
40
|
+
authConfig: Record<string, unknown> | null
|
|
41
|
+
rateLimitRequests: number
|
|
42
|
+
rateLimitWindowSeconds: number
|
|
43
|
+
isActive: boolean
|
|
44
|
+
createdAt: string | null
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function mapItem(item: Record<string, unknown>): CarrierConfigRow | null {
|
|
48
|
+
const id = typeof item.id === 'string' ? item.id : null
|
|
49
|
+
if (!id) return null
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
id,
|
|
53
|
+
carrierCode: (item.carrierCode as string) ?? '',
|
|
54
|
+
apiEndpoint: (item.apiEndpoint as string) ?? null,
|
|
55
|
+
authConfig: (item.authConfig as Record<string, unknown>) ?? null,
|
|
56
|
+
rateLimitRequests: typeof item.rateLimitRequests === 'number' ? item.rateLimitRequests : 60,
|
|
57
|
+
rateLimitWindowSeconds: typeof item.rateLimitWindowSeconds === 'number' ? item.rateLimitWindowSeconds : 60,
|
|
58
|
+
isActive: item.isActive === true,
|
|
59
|
+
createdAt: (item.createdAt as string) ?? null,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
type FormState = {
|
|
64
|
+
carrierCode: string
|
|
65
|
+
apiEndpoint: string
|
|
66
|
+
authConfig: string
|
|
67
|
+
rateLimitRequests: number
|
|
68
|
+
rateLimitWindowSeconds: number
|
|
69
|
+
isActive: boolean
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const emptyForm: FormState = {
|
|
73
|
+
carrierCode: '',
|
|
74
|
+
apiEndpoint: '',
|
|
75
|
+
authConfig: '',
|
|
76
|
+
rateLimitRequests: 60,
|
|
77
|
+
rateLimitWindowSeconds: 60,
|
|
78
|
+
isActive: true,
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function rowToForm(row: CarrierConfigRow): FormState {
|
|
82
|
+
return {
|
|
83
|
+
carrierCode: row.carrierCode,
|
|
84
|
+
apiEndpoint: row.apiEndpoint ?? '',
|
|
85
|
+
authConfig: row.authConfig ? JSON.stringify(row.authConfig, null, 2) : '',
|
|
86
|
+
rateLimitRequests: row.rateLimitRequests,
|
|
87
|
+
rateLimitWindowSeconds: row.rateLimitWindowSeconds,
|
|
88
|
+
isActive: row.isActive,
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// ─── BIC Config Types ────────────────────────────────────────
|
|
93
|
+
|
|
94
|
+
type BicConfigData = {
|
|
95
|
+
id: string
|
|
96
|
+
organizationId: string
|
|
97
|
+
tenantId: string
|
|
98
|
+
isEnabled: boolean
|
|
99
|
+
username: string
|
|
100
|
+
baseUrl: string
|
|
101
|
+
createdAt: string
|
|
102
|
+
updatedAt: string
|
|
103
|
+
} | null
|
|
104
|
+
|
|
105
|
+
type BicFormState = {
|
|
106
|
+
isEnabled: boolean
|
|
107
|
+
username: string
|
|
108
|
+
password: string
|
|
109
|
+
baseUrl: string
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const emptyBicForm: BicFormState = {
|
|
113
|
+
isEnabled: false,
|
|
114
|
+
username: '',
|
|
115
|
+
password: '',
|
|
116
|
+
baseUrl: 'https://api.bic-code.org',
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ─── BIC Config Section ──────────────────────────────────────
|
|
120
|
+
|
|
121
|
+
function BicConfigSection() {
|
|
122
|
+
const t = useT()
|
|
123
|
+
const [config, setConfig] = React.useState<BicConfigData>(null)
|
|
124
|
+
const [form, setForm] = React.useState<BicFormState>(emptyBicForm)
|
|
125
|
+
const [loading, setLoading] = React.useState(true)
|
|
126
|
+
const [saving, setSaving] = React.useState(false)
|
|
127
|
+
const [testing, setTesting] = React.useState(false)
|
|
128
|
+
const [testResult, setTestResult] = React.useState<{ success: boolean; message: string } | null>(null)
|
|
129
|
+
|
|
130
|
+
const fetchConfig = React.useCallback(async () => {
|
|
131
|
+
setLoading(true)
|
|
132
|
+
try {
|
|
133
|
+
const { result } = await apiCallOrThrow<{ config: BicConfigData }>('/api/shipment_tracking/bic-configs')
|
|
134
|
+
setConfig(result?.config ?? null)
|
|
135
|
+
if (result?.config) {
|
|
136
|
+
setForm({
|
|
137
|
+
isEnabled: result.config.isEnabled,
|
|
138
|
+
username: result.config.username,
|
|
139
|
+
password: '', // Password is never returned from API
|
|
140
|
+
baseUrl: result.config.baseUrl,
|
|
141
|
+
})
|
|
142
|
+
} else {
|
|
143
|
+
setForm(emptyBicForm)
|
|
144
|
+
}
|
|
145
|
+
} catch {
|
|
146
|
+
// Config doesn't exist yet, that's fine
|
|
147
|
+
setConfig(null)
|
|
148
|
+
setForm(emptyBicForm)
|
|
149
|
+
} finally {
|
|
150
|
+
setLoading(false)
|
|
151
|
+
}
|
|
152
|
+
}, [])
|
|
153
|
+
|
|
154
|
+
React.useEffect(() => {
|
|
155
|
+
fetchConfig()
|
|
156
|
+
}, [fetchConfig])
|
|
157
|
+
|
|
158
|
+
const handleTest = React.useCallback(async () => {
|
|
159
|
+
if (!form.username || !form.password) {
|
|
160
|
+
flash(t('shipment_tracking.bic_config.validation.usernameRequired', 'Username is required'), 'error')
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
setTesting(true)
|
|
165
|
+
setTestResult(null)
|
|
166
|
+
|
|
167
|
+
try {
|
|
168
|
+
const { result } = await apiCallOrThrow<{ success: boolean; message: string }>(
|
|
169
|
+
'/api/shipment_tracking/bic-configs/test',
|
|
170
|
+
{
|
|
171
|
+
method: 'POST',
|
|
172
|
+
body: JSON.stringify({
|
|
173
|
+
username: form.username,
|
|
174
|
+
password: form.password,
|
|
175
|
+
baseUrl: form.baseUrl,
|
|
176
|
+
}),
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
setTestResult(result ?? { success: false, message: 'Unknown error' })
|
|
181
|
+
|
|
182
|
+
if (result?.success) {
|
|
183
|
+
flash(t('shipment_tracking.bic_config.flash.testSuccess', 'BIC API connection successful'), 'success')
|
|
184
|
+
} else {
|
|
185
|
+
flash(result?.message ?? t('shipment_tracking.bic_config.flash.testFailed', 'BIC API connection failed'), 'error')
|
|
186
|
+
}
|
|
187
|
+
} catch (err) {
|
|
188
|
+
const message = err instanceof Error ? err.message : 'Connection test failed'
|
|
189
|
+
setTestResult({ success: false, message })
|
|
190
|
+
flash(message, 'error')
|
|
191
|
+
} finally {
|
|
192
|
+
setTesting(false)
|
|
193
|
+
}
|
|
194
|
+
}, [form, t])
|
|
195
|
+
|
|
196
|
+
const handleSave = React.useCallback(async () => {
|
|
197
|
+
if (!form.username) {
|
|
198
|
+
flash(t('shipment_tracking.bic_config.validation.usernameRequired', 'Username is required'), 'error')
|
|
199
|
+
return
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Password is required for new config or when enabling
|
|
203
|
+
if (!config && !form.password) {
|
|
204
|
+
flash(t('shipment_tracking.bic_config.validation.passwordRequired', 'Password is required'), 'error')
|
|
205
|
+
return
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
setSaving(true)
|
|
209
|
+
try {
|
|
210
|
+
const body: Record<string, unknown> = {
|
|
211
|
+
isEnabled: form.isEnabled,
|
|
212
|
+
username: form.username,
|
|
213
|
+
baseUrl: form.baseUrl || 'https://api.bic-code.org',
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Only include password if it was changed
|
|
217
|
+
if (form.password) {
|
|
218
|
+
body.password = form.password
|
|
219
|
+
} else if (config) {
|
|
220
|
+
// If editing and no new password, we still need to send something
|
|
221
|
+
// The API should handle this gracefully
|
|
222
|
+
body.password = '__UNCHANGED__'
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
await apiCallOrThrow('/api/shipment_tracking/bic-configs', {
|
|
226
|
+
method: 'PUT',
|
|
227
|
+
body: JSON.stringify(body),
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
flash(t('shipment_tracking.bic_config.flash.saved', 'BIC configuration saved'), 'success')
|
|
231
|
+
fetchConfig()
|
|
232
|
+
} catch (err) {
|
|
233
|
+
const message = err instanceof Error ? err.message : 'Failed to save'
|
|
234
|
+
flash(message, 'error')
|
|
235
|
+
} finally {
|
|
236
|
+
setSaving(false)
|
|
237
|
+
}
|
|
238
|
+
}, [form, config, t, fetchConfig])
|
|
239
|
+
|
|
240
|
+
const handleKeyDown = React.useCallback(
|
|
241
|
+
(event: React.KeyboardEvent) => {
|
|
242
|
+
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
243
|
+
event.preventDefault()
|
|
244
|
+
handleSave()
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
[handleSave]
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
if (loading) {
|
|
251
|
+
return (
|
|
252
|
+
<Card>
|
|
253
|
+
<CardHeader>
|
|
254
|
+
<CardTitle className="flex items-center gap-2">
|
|
255
|
+
<Shield className="h-5 w-5" />
|
|
256
|
+
{t('shipment_tracking.bic_config.title', 'BIC Facility API')}
|
|
257
|
+
</CardTitle>
|
|
258
|
+
</CardHeader>
|
|
259
|
+
<CardContent className="flex items-center justify-center py-8">
|
|
260
|
+
<Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />
|
|
261
|
+
</CardContent>
|
|
262
|
+
</Card>
|
|
263
|
+
)
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return (
|
|
267
|
+
<Card>
|
|
268
|
+
<CardHeader>
|
|
269
|
+
<div className="flex items-center justify-between">
|
|
270
|
+
<div className="flex items-center gap-2">
|
|
271
|
+
<Shield className="h-5 w-5" />
|
|
272
|
+
<CardTitle>{t('shipment_tracking.bic_config.title', 'BIC Facility API')}</CardTitle>
|
|
273
|
+
</div>
|
|
274
|
+
<div className="flex items-center gap-2">
|
|
275
|
+
{config ? (
|
|
276
|
+
<>
|
|
277
|
+
<Badge variant="outline">
|
|
278
|
+
{t('shipment_tracking.bic_config.status.configured', 'Configured')}
|
|
279
|
+
</Badge>
|
|
280
|
+
<Badge variant={config.isEnabled ? 'default' : 'secondary'}>
|
|
281
|
+
{config.isEnabled
|
|
282
|
+
? t('shipment_tracking.bic_config.status.enabled', 'Enabled')
|
|
283
|
+
: t('shipment_tracking.bic_config.status.disabled', 'Disabled')}
|
|
284
|
+
</Badge>
|
|
285
|
+
</>
|
|
286
|
+
) : (
|
|
287
|
+
<Badge variant="secondary">
|
|
288
|
+
{t('shipment_tracking.bic_config.status.notConfigured', 'Not Configured')}
|
|
289
|
+
</Badge>
|
|
290
|
+
)}
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
<CardDescription>
|
|
294
|
+
{t(
|
|
295
|
+
'shipment_tracking.bic_config.description',
|
|
296
|
+
'Configure BIC Facility Code API credentials to enrich shipment tracking locations with coordinates, addresses, and terminal operator information.'
|
|
297
|
+
)}
|
|
298
|
+
</CardDescription>
|
|
299
|
+
</CardHeader>
|
|
300
|
+
<CardContent onKeyDown={handleKeyDown}>
|
|
301
|
+
<div className="grid gap-4">
|
|
302
|
+
<div className="flex items-center gap-2">
|
|
303
|
+
<Checkbox
|
|
304
|
+
id="bicEnabled"
|
|
305
|
+
checked={form.isEnabled}
|
|
306
|
+
onCheckedChange={(checked) =>
|
|
307
|
+
setForm((prev) => ({ ...prev, isEnabled: checked === true }))
|
|
308
|
+
}
|
|
309
|
+
/>
|
|
310
|
+
<Label htmlFor="bicEnabled" className="cursor-pointer font-medium">
|
|
311
|
+
{t('shipment_tracking.bic_config.fields.isEnabled', 'Enable BIC Enrichment')}
|
|
312
|
+
</Label>
|
|
313
|
+
</div>
|
|
314
|
+
|
|
315
|
+
<div className="grid gap-4 md:grid-cols-2">
|
|
316
|
+
<div className="grid gap-2">
|
|
317
|
+
<Label htmlFor="bicUsername">
|
|
318
|
+
{t('shipment_tracking.bic_config.fields.username', 'Username')}
|
|
319
|
+
</Label>
|
|
320
|
+
<Input
|
|
321
|
+
id="bicUsername"
|
|
322
|
+
value={form.username}
|
|
323
|
+
onChange={(e) => setForm((prev) => ({ ...prev, username: e.target.value }))}
|
|
324
|
+
placeholder="your-bic-username"
|
|
325
|
+
/>
|
|
326
|
+
</div>
|
|
327
|
+
|
|
328
|
+
<div className="grid gap-2">
|
|
329
|
+
<Label htmlFor="bicPassword">
|
|
330
|
+
{t('shipment_tracking.bic_config.fields.password', 'Password')}
|
|
331
|
+
</Label>
|
|
332
|
+
<Input
|
|
333
|
+
id="bicPassword"
|
|
334
|
+
type="password"
|
|
335
|
+
value={form.password}
|
|
336
|
+
onChange={(e) => setForm((prev) => ({ ...prev, password: e.target.value }))}
|
|
337
|
+
placeholder={config ? '••••••••' : 'your-bic-password'}
|
|
338
|
+
/>
|
|
339
|
+
<p className="text-xs text-muted-foreground">
|
|
340
|
+
{t(
|
|
341
|
+
'shipment_tracking.bic_config.hints.password',
|
|
342
|
+
'Your password will be encrypted and stored securely.'
|
|
343
|
+
)}
|
|
344
|
+
</p>
|
|
345
|
+
</div>
|
|
346
|
+
</div>
|
|
347
|
+
|
|
348
|
+
<div className="grid gap-2">
|
|
349
|
+
<Label htmlFor="bicBaseUrl">
|
|
350
|
+
{t('shipment_tracking.bic_config.fields.baseUrl', 'API Base URL')}
|
|
351
|
+
</Label>
|
|
352
|
+
<Input
|
|
353
|
+
id="bicBaseUrl"
|
|
354
|
+
value={form.baseUrl}
|
|
355
|
+
onChange={(e) => setForm((prev) => ({ ...prev, baseUrl: e.target.value }))}
|
|
356
|
+
placeholder="https://api.bic-code.org"
|
|
357
|
+
/>
|
|
358
|
+
<p className="text-xs text-muted-foreground">
|
|
359
|
+
{t('shipment_tracking.bic_config.hints.baseUrl', 'Default: https://api.bic-code.org')}
|
|
360
|
+
</p>
|
|
361
|
+
</div>
|
|
362
|
+
|
|
363
|
+
{testResult && (
|
|
364
|
+
<div
|
|
365
|
+
className={`flex items-center gap-2 rounded-md p-3 text-sm ${
|
|
366
|
+
testResult.success
|
|
367
|
+
? 'bg-green-50 text-green-700 dark:bg-green-900/20 dark:text-green-400'
|
|
368
|
+
: 'bg-red-50 text-red-700 dark:bg-red-900/20 dark:text-red-400'
|
|
369
|
+
}`}
|
|
370
|
+
>
|
|
371
|
+
{testResult.success ? (
|
|
372
|
+
<CheckCircle2 className="h-4 w-4" />
|
|
373
|
+
) : (
|
|
374
|
+
<XCircle className="h-4 w-4" />
|
|
375
|
+
)}
|
|
376
|
+
<span>{testResult.message}</span>
|
|
377
|
+
</div>
|
|
378
|
+
)}
|
|
379
|
+
|
|
380
|
+
<div className="flex items-center gap-2 pt-2">
|
|
381
|
+
<Button
|
|
382
|
+
variant="outline"
|
|
383
|
+
onClick={handleTest}
|
|
384
|
+
disabled={testing || !form.username || !form.password}
|
|
385
|
+
>
|
|
386
|
+
{testing && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
|
387
|
+
{t('shipment_tracking.bic_config.actions.testConnection', 'Test Connection')}
|
|
388
|
+
</Button>
|
|
389
|
+
<Button onClick={handleSave} disabled={saving}>
|
|
390
|
+
{saving && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
|
391
|
+
{t('shipment_tracking.bic_config.actions.save', 'Save Configuration')}
|
|
392
|
+
</Button>
|
|
393
|
+
</div>
|
|
394
|
+
</div>
|
|
395
|
+
</CardContent>
|
|
396
|
+
</Card>
|
|
397
|
+
)
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// ─── Main Page ───────────────────────────────────────────────
|
|
401
|
+
|
|
402
|
+
export default function TrackingAuthConfigPage() {
|
|
403
|
+
const t = useT()
|
|
404
|
+
|
|
405
|
+
const [dialogOpen, setDialogOpen] = useState(false)
|
|
406
|
+
const [editingId, setEditingId] = useState<string | null>(null)
|
|
407
|
+
const [form, setForm] = useState<FormState>(emptyForm)
|
|
408
|
+
const [submitting, setSubmitting] = useState(false)
|
|
409
|
+
|
|
410
|
+
const isEdit = editingId !== null
|
|
411
|
+
|
|
412
|
+
const columns = useMemo<ColumnDef[]>(
|
|
413
|
+
() => [
|
|
414
|
+
{
|
|
415
|
+
data: 'carrierCode',
|
|
416
|
+
title: t('shipment_tracking.carrier_configs.fields.carrierCode', 'Carrier Code'),
|
|
417
|
+
width: 150,
|
|
418
|
+
readOnly: true,
|
|
419
|
+
renderer: (value: unknown) => (
|
|
420
|
+
<span className="font-medium">{String(value ?? '')}</span>
|
|
421
|
+
),
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
data: 'apiEndpoint',
|
|
425
|
+
title: t('shipment_tracking.carrier_configs.fields.apiEndpoint', 'API Endpoint'),
|
|
426
|
+
width: 280,
|
|
427
|
+
readOnly: true,
|
|
428
|
+
renderer: (value: unknown) => (
|
|
429
|
+
<span className="text-sm truncate max-w-[260px] block">{String(value || '-')}</span>
|
|
430
|
+
),
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
data: 'rateLimit',
|
|
434
|
+
title: t('shipment_tracking.carrier_configs.fields.rateLimit', 'Rate Limit'),
|
|
435
|
+
width: 120,
|
|
436
|
+
readOnly: true,
|
|
437
|
+
renderer: (_value: unknown, rowData: Record<string, unknown>) => (
|
|
438
|
+
<span className="text-sm">
|
|
439
|
+
{String(rowData.rateLimitRequests ?? 60)} / {String(rowData.rateLimitWindowSeconds ?? 60)}s
|
|
440
|
+
</span>
|
|
441
|
+
),
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
data: 'isActive',
|
|
445
|
+
title: t('shipment_tracking.carrier_configs.fields.isActive', 'Active'),
|
|
446
|
+
width: 80,
|
|
447
|
+
readOnly: true,
|
|
448
|
+
renderer: (value: unknown) => <BooleanIcon value={value === true || value === 'true'} />,
|
|
449
|
+
},
|
|
450
|
+
],
|
|
451
|
+
[t],
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
const openCreateDialog = useCallback(() => {
|
|
455
|
+
setEditingId(null)
|
|
456
|
+
setForm(emptyForm)
|
|
457
|
+
setDialogOpen(true)
|
|
458
|
+
}, [])
|
|
459
|
+
|
|
460
|
+
const addButton = useMemo(
|
|
461
|
+
() => (
|
|
462
|
+
<ButtonV2 variant="primary" size="sm" icon={<Plus className="h-4 w-4" />} onClick={openCreateDialog}>
|
|
463
|
+
{t('shipment_tracking.carrier_configs.create', 'Add Carrier Config')}
|
|
464
|
+
</ButtonV2>
|
|
465
|
+
),
|
|
466
|
+
[openCreateDialog, t],
|
|
467
|
+
)
|
|
468
|
+
|
|
469
|
+
const table = useDynamicTablePage<CarrierConfigRow>({
|
|
470
|
+
source: '/api/shipment_tracking/carrier-configs',
|
|
471
|
+
// Saved views. Without this the perspective tab strip auto-hides
|
|
472
|
+
// (hidePerspectiveTabs ?? !hasPerspectives), so users cannot save or
|
|
473
|
+
// switch a view on this list at all.
|
|
474
|
+
perspectives: 'shipment_tracking_carrier_configs',
|
|
475
|
+
columns,
|
|
476
|
+
tableName: t('shipment_tracking.carrier_configs.title', 'Carrier Configs'),
|
|
477
|
+
defaultPageSize: 20,
|
|
478
|
+
mapApiItem: mapItem,
|
|
479
|
+
cellEdit: false,
|
|
480
|
+
tableProps: {
|
|
481
|
+
height: '100%',
|
|
482
|
+
uiConfig: {
|
|
483
|
+
readOnlyStyle: 'normal',
|
|
484
|
+
hideAddRowButton: true,
|
|
485
|
+
searchBarEnd: addButton,
|
|
486
|
+
},
|
|
487
|
+
},
|
|
488
|
+
})
|
|
489
|
+
|
|
490
|
+
const openEditDialog = useCallback(
|
|
491
|
+
(id: string) => {
|
|
492
|
+
const items = (table.query.data as { items?: Record<string, unknown>[] })?.items ?? []
|
|
493
|
+
const mapped = items.map(mapItem).filter((x): x is CarrierConfigRow => x !== null)
|
|
494
|
+
const row = mapped.find((r) => r.id === id)
|
|
495
|
+
if (!row) return
|
|
496
|
+
setEditingId(id)
|
|
497
|
+
setForm(rowToForm(row))
|
|
498
|
+
setDialogOpen(true)
|
|
499
|
+
},
|
|
500
|
+
[table.query.data],
|
|
501
|
+
)
|
|
502
|
+
|
|
503
|
+
const handleSubmit = useCallback(async () => {
|
|
504
|
+
if (submitting) return
|
|
505
|
+
|
|
506
|
+
if (!isEdit && !form.carrierCode.trim()) {
|
|
507
|
+
flash(t('shipment_tracking.carrier_configs.validation.carrierCodeRequired', 'Carrier code is required'), 'error')
|
|
508
|
+
return
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
if (form.authConfig.trim()) {
|
|
512
|
+
try {
|
|
513
|
+
JSON.parse(form.authConfig)
|
|
514
|
+
} catch {
|
|
515
|
+
flash(t('shipment_tracking.carrier_configs.validation.authConfigInvalidJson', 'Auth config must be valid JSON'), 'error')
|
|
516
|
+
return
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
if (form.apiEndpoint.trim()) {
|
|
521
|
+
try {
|
|
522
|
+
new URL(form.apiEndpoint.trim())
|
|
523
|
+
} catch {
|
|
524
|
+
flash(t('shipment_tracking.carrier_configs.validation.apiEndpointInvalidUrl', 'API endpoint must be a valid URL'), 'error')
|
|
525
|
+
return
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
setSubmitting(true)
|
|
530
|
+
try {
|
|
531
|
+
const authConfig = form.authConfig.trim() ? JSON.parse(form.authConfig) : undefined
|
|
532
|
+
|
|
533
|
+
if (isEdit) {
|
|
534
|
+
const body: Record<string, unknown> = { id: editingId }
|
|
535
|
+
if (form.apiEndpoint.trim()) body.apiEndpoint = form.apiEndpoint.trim()
|
|
536
|
+
else body.apiEndpoint = null
|
|
537
|
+
body.authConfig = authConfig ?? null
|
|
538
|
+
body.rateLimitRequests = form.rateLimitRequests
|
|
539
|
+
body.rateLimitWindowSeconds = form.rateLimitWindowSeconds
|
|
540
|
+
body.isActive = form.isActive
|
|
541
|
+
|
|
542
|
+
await apiCallOrThrow('/api/shipment_tracking/carrier-configs', {
|
|
543
|
+
method: 'PUT',
|
|
544
|
+
body: JSON.stringify(body),
|
|
545
|
+
})
|
|
546
|
+
flash(t('shipment_tracking.carrier_configs.flash.updated', 'Carrier config updated'), 'success')
|
|
547
|
+
} else {
|
|
548
|
+
const body: Record<string, unknown> = {
|
|
549
|
+
carrierCode: form.carrierCode.trim(),
|
|
550
|
+
rateLimitRequests: form.rateLimitRequests,
|
|
551
|
+
rateLimitWindowSeconds: form.rateLimitWindowSeconds,
|
|
552
|
+
isActive: form.isActive,
|
|
553
|
+
}
|
|
554
|
+
if (form.apiEndpoint.trim()) body.apiEndpoint = form.apiEndpoint.trim()
|
|
555
|
+
if (authConfig) body.authConfig = authConfig
|
|
556
|
+
|
|
557
|
+
await apiCallOrThrow('/api/shipment_tracking/carrier-configs', {
|
|
558
|
+
method: 'POST',
|
|
559
|
+
body: JSON.stringify(body),
|
|
560
|
+
})
|
|
561
|
+
flash(t('shipment_tracking.carrier_configs.flash.created', 'Carrier config created'), 'success')
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
setDialogOpen(false)
|
|
565
|
+
table.refresh()
|
|
566
|
+
} catch {
|
|
567
|
+
flash(isEdit ? t('shipment_tracking.carrier_configs.flash.updateFailed', 'Failed to update carrier config') : t('shipment_tracking.carrier_configs.flash.createFailed', 'Failed to create carrier config'), 'error')
|
|
568
|
+
} finally {
|
|
569
|
+
setSubmitting(false)
|
|
570
|
+
}
|
|
571
|
+
}, [form, isEdit, editingId, submitting, table.refresh, t])
|
|
572
|
+
|
|
573
|
+
const handleDialogKeyDown = useCallback(
|
|
574
|
+
(event: React.KeyboardEvent) => {
|
|
575
|
+
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
576
|
+
event.preventDefault()
|
|
577
|
+
handleSubmit()
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
[handleSubmit],
|
|
581
|
+
)
|
|
582
|
+
|
|
583
|
+
const handleDelete = useCallback(
|
|
584
|
+
async (id: string) => {
|
|
585
|
+
if (!confirm(t('shipment_tracking.carrier_configs.confirmDelete', 'Delete this carrier config?'))) return
|
|
586
|
+
|
|
587
|
+
try {
|
|
588
|
+
await apiCallOrThrow('/api/shipment_tracking/carrier-configs', {
|
|
589
|
+
method: 'DELETE',
|
|
590
|
+
body: JSON.stringify({ id }),
|
|
591
|
+
})
|
|
592
|
+
flash(t('shipment_tracking.carrier_configs.flash.deleted', 'Carrier config deleted'), 'success')
|
|
593
|
+
table.refresh()
|
|
594
|
+
} catch {
|
|
595
|
+
flash(t('shipment_tracking.carrier_configs.flash.deleteFailed', 'Failed to delete carrier config'), 'error')
|
|
596
|
+
}
|
|
597
|
+
},
|
|
598
|
+
[table.refresh, t],
|
|
599
|
+
)
|
|
600
|
+
|
|
601
|
+
const rowActions = useCallback(
|
|
602
|
+
(rowData: any): ContextMenuAction[] => {
|
|
603
|
+
if (!rowData?.id) return []
|
|
604
|
+
return [
|
|
605
|
+
{ id: 'edit', label: t('common.edit', 'Edit') },
|
|
606
|
+
{ id: 'delete', label: t('common.delete', 'Delete') },
|
|
607
|
+
]
|
|
608
|
+
},
|
|
609
|
+
[t],
|
|
610
|
+
)
|
|
611
|
+
|
|
612
|
+
const handleRowAction = useCallback(
|
|
613
|
+
(actionId: string, rowData: any) => {
|
|
614
|
+
const id = rowData?.id as string | undefined
|
|
615
|
+
if (!id) return
|
|
616
|
+
if (actionId === 'edit') openEditDialog(id)
|
|
617
|
+
else if (actionId === 'delete') handleDelete(id)
|
|
618
|
+
},
|
|
619
|
+
[openEditDialog, handleDelete],
|
|
620
|
+
)
|
|
621
|
+
|
|
622
|
+
const tableHeight = useMemo(() => {
|
|
623
|
+
const rowH = 40
|
|
624
|
+
const headerH = 40
|
|
625
|
+
const toolbarH = 50
|
|
626
|
+
const minHeight = 200
|
|
627
|
+
const maxHeight = 400
|
|
628
|
+
const rowCount = (table.query.data as { total?: number })?.total ?? 0
|
|
629
|
+
const contentHeight = toolbarH + headerH + rowCount * rowH + 20
|
|
630
|
+
return Math.min(Math.max(contentHeight, minHeight), maxHeight)
|
|
631
|
+
}, [table.query.data])
|
|
632
|
+
|
|
633
|
+
if (table.isLoading) {
|
|
634
|
+
return (
|
|
635
|
+
<Page>
|
|
636
|
+
<PageBody className="space-y-6">
|
|
637
|
+
<BicConfigSection />
|
|
638
|
+
<ShipsGoConfigSection />
|
|
639
|
+
<Card>
|
|
640
|
+
<CardHeader>
|
|
641
|
+
<CardTitle>{t('shipment_tracking.carrier_configs.title', 'Carrier Configs')}</CardTitle>
|
|
642
|
+
</CardHeader>
|
|
643
|
+
<CardContent>
|
|
644
|
+
<TableSkeleton rows={5} columns={4} />
|
|
645
|
+
</CardContent>
|
|
646
|
+
</Card>
|
|
647
|
+
</PageBody>
|
|
648
|
+
</Page>
|
|
649
|
+
)
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
return (
|
|
653
|
+
<Page>
|
|
654
|
+
<PageBody className="space-y-6">
|
|
655
|
+
{/* BIC Config Section */}
|
|
656
|
+
<BicConfigSection />
|
|
657
|
+
|
|
658
|
+
{/* ShipsGo Aggregator Config Section */}
|
|
659
|
+
<ShipsGoConfigSection />
|
|
660
|
+
|
|
661
|
+
{/* Carrier Configs Section */}
|
|
662
|
+
<Card>
|
|
663
|
+
<CardHeader>
|
|
664
|
+
<CardTitle>{t('shipment_tracking.carrier_configs.title', 'Carrier Configs')}</CardTitle>
|
|
665
|
+
<CardDescription>
|
|
666
|
+
{t(
|
|
667
|
+
'shipment_tracking.auth_config.description',
|
|
668
|
+
'Configure authentication for carrier tracking APIs and facility enrichment services.'
|
|
669
|
+
)}
|
|
670
|
+
</CardDescription>
|
|
671
|
+
</CardHeader>
|
|
672
|
+
<CardContent>
|
|
673
|
+
<div style={{ height: tableHeight }}>
|
|
674
|
+
<DynamicTable
|
|
675
|
+
{...table.props}
|
|
676
|
+
striped
|
|
677
|
+
density="md"
|
|
678
|
+
rowActions={rowActions}
|
|
679
|
+
onRowAction={handleRowAction}
|
|
680
|
+
/>
|
|
681
|
+
</div>
|
|
682
|
+
</CardContent>
|
|
683
|
+
</Card>
|
|
684
|
+
|
|
685
|
+
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
|
|
686
|
+
<DialogContent className="sm:max-w-lg" onKeyDown={handleDialogKeyDown}>
|
|
687
|
+
<DialogHeader>
|
|
688
|
+
<DialogTitle>{isEdit ? t('shipment_tracking.carrier_configs.edit', 'Edit Carrier Config') : t('shipment_tracking.carrier_configs.create', 'Add Carrier Config')}</DialogTitle>
|
|
689
|
+
</DialogHeader>
|
|
690
|
+
|
|
691
|
+
<div className="grid gap-4 py-2">
|
|
692
|
+
<div className="grid gap-2">
|
|
693
|
+
<Label htmlFor="carrierCode">{t('shipment_tracking.carrier_configs.fields.carrierCode', 'Carrier Code')}</Label>
|
|
694
|
+
<Input
|
|
695
|
+
id="carrierCode"
|
|
696
|
+
value={form.carrierCode}
|
|
697
|
+
onChange={(event) => setForm((prev) => ({ ...prev, carrierCode: event.target.value }))}
|
|
698
|
+
placeholder="e.g. maersk, msc, cma-cgm"
|
|
699
|
+
disabled={isEdit}
|
|
700
|
+
autoFocus={!isEdit}
|
|
701
|
+
/>
|
|
702
|
+
</div>
|
|
703
|
+
|
|
704
|
+
<div className="grid gap-2">
|
|
705
|
+
<Label htmlFor="apiEndpoint">{t('shipment_tracking.carrier_configs.fields.apiEndpoint', 'API Endpoint')}</Label>
|
|
706
|
+
<Input
|
|
707
|
+
id="apiEndpoint"
|
|
708
|
+
value={form.apiEndpoint}
|
|
709
|
+
onChange={(event) => setForm((prev) => ({ ...prev, apiEndpoint: event.target.value }))}
|
|
710
|
+
placeholder="https://api.example.com/tracking"
|
|
711
|
+
/>
|
|
712
|
+
</div>
|
|
713
|
+
|
|
714
|
+
<div className="grid gap-2">
|
|
715
|
+
<Label htmlFor="authConfig">{t('shipment_tracking.carrier_configs.fields.authConfig', 'Auth Config (JSON)')}</Label>
|
|
716
|
+
<Textarea
|
|
717
|
+
id="authConfig"
|
|
718
|
+
value={form.authConfig}
|
|
719
|
+
onChange={(event) => setForm((prev) => ({ ...prev, authConfig: event.target.value }))}
|
|
720
|
+
placeholder='{"apiKey": "..."}'
|
|
721
|
+
rows={3}
|
|
722
|
+
className="font-mono text-xs"
|
|
723
|
+
/>
|
|
724
|
+
</div>
|
|
725
|
+
|
|
726
|
+
<div className="grid grid-cols-2 gap-4">
|
|
727
|
+
<div className="grid gap-2">
|
|
728
|
+
<Label htmlFor="rateLimitRequests">{t('shipment_tracking.carrier_configs.fields.rateLimitRequests', 'Rate Limit (requests)')}</Label>
|
|
729
|
+
<Input
|
|
730
|
+
id="rateLimitRequests"
|
|
731
|
+
type="number"
|
|
732
|
+
min={1}
|
|
733
|
+
max={10000}
|
|
734
|
+
value={form.rateLimitRequests}
|
|
735
|
+
onChange={(event) =>
|
|
736
|
+
setForm((prev) => ({ ...prev, rateLimitRequests: Number(event.target.value) || 60 }))
|
|
737
|
+
}
|
|
738
|
+
/>
|
|
739
|
+
</div>
|
|
740
|
+
<div className="grid gap-2">
|
|
741
|
+
<Label htmlFor="rateLimitWindowSeconds">{t('shipment_tracking.carrier_configs.fields.rateLimitWindowSeconds', 'Window (seconds)')}</Label>
|
|
742
|
+
<Input
|
|
743
|
+
id="rateLimitWindowSeconds"
|
|
744
|
+
type="number"
|
|
745
|
+
min={1}
|
|
746
|
+
max={86400}
|
|
747
|
+
value={form.rateLimitWindowSeconds}
|
|
748
|
+
onChange={(event) =>
|
|
749
|
+
setForm((prev) => ({ ...prev, rateLimitWindowSeconds: Number(event.target.value) || 60 }))
|
|
750
|
+
}
|
|
751
|
+
/>
|
|
752
|
+
</div>
|
|
753
|
+
</div>
|
|
754
|
+
|
|
755
|
+
<div className="flex items-center gap-2">
|
|
756
|
+
<Checkbox
|
|
757
|
+
id="isActive"
|
|
758
|
+
checked={form.isActive}
|
|
759
|
+
onCheckedChange={(checked) =>
|
|
760
|
+
setForm((prev) => ({ ...prev, isActive: checked === true }))
|
|
761
|
+
}
|
|
762
|
+
/>
|
|
763
|
+
<Label htmlFor="isActive" className="cursor-pointer">
|
|
764
|
+
{t('shipment_tracking.carrier_configs.fields.isActive', 'Active')}
|
|
765
|
+
</Label>
|
|
766
|
+
</div>
|
|
767
|
+
</div>
|
|
768
|
+
|
|
769
|
+
<DialogFooter>
|
|
770
|
+
<Button variant="outline" onClick={() => setDialogOpen(false)} disabled={submitting}>
|
|
771
|
+
{t('common.cancel', 'Cancel')}
|
|
772
|
+
</Button>
|
|
773
|
+
<Button onClick={handleSubmit} disabled={submitting}>
|
|
774
|
+
{submitting ? t('common.saving', 'Saving...') : isEdit ? t('common.save', 'Save') : t('common.create', 'Create')}
|
|
775
|
+
</Button>
|
|
776
|
+
</DialogFooter>
|
|
777
|
+
</DialogContent>
|
|
778
|
+
</Dialog>
|
|
779
|
+
</PageBody>
|
|
780
|
+
</Page>
|
|
781
|
+
)
|
|
782
|
+
}
|