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: display titles in issue report

Brad Barbinf60d95a810e4
diff --git a/apps/erp/app/routes/file+/issue+/$id[.]pdf.tsx b/apps/erp/app/routes/file+/issue+/$id[.]pdf.tsx
index be93f21011..9c4acdf7b1 100644
--- a/apps/erp/app/routes/file+/issue+/$id[.]pdf.tsx
+++ b/apps/erp/app/routes/file+/issue+/$id[.]pdf.tsx
@@ -3,12 +3,14 @@ import { IssuePDF } from "@carbon/documents/pdf";
import { renderToStream } from "@react-pdf/renderer";
import { type LoaderFunctionArgs } from "@vercel/remix";
import {
+ getInvestigationTypesList,
getIssue,
getIssueActionTasks,
getIssueApprovalTasks,
getIssueInvestigationTasks,
getIssueReviewers,
getIssueTypes,
+ getRequiredActionsList,
} from "~/modules/quality";
import { getCompany } from "~/modules/settings";
import { getLocale } from "~/utils/request";
@@ -31,6 +33,8 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
actionTasks,
approvalTasks,
reviewers,
+ investigationTypes,
+ actionTypes,
] = await Promise.all([
getCompany(client, companyId),
getIssue(client, id),
@@ -39,6 +43,8 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
getIssueActionTasks(client, id, companyId),
getIssueApprovalTasks(client, id, companyId),
getIssueReviewers(client, id, companyId),
+ getInvestigationTypesList(client, companyId),
+ getRequiredActionsList(client, companyId),
]);
if (company.error) {
@@ -85,7 +91,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
nonConformance={nonConformance.data}
nonConformanceTypes={nonConformanceTypes.data ?? []}
investigationTasks={investigationTasks.data ?? []}
+ investigationTypes={investigationTypes.data ?? []}
actionTasks={actionTasks.data ?? []}
+ actionTypes={actionTypes.data ?? []}
reviewers={reviewers.data ?? []}
/>
);
diff --git a/packages/documents/src/pdf/IssuePDF.tsx b/packages/documents/src/pdf/IssuePDF.tsx
index 2889200ece..534388492a 100644
--- a/packages/documents/src/pdf/IssuePDF.tsx
+++ b/packages/documents/src/pdf/IssuePDF.tsx
@@ -6,11 +6,18 @@ import type { JSONContent } from "@carbon/react";
import type { PDF } from "../types";
import { Header, Note, Summary, Template } from "./components";
+type ListItem = {
+ id: string;
+ name: string;
+};
+
interface IssuePDFProps extends PDF {
nonConformance: Database["public"]["Tables"]["nonConformance"]["Row"];
nonConformanceTypes: Database["public"]["Tables"]["nonConformanceType"]["Row"][];
investigationTasks: Database["public"]["Tables"]["nonConformanceInvestigationTask"]["Row"][];
+ investigationTypes: ListItem[];
actionTasks: Database["public"]["Tables"]["nonConformanceActionTask"]["Row"][];
+ actionTypes: ListItem[];
reviewers: Database["public"]["Tables"]["nonConformanceReviewer"]["Row"][];
}
@@ -37,7 +44,9 @@ const IssuePDF = ({
nonConformance,
nonConformanceTypes,
investigationTasks,
+ investigationTypes,
actionTasks,
+ actionTypes,
reviewers,
title = "Issue Report",
}: IssuePDFProps) => {
@@ -98,7 +107,13 @@ const IssuePDF = ({
style={tw("flex flex-col gap-2 border-b border-gray-300 mb-10")}
>
<View style={tw("flex flex-row justify-between")}>
- <Text style={tw("font-bold")}>{task.investigationType}</Text>
+ <Text style={tw("font-bold")}>
+ {
+ investigationTypes.find(
+ (type) => type.id === task.investigationTypeId
+ )?.name
+ }
+ </Text>
</View>
{task.completedDate && (
<Text style={tw("text-sm")}>
@@ -121,7 +136,12 @@ const IssuePDF = ({
style={tw("flex flex-col gap-2 border-b border-gray-300 mb-10")}
>
<View style={tw("flex flex-row justify-between")}>
- <Text style={tw("font-bold")}>{task.actionType}</Text>
+ <Text style={tw("font-bold")}>
+ {
+ actionTypes.find((type) => type.id === task.actionTypeId)
+ ?.name
+ }
+ </Text>
</View>
{task.completedDate && (
<Text style={tw("text-sm")}>