feat: integrate shipment cart into inventory summary tables
Some checks failed
Build and Deploy / build (push) Successful in 4m50s
Build and Deploy / deploy (push) Failing after 2s

Pass cartEnabled prop through inventory summary and detail tables
to show the CartBar component for users with shipment request
permissions. Fix embedded detail table missing cart/category props.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lorentz Hinrichsen 2026-02-18 07:27:58 -05:00
parent 500811f3e3
commit 9654ccee26
4 changed files with 22 additions and 11 deletions

Binary file not shown.

View file

@ -4,6 +4,7 @@ import {
getQuestSession,
getActiveCompany,
isSubUser,
hasPermission,
} from '@/lib/permissions';
import { redirect } from 'next/navigation';
import { InventorySummaryTable } from '@/components/inventory/inventory-summary-table';
@ -23,13 +24,16 @@ async function FinishedGoodsInventoryData() {
const dbName = `[${process.env.PORTAL_DB_NAME || 'VorteqPortal'}]`;
const sub = userIsSubUser ? 1 : 0;
const inventory = await getFinishedGoodsSummary(
activeCompany.epicor_cust_id,
dbName,
sub
).catch(() => []);
const [inventory, canShip] = await Promise.all([
getFinishedGoodsSummary(
activeCompany.epicor_cust_id,
dbName,
sub
).catch(() => []),
hasPermission('create_shipment_request'),
]);
return <InventorySummaryTable data={inventory} category="finished-goods" />;
return <InventorySummaryTable data={inventory} category="finished-goods" cartEnabled={canShip} />;
}
function LoadingSkeleton() {

View file

@ -564,7 +564,7 @@ export function InventoryDetailTable({
category,
}: Props) {
if (embedded) {
return <DetailTableContent data={data} partNum={partNum} plant={plant} />;
return <DetailTableContent data={data} partNum={partNum} plant={plant} cartEnabled={cartEnabled} category={category} />;
}
return (

View file

@ -2,7 +2,6 @@
import { useState, useCallback } from 'react';
import {
Table,
TableBody,
TableCell,
TableRow,
@ -24,6 +23,7 @@ import {
SortableTableHead,
useSortableTable,
} from '@/components/ui/sortable-table-head';
import { CartBar } from '@/components/requests/cart-bar';
const CATEGORY_COLORS: Record<string, string> = {
wip: 'bg-emerald-600 text-white',
@ -37,11 +37,14 @@ const CATEGORY_COLORS: Record<string, string> = {
type InventorySummaryTableProps = {
data: InventorySummaryRow[];
category: string;
/** Whether to show the shipment cart bar */
cartEnabled?: boolean;
};
export function InventorySummaryTable({
data,
category,
cartEnabled = false,
}: InventorySummaryTableProps) {
const [searchTerm, setSearchTerm] = useState('');
const [dialogOpen, setDialogOpen] = useState(false);
@ -142,6 +145,8 @@ export function InventorySummaryTable({
return (
<div>
{cartEnabled && <CartBar />}
<div className="mb-4 flex items-center justify-between">
<div className="relative max-w-sm flex-1">
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
@ -160,7 +165,7 @@ export function InventorySummaryTable({
</div>
<div className="overflow-hidden rounded-md border">
<Table>
<table className="w-full caption-bottom text-sm">
<thead>
<tr className={headerColor}>
<SortableTableHead
@ -221,7 +226,7 @@ export function InventorySummaryTable({
>
Rows
</SortableTableHead>
<th className="w-[70px]"></th>
<th className="w-[70px] px-4 py-2"></th>
</tr>
</thead>
<TableBody>
@ -251,7 +256,7 @@ export function InventorySummaryTable({
</TableRow>
))}
</TableBody>
</Table>
</table>
</div>
<div className="mt-4 text-sm text-muted-foreground">
@ -321,6 +326,8 @@ export function InventorySummaryTable({
plant={selectedRow?.plant_key || selectedRow?.plant}
warehouse={selectedRow?.warehouse}
embedded
cartEnabled={cartEnabled}
category={category}
/>
)}
</div>