Bulk update category order and improve number formatting

Category order is now updated via a bulk API endpoint instead of individual requests, improving efficiency. Number formatting in pricing tiers form now avoids cursor jumping by only formatting decimals when necessary.
This commit is contained in:
NotII
2025-10-02 04:17:27 +01:00
parent be952509a1
commit d1f3e6b214
2 changed files with 11 additions and 4 deletions

View File

@@ -180,10 +180,15 @@ export default function CategoriesPage() {
return updatedCat || cat;
}));
// Save the new order to the server
// Save the new order to the server using bulk update
try {
await apiRequest(`/categories/${dragId}`, "PUT", {
order: filteredSiblings.find(cat => cat._id === dragId)?.order,
const categoriesToUpdate = filteredSiblings.map(cat => ({
_id: cat._id,
order: cat.order
}));
await apiRequest("/categories/bulk-order", "PUT", {
categories: categoriesToUpdate
});
} catch (error) {
toast.error("Failed to update category order");