feat(dashboard): drop the category filter
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.
This commit is contained in:
@@ -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 =
|
||||
|
||||
@@ -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() {
|
||||
<FilterToolbar
|
||||
filters={filters}
|
||||
onChange={setFilters}
|
||||
categories={categoryOptions}
|
||||
suppliers={supplierOptions}
|
||||
sortDir={sortDir}
|
||||
onToggleSort={() => setSortDir((d) => (d === "desc" ? "asc" : "desc"))}
|
||||
|
||||
@@ -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<string, string> = {
|
||||
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<Filters>) => 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({
|
||||
|
||||
{/* دراپداونها داخل کشو */}
|
||||
<div className="flex flex-col gap-3.5">
|
||||
<div className="field">
|
||||
<label className="mb-1 block text-xs font-semibold text-muted">دسته</label>
|
||||
<Combobox
|
||||
value={filters.category}
|
||||
onChange={(it: { id: string; label: string }) => set({ category: it.label })}
|
||||
items={categories}
|
||||
allowAdd={false}
|
||||
placeholder="همه دستهها"
|
||||
onInputChange={(v) => set({ category: v })}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="field">
|
||||
<label className="mb-1 block text-xs font-semibold text-muted">تأمینکننده</label>
|
||||
<Combobox
|
||||
@@ -204,17 +189,6 @@ export function FilterToolbar({
|
||||
|
||||
{/* ===== نمای دسکتاپ (md به بالا) ===== */}
|
||||
<div className="hidden md:flex flex-wrap items-end gap-3">
|
||||
<div className="field min-w-[150px] flex-1">
|
||||
<label>دسته</label>
|
||||
<Combobox
|
||||
value={filters.category}
|
||||
onChange={(it: { id: string; label: string }) => set({ category: it.label })}
|
||||
items={categories}
|
||||
allowAdd={false}
|
||||
placeholder="همه"
|
||||
onInputChange={(v) => set({ category: v })}
|
||||
/>
|
||||
</div>
|
||||
<div className="field min-w-[170px] flex-1">
|
||||
<label>تأمینکننده</label>
|
||||
<Combobox
|
||||
|
||||
Reference in New Issue
Block a user