fix(catalog): show real material names, not categories, across quote views
New shared materialLabel() renders the global materials.name with brand/specs appended only when not already part of the name (deduped; «؟» fallback kept). Replaces the category-first composer in five places: supplier card badges (CategoryPage), dashboard item lines (QuoteCard), ledger items summary, project rows and purchase history. Also fixes the stale Units subtitle «ضریب تبدیل همان دسته» → «ضریب تبدیل متریال» (category model kept).
This commit is contained in:
@@ -40,6 +40,22 @@ export function specsLabel(specs: string[]): string {
|
||||
return specs.join(" · ");
|
||||
}
|
||||
|
||||
// نام نمایشی متریال — نام سراسری واقعی (materials.name)، نه دسته.
|
||||
// برند و مشخصه فقط وقتی به نام اضافه میشوند که داخلش نیامده باشند (بدون تکرار).
|
||||
export function materialLabel(m: Pick<Material, "name" | "brand" | "specs" | "category">): string {
|
||||
const name = (m.name || "").trim();
|
||||
const specs = (m.specs || []).filter(Boolean);
|
||||
if (!name && !m.brand && !specs.length) return m.category === "؟" ? "؟" : "کالا";
|
||||
if (!name) {
|
||||
return [m.brand, ...specs].filter(Boolean).join(" ") || "کالا";
|
||||
}
|
||||
const parts = [name];
|
||||
if (m.brand && !name.includes(m.brand)) parts.push(m.brand);
|
||||
const missing = specs.filter((s) => !name.includes(s));
|
||||
if (missing.length) parts.push(`(${missing.join("، ")})`);
|
||||
return parts.join(" ");
|
||||
}
|
||||
|
||||
// آرایهی termsheet_ids یک قلم (هر دو فرمت قدیم/جدید)
|
||||
export function itemTermsheetIds(li: LineItem): string[] {
|
||||
if (li.termsheet_ids) return li.termsheet_ids;
|
||||
@@ -157,8 +173,7 @@ export function projectCell(q: Quote): string {
|
||||
export function itemsSummary(store: Store, q: Quote): { text: string; count: number } {
|
||||
const items = activeItems(q).map((li) => {
|
||||
const m = materialById(store.materials, li.material_id);
|
||||
const specs = materialSpecs(m);
|
||||
return `${m.category} ${m.brand}${specs.length ? " " + specs.join(" · ") : ""}`;
|
||||
return materialLabel(m);
|
||||
});
|
||||
return { text: items.join("، "), count: items.length };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user