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 total timecard calculation from maintenance properties

Brad Barbin213b8d1dd27f
diff --git a/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchProperties.tsx b/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchProperties.tsx
index a72918d010..4ba4aad3fa 100644
--- a/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchProperties.tsx
+++ b/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchProperties.tsx
@@ -2,7 +2,6 @@ import { DateTimePicker, Hidden, Select, ValidatedForm } from "@carbon/form";
import {
Button,
HStack,
- IconButton,
Modal,
ModalBody,
ModalContent,
@@ -17,7 +16,7 @@ import {
VStack
} from "@carbon/react";
import { useCallback, useEffect, useState } from "react";
-import { LuClock, LuCopy, LuKeySquare, LuLink, LuPencil } from "react-icons/lu";
+import { LuCopy, LuKeySquare, LuLink } from "react-icons/lu";
import { useFetcher, useParams } from "react-router";
import { z } from "zod/v3";
import {
@@ -46,16 +45,6 @@ import MaintenanceSeverity from "./MaintenanceSeverity";
import MaintenanceSource from "./MaintenanceSource";
import MaintenanceStatus from "./MaintenanceStatus";
-function formatDuration(seconds: number | null): string {
- if (!seconds) return "-";
- const hours = Math.floor(seconds / 3600);
- const minutes = Math.floor((seconds % 3600) / 60);
- if (hours > 0) {
- return `${hours}h ${minutes}m`;
- }
- return `${minutes}m`;
-}
-
const MaintenanceDispatchProperties = () => {
const { dispatchId } = useParams();
if (!dispatchId) throw new Error("dispatchId not found");
@@ -71,8 +60,6 @@ const MaintenanceDispatchProperties = () => {
failureModes: { id: string; name: string }[];
}>(path.to.maintenanceDispatch(dispatchId));
- const events = routeData?.events ?? [];
-
const optimisticAssignment = useOptimisticAssignment({
id: dispatchId,
table: "maintenanceDispatch"
@@ -521,52 +508,6 @@ const MaintenanceDispatchProperties = () => {
</>
)}
- <VStack spacing={2} className="w-full">
- <HStack className="w-full justify-between">
- <h3 className="text-xs text-muted-foreground">Timecards</h3>
- <LuClock className="w-3 h-3 text-muted-foreground" />
- </HStack>
- {events.length === 0 ? (
- <span className="text-xs text-muted-foreground">No timecards</span>
- ) : (
- <div className="w-full space-y-1">
- {events.map((event) => (
- <HStack
- key={event.id}
- className="w-full justify-between py-1 px-2 rounded hover:bg-muted/50 cursor-pointer"
- onClick={() => {
- setSelectedEvent(event);
- eventModal.onOpen();
- }}
- >
- <HStack spacing={2}>
- <EmployeeAvatar employeeId={event.employeeId} size="xs" />
- <span className="text-sm font-mono">
- {formatDuration(event.duration)}
- </span>
- {!event.endTime && (
- <span className="text-xs bg-green-100 text-green-800 px-1 rounded">
- Active
- </span>
- )}
- </HStack>
- <IconButton
- aria-label="Edit timecard"
- icon={<LuPencil className="w-3 h-3" />}
- size="sm"
- variant="ghost"
- onClick={(e) => {
- e.stopPropagation();
- setSelectedEvent(event);
- eventModal.onOpen();
- }}
- />
- </HStack>
- ))}
- </div>
- )}
- </VStack>
-
<VStack spacing={2}>
<h3 className="text-xs text-muted-foreground">Created By</h3>
<EmployeeAvatar
@@ -595,9 +536,9 @@ const MaintenanceDispatchProperties = () => {
defaultValues={{
id: selectedEvent.id,
maintenanceDispatchId: dispatchId,
- employeeId: selectedEvent.employeeId,
+ employeeId: selectedEvent.employee.id,
workCenterId:
- selectedEvent.workCenterId ??
+ selectedEvent.workCenter.id ??
routeData?.dispatch?.workCenterId ??
"",
startTime: selectedEvent.startTime,
@@ -611,7 +552,7 @@ const MaintenanceDispatchProperties = () => {
<VStack spacing={4}>
<HStack spacing={2}>
<EmployeeAvatar
- employeeId={selectedEvent.employeeId}
+ employeeId={selectedEvent.employee.id}
size="sm"
/>
<span className="text-sm font-medium">
@@ -620,11 +561,11 @@ const MaintenanceDispatchProperties = () => {
</HStack>
<Hidden name="id" value={selectedEvent.id} />
<Hidden name="maintenanceDispatchId" value={dispatchId} />
- <Hidden name="employeeId" value={selectedEvent.employeeId} />
+ <Hidden name="employeeId" value={selectedEvent.employee.id} />
<Hidden
name="workCenterId"
value={
- selectedEvent.workCenterId ??
+ selectedEvent.workCenter.id ??
routeData?.dispatch?.workCenterId ??
""
}
diff --git a/apps/mes/app/components/JobOperation/components/Step.tsx b/apps/mes/app/components/JobOperation/components/Step.tsx
index b9d4214665..36d24b893a 100644
--- a/apps/mes/app/components/JobOperation/components/Step.tsx
+++ b/apps/mes/app/components/JobOperation/components/Step.tsx
@@ -219,7 +219,7 @@ export function StepsListItem({
</div>
{disclosure.isOpen && hasDescription && (
<div
- className="mt-4 text-sm prose prose-sm dark:prose-invert"
+ className="my-4 text-sm prose prose-sm dark:prose-invert"
dangerouslySetInnerHTML={{
__html: generateHTML(description as JSONContent)
}}
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 3e0b095348..ddcd1410da 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -45116,14 +45116,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"]
@@ -46496,14 +46496,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -49023,14 +49023,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -52996,19 +52996,25 @@ export type Database = {
companyId: string
createdAt: string
createdBy: string
- daysOfWeek: number[]
description: string
estimatedDuration: number
frequency: Database["public"]["Enums"]["maintenanceFrequency"]
+ friday: boolean
id: string
lastGeneratedAt: string
locationId: string
locationName: string
+ monday: boolean
name: string
nextDueAt: string
priority: Database["public"]["Enums"]["maintenanceDispatchPriority"]
+ saturday: boolean
+ sunday: boolean
+ thursday: boolean
+ tuesday: boolean
updatedAt: string
updatedBy: string
+ wednesday: boolean
workCenterId: string
workCenterName: string
}[]
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 3e0b095348..ddcd1410da 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -45116,14 +45116,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"]
@@ -46496,14 +46496,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -49023,14 +49023,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -52996,19 +52996,25 @@ export type Database = {
companyId: string
createdAt: string
createdBy: string
- daysOfWeek: number[]
description: string
estimatedDuration: number
frequency: Database["public"]["Enums"]["maintenanceFrequency"]
+ friday: boolean
id: string
lastGeneratedAt: string
locationId: string
locationName: string
+ monday: boolean
name: string
nextDueAt: string
priority: Database["public"]["Enums"]["maintenanceDispatchPriority"]
+ saturday: boolean
+ sunday: boolean
+ thursday: boolean
+ tuesday: boolean
updatedAt: string
updatedBy: string
+ wednesday: boolean
workCenterId: string
workCenterName: string
}[]