From e0e6020020a07994999c434a4d74bdbbe4e946c9 Mon Sep 17 00:00:00 2001 From: ghost2023 Date: Tue, 16 Jun 2026 14:54:07 +0300 Subject: [PATCH 1/7] fixes --- apps/edr-freight-web/portal/src/App.tsx | 2 +- .../portal/src/components/AppLayout.tsx | 1 - .../src/components/bookings/BookingTable.tsx | 33 ---- .../step3-first-last-mile.tsx | 144 --------------- .../new-booking-form/step7-documents.tsx | 65 ------- .../src/pages/settings/TabPowerOfAttorney.tsx | 14 +- .../src/pages/tracking/NewShipmentPage.tsx | 174 ------------------ .../src/pages/tracking/TrackingPage.tsx | 68 ++----- 8 files changed, 28 insertions(+), 473 deletions(-) delete mode 100644 apps/edr-freight-web/portal/src/components/bookings/BookingTable.tsx delete mode 100644 apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step3-first-last-mile.tsx delete mode 100644 apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step7-documents.tsx delete mode 100644 apps/edr-freight-web/portal/src/pages/tracking/NewShipmentPage.tsx diff --git a/apps/edr-freight-web/portal/src/App.tsx b/apps/edr-freight-web/portal/src/App.tsx index dd3627fef..080df0ed2 100644 --- a/apps/edr-freight-web/portal/src/App.tsx +++ b/apps/edr-freight-web/portal/src/App.tsx @@ -173,7 +173,7 @@ const App = () => { } /> - }> + }> [] = [ - { key: "reference", header: "Reference" }, - { key: "customerId", header: "Customer" }, - { key: "status", header: "Status" }, - { - key: "scheduledDate", - header: "Scheduled", - render: (row) => new Date(row.scheduledDate).toLocaleDateString(), - }, - { - key: "totalAmount", - header: "Total", - render: (row) => row.totalAmount.toFixed(2), - }, -]; - -const BookingTable = ({ bookings }: BookingTableProps) => ( - row.id} - emptyMessage="No bookings yet" - /> -); - -export default BookingTable; diff --git a/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step3-first-last-mile.tsx b/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step3-first-last-mile.tsx deleted file mode 100644 index 3bc5629ca..000000000 --- a/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step3-first-last-mile.tsx +++ /dev/null @@ -1,144 +0,0 @@ -import { Controller, type UseFormReturn } from "react-hook-form"; -import { Field, FieldError, Input, Switch } from "@edr/ui-common"; -import { type BookingFormValues } from "./schema"; -import { StepHeader } from "./shared"; - -type BookingForm = UseFormReturn; - -export function Step3FirstLastMile({ form }: { form: BookingForm }) { - const firstMileEnabled = form.watch("firstMileEnabled"); - const lastMileEnabled = form.watch("lastMileEnabled"); - const equipmentReturn = form.watch("equipmentReturn"); - - return ( -
- - -
-
- ( -
-
-

First Mile - Pick-up

-

- Truck pick-up from your premises (Door to Port) to the - origin rail yard. -

-
- { - field.onChange(value); - if (!value) { - form.setValue("pickUpAddress", "", { - shouldDirty: true, - shouldValidate: true, - }); - } - }} - /> -
- )} - /> - {firstMileEnabled && ( - ( - - - - - )} - /> - )} -
- -
- ( -
-
-

Last Mile - Delivery

-

- Truck delivery from the destination rail yard to the final - address (Port to Door). -

-
- { - field.onChange(value); - if (!value) { - form.setValue("deliveryAddress", "", { - shouldDirty: true, - shouldValidate: true, - }); - } - }} - /> -
- )} - /> - {lastMileEnabled && ( - ( - - - - - )} - /> - )} - - {lastMileEnabled && ( -
- ( -
-
-

Equipment Return

-

- {field.value === "with_return" - ? "Container returned to EDR after unloading." - : "Container retained by the customer after delivery."} -

-
- { - field.onChange( - value ? "with_return" : "without_return", - ); - }} - /> -
- )} - /> -
- )} -
-
-
- ); -} diff --git a/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step7-documents.tsx b/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step7-documents.tsx deleted file mode 100644 index a4ac23a4b..000000000 --- a/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step7-documents.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import { Controller, type UseFormReturn } from "react-hook-form"; -import { Field, FieldError, SmartFileInput } from "@edr/ui-common"; -import { - BOOKING_DOCS_SETTING, - REQUIRED_DOC_KEYS, - type BookingFormValues, -} from "./schema"; -import { getUploadedRequiredCount, StepHeader } from "./shared"; - -type BookingForm = UseFormReturn; - -export function Step7Documents({ form }: { form: BookingForm }) { - const documents = form.watch("documents"); - const uploadedRequired = getUploadedRequiredCount(documents); - const documentErrors = form.formState.errors.documents as - | Record - | undefined; - const smartFileErrors = Object.fromEntries( - Object.entries(documentErrors ?? {}).map(([key, value]) => [ - key, - value?.message ?? "", - ]), - ); - - return ( -
- - -
-
- {uploadedRequired}/{REQUIRED_DOC_KEYS.length} -
-

- {uploadedRequired < REQUIRED_DOC_KEYS.length - ? `${REQUIRED_DOC_KEYS.length - uploadedRequired} mandatory document(s) still needed.` - : "All mandatory documents uploaded. Power of Attorney is optional."} -

-
- - ( - - field.onChange(value)} - errors={smartFileErrors} - /> - - - )} - /> -
- ); -} diff --git a/apps/edr-freight-web/portal/src/pages/settings/TabPowerOfAttorney.tsx b/apps/edr-freight-web/portal/src/pages/settings/TabPowerOfAttorney.tsx index 00ecbfdf6..07f3b7720 100644 --- a/apps/edr-freight-web/portal/src/pages/settings/TabPowerOfAttorney.tsx +++ b/apps/edr-freight-web/portal/src/pages/settings/TabPowerOfAttorney.tsx @@ -3,7 +3,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; -import { CheckCircle2, Loader2, Save, UserCheck, XCircle } from "lucide-react"; +import { CheckCircle2, Save, UserCheck, XCircle } from "lucide-react"; import { Card, Group, @@ -100,8 +100,8 @@ export default function TabPowerOfAttorney({
- Power of Attorney details are optional. Fill them in if you have - an authorized representative, or leave blank. + Power of Attorney details are optional. Fill them in if you have an + authorized representative, or leave blank. - Saved successfully + + Saved successfully + )} {mutation.isError && ( - Save failed + + Save failed + )} diff --git a/apps/edr-freight-web/portal/src/pages/tracking/NewShipmentPage.tsx b/apps/edr-freight-web/portal/src/pages/tracking/NewShipmentPage.tsx deleted file mode 100644 index 81a37f137..000000000 --- a/apps/edr-freight-web/portal/src/pages/tracking/NewShipmentPage.tsx +++ /dev/null @@ -1,174 +0,0 @@ -import type { ReactNode } from "react"; -import { Calendar, MapPin } from "lucide-react"; - -import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, - DialogTrigger, -} from "@/components/ui/dialog"; -import { Input } from "@/components/ui/input"; -import { Label } from "@/components/ui/label"; -import { Button } from "@/components/ui/button"; - -import { consignments } from "../consignments/consignments.mock"; -import type { ShipmentMode, ShipmentStatus } from "./shipments.mock"; - -export interface ShipmentFormData { - consignmentId?: number; - consignmentReference?: string; - originStation?: string; - destinationStation?: string; - mode?: ShipmentMode; - status?: ShipmentStatus; - currentLocation?: string; - eta?: string; -} - -export interface NewShipmentPageProps { - mode?: "create" | "edit"; - shipment?: ShipmentFormData; - children?: ReactNode; -} - -const selectClass = - "flex h-10 w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700 shadow-xs outline-none transition hover:border-slate-300 focus:border-[#10B981]/50 focus:ring-2 focus:ring-[#10B981]/20"; - -export default function NewShipmentPage({ - mode = "create", - shipment, - children, -}: NewShipmentPageProps = {}) { - const isEdit = mode === "edit"; - const title = isEdit ? "Edit Shipment" : "New Shipment"; - const description = isEdit - ? "Update shipment tracking information." - : "Create a new shipment for real-time tracking."; - const submitLabel = isEdit ? "Save Changes" : "Create Shipment"; - - return ( - - - {children ?? } - - - - - {title} - {description} - - -
- {/* Consignment */} -
- - -

- Origin and destination auto-fill from the linked consignment. -

-
- - {/* Status */} -
- - -
- - {/* Mode */} -
- - -
- - {/* Origin */} -
- -
- - -
-
- - {/* Destination */} -
- -
- - -
-
- - {/* ETA */} -
- -
- - -
-
- - {/* Current Location */} -
- -
- - -
-
-
- -
- - -
-
-
- ); -} diff --git a/apps/edr-freight-web/portal/src/pages/tracking/TrackingPage.tsx b/apps/edr-freight-web/portal/src/pages/tracking/TrackingPage.tsx index 144bc2bef..ccd8e398c 100644 --- a/apps/edr-freight-web/portal/src/pages/tracking/TrackingPage.tsx +++ b/apps/edr-freight-web/portal/src/pages/tracking/TrackingPage.tsx @@ -8,7 +8,6 @@ import { List, MapPin, MoreHorizontal, - Pencil, Plus, Search, Train, @@ -17,7 +16,6 @@ import { } from "lucide-react"; import Breadcrumbs from "@/components/Breadcrumbs"; -import NewShipmentPage from "./NewShipmentPage"; import DeleteShipmentDialog from "./DeleteShipmentDialog"; import { shipments, @@ -93,13 +91,6 @@ export default function TrackingPage() { className="pl-8!" /> - - - - @@ -279,7 +270,10 @@ function ShipmentCard({ shipment }: { shipment: Shipment }) { -
e.stopPropagation()}> +
e.stopPropagation()} + > - - ); -}; - -export default BookingForm; diff --git a/apps/edr-freight-web/portal/src/components/consignments/ConsignmentForm.tsx b/apps/edr-freight-web/portal/src/components/consignments/ConsignmentForm.tsx deleted file mode 100644 index 1738cb1d0..000000000 --- a/apps/edr-freight-web/portal/src/components/consignments/ConsignmentForm.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import { FormEvent, useState } from "react"; -import { Button, FormField } from "@edr/ui-common"; - -export interface ConsignmentFormProps { - onSubmit: (payload: { - bookingId: string; - trackingNumber: string; - cargoType: string; - weightKg: number; - originStation: string; - destinationStation: string; - }) => void; - isSubmitting?: boolean; -} - -const ConsignmentForm = ({ onSubmit, isSubmitting }: ConsignmentFormProps) => { - const [bookingId, setBookingId] = useState(""); - const [trackingNumber, setTrackingNumber] = useState(""); - const [cargoType, setCargoType] = useState("GENERAL"); - const [weightKg, setWeightKg] = useState("0"); - const [originStation, setOriginStation] = useState(""); - const [destinationStation, setDestinationStation] = useState(""); - - const handleSubmit = (event: FormEvent) => { - event.preventDefault(); - onSubmit({ - bookingId, - trackingNumber, - cargoType, - weightKg: Number(weightKg), - originStation, - destinationStation, - }); - }; - - return ( -
- setBookingId(e.target.value)} - required - /> - setTrackingNumber(e.target.value)} - required - /> - setCargoType(e.target.value)} - /> - setWeightKg(e.target.value)} - min="0" - /> - setOriginStation(e.target.value)} - required - /> - setDestinationStation(e.target.value)} - required - /> - - - ); -}; - -export default ConsignmentForm; diff --git a/apps/edr-freight-web/portal/src/components/consignments/ConsignmentTable.tsx b/apps/edr-freight-web/portal/src/components/consignments/ConsignmentTable.tsx deleted file mode 100644 index cc04524bf..000000000 --- a/apps/edr-freight-web/portal/src/components/consignments/ConsignmentTable.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import type { Freight } from "@edr/types"; -import { Table, type TableColumn } from "@edr/ui-common"; - -export interface ConsignmentTableProps { - consignments: Freight.IConsignment[]; -} - -const columns: TableColumn[] = [ - { key: "trackingNumber", header: "Tracking #" }, - { key: "cargoType", header: "Cargo" }, - { key: "status", header: "Status" }, - { key: "originStation", header: "Origin" }, - { key: "destinationStation", header: "Destination" }, - { - key: "weightKg", - header: "Weight (kg)", - render: (row) => row.weightKg.toFixed(2), - }, -]; - -const ConsignmentTable = ({ consignments }: ConsignmentTableProps) => ( -
row.id} - emptyMessage="No consignments yet" - /> -); - -export default ConsignmentTable; diff --git a/apps/edr-freight-web/portal/src/components/dynamic-select/DynamicSelect.tsx b/apps/edr-freight-web/portal/src/components/dynamic-select/DynamicSelect.tsx index 2003457f0..fa10a795e 100644 --- a/apps/edr-freight-web/portal/src/components/dynamic-select/DynamicSelect.tsx +++ b/apps/edr-freight-web/portal/src/components/dynamic-select/DynamicSelect.tsx @@ -2,7 +2,6 @@ import { useQuery } from "@tanstack/react-query"; import { cn } from "@/lib/utils"; import { api } from "@/services/api"; import { Loader2, AlertCircle } from "lucide-react"; -import * as React from "react"; import { Select, @@ -64,11 +63,7 @@ export function DynamicSelect({ const options = [...data.children].sort((a, b) => a.order - b.order); return ( - diff --git a/apps/edr-freight-web/portal/src/components/tracking/TrackingTimeline.tsx b/apps/edr-freight-web/portal/src/components/tracking/TrackingTimeline.tsx index c167e1371..ac02239ad 100644 --- a/apps/edr-freight-web/portal/src/components/tracking/TrackingTimeline.tsx +++ b/apps/edr-freight-web/portal/src/components/tracking/TrackingTimeline.tsx @@ -17,7 +17,7 @@ const TrackingTimeline = ({ events }: TrackingTimelineProps) => {
{event.location} - {event.status} + {event.status}