Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix: Sales status compute and tooltips changes (#433)

Ayush Soni8529f628342a
diff --git a/apps/erp/app/components/Gantt/components/GanttTaskStatus.tsx b/apps/erp/app/components/Gantt/components/GanttTaskStatus.tsx
index 9e5d2a597c..737a40d215 100644
--- a/apps/erp/app/components/Gantt/components/GanttTaskStatus.tsx
+++ b/apps/erp/app/components/Gantt/components/GanttTaskStatus.tsx
@@ -1,4 +1,10 @@
-import { cn, Spinner } from "@carbon/react";
+import {
+ cn,
+ Spinner,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger
+} from "@carbon/react";
import assertNever from "assert-never";
import {
LuBan,
@@ -108,68 +114,94 @@ export function GanttTaskStatusIcon({
status: GanttTaskStatus;
className: string;
}) {
- switch (status) {
- case "PENDING":
- return (
- <LuLayers className={cn(runStatusClassNameColor(status), className)} />
- );
- case "EXECUTING":
- return (
- <Spinner
- className={cn(runStatusClassNameColor(status), "w-2 h-2", className)}
- />
- );
- case "WAITING_TO_RESUME":
- return (
- <LuSnowflake
- className={cn(runStatusClassNameColor(status), className)}
- />
- );
- case "RETRYING_AFTER_FAILURE":
- return (
- <LuRefreshCcw
- className={cn(runStatusClassNameColor(status), className)}
- />
- );
- case "PAUSED":
- return (
- <LuCirclePause
- className={cn(runStatusClassNameColor(status), className)}
- />
- );
- case "CANCELED":
- return (
- <LuBan className={cn(runStatusClassNameColor(status), className)} />
- );
- case "INTERRUPTED":
- return (
- <LuCircleSlash
- className={cn(runStatusClassNameColor(status), className)}
- />
- );
- case "COMPLETED_SUCCESSFULLY":
- return (
- <LuCircleCheck
- className={cn(runStatusClassNameColor(status), className)}
- />
- );
- case "COMPLETED_WITH_ERRORS":
- return (
- <LuCircleX className={cn(runStatusClassNameColor(status), className)} />
- );
- case "SYSTEM_FAILURE":
- return (
- <LuCircleX className={cn(runStatusClassNameColor(status), className)} />
- );
- case "CRASHED":
- return (
- <LuFlame className={cn(runStatusClassNameColor(status), className)} />
- );
+ const getIcon = () => {
+ switch (status) {
+ case "PENDING":
+ return (
+ <LuLayers
+ className={cn(runStatusClassNameColor(status), className)}
+ />
+ );
+ case "EXECUTING":
+ return (
+ <Spinner
+ className={cn(
+ runStatusClassNameColor(status),
+ "w-2 h-2",
+ className
+ )}
+ />
+ );
+ case "WAITING_TO_RESUME":
+ return (
+ <LuSnowflake
+ className={cn(runStatusClassNameColor(status), className)}
+ />
+ );
+ case "RETRYING_AFTER_FAILURE":
+ return (
+ <LuRefreshCcw
+ className={cn(runStatusClassNameColor(status), className)}
+ />
+ );
+ case "PAUSED":
+ return (
+ <LuCirclePause
+ className={cn(runStatusClassNameColor(status), className)}
+ />
+ );
+ case "CANCELED":
+ return (
+ <LuBan className={cn(runStatusClassNameColor(status), className)} />
+ );
+ case "INTERRUPTED":
+ return (
+ <LuCircleSlash
+ className={cn(runStatusClassNameColor(status), className)}
+ />
+ );
+ case "COMPLETED_SUCCESSFULLY":
+ return (
+ <LuCircleCheck
+ className={cn(runStatusClassNameColor(status), className)}
+ />
+ );
+ case "COMPLETED_WITH_ERRORS":
+ return (
+ <LuCircleX
+ className={cn(runStatusClassNameColor(status), className)}
+ />
+ );
+ case "SYSTEM_FAILURE":
+ return (
+ <LuCircleX
+ className={cn(runStatusClassNameColor(status), className)}
+ />
+ );
+ case "CRASHED":
+ return (
+ <LuFlame className={cn(runStatusClassNameColor(status), className)} />
+ );
- default: {
- assertNever(status);
+ default: {
+ assertNever(status);
+ }
}
- }
+ };
+
+ const icon = getIcon();
+ const tooltipText = runStatusTitle(status);
+
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span className="inline-flex">{icon}</span>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>{tooltipText}</span>
+ </TooltipContent>
+ </Tooltip>
+ );
}
export function runStatusClassNameColor(status: GanttTaskStatus): string {
diff --git a/apps/erp/app/components/Icons.tsx b/apps/erp/app/components/Icons.tsx
index b1efdbc2ca..c3b11d82d0 100644
--- a/apps/erp/app/components/Icons.tsx
+++ b/apps/erp/app/components/Icons.tsx
@@ -1,7 +1,14 @@
import type { Database } from "@carbon/database";
import type { LinearIssue } from "@carbon/ee/linear";
import { mapLinearStatusToCarbonStatus } from "@carbon/ee/linear";
-import { Badge, cn, Status } from "@carbon/react";
+import {
+ Badge,
+ cn,
+ Status,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger
+} from "@carbon/react";
import { useMode } from "@carbon/remix";
import { getColor } from "@carbon/utils";
import type { ReactNode } from "react";
@@ -153,18 +160,43 @@ export const OnshapeStatus = ({
status: string;
className?: string;
}) => {
- switch (status) {
- case "In progress":
- return <AlmostDoneIcon className={className} />;
- case "Released":
- return <LuCircleCheck className={cn("text-blue-600", className)} />;
- case "Rejected":
- return <LuCircleX className={cn("text-red-600", className)} />;
- case "Pending":
- return <InProgressStatusIcon className={className} />;
- default:
- return <Status color="gray">{status}</Status>;
+ const getIcon = () => {
+ switch (status) {
+ case "In progress":
+ return <AlmostDoneIcon className={className} />;
+ case "Released":
+ return <LuCircleCheck className={cn("text-blue-600", className)} />;
+ case "Rejected":
+ return <LuCircleX className={cn("text-red-600", className)} />;
+ case "Pending":
+ return <InProgressStatusIcon className={className} />;
+ default:
+ return <Status color="gray">{status}</Status>;
+ }
+ };
+
+ const icon = getIcon();
+
+ // Status component already has tooltip, so return it directly
+ if (
+ status !== "In progress" &&
+ status !== "Released" &&
+ status !== "Rejected" &&
+ status !== "Pending"
+ ) {
+ return icon;
}
+
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span className="inline-flex">{icon}</span>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>{status}</span>
+ </TooltipContent>
+ </Tooltip>
+ );
};
export function OperationStatusIcon({
@@ -174,25 +206,41 @@ export function OperationStatusIcon({
status: JobOperation["status"];
className?: string;
}) {
- switch (status) {
- case "Todo":
- return (
- <LuCircleDashed className={cn("text-muted-foreground", className)} />
- );
- case "Ready":
- return <TodoStatusIcon className={cn("text-blue-600", className)} />;
- case "Waiting":
- case "Canceled":
- return <LuCircleX className={cn("text-red-600", className)} />;
- case "Done":
- return <LuCircleCheck className={cn("text-green-600", className)} />;
- case "In Progress":
- return <AlmostDoneIcon className={className} />;
- case "Paused":
- return <InProgressStatusIcon className={className} />;
- default:
- return null;
- }
+ const getIcon = () => {
+ switch (status) {
+ case "Todo":
+ return (
+ <LuCircleDashed className={cn("text-muted-foreground", className)} />
+ );
+ case "Ready":
+ return <TodoStatusIcon className={cn("text-blue-600", className)} />;
+ case "Waiting":
+ case "Canceled":
+ return <LuCircleX className={cn("text-red-600", className)} />;
+ case "Done":
+ return <LuCircleCheck className={cn("text-green-600", className)} />;
+ case "In Progress":
+ return <AlmostDoneIcon className={className} />;
+ case "Paused":
+ return <InProgressStatusIcon className={className} />;
+ default:
+ return null;
+ }
+ };
+
+ const icon = getIcon();
+ if (!icon) return null;
+
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span className="inline-flex">{icon}</span>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>{status}</span>
+ </TooltipContent>
+ </Tooltip>
+ );
}
export const IssueTaskStatusIcon = ({
@@ -202,18 +250,34 @@ export const IssueTaskStatusIcon = ({
status: (typeof nonConformanceTaskStatus)[number];
className?: string;
}) => {
- switch (status) {
- case "Pending":
- return <LuCircleDashed className={cn("text-foreground", className)} />;
- case "Skipped":
- return <LuCircleX className={cn("text-muted-foreground", className)} />;
- case "Completed":
- return <LuCircleCheck className={cn("text-emerald-600", className)} />;
- case "In Progress":
- return <AlmostDoneIcon className={className} />;
- default:
- return null;
- }
+ const getIcon = () => {
+ switch (status) {
+ case "Pending":
+ return <LuCircleDashed className={cn("text-foreground", className)} />;
+ case "Skipped":
+ return <LuCircleX className={cn("text-muted-foreground", className)} />;
+ case "Completed":
+ return <LuCircleCheck className={cn("text-emerald-600", className)} />;
+ case "In Progress":
+ return <AlmostDoneIcon className={className} />;
+ default:
+ return null;
+ }
+ };
+
+ const icon = getIcon();
+ if (!icon) return null;
+
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span className="inline-flex">{icon}</span>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>{status}</span>
+ </TooltipContent>
+ </Tooltip>
+ );
};
export const QuoteLineStatusIcon = ({
@@ -221,18 +285,34 @@ export const QuoteLineStatusIcon = ({
}: {
status: Database["public"]["Enums"]["quoteLineStatus"];
}) => {
- switch (status) {
- case "Not Started":
- return <LuCircle size={12} className="text-blue-600" />;
- case "No Quote":
- return <LuCircleX size={12} className="text-red-600" />;
- case "Complete":
- return <LuCircleCheck size={12} className="text-emerald-600" />;
- case "In Progress":
- return <LuClock3 size={12} className="text-yellow-600" />;
- default:
- return null;
- }
+ const getIcon = () => {
+ switch (status) {
+ case "Not Started":
+ return <LuCircle size={12} className="text-blue-600" />;
+ case "No Quote":
+ return <LuCircleX size={12} className="text-red-600" />;
+ case "Complete":
+ return <LuCircleCheck size={12} className="text-emerald-600" />;
+ case "In Progress":
+ return <LuClock3 size={12} className="text-yellow-600" />;
+ default:
+ return null;
+ }
+ };
+
+ const icon = getIcon();
+ if (!icon) return null;
+
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span className="inline-flex">{icon}</span>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>{status}</span>
+ </TooltipContent>
+ </Tooltip>
+ );
};
export const ProcedureStepTypeIcon = ({
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobStatus.tsx b/apps/erp/app/modules/production/ui/Jobs/JobStatus.tsx
index fae54d5381..417560eba1 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobStatus.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobStatus.tsx
@@ -6,56 +6,35 @@ type JobStatusProps = {
className?: string;
};
+const STATUS_COLOR_MAP: Record<
+ (typeof jobStatus)[number],
+ "gray" | "yellow" | "blue" | "orange" | "green" | "red"
+> = {
+ Draft: "gray",
+ Planned: "yellow",
+ Ready: "blue",
+ "In Progress": "blue",
+ Paused: "orange",
+ "Due Today": "orange",
+ Completed: "green",
+ Overdue: "red",
+ Cancelled: "red"
+} as const;
+
function JobStatus({ status, className }: JobStatusProps) {
- switch (status) {
- case "Draft":
- return (
- <Status color="gray" className={className}>
- {status}
- </Status>
- );
- case "Planned":
- return (
- <Status color="yellow" className={className}>
- {status}
- </Status>
- );
- case "Ready":
- return (
- <Status color="blue" className={className}>
- Released
- </Status>
- ); // TODO: update this properly
- case "In Progress":
- return (
- <Status color="blue" className={className}>
- {status}
- </Status>
- );
- case "Paused":
- case "Due Today":
- return (
- <Status color="orange" className={className}>
- {status}
- </Status>
- );
- case "Completed":
- return (
- <Status color="green" className={className}>
- {status}
- </Status>
- );
- case "Overdue":
- case "Cancelled":
- return (
- <Status color="red" className={className}>
- {status}
- </Status>
- );
+ if (!status) return null;
+
+ const color = STATUS_COLOR_MAP[status];
+ if (!color) return null;
+
+ const displayText = status === "Ready" ? "Released" : status;
+ const tooltip = status === "Ready" ? status : undefined;
- default:
- return null;
- }
+ return (
+ <Status color={color} className={className} tooltip={tooltip}>
+ {displayText}
+ </Status>
+ );
}
export default JobStatus;
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
index 798df079d1..02616281d7 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
@@ -288,7 +288,24 @@ const SalesOrderHeader = () => {
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
- <SalesStatus status={routeData?.salesOrder?.status} />
+ <SalesStatus
+ status={routeData?.salesOrder?.status}
+ jobs={
+ routeData?.salesOrder?.jobs as Array<{
+ salesOrderLineId: string;
+ productionQuantity: number;
+ quantityComplete: number;
+ status: string;
+ }>
+ }
+ lines={
+ routeData?.salesOrder?.lines as Array<{
+ id: string;
+ methodType: "Buy" | "Make" | "Pick";
+ saleQuantity: number;
+ }>
+ }
+ />
</HStack>
<HStack>
<DropdownMenu>
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsx
index d1b688677c..0de832c917 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsx
@@ -21,6 +21,7 @@ import {
today
} from "@internationalized/date";
import type { ColumnDef } from "@tanstack/react-table";
+import type { ReactNode } from "react";
import { memo, useMemo, useState } from "react";
import {
LuBookMarked,
@@ -70,6 +71,23 @@ type SalesOrdersTableProps = {
count: number;
};
+const IconWithTooltip = ({
+ icon,
+ tooltip
+}: {
+ icon: ReactNode;
+ tooltip: string;
+}) => (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span className="inline-flex">{icon}</span>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>{tooltip}</p>
+ </TooltipContent>
+ </Tooltip>
+);
+
const SalesOrdersTable = memo(({ data, count }: SalesOrdersTableProps) => {
const permissions = usePermissions();
const currencyFormatter = useCurrencyFormatter();
@@ -132,9 +150,32 @@ const SalesOrdersTable = memo(({ data, count }: SalesOrdersTableProps) => {
{
accessorKey: "status",
header: "Status",
- cell: (item) => {
- const status = item.getValue<(typeof salesOrderStatusType)[number]>();
- return <SalesStatus status={status} />;
+ cell: ({ row }) => {
+ const status =
+ row.getValue<(typeof salesOrderStatusType)[number]>("status");
+ const jobs = (row.original.jobs ?? []) as SalesOrderJob[];
+ const lines =
+ (row.original.lines as {
+ id: string;
+ saleQuantity: number;
+ methodType: "Buy" | "Make" | "Pick";
+ }[]) ?? [];
+ return (
+ <SalesStatus
+ status={status}
+ jobs={jobs.map((job) => ({
+ salesOrderLineId: job.salesOrderLineId,
+ productionQuantity: job.productionQuantity,
+ quantityComplete: job.quantityComplete,
+ status: job.status
+ }))}
+ lines={lines.map((line) => ({
+ id: line.id,
+ methodType: line.methodType,
+ saleQuantity: line.saleQuantity
+ }))}
+ />
+ );
},
meta: {
filter: {
@@ -191,11 +232,20 @@ const SalesOrdersTable = memo(({ data, count }: SalesOrdersTableProps) => {
});
const statusIcon = everyMadeLineIsCompleted ? (
- <LuCheck className="w-3 h-3 mr-2 text-emerald-500" />
+ <IconWithTooltip
+ icon={<LuCheck className="w-3 h-3 mr-2 text-emerald-500" />}
+ tooltip="All jobs completed"
+ />
) : everyMadeLineHasSufficientJobs ? (
- <LuLoader className="w-3 h-3 mr-2 text-orange-500" />
+ <IconWithTooltip
+ icon={<LuLoader className="w-3 h-3 mr-2 text-orange-500" />}
+ tooltip="Jobs in progress"
+ />
) : (
- <LuTriangleAlert className="w-3 h-3 mr-2 text-red-500" />
+ <IconWithTooltip
+ icon={<LuTriangleAlert className="w-3 h-3 mr-2 text-red-500" />}
+ tooltip="Not enough jobs to cover quantity"
+ />
);
return (
@@ -209,8 +259,10 @@ const SalesOrdersTable = memo(({ data, count }: SalesOrdersTableProps) => {
>
{!everyMadeLineHasSufficientJobs && jobs.length === 0 && (
<Tooltip>
- <TooltipTrigger>
- <LuTriangleAlert className="w-3 h-3 mr-2 text-red-500" />
+ <TooltipTrigger asChild>
+ <span className="inline-flex">
+ <LuTriangleAlert className="w-3 h-3 mr-2 text-red-500" />
+ </span>
</TooltipTrigger>
<TooltipContent side="left">
<p>Not enough jobs to cover quantity</p>
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesStatus.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesStatus.tsx
index c9916280de..f263ca92c4 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesStatus.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesStatus.tsx
@@ -1,32 +1,60 @@
import type { Database } from "@carbon/database";
import { Status } from "@carbon/react";
+import { hasIncompleteJobs } from "@carbon/utils";
type SalesOrderStatusProps = {
status?: Database["public"]["Enums"]["salesOrderStatus"] | null;
+ jobs?: Array<{
+ salesOrderLineId: string;
+ productionQuantity: number;
+ quantityComplete: number;
+ status: string;
+ }>;
+ lines?: Array<{
+ id: string;
+ methodType: "Buy" | "Make" | "Pick";
+ saleQuantity: number;
+ }>;
};
-const SalesStatus = ({ status }: SalesOrderStatusProps) => {
- switch (status) {
- case "Draft":
- return <Status color="gray">{status}</Status>;
- case "Cancelled":
- case "Closed":
- return <Status color="red">{status}</Status>;
- case "To Ship and Invoice":
- case "To Ship":
- return <Status color="orange">{status}</Status>;
- case "To Invoice":
- case "Confirmed":
- return <Status color="blue">{status}</Status>;
- case "Needs Approval":
- case "In Progress":
- return <Status color="yellow">{status}</Status>;
- case "Invoiced":
- case "Completed":
- return <Status color="green">{status}</Status>;
- default:
- return null;
+const STATUS_COLOR_MAP: Record<
+ Database["public"]["Enums"]["salesOrderStatus"],
+ "gray" | "yellow" | "orange" | "blue" | "green" | "red"
+> = {
+ Draft: "gray",
+ Cancelled: "red",
+ Closed: "red",
+ "To Ship and Invoice": "orange",
+ "To Ship": "orange",
+ "To Invoice": "blue",
+ Confirmed: "blue",
+ "Needs Approval": "yellow",
+ "In Progress": "yellow",
+ Invoiced: "green",
+ Completed: "green"
+} as const;
+
+const SalesStatus = ({ status, jobs, lines }: SalesOrderStatusProps) => {
+ if (!status) return null;
+
+ // Check if the order has incomplete jobs
+ const isManufacturing =
+ jobs !== undefined &&
+ lines !== undefined &&
+ hasIncompleteJobs({ jobs, lines });
+
+ if (isManufacturing && !(status === "Closed" || status === "Cancelled")) {
+ return (
+ <Status color="yellow" tooltip={status}>
+ In Progress
+ </Status>
+ );
}
+
+ const color = STATUS_COLOR_MAP[status];
+ if (!color) return null;
+
+ return <Status color={color}>{status}</Status>;
};
export default SalesStatus;
diff --git a/apps/mes/app/components/Icons.tsx b/apps/mes/app/components/Icons.tsx
index 5c35c9ee42..65c0562df7 100644
--- a/apps/mes/app/components/Icons.tsx
+++ b/apps/mes/app/components/Icons.tsx
@@ -1,5 +1,5 @@
import type { Database } from "@carbon/database";
-import { cn } from "@carbon/react";
+import { cn, Tooltip, TooltipContent, TooltipTrigger } from "@carbon/react";
import { AiOutlinePartition } from "react-icons/ai";
import {
BsExclamationSquareFill,
@@ -193,23 +193,39 @@ export function OperationStatusIcon({
}: {
status: Operation["operationStatus"];
}) {
- switch (status) {
- case "Todo":
- return <TodoStatusIcon className="text-foreground" />;
- case "Ready":
- return <TodoStatusIcon className="text-blue-600" />;
- case "Waiting":
- case "Canceled":
- return <LuCircleX className="text-red-600" />;
- case "Done":
- return <LuCircleCheck className="text-green-600" />;
- case "In Progress":
- return <AlmostDoneIcon />;
- case "Paused":
- return <InProgressStatusIcon />;
- default:
- return null;
- }
+ const getIcon = () => {
+ switch (status) {
+ case "Todo":
+ return <TodoStatusIcon className="text-foreground" />;
+ case "Ready":
+ return <TodoStatusIcon className="text-blue-600" />;
+ case "Waiting":
+ case "Canceled":
+ return <LuCircleX className="text-red-600" />;
+ case "Done":
+ return <LuCircleCheck className="text-green-600" />;
+ case "In Progress":
+ return <AlmostDoneIcon />;
+ case "Paused":
+ return <InProgressStatusIcon />;
+ default:
+ return null;
+ }
+ };
+
+ const icon = getIcon();
+ if (!icon) return null;
+
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span className="inline-flex">{icon}</span>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>{status}</span>
+ </TooltipContent>
+ </Tooltip>
+ );
}
export const ProcedureStepTypeIcon = ({
diff --git a/apps/mes/app/components/Kanban/components/ItemCard.tsx b/apps/mes/app/components/Kanban/components/ItemCard.tsx
index 987c70f213..b32ba5483d 100644
--- a/apps/mes/app/components/Kanban/components/ItemCard.tsx
+++ b/apps/mes/app/components/Kanban/components/ItemCard.tsx
@@ -307,20 +307,36 @@ export function ItemCard({
}
function getStatusIcon(status: Item["status"] | "In Progress") {
- switch (status) {
- case "Ready":
- case "Todo":
- return <TodoStatusIcon className="text-foreground" />;
- case "Waiting":
- case "Canceled":
- return <LuCircleX className="text-muted-foreground" />;
- case "Done":
- return <LuCircleCheck className="text-blue-600" />;
- case "In Progress":
- return <AlmostDoneIcon />;
- case "Paused":
- return <InProgressStatusIcon />;
- default:
- return null;
- }
+ const getIcon = () => {
+ switch (status) {
+ case "Ready":
+ case "Todo":
+ return <TodoStatusIcon className="text-foreground" />;
+ case "Waiting":
+ case "Canceled":
+ return <LuCircleX className="text-muted-foreground" />;
+ case "Done":
+ return <LuCircleCheck className="text-blue-600" />;
+ case "In Progress":
+ return <AlmostDoneIcon />;
+ case "Paused":
+ return <InProgressStatusIcon />;
+ default:
+ return null;
+ }
+ };
+
+ const icon = getIcon();
+ if (!icon) return null;
+
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span className="inline-flex">{icon}</span>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>{status}</span>
+ </TooltipContent>
+ </Tooltip>
+ );
}
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index bbb499b68a..a58856ef12 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -13218,6 +13218,9 @@ export default {
{
$ref: "#/parameters/rowFilter.configurationParameter.updatedBy",
},
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.materialFormFilterId",
+ },
{
$ref: "#/parameters/select",
},
@@ -13316,6 +13319,9 @@ export default {
{
$ref: "#/parameters/rowFilter.configurationParameter.updatedBy",
},
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.materialFormFilterId",
+ },
{
$ref: "#/parameters/preferReturn",
},
@@ -13368,6 +13374,9 @@ export default {
{
$ref: "#/parameters/rowFilter.configurationParameter.updatedBy",
},
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.materialFormFilterId",
+ },
{
$ref: "#/parameters/body.configurationParameter",
},
@@ -63066,6 +63075,41 @@ export default {
tags: ["(rpc) xid_encode"],
},
},
+ "/rpc/populate_sales_search_results": {
+ post: {
+ parameters: [
+ {
+ in: "body",
+ name: "args",
+ required: true,
+ schema: {
+ properties: {
+ p_company_id: {
+ format: "text",
+ type: "string",
+ },
+ },
+ required: ["p_company_id"],
+ type: "object",
+ },
+ },
+ {
+ $ref: "#/parameters/preferParams",
+ },
+ ],
+ produces: [
+ "application/json",
+ "application/vnd.pgrst.object+json;nulls=stripped",
+ "application/vnd.pgrst.object+json",
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ },
+ },
+ tags: ["(rpc) populate_sales_search_results"],
+ },
+ },
"/rpc/get_direct_descendants_of_tracked_entity": {
post: {
parameters: [
@@ -71267,6 +71311,12 @@ export default {
format: "text",
type: "string",
},
+ materialFormFilterId: {
+ description:
+ "Note:\nThis is a Foreign Key to `materialForm.id`.<fk table='materialForm' column='id'/>",
+ format: "text",
+ type: "string",
+ },
},
type: "object",
},
@@ -100991,6 +101041,12 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.configurationParameter.materialFormFilterId": {
+ name: "materialFormFilterId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.nonConformanceReceiptLine": {
name: "nonConformanceReceiptLine",
description: "nonConformanceReceiptLine",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 30e2023b66..d663b736e8 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -10280,7 +10280,6 @@ export type Database = {
}
jobMaterial: {
Row: {
- bomId: string | null
companyId: string
createdAt: string
createdBy: string
@@ -10310,7 +10309,6 @@ export type Database = {
updatedBy: string | null
}
Insert: {
- bomId?: string | null
companyId: string
createdAt?: string
createdBy: string
@@ -10340,7 +10338,6 @@ export type Database = {
updatedBy?: string | null
}
Update: {
- bomId?: string | null
companyId?: string
createdAt?: string
createdBy?: string
@@ -15188,7 +15185,6 @@ export type Database = {
}
methodMaterial: {
Row: {
- bomId: string | null
companyId: string
createdAt: string
createdBy: string
@@ -15212,7 +15208,6 @@ export type Database = {
updatedBy: string | null
}
Insert: {
- bomId?: string | null
companyId: string
createdAt?: string
createdBy: string
@@ -15236,7 +15231,6 @@ export type Database = {
updatedBy?: string | null
}
Update: {
- bomId?: string | null
companyId?: string
createdAt?: string
createdBy?: string
@@ -19907,21 +19901,21 @@ export type Database = {
opportunity: {
Row: {
companyId: string
- customerId: string
+ customerId: string | null
id: string
purchaseOrderDocumentPath: string | null
requestForQuoteDocumentPath: string | null
}
Insert: {
companyId: string
- customerId: string
+ customerId?: string | null
id?: string
purchaseOrderDocumentPath?: string | null
requestForQuoteDocumentPath?: string | null
}
Update: {
companyId?: string
- customerId?: string
+ customerId?: string | null
id?: string
purchaseOrderDocumentPath?: string | null
requestForQuoteDocumentPath?: string | null
@@ -26495,7 +26489,6 @@ export type Database = {
}
quoteMaterial: {
Row: {
- bomId: string | null
companyId: string
createdAt: string
createdBy: string
@@ -26522,7 +26515,6 @@ export type Database = {
updatedBy: string | null
}
Insert: {
- bomId?: string | null
companyId: string
createdAt?: string
createdBy: string
@@ -26549,7 +26541,6 @@ export type Database = {
updatedBy?: string | null
}
Update: {
- bomId?: string | null
companyId?: string
createdAt?: string
createdBy?: string
@@ -31334,174 +31325,6 @@ export type Database = {
},
]
}
- searchIndex_BJiGdDNuetJ1iyE8USN7AD: {
- Row: {
- createdAt: string
- description: string | null
- entityId: string
- entityType: string
- id: number
- link: string
- metadata: Json | null
- searchVector: unknown
- tags: string[] | null
- title: string
- updatedAt: string | null
- }
- Insert: {
- createdAt?: string
- description?: string | null
- entityId: string
- entityType: string
- id?: number
- link: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title: string
- updatedAt?: string | null
- }
- Update: {
- createdAt?: string
- description?: string | null
- entityId?: string
- entityType?: string
- id?: number
- link?: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title?: string
- updatedAt?: string | null
- }
- Relationships: []
- }
- searchIndex_L4saDKMCpFQurK9c3bEr1G: {
- Row: {
- createdAt: string
- description: string | null
- entityId: string
- entityType: string
- id: number
- link: string
- metadata: Json | null
- searchVector: unknown
- tags: string[] | null
- title: string
- updatedAt: string | null
- }
- Insert: {
- createdAt?: string
- description?: string | null
- entityId: string
- entityType: string
- id?: number
- link: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title: string
- updatedAt?: string | null
- }
- Update: {
- createdAt?: string
- description?: string | null
- entityId?: string
- entityType?: string
- id?: number
- link?: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title?: string
- updatedAt?: string | null
- }
- Relationships: []
- }
- searchIndex_Nrc78GJXti5gro8G5m3k9u: {
- Row: {
- createdAt: string
- description: string | null
- entityId: string
- entityType: string
- id: number
- link: string
- metadata: Json | null
- searchVector: unknown
- tags: string[] | null
- title: string
- updatedAt: string | null
- }
- Insert: {
- createdAt?: string
- description?: string | null
- entityId: string
- entityType: string
- id?: number
- link: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title: string
- updatedAt?: string | null
- }
- Update: {
- createdAt?: string
- description?: string | null
- entityId?: string
- entityType?: string
- id?: number
- link?: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title?: string
- updatedAt?: string | null
- }
- Relationships: []
- }
- searchIndex_TzPMV5bvte7aRhGwLwmjs9: {
- Row: {
- createdAt: string
- description: string | null
- entityId: string
- entityType: string
- id: number
- link: string
- metadata: Json | null
- searchVector: unknown
- tags: string[] | null
- title: string
- updatedAt: string | null
- }
- Insert: {
- createdAt?: string
- description?: string | null
- entityId: string
- entityType: string
- id?: number
- link: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title: string
- updatedAt?: string | null
- }
- Update: {
- createdAt?: string
- description?: string | null
- entityId?: string
- entityType?: string
- id?: number
- link?: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title?: string
- updatedAt?: string | null
- }
- Relationships: []
- }
searchIndexRegistry: {
Row: {
companyId: string
@@ -42916,7 +42739,6 @@ export type Database = {
}
jobMaterialWithMakeMethodId: {
Row: {
- bomId: string | null
companyId: string | null
createdAt: string | null
createdBy: string | null
@@ -42943,6 +42765,7 @@ export type Database = {
requiresSerialTracking: boolean | null
scrapQuantity: number | null
shelfId: string | null
+ shelfName: string | null
unitCost: number | null
unitOfMeasureCode: string | null
updatedAt: string | null
@@ -45548,14 +45371,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -46928,14 +46751,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -48154,7 +47977,6 @@ export type Database = {
}
quoteMaterialWithMakeMethodId: {
Row: {
- bomId: string | null
companyId: string | null
createdAt: string | null
createdBy: string | null
@@ -49620,14 +49442,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -50163,14 +49985,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["paymentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["paymentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -53373,7 +53195,6 @@ export type Database = {
get_job_method: {
Args: { jid: string }
Returns: {
- bomId: string
description: string
isRoot: boolean
itemId: string
@@ -53397,7 +53218,6 @@ export type Database = {
get_job_methods_by_method_id: {
Args: { mid: string }
Returns: {
- bomId: string
description: string
isRoot: boolean
itemId: string
@@ -53695,7 +53515,6 @@ export type Database = {
get_method_tree: {
Args: { uid: string }
Returns: {
- bomId: string
description: string
externalId: Json
isRoot: boolean
@@ -54033,7 +53852,6 @@ export type Database = {
get_quote_methods: {
Args: { qid: string }
Returns: {
- bomId: string
description: string
externalId: Json
isRoot: boolean
@@ -54059,7 +53877,6 @@ export type Database = {
get_quote_methods_by_method_id: {
Args: { mid: string }
Returns: {
- bomId: string
description: string
externalId: Json
isRoot: boolean
@@ -54415,6 +54232,10 @@ export type Database = {
Args: { p_company_id: string }
Returns: undefined
}
+ populate_sales_search_results: {
+ Args: { p_company_id: string }
+ Returns: undefined
+ }
search_company_index: {
Args: {
p_company_id: string
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 30e2023b66..d663b736e8 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -10280,7 +10280,6 @@ export type Database = {
}
jobMaterial: {
Row: {
- bomId: string | null
companyId: string
createdAt: string
createdBy: string
@@ -10310,7 +10309,6 @@ export type Database = {
updatedBy: string | null
}
Insert: {
- bomId?: string | null
companyId: string
createdAt?: string
createdBy: string
@@ -10340,7 +10338,6 @@ export type Database = {
updatedBy?: string | null
}
Update: {
- bomId?: string | null
companyId?: string
createdAt?: string
createdBy?: string
@@ -15188,7 +15185,6 @@ export type Database = {
}
methodMaterial: {
Row: {
- bomId: string | null
companyId: string
createdAt: string
createdBy: string
@@ -15212,7 +15208,6 @@ export type Database = {
updatedBy: string | null
}
Insert: {
- bomId?: string | null
companyId: string
createdAt?: string
createdBy: string
@@ -15236,7 +15231,6 @@ export type Database = {
updatedBy?: string | null
}
Update: {
- bomId?: string | null
companyId?: string
createdAt?: string
createdBy?: string
@@ -19907,21 +19901,21 @@ export type Database = {
opportunity: {
Row: {
companyId: string
- customerId: string
+ customerId: string | null
id: string
purchaseOrderDocumentPath: string | null
requestForQuoteDocumentPath: string | null
}
Insert: {
companyId: string
- customerId: string
+ customerId?: string | null
id?: string
purchaseOrderDocumentPath?: string | null
requestForQuoteDocumentPath?: string | null
}
Update: {
companyId?: string
- customerId?: string
+ customerId?: string | null
id?: string
purchaseOrderDocumentPath?: string | null
requestForQuoteDocumentPath?: string | null
@@ -26495,7 +26489,6 @@ export type Database = {
}
quoteMaterial: {
Row: {
- bomId: string | null
companyId: string
createdAt: string
createdBy: string
@@ -26522,7 +26515,6 @@ export type Database = {
updatedBy: string | null
}
Insert: {
- bomId?: string | null
companyId: string
createdAt?: string
createdBy: string
@@ -26549,7 +26541,6 @@ export type Database = {
updatedBy?: string | null
}
Update: {
- bomId?: string | null
companyId?: string
createdAt?: string
createdBy?: string
@@ -31334,174 +31325,6 @@ export type Database = {
},
]
}
- searchIndex_BJiGdDNuetJ1iyE8USN7AD: {
- Row: {
- createdAt: string
- description: string | null
- entityId: string
- entityType: string
- id: number
- link: string
- metadata: Json | null
- searchVector: unknown
- tags: string[] | null
- title: string
- updatedAt: string | null
- }
- Insert: {
- createdAt?: string
- description?: string | null
- entityId: string
- entityType: string
- id?: number
- link: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title: string
- updatedAt?: string | null
- }
- Update: {
- createdAt?: string
- description?: string | null
- entityId?: string
- entityType?: string
- id?: number
- link?: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title?: string
- updatedAt?: string | null
- }
- Relationships: []
- }
- searchIndex_L4saDKMCpFQurK9c3bEr1G: {
- Row: {
- createdAt: string
- description: string | null
- entityId: string
- entityType: string
- id: number
- link: string
- metadata: Json | null
- searchVector: unknown
- tags: string[] | null
- title: string
- updatedAt: string | null
- }
- Insert: {
- createdAt?: string
- description?: string | null
- entityId: string
- entityType: string
- id?: number
- link: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title: string
- updatedAt?: string | null
- }
- Update: {
- createdAt?: string
- description?: string | null
- entityId?: string
- entityType?: string
- id?: number
- link?: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title?: string
- updatedAt?: string | null
- }
- Relationships: []
- }
- searchIndex_Nrc78GJXti5gro8G5m3k9u: {
- Row: {
- createdAt: string
- description: string | null
- entityId: string
- entityType: string
- id: number
- link: string
- metadata: Json | null
- searchVector: unknown
- tags: string[] | null
- title: string
- updatedAt: string | null
- }
- Insert: {
- createdAt?: string
- description?: string | null
- entityId: string
- entityType: string
- id?: number
- link: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title: string
- updatedAt?: string | null
- }
- Update: {
- createdAt?: string
- description?: string | null
- entityId?: string
- entityType?: string
- id?: number
- link?: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title?: string
- updatedAt?: string | null
- }
- Relationships: []
- }
- searchIndex_TzPMV5bvte7aRhGwLwmjs9: {
- Row: {
- createdAt: string
- description: string | null
- entityId: string
- entityType: string
- id: number
- link: string
- metadata: Json | null
- searchVector: unknown
- tags: string[] | null
- title: string
- updatedAt: string | null
- }
- Insert: {
- createdAt?: string
- description?: string | null
- entityId: string
- entityType: string
- id?: number
- link: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title: string
- updatedAt?: string | null
- }
- Update: {
- createdAt?: string
- description?: string | null
- entityId?: string
- entityType?: string
- id?: number
- link?: string
- metadata?: Json | null
- searchVector?: unknown
- tags?: string[] | null
- title?: string
- updatedAt?: string | null
- }
- Relationships: []
- }
searchIndexRegistry: {
Row: {
companyId: string
@@ -42916,7 +42739,6 @@ export type Database = {
}
jobMaterialWithMakeMethodId: {
Row: {
- bomId: string | null
companyId: string | null
createdAt: string | null
createdBy: string | null
@@ -42943,6 +42765,7 @@ export type Database = {
requiresSerialTracking: boolean | null
scrapQuantity: number | null
shelfId: string | null
+ shelfName: string | null
unitCost: number | null
unitOfMeasureCode: string | null
updatedAt: string | null
@@ -45548,14 +45371,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -46928,14 +46751,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -48154,7 +47977,6 @@ export type Database = {
}
quoteMaterialWithMakeMethodId: {
Row: {
- bomId: string | null
companyId: string | null
createdAt: string | null
createdBy: string | null
@@ -49620,14 +49442,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -50163,14 +49985,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["paymentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["paymentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -53373,7 +53195,6 @@ export type Database = {
get_job_method: {
Args: { jid: string }
Returns: {
- bomId: string
description: string
isRoot: boolean
itemId: string
@@ -53397,7 +53218,6 @@ export type Database = {
get_job_methods_by_method_id: {
Args: { mid: string }
Returns: {
- bomId: string
description: string
isRoot: boolean
itemId: string
@@ -53695,7 +53515,6 @@ export type Database = {
get_method_tree: {
Args: { uid: string }
Returns: {
- bomId: string
description: string
externalId: Json
isRoot: boolean
@@ -54033,7 +53852,6 @@ export type Database = {
get_quote_methods: {
Args: { qid: string }
Returns: {
- bomId: string
description: string
externalId: Json
isRoot: boolean
@@ -54059,7 +53877,6 @@ export type Database = {
get_quote_methods_by_method_id: {
Args: { mid: string }
Returns: {
- bomId: string
description: string
externalId: Json
isRoot: boolean
@@ -54415,6 +54232,10 @@ export type Database = {
Args: { p_company_id: string }
Returns: undefined
}
+ populate_sales_search_results: {
+ Args: { p_company_id: string }
+ Returns: undefined
+ }
search_company_index: {
Args: {
p_company_id: string
diff --git a/packages/react/src/Badge.tsx b/packages/react/src/Badge.tsx
index cc82ff9ee2..d42fd664cc 100644
--- a/packages/react/src/Badge.tsx
+++ b/packages/react/src/Badge.tsx
@@ -44,14 +44,18 @@ export interface BadgeProps
extends HTMLAttributes<HTMLDivElement>,
VariantProps<typeof badgeVariants> {}
-function Badge({ className, variant, ...props }: BadgeProps) {
- return (
- <div
- className={cn(badgeVariants({ variant }), "min-w-0", className)}
- {...props}
- />
- );
-}
+const Badge = forwardRef<HTMLDivElement, BadgeProps>(
+ ({ className, variant, ...props }, ref) => {
+ return (
+ <div
+ ref={ref}
+ className={cn(badgeVariants({ variant }), "min-w-0", className)}
+ {...props}
+ />
+ );
+ }
+);
+Badge.displayName = "Badge";
const BadgeCloseButton = forwardRef<
ElementRef<"button">,
diff --git a/packages/react/src/Status.tsx b/packages/react/src/Status.tsx
index 421eb1201c..d99d95ac4a 100644
--- a/packages/react/src/Status.tsx
+++ b/packages/react/src/Status.tsx
@@ -1,4 +1,4 @@
-import type { ComponentProps } from "react";
+import type { ComponentProps, ReactNode } from "react";
import {
LuCircleAlert,
LuCircleCheck,
@@ -9,10 +9,12 @@ import {
LuStar
} from "react-icons/lu";
import { Badge } from "./Badge";
+import { Tooltip, TooltipContent, TooltipTrigger } from "./Tooltip";
import { cn } from "./utils/cn";
type StatusProps = ComponentProps<"div"> & {
color?: "green" | "orange" | "red" | "yellow" | "blue" | "gray" | "purple";
+ tooltip?: ReactNode;
};
const getStatusIcon = (color: string) => {
@@ -38,18 +40,28 @@ const getStatusIcon = (color: string) => {
const Status = ({
color = "gray",
children,
+ tooltip,
className,
...props
}: StatusProps) => {
+ const tooltipContent = tooltip ?? children;
+
return (
- <Badge
- variant={color}
- className={cn("inline-flex items-center gap-1", className)}
- {...props}
- >
- {getStatusIcon(color)}
- {children}
- </Badge>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Badge
+ variant={color}
+ className={cn("inline-flex items-center gap-1", className)}
+ {...props}
+ >
+ {getStatusIcon(color)}
+ {children}
+ </Badge>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>{tooltipContent}</span>
+ </TooltipContent>
+ </Tooltip>
);
};
diff --git a/packages/utils/src/status.ts b/packages/utils/src/status.ts
index dff1e8d826..f08a4787e4 100644
--- a/packages/utils/src/status.ts
+++ b/packages/utils/src/status.ts
@@ -147,3 +147,51 @@ export const getSalesOrderJobStatus = (
return { jobVariant, jobLabel, jobs: filteredJobs };
};
+
+type SalesOrderForProductionCheck = {
+ jobs?: Array<{
+ salesOrderLineId: string;
+ productionQuantity: number;
+ quantityComplete: number;
+ status: string;
+ }>;
+ lines?: Array<{
+ id: string;
+ methodType: "Buy" | "Make" | "Pick";
+ saleQuantity: number;
+ }>;
+};
+
+/**
+ * Checks if a Sales Order has incomplete jobs.
+ * Returns true if any "Make" line item has incomplete jobs.
+ * A job is considered complete when quantityComplete >= saleQuantity for that line.
+ */
+export const hasIncompleteJobs = (
+ salesOrder: SalesOrderForProductionCheck
+): boolean => {
+ const jobs = salesOrder.jobs ?? [];
+ const lines = salesOrder.lines ?? [];
+
+ const makeLines = lines.filter((line) => line.methodType === "Make");
+ if (makeLines.length === 0) {
+ return false;
+ }
+
+ for (const line of makeLines) {
+ const lineJobs = jobs.filter((job) => job.salesOrderLineId === line.id);
+ if (lineJobs.length === 0) {
+ return true;
+ }
+
+ const totalCompleted = lineJobs.reduce(
+ (acc, job) => acc + (job.quantityComplete ?? 0),
+ 0
+ );
+ if (totalCompleted < (line.saleQuantity ?? 0)) {
+ return true;
+ }
+ }
+
+ return false;
+};