diff --git a/src/food-market.api/Controllers/Catalog/ProductsController.cs b/src/food-market.api/Controllers/Catalog/ProductsController.cs index 35b7438..167094a 100644 --- a/src/food-market.api/Controllers/Catalog/ProductsController.cs +++ b/src/food-market.api/Controllers/Catalog/ProductsController.cs @@ -94,6 +94,10 @@ private async Task ResolveDefaultVatAsync(CancellationToken ct) [FromQuery] bool? isMarked, [FromQuery] decimal? purchasePriceFrom, [FromQuery] decimal? purchasePriceTo, + [FromQuery] decimal? referencePriceFrom, + [FromQuery] decimal? referencePriceTo, + [FromQuery] int? shelfLifeDaysFrom, + [FromQuery] int? shelfLifeDaysTo, CancellationToken ct) { var q = QueryIncludes().AsNoTracking(); @@ -115,8 +119,14 @@ private async Task ResolveDefaultVatAsync(CancellationToken ct) if (isService is not null) q = q.Where(p => p.IsService == isService); if (packaging is not null) q = q.Where(p => p.Packaging == packaging); if (isMarked is not null) q = q.Where(p => p.IsMarked == isMarked); - if (purchasePriceFrom is not null) q = q.Where(p => p.ReferencePrice >= purchasePriceFrom); - if (purchasePriceTo is not null) q = q.Where(p => p.ReferencePrice <= purchasePriceTo); + // referencePriceFrom/To — новый, актуальный параметр; purchasePriceFrom/To + // — обратная совместимость c прежним UI (тоже по ReferencePrice). + var refFrom = referencePriceFrom ?? purchasePriceFrom; + var refTo = referencePriceTo ?? purchasePriceTo; + if (refFrom is not null) q = q.Where(p => p.ReferencePrice >= refFrom); + if (refTo is not null) q = q.Where(p => p.ReferencePrice <= refTo); + if (shelfLifeDaysFrom is not null) q = q.Where(p => p.ShelfLifeDays >= shelfLifeDaysFrom); + if (shelfLifeDaysTo is not null) q = q.Where(p => p.ShelfLifeDays <= shelfLifeDaysTo); if (!string.IsNullOrWhiteSpace(req.Search)) { diff --git a/src/food-market.web/src/pages/ProductEditPage.tsx b/src/food-market.web/src/pages/ProductEditPage.tsx index 26313de..b54ef22 100644 --- a/src/food-market.web/src/pages/ProductEditPage.tsx +++ b/src/food-market.web/src/pages/ProductEditPage.tsx @@ -34,6 +34,7 @@ interface Form { referencePrice: string purchaseCurrencyId: string imageUrl: string + shelfLifeDays: string prices: PriceRow[] barcodes: BarcodeRow[] } @@ -47,6 +48,7 @@ const emptyForm: Form = { minStock: '', maxStock: '', referencePrice: '', purchaseCurrencyId: '', imageUrl: '', + shelfLifeDays: '', prices: [], barcodes: [], } @@ -89,6 +91,7 @@ export function ProductEditPage() { referencePrice: p.referencePrice?.toString() ?? '', purchaseCurrencyId: p.purchaseCurrencyId ?? '', imageUrl: p.imageUrl ?? '', + shelfLifeDays: p.shelfLifeDays?.toString() ?? '', prices: p.prices.map((x) => ({ id: x.id, priceTypeId: x.priceTypeId, amount: x.amount, currencyId: x.currencyId })), barcodes: p.barcodes.map((x) => ({ id: x.id, code: x.code, type: x.type, isPrimary: x.isPrimary })), }) @@ -149,6 +152,7 @@ export function ProductEditPage() { referencePrice: form.referencePrice === '' ? null : Number(form.referencePrice), purchaseCurrencyId: form.purchaseCurrencyId || null, imageUrl: form.imageUrl || null, + shelfLifeDays: form.shelfLifeDays === '' ? null : Number(form.shelfLifeDays), prices: form.prices.map((p) => ({ priceTypeId: p.priceTypeId, amount: Number(p.amount), currencyId: p.currencyId })), barcodes: form.barcodes.map((b) => ({ code: b.code, type: b.type, isPrimary: b.isPrimary })), } @@ -250,6 +254,14 @@ export function ProductEditPage() { setForm({ ...form, article: e.target.value })} /> + + setForm({ ...form, shelfLifeDays: n == null ? '' : String(Math.max(0, Math.round(n))) })} + placeholder="—" + /> +

не обязательное поле

+