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.

refactor: remove deadline text function

Brad Barbin5e7e838a0a87
diff --git a/apps/erp/app/modules/production/ui/Jobs/Deadline.tsx b/apps/erp/app/modules/production/ui/Jobs/Deadline.tsx
index fd359282bb..ea8da05fd2 100644
--- a/apps/erp/app/modules/production/ui/Jobs/Deadline.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/Deadline.tsx
@@ -16,16 +16,3 @@ export function getDeadlineIcon(deadlineType: (typeof deadlineTypes)[number]) {
return <LowPriorityIcon />;
}
}
-
-export function getDeadlineText(deadlineType: (typeof deadlineTypes)[number]) {
- switch (deadlineType) {
- case "ASAP":
- return "ASAP";
- case "Hard Deadline":
- return "Hard deadline";
- case "Soft Deadline":
- return "Soft deadline";
- case "No Deadline":
- return "No deadline";
- }
-}
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobForm.tsx b/apps/erp/app/modules/production/ui/Jobs/JobForm.tsx
index 599105db8d..f1ceb3b0ad 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobForm.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobForm.tsx
@@ -48,7 +48,7 @@ import {
deadlineTypes,
jobValidator,
} from "../../production.models";
-import { getDeadlineIcon, getDeadlineText } from "./Deadline";
+import { getDeadlineIcon } from "./Deadline";
type JobFormValues = z.infer<typeof jobValidator> & {
description: string;
@@ -351,7 +351,7 @@ const JobForm = ({ initialValues }: JobFormProps) => {
label: (
<div className="flex gap-1 items-center">
{getDeadlineIcon(d)}
- <span>{getDeadlineText(d)}</span>
+ <span>{d}</span>
</div>
),
}))}
@@ -516,7 +516,7 @@ const JobForm = ({ initialValues }: JobFormProps) => {
label: (
<div className="flex gap-1 items-center">
{getDeadlineIcon(d)}
- <span>{getDeadlineText(d)}</span>
+ <span>{d}</span>
</div>
),
}))}
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobProperties.tsx b/apps/erp/app/modules/production/ui/Jobs/JobProperties.tsx
index 8edd134c2e..fecf32dda1 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobProperties.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobProperties.tsx
@@ -41,7 +41,7 @@ import { path } from "~/utils/path";
import { copyToClipboard } from "~/utils/string";
import { deadlineTypes } from "../../production.models";
import type { Job } from "../../types";
-import { getDeadlineIcon, getDeadlineText } from "./Deadline";
+import { getDeadlineIcon } from "./Deadline";
const JobProperties = () => {
const { jobId } = useParams();
@@ -408,7 +408,7 @@ const JobProperties = () => {
return (
<div className="flex gap-1 items-center">
{getDeadlineIcon(deadlineType)}
- <span>{getDeadlineText(deadlineType)}</span>
+ <span>{deadlineType}</span>
</div>
);
}}
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobsTable.tsx b/apps/erp/app/modules/production/ui/Jobs/JobsTable.tsx
index 90f4c809a2..66c0b60fec 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobsTable.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobsTable.tsx
@@ -37,7 +37,7 @@ import { useCustomers, useParts, usePeople, useTools } from "~/stores";
import { path } from "~/utils/path";
import { deadlineTypes, jobStatus } from "../../production.models";
import type { Job } from "../../types";
-import { getDeadlineIcon, getDeadlineText } from "./Deadline";
+import { getDeadlineIcon } from "./Deadline";
import JobStatus from "./JobStatus";
type JobsTableProps = {
@@ -239,14 +239,14 @@ const JobsTable = memo(({ data, count, tags }: JobsTableProps) => {
return (
<div className="flex gap-1 items-center">
{getDeadlineIcon(deadlineType)}
- <span>{getDeadlineText(deadlineType)}</span>
+ <span>{deadlineType}</span>
</div>
);
return (
<div className="flex items-center gap-1">
{getDeadlineIcon(deadlineType)}
- <span>{getDeadlineText(deadlineType)}</span>
+ <span>{deadlineType}</span>
</div>
);
},
@@ -258,7 +258,7 @@ const JobsTable = memo(({ data, count, tags }: JobsTableProps) => {
label: (
<div className="flex gap-1 items-center">
{getDeadlineIcon(type)}
- <span>{getDeadlineText(type)}</span>
+ <span>{type}</span>
</div>
),
})),
diff --git a/apps/erp/app/modules/production/ui/Jobs/index.ts b/apps/erp/app/modules/production/ui/Jobs/index.ts
index 63c9cbf1af..121ce08f05 100644
--- a/apps/erp/app/modules/production/ui/Jobs/index.ts
+++ b/apps/erp/app/modules/production/ui/Jobs/index.ts
@@ -1,4 +1,4 @@
-import { getDeadlineIcon, getDeadlineText } from "./Deadline";
+import { getDeadlineIcon } from "./Deadline";
import JobBillOfMaterial from "./JobBillOfMaterial";
import JobBillOfProcess from "./JobBillOfProcess";
import JobBoMExplorer from "./JobBoMExplorer";
@@ -19,7 +19,6 @@ import ProductionQuantityForm from "./ProductionQuantityForm";
export {
getDeadlineIcon,
- getDeadlineText,
JobBillOfMaterial,
JobBillOfProcess,
JobBoMExplorer,
diff --git a/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx b/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx
index 62af000fb9..0efd40541e 100644
--- a/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx
+++ b/apps/erp/app/modules/production/ui/Schedule/Kanban/components/ItemCard.tsx
@@ -50,10 +50,7 @@ import { FaTasks } from "react-icons/fa";
import { z } from "zod";
import { Tags } from "~/components/Form";
import { useTags } from "~/hooks/useTags";
-import {
- getDeadlineIcon,
- getDeadlineText,
-} from "~/modules/production/ui/Jobs/Deadline";
+import { getDeadlineIcon } from "~/modules/production/ui/Jobs/Deadline";
import { JobOperationStatus } from "~/modules/production/ui/Jobs/JobOperationStatus";
import { getPrivateUrl, path } from "~/utils/path";
import { useKanban } from "../context/KanbanContext";
@@ -342,7 +339,7 @@ export function ItemCard({ item, isOverlay, progressByItemId }: ItemCardProps) {
className={cn("text-sm", isOverdue ? "text-red-500" : "")}
>
{["ASAP", "No Deadline"].includes(item.deadlineType)
- ? getDeadlineText(item.deadlineType)
+ ? item.deadlineType
: item.dueDate
? `Due ${formatRelativeTime(
convertDateStringToIsoString(item.dueDate)
@@ -350,9 +347,7 @@ export function ItemCard({ item, isOverlay, progressByItemId }: ItemCardProps) {
: "–"}
</span>
</TooltipTrigger>
- <TooltipContent side="right">
- {getDeadlineText(item.deadlineType)}
- </TooltipContent>
+ <TooltipContent side="right">{item.deadlineType}</TooltipContent>
</Tooltip>
</HStack>
)}
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineJobs.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineJobs.tsx
index 0121748024..76ba27e930 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineJobs.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderLineJobs.tsx
@@ -54,10 +54,7 @@ import {
salesOrderToJobValidator,
} from "~/modules/production/production.models";
import type { Job, JobOperation } from "~/modules/production/types";
-import {
- getDeadlineIcon,
- getDeadlineText,
-} from "~/modules/production/ui/Jobs/Deadline";
+import { getDeadlineIcon } from "~/modules/production/ui/Jobs/Deadline";
import { JobStartModal } from "~/modules/production/ui/Jobs/JobHeader";
import { JobOperationStatus } from "~/modules/production/ui/Jobs/JobOperationStatus";
import JobStatus from "~/modules/production/ui/Jobs/JobStatus";
@@ -234,8 +231,8 @@ export function SalesOrderLineJobs({
value: d,
label: (
<div className="flex gap-1 items-center">
- {getDeadlineIcon(d, false)}
- <span>{getDeadlineText(d)}</span>
+ {getDeadlineIcon(d)}
+ <span>{d}</span>
</div>
),
}))}
@@ -467,8 +464,7 @@ function JobDetails({ job }: { job: Job }) {
operation.jobMakeMethod?.parentMaterialId
? path.to.jobMakeMethod(
operation.jobId,
- operation.jobMakeMethodId ?? "",
- operation.jobMakeMethod?.parentMaterialId
+ operation.jobMakeMethodId ?? ""
)
: path.to.jobMethod(
operation.jobId,
diff --git a/apps/erp/app/routes/x+/production+/_index.tsx b/apps/erp/app/routes/x+/production+/_index.tsx
index 0723d038ff..be7b8ba9eb 100644
--- a/apps/erp/app/routes/x+/production+/_index.tsx
+++ b/apps/erp/app/routes/x+/production+/_index.tsx
@@ -82,7 +82,7 @@ import type { RealtimeChannel } from "@supabase/supabase-js";
import type { LoaderFunctionArgs } from "@vercel/remix";
import { flushSync } from "react-dom";
import { RiProgress8Line } from "react-icons/ri";
-import { getDeadlineIcon, getDeadlineText } from "~/modules/production/ui/Jobs";
+import { getDeadlineIcon } from "~/modules/production/ui/Jobs";
import type { WorkCenter } from "~/modules/resources";
import { getWorkCentersList } from "~/modules/resources";
@@ -933,7 +933,7 @@ function WorkCenterCards({
)}
>
{["ASAP", "No Deadline"].includes(deadlineType)
- ? getDeadlineText(deadlineType)
+ ? deadlineType
: dueDate
? `Due ${formatRelativeTime(
convertDateStringToIsoString(dueDate)
@@ -942,7 +942,7 @@ function WorkCenterCards({
</span>
</TooltipTrigger>
<TooltipContent side="right">
- {getDeadlineText(deadlineType)}
+ {deadlineType}
</TooltipContent>
</Tooltip>
</HStack>