diff --git a/distribution_fe/app/(dashboard)/operations/loading/new/page.tsx b/distribution_fe/app/(dashboard)/operations/loading/new/page.tsx index 5953b47..c3ebb7e 100644 --- a/distribution_fe/app/(dashboard)/operations/loading/new/page.tsx +++ b/distribution_fe/app/(dashboard)/operations/loading/new/page.tsx @@ -25,6 +25,7 @@ import { Button } from '@/components/ui/button' import { FieldGroup } from '@/components/ui/field' import { Separator } from '@/components/ui/separator' import { toast } from '@/components/ui/toast' +import { cn } from '@/lib/utils' import { shopPos as shopPosApi, regions as regionsApi, @@ -53,6 +54,39 @@ import type { LoadingSheetItemInput } from '@/lib/api/operations' const ALL = '__all__' +const STEPS = [ + { + n: 1, + label: 'Route & Warehouse', + title: 'Where is this load coming from?', + help: "Pick the route this ride will deliver (optional if you're only adding items manually below) and the warehouse every item will be dispatched from.", + }, + { + n: 2, + label: 'Ride & Assignment', + title: 'Which vehicle, and who is populating this sheet?', + help: 'Choose the open ride whose vehicle gets loaded, and who is creating this sheet.', + }, + { + n: 3, + label: 'Items', + title: 'What should be loaded from Shop POs?', + help: "Expand a shop to tick items and set quantities. If the main warehouse doesn't have enough stock, use \"Take remaining from another warehouse\" to top up the rest.", + }, + { + n: 4, + label: 'Additional Items', + title: "Anything to load that's not on a PO?", + help: "Optional — add extra stock for the vehicle that isn't tied to any shop order.", + }, + { + n: 5, + label: 'Review & Confirm', + title: 'Double-check before saving', + help: 'This is everything that will be saved to the sheet. Fix anything short before confirming later on the loading sheet list.', + }, +] as const + interface ExtraAllocation { warehouseId: string quantity: number @@ -115,6 +149,8 @@ function LoadingSheetForm() { const [rideId, setRideId] = useState('') const [populatedByUserId, setPopulatedByUserId] = useState('') + const [step, setStep] = useState<1 | 2 | 3 | 4 | 5>(1) + const [viewStoreId, setViewStoreId] = useState('') const [itemsList, setItemsList] = useState([]) const [manualItems, setManualItems] = useState([]) @@ -441,6 +477,34 @@ function LoadingSheetForm() { updateExtras(line, line.extras.filter((_, i) => i !== index)) } + function goNext() { + if (step === 1) { + if (!warehouseId) { + toast.add({ title: 'Select a warehouse first', type: 'error' }) + return + } + setStep(2) + return + } + if (step === 2) { + if (!rideId) { + toast.add({ title: 'Select a ride to load the vehicle', type: 'error' }) + return + } + if (!populatedByUserId) { + toast.add({ title: 'Select who is populating this sheet', type: 'error' }) + return + } + setStep(3) + return + } + if (step < 5) setStep((s) => (s + 1) as typeof step) + } + + function goBack() { + setStep((s) => Math.max(1, s - 1) as typeof step) + } + async function handleSubmit() { if (!routeId && manualItems.length === 0) { toast.add({ title: 'Select a route first', type: 'error' }) @@ -541,13 +605,43 @@ function LoadingSheetForm() {

{isEdit ? 'Edit Loading Sheet' : 'New Loading Sheet'}

-

- Select a route first. Confirmed Shop POs for that route's shops will then be - available to pick items from. Pick the ride to load last. -

+

Work through the steps below to build the loading sheet.

+ {/* Step indicator */} +
+ {STEPS.map((s, idx) => ( +
+ + {s.label} + {idx < STEPS.length - 1 &&
} +
+ ))} +
+ + {/* Step title & guidance */} +
+

{STEPS[step - 1].title}

+

{STEPS[step - 1].help}

+
+ + {step === 1 && (

Route & Warehouse

@@ -616,7 +710,9 @@ function LoadingSheetForm() {
+ )} + {step === 3 && (

Items

@@ -824,7 +920,9 @@ function LoadingSheetForm() {
+ )} + {step === 4 && (
@@ -897,7 +995,9 @@ function LoadingSheetForm() {
)}
+ )} + {step === 2 && (

Ride & Assignment

@@ -935,7 +1035,9 @@ function LoadingSheetForm() {
+ )} + {step === 5 && (

Loading Sheet Summary

@@ -969,15 +1071,31 @@ function LoadingSheetForm() {

Total Quantity

{totalQuantity}

+
+
+ )} -
- + )} +
+
+ + {step < 5 ? ( + + ) : ( -
+ )}