Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

fix(vendor): refine create-fulfillment error messages (#1201)

Viktor Holikece78d607991
diff --git a/packages/vendor/src/i18n/translations/en.json b/packages/vendor/src/i18n/translations/en.json
index 15196b7e4..f8a92c4f9 100644
--- a/packages/vendor/src/i18n/translations/en.json
+++ b/packages/vendor/src/i18n/translations/en.json
@@ -1808,7 +1808,8 @@
"error": {
"wrongQuantity": "Only one item is available for fulfillment",
"wrongQuantity_other": "Quantity should be a number between 1 and {{number}}",
- "noItems": "No items to fulfill.",
+ "noItems": "There are no items to fulfill.",
+ "exceedsReservedQuantity": "The quantity you want to fulfill exceeds the reserved quantity for items. Please review your fulfillment.",
"noShippingOption": "Shipping option is required",
"noLocation": "Location is required"
},
diff --git a/packages/vendor/src/pages/orders/[id]/fulfillment/order-create-fulfillment-form/order-create-fulfillment-form.tsx b/packages/vendor/src/pages/orders/[id]/fulfillment/order-create-fulfillment-form/order-create-fulfillment-form.tsx
index 1c0402b25..6f7c1778a 100644
--- a/packages/vendor/src/pages/orders/[id]/fulfillment/order-create-fulfillment-form/order-create-fulfillment-form.tsx
+++ b/packages/vendor/src/pages/orders/[id]/fulfillment/order-create-fulfillment-form/order-create-fulfillment-form.tsx
@@ -173,13 +173,25 @@ export function OrderCreateFulfillmentForm({
})),
}
+ if (!payload.items.length) {
+ toast.error(t("orders.fulfillment.error.noItems"))
+ return
+ }
+
try {
await createOrderFulfillment(payload)
toast.success(t("orders.fulfillment.toast.created"))
handleSuccess(`/orders/${order.id}`)
} catch (e: any) {
- toast.error(e.message)
+ const message: string = e?.message ?? ""
+
+ if (message.includes("exceeds the reserved quantity")) {
+ toast.error(t("orders.fulfillment.error.exceedsReservedQuantity"))
+ return
+ }
+
+ toast.error(message)
}
})