Remove shipping dialog from order details page

Replaces the shipping dialog with an inline tracking number input for marking orders as shipped. Simplifies the user flow and removes related state and dialog components.
This commit is contained in:
NotII
2025-10-10 14:01:53 +01:00
parent 864e1e9804
commit d3deb58ad6
2 changed files with 16 additions and 59 deletions

View File

@@ -158,8 +158,7 @@ export default function OrderDetailsPage() {
const [isAcknowledging, setIsAcknowledging] = useState(false);
const [isCancelling, setIsCancelling] = useState(false);
const [refreshTrigger, setRefreshTrigger] = useState(0);
const [showShippingDialog, setShowShippingDialog] = useState(false);
const [shippingTrackingNumber, setShippingTrackingNumber] = useState("");
// shipping dialog removed; use inline tracking input instead
const router = useRouter();
const params = useParams();
@@ -264,24 +263,24 @@ export default function OrderDetailsPage() {
}
};
const handleMarkAsShipped = async (trackingNumber?: string) => {
const handleMarkAsShipped = async () => {
try {
setIsMarkingShipped(true);
// Use clientFetch which handles API URL and auth token automatically
// If a tracking number is present in the inline box, add it first
if (trackingNumber && trackingNumber.trim()) {
await handleAddTrackingNumber(trackingNumber.trim());
setTrackingNumber("");
}
// Then mark as shipped (clientFetch handles API URL and auth token)
const response = await clientFetch(`/orders/${orderId}/status`, {
method: "PUT",
body: JSON.stringify({ status: "shipped" }),
});
if (response && response.message === "Order status updated successfully") {
setOrder((prevOrder) => prevOrder ? { ...prevOrder, status: "shipped" } : null);
// If tracking number is provided, add it
if (trackingNumber && trackingNumber.trim()) {
await handleAddTrackingNumber(trackingNumber.trim());
}
toast.success("Order marked as shipped successfully!");
} else {
throw new Error(response.error || "Failed to mark order as shipped");
@@ -325,16 +324,7 @@ export default function OrderDetailsPage() {
}
};
const handleShippingDialogConfirm = async () => {
await handleMarkAsShipped(shippingTrackingNumber);
setShowShippingDialog(false);
setShippingTrackingNumber("");
};
const handleShippingDialogCancel = () => {
setShowShippingDialog(false);
setShippingTrackingNumber("");
};
// shipping dialog removed
const handleMarkAsAcknowledged = async () => {
try {
@@ -972,7 +962,7 @@ export default function OrderDetailsPage() {
{order?.status === "acknowledged" && (
<Button
className="w-full"
onClick={() => setShowShippingDialog(true)}
onClick={handleMarkAsShipped}
disabled={isMarkingShipped}
>
{isMarkingShipped ? "Processing..." : "Mark as Shipped"}
@@ -1133,40 +1123,7 @@ export default function OrderDetailsPage() {
</div>
</div>
{/* Shipping Dialog */}
<AlertDialog open={showShippingDialog} onOpenChange={setShowShippingDialog}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Mark Order as Shipped</AlertDialogTitle>
<AlertDialogDescription>
Mark this order as shipped. You can optionally add a tracking number.
</AlertDialogDescription>
</AlertDialogHeader>
<div className="space-y-4 py-4">
<div>
<Label htmlFor="shipping-tracking">Tracking Number (Optional)</Label>
<Input
id="shipping-tracking"
value={shippingTrackingNumber}
onChange={(e) => setShippingTrackingNumber(e.target.value)}
placeholder="Enter tracking number"
className="mt-1"
/>
</div>
</div>
<AlertDialogFooter>
<AlertDialogCancel onClick={handleShippingDialogCancel}>
Cancel
</AlertDialogCancel>
<AlertDialogAction
onClick={handleShippingDialogConfirm}
disabled={isMarkingShipped}
>
{isMarkingShipped ? "Processing..." : "Mark as Shipped"}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
{/* Shipping Dialog removed; use inline tracking input above */}
</div>
</Layout>
);

View File

@@ -1,4 +1,4 @@
{
"commitHash": "32bf9d7",
"buildTime": "2025-10-09T19:56:57.229Z"
"commitHash": "864e1e9",
"buildTime": "2025-10-10T00:32:58.696Z"
}