From 2fd72fecf75b653cfa7efa61aff7dc3aef32fbf0 Mon Sep 17 00:00:00 2001 From: ZCode Date: Sun, 20 Sep 2026 19:25:19 +0000 Subject: [PATCH] feat(dashboard): drop the category filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The category filter is not used: remove it end to end — the toolbar's category combobox (desktop + mobile drawer), its option list, the active-filter count and the filterQuotes() clause it drove, plus the now-unused `category` field in the Filters type. Supplier and status filters are unchanged. The backend's own quote filtering by category is untouched (it filters on the quote's supplier category when ?category_id= is passed), so the API keeps its contract; only the dashboard UI stops offering the filter. --- frontend/src/lib/quoteUtils.ts | 7 +---- .../src/pages/Dashboard/DashboardPage.tsx | 9 +----- .../src/pages/Dashboard/FilterToolbar.tsx | 30 ++----------------- 3 files changed, 4 insertions(+), 42 deletions(-) diff --git a/frontend/src/lib/quoteUtils.ts b/frontend/src/lib/quoteUtils.ts index 0b79bae..643ec77 100644 --- a/frontend/src/lib/quoteUtils.ts +++ b/frontend/src/lib/quoteUtils.ts @@ -336,9 +336,8 @@ export function termsheetSummary(store: Store, q: Quote): { title: string; sub: // فیلترهای دفتر export function filterQuotes( store: Store, - filters: { category: string; supplier: string; status: string; search: string }, + filters: { supplier: string; status: string; search: string }, ): Quote[] { - const catVal = filters.category.trim(); const supVal = filters.supplier.trim(); const stVal = filters.status.trim(); const q = filters.search.trim().toLowerCase(); @@ -361,10 +360,6 @@ export function filterQuotes( if (stKey && quote.status !== stKey) return false; const matInfo = activeItems(quote).map((li) => materialById(store.materials, li.material_id)); - // v2.7: دسته روی تأمین‌کننده است و بک‌اند هم پیشنهادها را با دسته‌ی - // تأمین‌کننده فیلتر می‌کند — همین قاعده اینجا هم اعمال می‌شود تا لیست و - // فیلتر یک رفتار داشته باشند. - if (catVal && !(supObj.categories || []).includes(catVal)) return false; if (q) { const hay = diff --git a/frontend/src/pages/Dashboard/DashboardPage.tsx b/frontend/src/pages/Dashboard/DashboardPage.tsx index 36e372d..08cc5cd 100644 --- a/frontend/src/pages/Dashboard/DashboardPage.tsx +++ b/frontend/src/pages/Dashboard/DashboardPage.tsx @@ -19,7 +19,7 @@ import { AppSwitcherMenu } from "../../components/AppSwitcherMenu"; import { AcceptModal } from "./AcceptModal"; import { EditModal } from "./EditModal"; -const EMPTY_FILTERS: Filters = { category: "", supplier: "", status: "", search: "" }; +const EMPTY_FILTERS: Filters = { supplier: "", status: "", search: "" }; export function DashboardPage() { useStoreData(); @@ -80,12 +80,6 @@ export function DashboardPage() { })); }; - // دسته‌ها روی تأمین‌کننده هستند (v2.7) و بک‌اند هم فیلتر پیشنهادها را با - // دسته‌ی تأمین‌کننده انجام می‌دهد — پس گزینه‌های فیلتر از همان‌جا می‌آید. - const categoryOptions = useMemo( - () => [...new Set(suppliers.flatMap((s) => s.categories || []).filter(Boolean))].sort((a, b) => a.localeCompare(b, "fa")), - [suppliers], - ); const supplierOptions = useMemo(() => suppliers.map((s) => ({ id: s.id, name: s.name })), [suppliers]); return ( @@ -143,7 +137,6 @@ export function DashboardPage() { setSortDir((d) => (d === "desc" ? "asc" : "desc"))} diff --git a/frontend/src/pages/Dashboard/FilterToolbar.tsx b/frontend/src/pages/Dashboard/FilterToolbar.tsx index d333df7..e12b0ca 100644 --- a/frontend/src/pages/Dashboard/FilterToolbar.tsx +++ b/frontend/src/pages/Dashboard/FilterToolbar.tsx @@ -3,7 +3,6 @@ import { SlidersHorizontal, X, ArrowUpDown, RotateCcw } from "lucide-react"; import { Combobox } from "../../components/Combobox"; export interface Filters { - category: string; supplier: string; status: string; search: string; @@ -40,7 +39,6 @@ const STATUS_TO_KEY: Record = { export interface FilterToolbarProps { filters: Filters; onChange: (f: Filters) => void; - categories: string[]; suppliers: { id: string; name: string }[]; sortDir: "desc" | "asc"; onToggleSort: () => void; @@ -49,7 +47,6 @@ export interface FilterToolbarProps { export function FilterToolbar({ filters, onChange, - categories, suppliers, sortDir, onToggleSort, @@ -58,10 +55,10 @@ export function FilterToolbar({ const set = (patch: Partial) => onChange({ ...filters, ...patch }); // شمارش تعداد فیلترهای فعال به جز سرچ - const activeFilterCount = [filters.category, filters.supplier, filters.status].filter(Boolean).length; + const activeFilterCount = [filters.supplier, filters.status].filter(Boolean).length; const clearFilters = () => { - onChange({ ...filters, category: "", supplier: "", status: "" }); + onChange({ ...filters, supplier: "", status: "" }); }; // تبدیل کلید انگلیسی به لیبل فارسی برای نمایش داخل کامبوباکس @@ -153,18 +150,6 @@ export function FilterToolbar({ {/* دراپ‌داون‌ها داخل کشو */}
-
- - set({ category: it.label })} - items={categories} - allowAdd={false} - placeholder="همه دسته‌ها" - onInputChange={(v) => set({ category: v })} - /> -
-
-
- - set({ category: it.label })} - items={categories} - allowAdd={false} - placeholder="همه" - onInputChange={(v) => set({ category: v })} - /> -