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:
@@ -158,8 +158,7 @@ export default function OrderDetailsPage() {
|
|||||||
const [isAcknowledging, setIsAcknowledging] = useState(false);
|
const [isAcknowledging, setIsAcknowledging] = useState(false);
|
||||||
const [isCancelling, setIsCancelling] = useState(false);
|
const [isCancelling, setIsCancelling] = useState(false);
|
||||||
const [refreshTrigger, setRefreshTrigger] = useState(0);
|
const [refreshTrigger, setRefreshTrigger] = useState(0);
|
||||||
const [showShippingDialog, setShowShippingDialog] = useState(false);
|
// shipping dialog removed; use inline tracking input instead
|
||||||
const [shippingTrackingNumber, setShippingTrackingNumber] = useState("");
|
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
@@ -264,11 +263,17 @@ export default function OrderDetailsPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMarkAsShipped = async (trackingNumber?: string) => {
|
const handleMarkAsShipped = async () => {
|
||||||
try {
|
try {
|
||||||
setIsMarkingShipped(true);
|
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`, {
|
const response = await clientFetch(`/orders/${orderId}/status`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
body: JSON.stringify({ status: "shipped" }),
|
body: JSON.stringify({ status: "shipped" }),
|
||||||
@@ -276,12 +281,6 @@ export default function OrderDetailsPage() {
|
|||||||
|
|
||||||
if (response && response.message === "Order status updated successfully") {
|
if (response && response.message === "Order status updated successfully") {
|
||||||
setOrder((prevOrder) => prevOrder ? { ...prevOrder, status: "shipped" } : null);
|
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!");
|
toast.success("Order marked as shipped successfully!");
|
||||||
} else {
|
} else {
|
||||||
throw new Error(response.error || "Failed to mark order as shipped");
|
throw new Error(response.error || "Failed to mark order as shipped");
|
||||||
@@ -325,16 +324,7 @@ export default function OrderDetailsPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleShippingDialogConfirm = async () => {
|
// shipping dialog removed
|
||||||
await handleMarkAsShipped(shippingTrackingNumber);
|
|
||||||
setShowShippingDialog(false);
|
|
||||||
setShippingTrackingNumber("");
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleShippingDialogCancel = () => {
|
|
||||||
setShowShippingDialog(false);
|
|
||||||
setShippingTrackingNumber("");
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleMarkAsAcknowledged = async () => {
|
const handleMarkAsAcknowledged = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -972,7 +962,7 @@ export default function OrderDetailsPage() {
|
|||||||
{order?.status === "acknowledged" && (
|
{order?.status === "acknowledged" && (
|
||||||
<Button
|
<Button
|
||||||
className="w-full"
|
className="w-full"
|
||||||
onClick={() => setShowShippingDialog(true)}
|
onClick={handleMarkAsShipped}
|
||||||
disabled={isMarkingShipped}
|
disabled={isMarkingShipped}
|
||||||
>
|
>
|
||||||
{isMarkingShipped ? "Processing..." : "Mark as Shipped"}
|
{isMarkingShipped ? "Processing..." : "Mark as Shipped"}
|
||||||
@@ -1133,40 +1123,7 @@ export default function OrderDetailsPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Shipping Dialog */}
|
{/* Shipping Dialog removed; use inline tracking input above */}
|
||||||
<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>
|
|
||||||
</div>
|
</div>
|
||||||
</Layout>
|
</Layout>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"commitHash": "32bf9d7",
|
"commitHash": "864e1e9",
|
||||||
"buildTime": "2025-10-09T19:56:57.229Z"
|
"buildTime": "2025-10-10T00:32:58.696Z"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user