diff --git a/app/frontend/src/javascript/components/store/product-item.tsx b/app/frontend/src/javascript/components/store/product-item.tsx index ea1fbb7f4..6277a7d02 100644 --- a/app/frontend/src/javascript/components/store/product-item.tsx +++ b/app/frontend/src/javascript/components/store/product-item.tsx @@ -46,17 +46,18 @@ export const ProductItem: React.FC = ({ product, onEdit, onDel /** * Returns CSS class from stock status */ - const statusColor = (product: Product) => { - if (product.stock.external < 1 && product.stock.internal < 1) { + const statusColor = (product: Product, stockType: string) => { + if (product.stock[stockType] < (product.quantity_min || 1)) { return 'out-of-stock'; } - if (product.low_stock_threshold && (product.stock.external < product.low_stock_threshold || product.stock.internal < product.low_stock_threshold)) { + if (product.low_stock_threshold && product.stock[stockType] <= product.low_stock_threshold) { return 'low'; } + return ''; }; return ( -
+

{product.name}

@@ -68,11 +69,11 @@ export const ProductItem: React.FC = ({ product, onEdit, onDel : t('app.admin.store.product_item.hidden') } -
+
{t('app.admin.store.product_item.stock.internal')}

{product.stock.internal}

-
+
{t('app.admin.store.product_item.stock.external')}

{product.stock.external}

diff --git a/app/frontend/src/javascript/components/store/store-product-item.tsx b/app/frontend/src/javascript/components/store/store-product-item.tsx index 4e2ca159f..240ae9d79 100644 --- a/app/frontend/src/javascript/components/store/store-product-item.tsx +++ b/app/frontend/src/javascript/components/store/store-product-item.tsx @@ -57,7 +57,7 @@ export const StoreProductItem: React.FC = ({ product, car if (product.stock.external < (product.quantity_min || 1)) { return 'out-of-stock'; } - if (product.low_stock_threshold && product.stock.external < product.low_stock_threshold) { + if (product.low_stock_threshold && product.stock.external <= product.low_stock_threshold) { return 'low'; } return ''; diff --git a/app/frontend/src/javascript/components/store/store-product.tsx b/app/frontend/src/javascript/components/store/store-product.tsx index 8bd244f03..2b089ba85 100644 --- a/app/frontend/src/javascript/components/store/store-product.tsx +++ b/app/frontend/src/javascript/components/store/store-product.tsx @@ -71,7 +71,7 @@ export const StoreProduct: React.FC = ({ productSlug, current if (product.stock.external < (product.quantity_min || 1)) { return 'out-of-stock'; } - if (product.low_stock_threshold && product.stock.external < product.low_stock_threshold) { + if (product.low_stock_threshold && product.stock.external <= product.low_stock_threshold) { return 'low'; } return ''; diff --git a/app/frontend/src/javascript/lib/product.ts b/app/frontend/src/javascript/lib/product.ts index bdf7041fb..9a050fc45 100644 --- a/app/frontend/src/javascript/lib/product.ts +++ b/app/frontend/src/javascript/lib/product.ts @@ -44,7 +44,7 @@ export default class ProductLib { if (product.stock.external < (product.quantity_min || 1)) { return 'app.public.stock_status.out_of_stock'; } - if (product.low_stock_threshold && product.stock.external < product.low_stock_threshold) { + if (product.low_stock_threshold && product.stock.external <= product.low_stock_threshold) { return 'app.public.stock_status.limited_stock'; } return 'app.public.stock_status.available'; diff --git a/app/frontend/src/stylesheets/modules/store/products-list.scss b/app/frontend/src/stylesheets/modules/store/products-list.scss index e5588adc9..148912016 100644 --- a/app/frontend/src/stylesheets/modules/store/products-list.scss +++ b/app/frontend/src/stylesheets/modules/store/products-list.scss @@ -63,6 +63,7 @@ color: var(--gray-hard-darkest); span { @include text-xs; } &.low { color: var(--alert-light); } + &.out-of-stock { color: var(--alert); } } .price { justify-self: flex-end; @@ -95,4 +96,4 @@ .actions { grid-area: auto; } } } -} \ No newline at end of file +} diff --git a/app/services/product_service.rb b/app/services/product_service.rb index 6e2a4d9e7..c2e82fea0 100644 --- a/app/services/product_service.rb +++ b/app/services/product_service.rb @@ -192,8 +192,8 @@ class ProductService def notify_on_low_stock(product) return product unless product.low_stock_threshold - if (product.stock['internal'] < product.low_stock_threshold) || - (product.stock['external'] < product.low_stock_threshold) + if (product.stock['internal'] <= product.low_stock_threshold) || + (product.stock['external'] <= product.low_stock_threshold) NotificationCenter.call type: 'notify_admin_low_stock_threshold', receiver: User.admins_and_managers, attached_object: product