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.

feat: scheduled maintenance forms

Brad Barbinfd57bec89877
diff --git a/apps/erp/app/modules/production/production.models.ts b/apps/erp/app/modules/production/production.models.ts
index 23fa2c9f79..6dd1b07900 100644
--- a/apps/erp/app/modules/production/production.models.ts
+++ b/apps/erp/app/modules/production/production.models.ts
@@ -962,7 +962,7 @@ export const maintenanceScheduleValidator = z.object({
frequency: z.enum(maintenanceFrequency),
priority: z.enum(maintenanceDispatchPriority),
estimatedDuration: zfd.numeric(z.number().optional()),
- active: z.boolean().default(true)
+ active: zfd.checkbox()
});
export const maintenanceScheduleItemValidator = z.object({
diff --git a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchExplorer.tsx b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchExplorer.tsx
index 2d9b39decf..c5a45366ea 100644
--- a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchExplorer.tsx
+++ b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchExplorer.tsx
@@ -330,7 +330,7 @@ function MaintenanceExplorerChildItem({
icon={<LuEllipsisVertical />}
variant="ghost"
size="sm"
- className="absolute right-1 top-0 flex-shrink-0 opacity-0 group-hover/child:opacity-100 data-[state=open]:opacity-100 text-foreground/70 hover:text-foreground"
+ className="absolute right-1 top-1 flex-shrink-0 opacity-0 group-hover/child:opacity-100 data-[state=open]:opacity-100 text-foreground/70 hover:text-foreground"
/>
</DropdownMenuTrigger>
<DropdownMenuContent>
diff --git a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchProperties.tsx b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchProperties.tsx
index 838af17fdc..a654ab083f 100644
--- a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchProperties.tsx
+++ b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchProperties.tsx
@@ -310,7 +310,7 @@ const MaintenanceDispatchProperties = () => {
inline
isDisabled={!permissions.can("update", "production") || isCompleted}
onChange={(date) => {
- onUpdate("plannedStartTime", date);
+ onUpdate("plannedStartTime", date?.toString() ?? null);
}}
/>
</ValidatedForm>
@@ -330,7 +330,7 @@ const MaintenanceDispatchProperties = () => {
inline
isDisabled={!permissions.can("update", "production") || isCompleted}
onChange={(date) => {
- onUpdate("plannedEndTime", date);
+ onUpdate("plannedEndTime", date?.toString() ?? null);
}}
/>
</ValidatedForm>
diff --git a/apps/erp/app/modules/production/ui/MaintenanceSchedule/MaintenanceScheduleForm.tsx b/apps/erp/app/modules/production/ui/MaintenanceSchedule/MaintenanceScheduleForm.tsx
index f050fcbae5..66883d247e 100644
--- a/apps/erp/app/modules/production/ui/MaintenanceSchedule/MaintenanceScheduleForm.tsx
+++ b/apps/erp/app/modules/production/ui/MaintenanceSchedule/MaintenanceScheduleForm.tsx
@@ -1,7 +1,6 @@
-import { Number, Select, ValidatedForm } from "@carbon/form";
+import { Boolean, Number, Select, ValidatedForm } from "@carbon/form";
import {
Button,
- Checkbox,
HStack,
ModalDrawer,
ModalDrawerBody,
@@ -15,8 +14,12 @@ import {
} from "@carbon/react";
import type { PostgrestResponse } from "@supabase/supabase-js";
import { useEffect } from "react";
+import { BsExclamationSquareFill } from "react-icons/bs";
import { useFetcher } from "react-router";
import type { z } from "zod/v3";
+import { HighPriorityIcon } from "~/assets/icons/HighPriorityIcon";
+import { LowPriorityIcon } from "~/assets/icons/LowPriorityIcon";
+import { MediumPriorityIcon } from "~/assets/icons/MediumPriorityIcon";
import { Hidden, Input, Submit, WorkCenter } from "~/components/Form";
import { usePermissions } from "~/hooks";
import { path } from "~/utils/path";
@@ -26,6 +29,21 @@ import {
maintenanceScheduleValidator
} from "../../production.models";
+function getPriorityIcon(
+ priority: (typeof maintenanceDispatchPriority)[number]
+) {
+ switch (priority) {
+ case "Critical":
+ return <BsExclamationSquareFill className="text-red-500" />;
+ case "High":
+ return <HighPriorityIcon />;
+ case "Medium":
+ return <MediumPriorityIcon />;
+ case "Low":
+ return <LowPriorityIcon />;
+ }
+}
+
type MaintenanceScheduleFormProps = {
initialValues: z.infer<typeof maintenanceScheduleValidator>;
type?: "modal" | "drawer";
@@ -83,7 +101,7 @@ const MaintenanceScheduleForm = ({
>
<ModalDrawerHeader>
<ModalDrawerTitle>
- {isEditing ? "Edit" : "New"} Maintenance Schedule
+ {isEditing ? "Edit" : "New"} Scheduled Maintenance
</ModalDrawerTitle>
</ModalDrawerHeader>
<ModalDrawerBody>
@@ -105,15 +123,20 @@ const MaintenanceScheduleForm = ({
label="Priority"
options={maintenanceDispatchPriority.map((priority) => ({
value: priority,
- label: priority
+ label: (
+ <div className="flex gap-1 items-center">
+ {getPriorityIcon(priority)}
+ <span>{priority}</span>
+ </div>
+ )
}))}
/>
<Number
name="estimatedDuration"
label="Estimated Duration (minutes)"
- min={0}
+ minValue={0}
/>
- <Checkbox name="active" label="Active" />
+ <Boolean name="active" label="Active" />
</VStack>
</ModalDrawerBody>
<ModalDrawerFooter>
diff --git a/apps/erp/app/modules/production/ui/MaintenanceSchedule/MaintenanceSchedulesTable.tsx b/apps/erp/app/modules/production/ui/MaintenanceSchedule/MaintenanceSchedulesTable.tsx
index 8efbf51714..2e7dd8b9a1 100644
--- a/apps/erp/app/modules/production/ui/MaintenanceSchedule/MaintenanceSchedulesTable.tsx
+++ b/apps/erp/app/modules/production/ui/MaintenanceSchedule/MaintenanceSchedulesTable.tsx
@@ -148,13 +148,13 @@ const MaintenanceSchedulesTable = memo(
primaryAction={
permissions.can("create", "production") && (
<New
- label="Maintenance Schedule"
+ label="Scheduled Maintenance"
to={`${path.to.newMaintenanceSchedule}?${params.toString()}`}
/>
)
}
renderContextMenu={renderContextMenu}
- title="Maintenance Schedules"
+ title="Scheduled Maintenances"
/>
);
}
diff --git a/apps/erp/app/routes/x+/production+/maintenance-schedules.$scheduleId.tsx b/apps/erp/app/routes/x+/production+/scheduled-maintenance.$scheduleId.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/production+/maintenance-schedules.$scheduleId.tsx
rename to apps/erp/app/routes/x+/production+/scheduled-maintenance.$scheduleId.tsx
diff --git a/apps/erp/app/routes/x+/production+/maintenance-schedules.delete.$scheduleId.tsx b/apps/erp/app/routes/x+/production+/scheduled-maintenance.delete.$scheduleId.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/production+/maintenance-schedules.delete.$scheduleId.tsx
rename to apps/erp/app/routes/x+/production+/scheduled-maintenance.delete.$scheduleId.tsx
diff --git a/apps/erp/app/routes/x+/production+/maintenance-schedules.new.tsx b/apps/erp/app/routes/x+/production+/scheduled-maintenance.new.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/production+/maintenance-schedules.new.tsx
rename to apps/erp/app/routes/x+/production+/scheduled-maintenance.new.tsx
diff --git a/apps/erp/app/routes/x+/production+/maintenance-schedules.tsx b/apps/erp/app/routes/x+/production+/scheduled-maintenance.tsx
similarity index 97%
rename from apps/erp/app/routes/x+/production+/maintenance-schedules.tsx
rename to apps/erp/app/routes/x+/production+/scheduled-maintenance.tsx
index 45eabb9e3c..b38d59559f 100644
--- a/apps/erp/app/routes/x+/production+/maintenance-schedules.tsx
+++ b/apps/erp/app/routes/x+/production+/scheduled-maintenance.tsx
@@ -9,7 +9,7 @@ import { path } from "~/utils/path";
import { getGenericQueryFilters } from "~/utils/query";
export const handle: Handle = {
- breadcrumb: "Maintenance Schedules",
+ breadcrumb: "Scheduled Maintenances",
to: path.to.maintenanceSchedules
};
diff --git a/apps/erp/app/utils/path.ts b/apps/erp/app/utils/path.ts
index 6ca69b618f..737439f33a 100644
--- a/apps/erp/app/utils/path.ts
+++ b/apps/erp/app/utils/path.ts
@@ -77,7 +77,7 @@ export const path = {
kanbanStart: (id: string) => generatePath(`${api}/kanban/start/${id}`),
locations: `${api}/resources/locations`,
maintenanceDispatches: `${api}/production/maintenance`,
- maintenanceSchedules: `${api}/production/maintenance-schedules`,
+ maintenanceSchedules: `${api}/production/scheduled-maintenance`,
materialDimensions: (formId: string) =>
generatePath(`${api}/items/dimensions/${formId}`),
materialFinishes: (substanceId: string) =>
@@ -604,7 +604,7 @@ export const path = {
deleteMaintenanceDispatch: (id: string) =>
generatePath(`${x}/production/maintenance/delete/${id}`),
deleteMaintenanceSchedule: (id: string) =>
- generatePath(`${x}/production/maintenance-schedules/delete/${id}`),
+ generatePath(`${x}/production/scheduled-maintenance/delete/${id}`),
deleteNoQuoteReason: (id: string) =>
generatePath(`${x}/sales/no-quote-reasons/delete/${id}`),
deleteCustomerPortal: (id: string) =>
@@ -878,8 +878,8 @@ export const path = {
generatePath(`${x}/maintenance/${dispatchId}/event/${eventId}/delete`),
maintenanceDispatches: `${x}/production/maintenance`,
maintenanceSchedule: (id: string) =>
- generatePath(`${x}/production/maintenance-schedules/${id}`),
- maintenanceSchedules: `${x}/production/maintenance-schedules`,
+ generatePath(`${x}/production/scheduled-maintenance/${id}`),
+ maintenanceSchedules: `${x}/production/scheduled-maintenance`,
makeMethodGet: `${x}/items/methods/get`,
makeMethodSave: `${x}/items/methods/save`,
markTrainingComplete: `${x}/resources/assignments/complete`,
@@ -1003,7 +1003,7 @@ export const path = {
newKanban: `${x}/inventory/kanbans/new`,
newLocation: `${x}/resources/locations/new`,
newMaintenanceDispatch: `${x}/maintenance/new`,
- newMaintenanceSchedule: `${x}/production/maintenance-schedules/new`,
+ newMaintenanceSchedule: `${x}/production/scheduled-maintenance/new`,
newMakeMethodVersion: `${x}/items/methods/version/new`,
newMaterial: `${x}/material/new`,
newMethodMaterial: `${x}/items/methods/material/new`,
diff --git a/packages/database/supabase/migrations/20251220150506_tracked-entity-readable-id-index.sql b/packages/database/supabase/migrations/20251220150506_tracked-entity-readable-id-index.sql
new file mode 100644
index 0000000000..ad70f0ebfb
--- /dev/null
+++ b/packages/database/supabase/migrations/20251220150506_tracked-entity-readable-id-index.sql
@@ -0,0 +1 @@
+CREATE INDEX IF NOT EXISTS idx_tracked_entity_readable_id ON "trackedEntity" ("readableId", "companyId");
\ No newline at end of file