Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
877eb9e09a | ||
|
|
6d3570909a |
@@ -1,7 +1,7 @@
|
|||||||
import type { OrderStatus } from "@orderops/shared/order-status";
|
import type { OrderStatus } from "@orderops/shared/order-status";
|
||||||
|
|
||||||
export function canEditOrderItems(status: OrderStatus) {
|
export function canEditOrderItems(status: OrderStatus) {
|
||||||
return status === "pending" || status === "processing";
|
return status === "pending";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function canEditShippingAddress(status: OrderStatus) {
|
export function canEditShippingAddress(status: OrderStatus) {
|
||||||
|
|||||||
@@ -72,6 +72,19 @@ export function OrderPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleUpdateQuantity(itemId: string, quantity: number) {
|
||||||
|
if (!order) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (order.status !== "pending") {
|
||||||
|
setToast({ message: "Order items cannot be changed for this order status.", variant: "error" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await runAction(() => updateOrderItemQuantity(order.id, itemId, quantity), "Quantity saved.");
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<Link className="inline-flex text-sm font-medium text-blue-600 hover:text-blue-700" to="/orders">
|
<Link className="inline-flex text-sm font-medium text-blue-600 hover:text-blue-700" to="/orders">
|
||||||
@@ -84,7 +97,7 @@ export function OrderPage() {
|
|||||||
<OrderDetailPage
|
<OrderDetailPage
|
||||||
order={order}
|
order={order}
|
||||||
auditEvents={auditEvents}
|
auditEvents={auditEvents}
|
||||||
onUpdateQuantity={(itemId, quantity) => runAction(() => updateOrderItemQuantity(order.id, itemId, quantity), "Quantity saved.")}
|
onUpdateQuantity={handleUpdateQuantity}
|
||||||
onSaveAddress={(address: Address) => runAction(() => updateShippingAddress(order.id, address), "Shipping address saved.")}
|
onSaveAddress={(address: Address) => runAction(() => updateShippingAddress(order.id, address), "Shipping address saved.")}
|
||||||
onSaveNotes={(notes) => runAction(() => updateOrderNotes(order.id, notes), "Notes saved.")}
|
onSaveNotes={(notes) => runAction(() => updateOrderNotes(order.id, notes), "Notes saved.")}
|
||||||
onCancel={() => runAction(() => cancelOrder(order.id), "Order cancelled.")}
|
onCancel={() => runAction(() => cancelOrder(order.id), "Order cancelled.")}
|
||||||
|
|||||||
Reference in New Issue
Block a user