From 87c1cdf8dadbef2895d9fc95263bcaba28e6a25a Mon Sep 17 00:00:00 2001 From: Lorentz Date: Mon, 16 Feb 2026 17:02:20 +0000 Subject: [PATCH] feat: update inventory columns to match legacy portal and grant admins all companies Inventory summary table now shows Plant, Cust Part#, Vorteq Part#, Vorteq Desc, Warehouse, Qty LB, Rows with a blue View button for drill-down. Admins see all active companies in the company selector. Co-Authored-By: Claude Opus 4.6 --- .../inventory/inventory-summary-table.tsx | 56 +++++++++++-------- src/lib/permissions.ts | 11 +++- src/services/inventory.ts | 2 + 3 files changed, 45 insertions(+), 24 deletions(-) diff --git a/src/components/inventory/inventory-summary-table.tsx b/src/components/inventory/inventory-summary-table.tsx index 73d970a..9424233 100644 --- a/src/components/inventory/inventory-summary-table.tsx +++ b/src/components/inventory/inventory-summary-table.tsx @@ -12,7 +12,7 @@ import { } from '@/components/ui/table'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; -import { Search, Download } from 'lucide-react'; +import { Search, Download, Eye } from 'lucide-react'; import { InventorySummaryRow } from '@/services/inventory'; type InventorySummaryTableProps = { @@ -30,31 +30,34 @@ export function InventorySummaryTable({ (row) => row.part_num.toLowerCase().includes(searchTerm.toLowerCase()) || row.description?.toLowerCase().includes(searchTerm.toLowerCase()) || - row.plant?.toLowerCase().includes(searchTerm.toLowerCase()) + row.plant?.toLowerCase().includes(searchTerm.toLowerCase()) || + row.cust_part_num?.toLowerCase().includes(searchTerm.toLowerCase()) ); const handleExportCSV = () => { - // Create CSV content const headers = [ - 'Part Number', - 'Description', 'Plant', + 'Cust Part#', + 'Vorteq Part#', + 'Vorteq Desc', 'Warehouse', - 'On Hand Qty', + 'Qty LB', + 'Rows', ]; const rows = filteredData.map((row) => [ + row.plant, + row.cust_part_num || '', row.part_num, row.description || '', - row.plant, row.warehouse, row.on_hand_qty, + row.rows, ]); const csvContent = [headers, ...rows] - .map((row) => row.join(',')) + .map((row) => row.map((cell) => `"${cell}"`).join(',')) .join('\n'); - // Download CSV const blob = new Blob([csvContent], { type: 'text/csv' }); const url = window.URL.createObjectURL(blob); const a = document.createElement('a'); @@ -95,32 +98,39 @@ export function InventorySummaryTable({ - Part Number - Description Plant + Cust Part# + Vorteq Part# + Vorteq Desc Warehouse - On Hand Qty + Qty LB + Rows + {filteredData.map((row, idx) => ( - - - {row.part_num} - - - - {row.description || 'N/A'} - {row.plant} + {row.cust_part_num || '-'} + {row.part_num} + + {row.description || '-'} + {row.warehouse} {Number(row.on_hand_qty).toLocaleString()} + {row.rows} + + + + + ))} diff --git a/src/lib/permissions.ts b/src/lib/permissions.ts index c76ba20..321fef4 100644 --- a/src/lib/permissions.ts +++ b/src/lib/permissions.ts @@ -247,7 +247,8 @@ export async function getActiveCompany() { } /** - * Get all companies accessible by the current user + * Get all companies accessible by the current user. + * Admins and Super Admins can access all active companies. */ export async function getUserCompanies() { const session = await getQuestSession(); @@ -256,6 +257,14 @@ export async function getUserCompanies() { return []; } + // Admins see all active companies + if (session.userType === 'Admin' || session.userType === 'Super Admin') { + return await db.quest_company.findMany({ + where: { is_active: true }, + orderBy: { display_name: 'asc' }, + }); + } + const questUser = await db.quest_user.findUnique({ where: { id: session.questUserId }, include: { diff --git a/src/services/inventory.ts b/src/services/inventory.ts index 5dc18e2..859ce3c 100644 --- a/src/services/inventory.ts +++ b/src/services/inventory.ts @@ -14,6 +14,7 @@ export type InventorySummaryRow = { plant_key: string; warehouse: string; on_hand_qty: number; + rows: number; paint_code?: string; cust_part_num?: string; }; @@ -50,6 +51,7 @@ function mapSummaryRow(raw: Record): InventorySummaryRow { plant_key: String(raw.PlantKey ?? ''), warehouse: String(raw.Warehouse ?? ''), on_hand_qty: Number(raw.OnHandQty ?? 0), + rows: Number(raw.Rows ?? 0), paint_code: raw.PaintCode ? String(raw.PaintCode) : undefined, cust_part_num: raw.CustPartNum ? String(raw.CustPartNum) : undefined, };