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: maintenance dispatch table

Brad Barbin974796ebaf97
diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.ts
index e1cbb90047..c2e7b3ad73 100644
--- a/apps/erp/app/modules/production/production.service.ts
+++ b/apps/erp/app/modules/production/production.service.ts
@@ -1636,7 +1636,7 @@ export async function getMaintenanceDispatchItems(
return client
.from("maintenanceDispatchItem")
.select(
- `id, quantity, unitOfMeasureCode, unitCost, totalCost,
+ `id, itemId, quantity, unitOfMeasureCode, unitCost, totalCost,
item:item!maintenanceDispatchItem_itemId_fkey(id, name)`
)
.eq("maintenanceDispatchId", dispatchId);
@@ -1649,7 +1649,7 @@ export async function getMaintenanceDispatchWorkCenters(
return client
.from("maintenanceDispatchWorkCenter")
.select(
- `id,
+ `id, workCenterId,
workCenter:workCenter!maintenanceDispatchWorkCenter_workCenterId_fkey(id, name)`
)
.eq("maintenanceDispatchId", dispatchId);
diff --git a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchExplorer.tsx b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchExplorer.tsx
new file mode 100644
index 0000000000..7b0abee3e9
--- /dev/null
+++ b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchExplorer.tsx
@@ -0,0 +1,266 @@
+import {
+ Count,
+ cn,
+ HStack,
+ IconButton,
+ Input,
+ InputGroup,
+ InputLeftElement,
+ ScrollArea,
+ Skeleton,
+ VStack
+} from "@carbon/react";
+import { useState } from "react";
+import {
+ LuBox,
+ LuChevronRight,
+ LuClock,
+ LuCog,
+ LuSearch
+} from "react-icons/lu";
+import { Link } from "react-router";
+import { EmployeeAvatar } from "~/components";
+import { LevelLine } from "~/components/TreeView";
+import { path } from "~/utils/path";
+import type {
+ MaintenanceDispatchEvent,
+ MaintenanceDispatchItem,
+ MaintenanceDispatchWorkCenter
+} from "../../types";
+
+export type MaintenanceExplorerNode = {
+ key: "items" | "events" | "workCenters";
+ name: string;
+ pluralName: string;
+ children: MaintenanceExplorerChild[];
+};
+
+export type MaintenanceExplorerChild =
+ | (MaintenanceDispatchItem & { type: "item" })
+ | (MaintenanceDispatchEvent & { type: "event" })
+ | (MaintenanceDispatchWorkCenter & { type: "workCenter" });
+
+export function MaintenanceDispatchExplorerSkeleton() {
+ return (
+ <div className="flex flex-col gap-1 w-full">
+ <Skeleton className="h-7 w-full" />
+ <Skeleton className="h-7 w-full" />
+ <Skeleton className="h-7 w-3/4" />
+ </div>
+ );
+}
+
+export function MaintenanceDispatchExplorer({
+ items,
+ events,
+ workCenters
+}: {
+ items: MaintenanceDispatchItem[];
+ events: MaintenanceDispatchEvent[];
+ workCenters: MaintenanceDispatchWorkCenter[];
+}) {
+ const [filterText, setFilterText] = useState("");
+
+ const tree: MaintenanceExplorerNode[] = [
+ {
+ key: "items",
+ name: "Item",
+ pluralName: "Items",
+ children: items.map((item) => ({ ...item, type: "item" as const }))
+ },
+ {
+ key: "events",
+ name: "Timecard",
+ pluralName: "Timecards",
+ children: events.map((event) => ({ ...event, type: "event" as const }))
+ },
+ {
+ key: "workCenters",
+ name: "Work Center",
+ pluralName: "Work Centers",
+ children: workCenters.map((wc) => ({
+ ...wc,
+ type: "workCenter" as const
+ }))
+ }
+ ];
+
+ return (
+ <ScrollArea className="h-full">
+ <VStack className="px-2">
+ <HStack className="w-full py-2">
+ <InputGroup size="sm" className="flex flex-grow">
+ <InputLeftElement>
+ <LuSearch className="h-4 w-4" />
+ </InputLeftElement>
+ <Input
+ placeholder="Search..."
+ value={filterText}
+ onChange={(e) => setFilterText(e.target.value)}
+ />
+ </InputGroup>
+ </HStack>
+ <VStack spacing={0}>
+ {tree.map((node) => (
+ <MaintenanceExplorerItem
+ key={node.key}
+ node={node}
+ filterText={filterText}
+ />
+ ))}
+ </VStack>
+ </VStack>
+ </ScrollArea>
+ );
+}
+
+function MaintenanceExplorerItem({
+ node,
+ filterText
+}: {
+ node: MaintenanceExplorerNode;
+ filterText: string;
+}) {
+ const [isExpanded, setIsExpanded] = useState(
+ node.children.length > 0 && node.children.length < 10
+ );
+
+ const filteredChildren = node.children.filter((child) => {
+ const searchText = getChildSearchText(child);
+ return searchText.toLowerCase().includes(filterText.toLowerCase());
+ });
+
+ return (
+ <>
+ <div className="flex h-8 items-center overflow-hidden rounded-sm px-2 gap-2 text-sm w-full hover:bg-muted/90">
+ <button
+ className="flex flex-grow cursor-pointer items-center overflow-hidden font-medium"
+ onClick={(e) => {
+ e.stopPropagation();
+ setIsExpanded(!isExpanded);
+ }}
+ >
+ <div className="h-8 w-4 flex items-center justify-center">
+ <LuChevronRight
+ className={cn("size-4", isExpanded && "rotate-90")}
+ />
+ </div>
+ <div className="flex flex-grow items-center justify-between gap-2">
+ <span>{node.pluralName}</span>
+ {filteredChildren.length > 0 && (
+ <Count count={filteredChildren.length} />
+ )}
+ </div>
+ </button>
+ </div>
+
+ {isExpanded && (
+ <div className="flex flex-col w-full px-2">
+ {node.children.length === 0 ? (
+ <div className="flex h-8 items-center overflow-hidden rounded-sm px-2 gap-4">
+ <LevelLine isSelected={false} />
+ <div className="text-xs text-muted-foreground">
+ No {node.name.toLowerCase()} found
+ </div>
+ </div>
+ ) : (
+ filteredChildren.map((child, index) => (
+ <MaintenanceExplorerChildItem
+ key={child.id}
+ child={child}
+ nodeKey={node.key}
+ />
+ ))
+ )}
+ </div>
+ )}
+ </>
+ );
+}
+
+function MaintenanceExplorerChildItem({
+ child,
+ nodeKey
+}: {
+ child: MaintenanceExplorerChild;
+ nodeKey: MaintenanceExplorerNode["key"];
+}) {
+ const link = getChildLink(child);
+ const icon = getNodeIcon(nodeKey);
+ const label = getChildLabel(child);
+
+ const content = (
+ <div className="flex pr-7 h-8 cursor-pointer items-center overflow-hidden rounded-sm px-1 gap-2 text-sm hover:bg-muted/90 w-full font-medium whitespace-nowrap">
+ <LevelLine isSelected={false} />
+ <div className="flex flex-grow items-center gap-2">
+ {icon}
+ <span className="truncate">{label}</span>
+ </div>
+ {child.type === "item" && <Count count={child.quantity ?? 0} />}
+ </div>
+ );
+
+ if (link) {
+ return (
+ <Link to={link} className="flex w-full">
+ {content}
+ </Link>
+ );
+ }
+
+ return <div className="flex w-full">{content}</div>;
+}
+
+function getNodeIcon(key: MaintenanceExplorerNode["key"]) {
+ switch (key) {
+ case "items":
+ return <LuBox className="text-blue-500" />;
+ case "events":
+ return <LuClock className="text-green-500" />;
+ case "workCenters":
+ return <LuCog className="text-amber-500" />;
+ default:
+ return null;
+ }
+}
+
+function getChildLabel(child: MaintenanceExplorerChild): string {
+ switch (child.type) {
+ case "item":
+ return child.item?.name ?? child.itemId;
+ case "event":
+ return child.startTime
+ ? new Date(child.startTime).toLocaleString()
+ : "Event";
+ case "workCenter":
+ return child.workCenter?.name ?? child.workCenterId;
+ default:
+ return "";
+ }
+}
+
+function getChildSearchText(child: MaintenanceExplorerChild): string {
+ switch (child.type) {
+ case "item":
+ return child.item?.name ?? child.itemId;
+ case "event":
+ return child.notes ?? new Date(child.startTime).toLocaleString();
+ case "workCenter":
+ return child.workCenter?.name ?? child.workCenterId;
+ default:
+ return "";
+ }
+}
+
+function getChildLink(child: MaintenanceExplorerChild): string | null {
+ switch (child.type) {
+ case "item":
+ return path.to.item(child.itemId);
+ case "workCenter":
+ return path.to.workCenter(child.workCenterId);
+ default:
+ return null;
+ }
+}
+
+export default MaintenanceDispatchExplorer;
diff --git a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchNotes.tsx b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchNotes.tsx
new file mode 100644
index 0000000000..2d345e153c
--- /dev/null
+++ b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchNotes.tsx
@@ -0,0 +1,142 @@
+import { useCarbon } from "@carbon/auth";
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
+ generateHTML,
+ type JSONContent,
+ toast,
+ useDebounce
+} from "@carbon/react";
+import { Editor } from "@carbon/react/Editor";
+import { nanoid } from "nanoid";
+import { Suspense, useState } from "react";
+import { Await } from "react-router";
+import { Files, FilesSkeleton } from "~/components";
+import { usePermissions, useUser } from "~/hooks";
+import type { StorageItem } from "~/types";
+import { getPrivateUrl } from "~/utils/path";
+
+export function MaintenanceDispatchNotes({
+ id,
+ content: initialContent,
+ isDisabled
+}: {
+ id: string;
+ content: JSONContent;
+ isDisabled: boolean;
+}) {
+ const {
+ id: userId,
+ company: { id: companyId }
+ } = useUser();
+ const { carbon } = useCarbon();
+ const permissions = usePermissions();
+
+ const [content, setContent] = useState(initialContent ?? {});
+
+ const onUploadImage = async (file: File) => {
+ const fileType = file.name.split(".").pop();
+ const fileName = `${companyId}/maintenance/${nanoid()}.${fileType}`;
+
+ const result = await carbon?.storage.from("private").upload(fileName, file);
+
+ if (result?.error) {
+ toast.error("Failed to upload image");
+ throw new Error(result.error.message);
+ }
+
+ if (!result?.data) {
+ throw new Error("Failed to upload image");
+ }
+
+ return getPrivateUrl(result.data.path);
+ };
+
+ const onUpdateContent = useDebounce(
+ async (content: JSONContent) => {
+ await carbon
+ ?.from("maintenanceDispatch")
+ .update({
+ content: content,
+ updatedBy: userId
+ })
+ .eq("id", id!);
+ },
+ 2500,
+ true
+ );
+
+ if (!id) return null;
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>Notes</CardTitle>
+ <CardDescription>
+ Add notes and documentation for this maintenance dispatch
+ </CardDescription>
+ </CardHeader>
+
+ <CardContent>
+ {permissions.can("update", "production") && !isDisabled ? (
+ <Editor
+ initialValue={(content ?? {}) as JSONContent}
+ onUpload={onUploadImage}
+ onChange={(value) => {
+ setContent(value);
+ onUpdateContent(value);
+ }}
+ />
+ ) : (
+ <div
+ className="prose dark:prose-invert"
+ // biome-ignore lint/security/noDangerouslySetInnerHtml: suppressed due to migration
+ dangerouslySetInnerHTML={{
+ __html: generateHTML(content as JSONContent)
+ }}
+ />
+ )}
+ </CardContent>
+ </Card>
+ );
+}
+
+export function MaintenanceDispatchFiles({
+ id,
+ files
+}: {
+ id: string;
+ files: Promise<StorageItem[]>;
+}) {
+ const permissions = usePermissions();
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>Files</CardTitle>
+ <CardDescription>
+ Attachments and documents related to this dispatch
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ <Suspense fallback={<FilesSkeleton />}>
+ <Await resolve={files}>
+ {(resolvedFiles) => (
+ <Files
+ bucket="private"
+ path={id}
+ files={resolvedFiles}
+ isReadOnly={!permissions.can("update", "production")}
+ />
+ )}
+ </Await>
+ </Suspense>
+ </CardContent>
+ </Card>
+ );
+}
+
+export default MaintenanceDispatchNotes;
diff --git a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchProperties.tsx b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchProperties.tsx
index 8b3371d1c5..ae4a9a0063 100644
--- a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchProperties.tsx
+++ b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchProperties.tsx
@@ -1,4 +1,4 @@
-import { Select, ValidatedForm } from "@carbon/form";
+import { DatePicker, Select, Switch, ValidatedForm } from "@carbon/form";
import {
Button,
HStack,
@@ -8,7 +8,7 @@ import {
toast,
VStack
} from "@carbon/react";
-import { useCallback, useEffect } from "react";
+import { useCallback, useEffect, useMemo } from "react";
import { LuCopy, LuKeySquare, LuLink } from "react-icons/lu";
import { useFetcher, useParams } from "react-router";
import { z } from "zod/v3";
@@ -17,6 +17,7 @@ import {
EmployeeAvatar,
useOptimisticAssignment
} from "~/components";
+import { useWorkCenters } from "~/components/Form/WorkCenter";
import { usePermissions, useRouteData } from "~/hooks";
import { path } from "~/utils/path";
import { copyToClipboard } from "~/utils/string";
@@ -27,6 +28,7 @@ import {
} from "../../production.models";
import type { MaintenanceDispatchDetail } from "../../types";
import MaintenancePriority from "./MaintenancePriority";
+import MaintenanceStatus from "./MaintenanceStatus";
const MaintenanceDispatchProperties = () => {
const { dispatchId } = useParams();
@@ -39,6 +41,8 @@ const MaintenanceDispatchProperties = () => {
failureModes: { id: string; name: string }[];
}>(path.to.maintenanceDispatch(dispatchId));
+ const { options: workCenterOptions } = useWorkCenters({});
+
const optimisticAssignment = useOptimisticAssignment({
id: dispatchId,
table: "maintenanceDispatch"
@@ -68,10 +72,12 @@ const MaintenanceDispatchProperties = () => {
[dispatchId, fetcher]
);
+ const isCompleted = routeData?.dispatch?.status === "Completed";
+
return (
<VStack
spacing={4}
- className="w-80 bg-card h-full overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent border-l border-border px-4 py-2 text-sm"
+ className="w-96 bg-card h-full overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent border-l border-border px-4 py-2 text-sm"
>
<VStack spacing={2}>
<HStack className="w-full justify-between">
@@ -137,6 +143,11 @@ const MaintenanceDispatchProperties = () => {
</span>
</VStack>
+ <VStack spacing={2}>
+ <h3 className="text-xs text-muted-foreground">Status</h3>
+ <MaintenanceStatus status={routeData?.dispatch?.status} />
+ </VStack>
+
<VStack spacing={2}>
<h3 className="text-xs text-muted-foreground">Assignee</h3>
<Assignee
@@ -148,6 +159,28 @@ const MaintenanceDispatchProperties = () => {
/>
</VStack>
+ <ValidatedForm
+ defaultValues={{
+ workCenterId: routeData?.dispatch?.workCenterId ?? ""
+ }}
+ validator={z.object({
+ workCenterId: z.string().optional()
+ })}
+ className="w-full"
+ >
+ <Select
+ options={workCenterOptions}
+ isReadOnly={!permissions.can("update", "production")}
+ label="Work Center"
+ name="workCenterId"
+ inline
+ isClearable
+ onChange={(value) => {
+ onUpdate("workCenterId", value?.value ?? null);
+ }}
+ />
+ </ValidatedForm>
+
<ValidatedForm
defaultValues={{
priority: routeData?.dispatch?.priority ?? ""
@@ -236,6 +269,65 @@ const MaintenanceDispatchProperties = () => {
/>
</ValidatedForm>
+ <ValidatedForm
+ defaultValues={{
+ plannedStartTime: routeData?.dispatch?.plannedStartTime ?? ""
+ }}
+ validator={z.object({
+ plannedStartTime: z.string().optional()
+ })}
+ className="w-full"
+ >
+ <DatePicker
+ name="plannedStartTime"
+ label="Planned Start"
+ inline
+ isDisabled={!permissions.can("update", "production") || isCompleted}
+ onChange={(date) => {
+ onUpdate("plannedStartTime", date);
+ }}
+ />
+ </ValidatedForm>
+
+ <ValidatedForm
+ defaultValues={{
+ plannedEndTime: routeData?.dispatch?.plannedEndTime ?? ""
+ }}
+ validator={z.object({
+ plannedEndTime: z.string().optional()
+ })}
+ className="w-full"
+ >
+ <DatePicker
+ name="plannedEndTime"
+ label="Planned End"
+ inline
+ isDisabled={!permissions.can("update", "production") || isCompleted}
+ onChange={(date) => {
+ onUpdate("plannedEndTime", date);
+ }}
+ />
+ </ValidatedForm>
+
+ <ValidatedForm
+ defaultValues={{
+ isFailure: routeData?.dispatch?.isFailure ?? false
+ }}
+ validator={z.object({
+ isFailure: z.boolean().optional()
+ })}
+ className="w-full"
+ >
+ <Switch
+ name="isFailure"
+ label="Is Failure"
+ isDisabled={!permissions.can("update", "production")}
+ onChange={(checked) => {
+ onUpdate("isFailure", checked.toString());
+ }}
+ />
+ </ValidatedForm>
+
<ValidatedForm
defaultValues={{
suspectedFailureModeId:
diff --git a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchesTable.tsx b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchesTable.tsx
index 4488c413b2..63a59dfa58 100644
--- a/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchesTable.tsx
+++ b/apps/erp/app/modules/production/ui/Maintenance/MaintenanceDispatchesTable.tsx
@@ -139,7 +139,7 @@ const MaintenanceDispatchesTable = memo(
return <span className="text-muted-foreground">Unassigned</span>;
}
const workCenter = workCenters.find(
- (workCenter) => workCenter.value === workCenterId
+ (wc) => wc.value === workCenterId
);
if (!workCenter) {
return <span className="text-muted-foreground">Unknown</span>;
diff --git a/apps/erp/app/modules/production/ui/Maintenance/index.ts b/apps/erp/app/modules/production/ui/Maintenance/index.ts
index f89e5ebeee..9a0303b31c 100644
--- a/apps/erp/app/modules/production/ui/Maintenance/index.ts
+++ b/apps/erp/app/modules/production/ui/Maintenance/index.ts
@@ -1,6 +1,14 @@
+export {
+ MaintenanceDispatchExplorer,
+ MaintenanceDispatchExplorerSkeleton
+} from "./MaintenanceDispatchExplorer";
export { default as MaintenanceDispatchesTable } from "./MaintenanceDispatchesTable";
export { default as MaintenanceDispatchForm } from "./MaintenanceDispatchForm";
export { default as MaintenanceDispatchHeader } from "./MaintenanceDispatchHeader";
+export {
+ MaintenanceDispatchFiles,
+ MaintenanceDispatchNotes
+} from "./MaintenanceDispatchNotes";
export { default as MaintenanceDispatchProperties } from "./MaintenanceDispatchProperties";
export { default as MaintenancePriority } from "./MaintenancePriority";
export { default as MaintenanceStatus } from "./MaintenanceStatus";
diff --git a/apps/erp/app/routes/x+/maintenance+/$dispatchId.properties.tsx b/apps/erp/app/routes/x+/maintenance+/$dispatchId.properties.tsx
index da1009b1d5..2e9d9f1726 100644
--- a/apps/erp/app/routes/x+/maintenance+/$dispatchId.properties.tsx
+++ b/apps/erp/app/routes/x+/maintenance+/$dispatchId.properties.tsx
@@ -72,8 +72,13 @@ export async function action({ request, params }: ActionFunctionArgs) {
case "source":
case "suspectedFailureModeId":
case "actualFailureModeId":
+ case "workCenterId":
updateData[field] = value || null;
break;
+ case "plannedStartTime":
+ case "plannedEndTime":
+ updateData[field] = value ? new Date(value).toISOString() : null;
+ break;
case "isFailure":
updateData[field] = value === "true";
break;
diff --git a/apps/erp/app/routes/x+/maintenance+/$dispatchId.tsx b/apps/erp/app/routes/x+/maintenance+/$dispatchId.tsx
index cf91c0182a..fa3bf11db5 100644
--- a/apps/erp/app/routes/x+/maintenance+/$dispatchId.tsx
+++ b/apps/erp/app/routes/x+/maintenance+/$dispatchId.tsx
@@ -1,21 +1,10 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import {
- Tabs,
- TabsContent,
- TabsList,
- TabsTrigger,
- VStack
-} from "@carbon/react";
+import { type JSONContent, VStack } from "@carbon/react";
import type { LoaderFunctionArgs } from "react-router";
-import {
- Outlet,
- redirect,
- useLoaderData,
- useNavigate,
- useParams
-} from "react-router";
+import { Outlet, redirect, useLoaderData, useParams } from "react-router";
+import { PanelProvider, ResizablePanels } from "~/components/Layout/Panels";
import {
getFailureModesList,
getMaintenanceDispatch,
@@ -25,7 +14,9 @@ import {
getMaintenanceDispatchWorkCenters
} from "~/modules/production";
import {
+ MaintenanceDispatchExplorer,
MaintenanceDispatchHeader,
+ MaintenanceDispatchNotes,
MaintenanceDispatchProperties
} from "~/modules/production/ui/Maintenance";
import type { Handle } from "~/utils/handle";
@@ -77,62 +68,44 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
export default function MaintenanceDispatchRoute() {
const { dispatchId } = useParams();
- const navigate = useNavigate();
- const { events, items, comments } = useLoaderData<typeof loader>();
+ const { dispatch, events, items, workCenters } =
+ useLoaderData<typeof loader>();
if (!dispatchId) throw new Error("Could not find dispatchId");
- const currentPath =
- typeof window !== "undefined" ? window.location.pathname : "";
- const currentTab = currentPath.includes("/events")
- ? "events"
- : currentPath.includes("/items")
- ? "items"
- : currentPath.includes("/comments")
- ? "comments"
- : "overview";
+ const isCompleted = dispatch?.status === "Completed";
return (
- <div className="flex flex-col h-[calc(100dvh-49px)] overflow-hidden w-full">
- <MaintenanceDispatchHeader />
- <div className="flex h-[calc(100dvh-99px)] overflow-hidden w-full">
- <div className="flex flex-grow overflow-hidden">
- <div className="flex-1 overflow-y-auto">
- <Tabs
- value={currentTab}
- onValueChange={(value) => {
- if (value === "overview") {
- navigate(path.to.maintenanceDispatch(dispatchId));
- } else {
- navigate(
- `${path.to.maintenanceDispatch(dispatchId)}/${value}`
- );
- }
- }}
- className="w-full"
- >
- <TabsList className="px-4 pt-2">
- <TabsTrigger value="overview">Overview</TabsTrigger>
- <TabsTrigger value="events">
- Events {events.length > 0 && `(${events.length})`}
- </TabsTrigger>
- <TabsTrigger value="items">
- Items {items.length > 0 && `(${items.length})`}
- </TabsTrigger>
- <TabsTrigger value="comments">
- Comments {comments.length > 0 && `(${comments.length})`}
- </TabsTrigger>
- </TabsList>
- <TabsContent value={currentTab} className="p-4">
- <VStack spacing={4}>
- <Outlet />
- </VStack>
- </TabsContent>
- </Tabs>
+ <PanelProvider>
+ <div className="flex flex-col h-[calc(100dvh-49px)] overflow-hidden w-full">
+ <MaintenanceDispatchHeader />
+ <div className="flex h-[calc(100dvh-99px)] overflow-hidden w-full">
+ <div className="flex flex-grow overflow-hidden">
+ <ResizablePanels
+ explorer={
+ <MaintenanceDispatchExplorer
+ items={items}
+ events={events}
+ workCenters={workCenters}
+ />
+ }
+ content={
+ <div className="h-[calc(100dvh-99px)] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
+ <VStack spacing={2} className="p-2">
+ <MaintenanceDispatchNotes
+ id={dispatchId}
+ content={(dispatch?.content ?? {}) as JSONContent}
+ isDisabled={isCompleted}
+ />
+ <Outlet />
+ </VStack>
+ </div>
+ }
+ properties={<MaintenanceDispatchProperties />}
+ />
</div>
- <MaintenanceDispatchProperties />
</div>
</div>
- </div>
+ </PanelProvider>
);
}