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:
@@ -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");
|
||||
|
||||
@@ -21,7 +21,9 @@ export const PricingTiers = ({
|
||||
handleAddTier,
|
||||
}: PricingTiersProps) => {
|
||||
const formatNumber = (num: number) => {
|
||||
return Number(num.toFixed(2)).toString();
|
||||
// Only format to 2 decimal places if the number has decimal places
|
||||
// This prevents cursor jumping when user types whole numbers
|
||||
return num % 1 === 0 ? num.toString() : num.toFixed(2);
|
||||
};
|
||||
|
||||
const formatTotal = (num: number) => {
|
||||
|
||||
Reference in New Issue
Block a user