1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-19 08:52:25 +01:00

(bug) fix product and order error message

This commit is contained in:
Du Peng 2022-10-14 12:57:55 +02:00
parent b9397388c5
commit 48de0f8b9e
5 changed files with 16 additions and 4 deletions

View File

@ -48,8 +48,12 @@ class API::ProductsController < API::ApiController
def destroy
authorize @product
begin
ProductService.destroy(@product)
head :no_content
rescue StandardError => e
render json: e, status: :unprocessable_entity
end
end
def stock_movements

View File

@ -40,7 +40,9 @@ export const StoreProductItem: React.FC<StoreProductItemProps> = ({ product, car
const addProductToCart = (e: React.BaseSyntheticEvent) => {
e.preventDefault();
e.stopPropagation();
CartAPI.addItem(cart, product.id, 1).then(onSuccessAddProductToCart).catch(onError);
CartAPI.addItem(cart, product.id, 1).then(onSuccessAddProductToCart).catch(() => {
onError(t('app.public.store_product_item.stock_limit'));
});
};
/**

View File

@ -110,7 +110,9 @@ export const StoreProduct: React.FC<StoreProductProps> = ({ productSlug, current
CartAPI.addItem(cart, product.id, toCartCount).then(data => {
setCart(data);
onSuccess(t('app.public.store_product.add_to_cart_success'));
}).catch(onError);
}).catch(() => {
onError(t('app.public.store_product.stock_limit'));
});
}
};

View File

@ -408,6 +408,7 @@ en:
documentation: "Documentation"
minimum_purchase: "Minimum purchase: "
add_to_cart: "Add to cart"
stock_limit: "You have reached the current stock limit"
stock_status:
available: "Available"
limited_stock: "Limited stock"
@ -416,6 +417,7 @@ en:
minimum_purchase: "Minimum purchase: "
add: "Add"
add_to_cart: "Add to cart"
stock_limit: "You have reached the current stock limit"
product_price:
per_unit: "/ unit"
free: "Free"

View File

@ -408,6 +408,7 @@ fr:
documentation: "Documentation"
minimum_purchase: "Achat minimum : "
add_to_cart: "Ajouter au panier"
stock_limit: "Vous avez atteint la limite actuelle de stock"
stock_status:
available: "Disponible"
limited_stock: "Stock limité"
@ -416,6 +417,7 @@ fr:
minimum_purchase: "Achat minimum : "
add: "Ajouter"
add_to_cart: "Ajouter au panier"
stock_limit: "Vous avez atteint la limite actuelle de stock"
product_price:
per_unit: "/ unité"
free: "Gratuit"