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: file upload for materials, tools, fixtures, consumables, and services

Brad Barbinc4f95c52cb51
diff --git a/apps/carbon/app/components/CreateableCombobox.tsx b/apps/carbon/app/components/CreateableCombobox.tsx
index f28b50d5bb..094220ca26 100644
--- a/apps/carbon/app/components/CreateableCombobox.tsx
+++ b/apps/carbon/app/components/CreateableCombobox.tsx
@@ -30,6 +30,7 @@ export type CreatableComboboxProps = Omit<
selected?: string[];
isClearable?: boolean;
isReadOnly?: boolean;
+ label?: string;
placeholder?: string;
onChange?: (selected: string) => void;
onCreateOption?: (inputValue: string) => void;
@@ -46,7 +47,7 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(
isReadOnly,
placeholder,
onChange,
-
+ label,
...props
},
ref
@@ -59,6 +60,8 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(
)
);
+ console.log({ search, label });
+
return (
<HStack spacing={1}>
<Popover open={open} onOpenChange={setOpen}>
@@ -125,15 +128,16 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(
</CommandItem>
);
})}
- {!isExactMatch && search.trim() !== "" && (
+ {!isExactMatch && (
<CommandItem
onSelect={() => {
props.onCreateOption?.(search);
}}
- value={search.trim()}
+ value={search.trim() || ""}
+ className="cursor-pointer"
>
<span>Create</span>
- <span className="ml-1 font-bold">{search}</span>
+ <span className="ml-1 font-bold">{search || label}</span>
</CommandItem>
)}
</CommandGroup>
diff --git a/apps/carbon/app/components/Form/CreatableCombobox.tsx b/apps/carbon/app/components/Form/CreatableCombobox.tsx
index 6ed34b8f4b..81df45a6b2 100644
--- a/apps/carbon/app/components/Form/CreatableCombobox.tsx
+++ b/apps/carbon/app/components/Form/CreatableCombobox.tsx
@@ -57,6 +57,7 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(
setValue(newValue ?? "");
onChange(newValue ?? "");
}}
+ label={label}
className="w-full"
/>
diff --git a/apps/carbon/app/lib/autodesk/autodesk.server.ts b/apps/carbon/app/lib/autodesk/autodesk.server.ts
index 6501dacbb2..689de1962e 100644
--- a/apps/carbon/app/lib/autodesk/autodesk.server.ts
+++ b/apps/carbon/app/lib/autodesk/autodesk.server.ts
@@ -239,13 +239,13 @@ export async function getAutodeskToken(refresh = false, scope?: string) {
}
export async function getManifest(urn: string, token: string) {
- // poll the manifest endpoint once every second for 30 seconds until we get a response with progress === "complete"
+ // poll the manifest endpoint for 15s until we get a response with progress === "complete"
let response;
let progress = "inprogress";
let tries = 0;
- while (progress !== "complete" && tries < 15) {
+ while (progress !== "complete" && tries < 10) {
try {
response = await fetch(autodeskAPI.getManifest.url(urn), {
method: autodeskAPI.getManifest.method,
@@ -270,7 +270,7 @@ export async function getManifest(urn: string, token: string) {
}
tries++;
- await new Promise((resolve) => setTimeout(resolve, 1000));
+ await new Promise((resolve) => setTimeout(resolve, 1500));
}
if (tries > 30) {
diff --git a/apps/carbon/app/modules/items/items.models.ts b/apps/carbon/app/modules/items/items.models.ts
index 30b873ff11..3996c55660 100644
--- a/apps/carbon/app/modules/items/items.models.ts
+++ b/apps/carbon/app/modules/items/items.models.ts
@@ -124,28 +124,101 @@ export const materialValidator = itemValidator.merge(
})
);
-export const methodMaterialValidator = z.object({
- id: zfd.text(z.string().optional()),
- makeMethodId: z.string().min(20, { message: "Make method is required" }),
- order: zfd.numeric(z.number().min(0)),
- itemType: z.enum(methodItemType, {
- errorMap: (issue, ctx) => ({
- message: "Item type is required",
+export const methodMaterialValidator = z
+ .object({
+ id: zfd.text(z.string().optional()),
+ makeMethodId: z.string().min(20, { message: "Make method is required" }),
+ order: zfd.numeric(z.number().min(0)),
+ itemType: z.enum(methodItemType, {
+ errorMap: (issue, ctx) => ({
+ message: "Item type is required",
+ }),
}),
- }),
- methodType: z.enum(methodType, {
- errorMap: (issue, ctx) => ({
- message: "Method type is required",
+ methodType: z.enum(methodType, {
+ errorMap: (issue, ctx) => ({
+ message: "Method type is required",
+ }),
}),
- }),
- itemId: z.string().min(20, { message: "Item is required" }),
- itemReadableId: z.string().min(1, { message: "Item ID is required" }),
- // description: z.string().min(1, { message: "Description is required" }),
- quantity: zfd.numeric(z.number().min(0)),
- unitOfMeasureCode: z
- .string()
- .min(1, { message: "Unit of Measure is required" }),
-});
+ itemId: z.string().optional(),
+ itemReadableId: z.string().optional(),
+ // description: z.string().min(1, { message: "Description is required" }),
+ quantity: zfd.numeric(z.number().min(0)),
+ unitOfMeasureCode: z
+ .string()
+ .min(1, { message: "Unit of Measure is required" }),
+ })
+ .refine(
+ (data) => {
+ if (data.itemType === "Part") {
+ return !!data.itemReadableId;
+ }
+ return true;
+ },
+ {
+ message: "Part ID is required",
+ path: ["itemId"],
+ }
+ )
+ .refine(
+ (data) => {
+ if (data.itemType === "Material") {
+ return !!data.itemReadableId;
+ }
+ return true;
+ },
+ {
+ message: "Material ID is required",
+ path: ["itemId"],
+ }
+ )
+ .refine(
+ (data) => {
+ if (data.itemType === "Fixture") {
+ return !!data.itemReadableId;
+ }
+ return true;
+ },
+ {
+ message: "Fixture ID is required",
+ path: ["itemId"],
+ }
+ )
+ .refine(
+ (data) => {
+ if (data.itemType === "Tool") {
+ return !!data.itemReadableId;
+ }
+ return true;
+ },
+ {
+ message: "Tool ID is required",
+ path: ["itemId"],
+ }
+ )
+ .refine(
+ (data) => {
+ if (data.itemType === "Consumable") {
+ return !!data.itemReadableId;
+ }
+ return true;
+ },
+ {
+ message: "Consumable ID is required",
+ path: ["itemId"],
+ }
+ )
+ .refine(
+ (data) => {
+ if (data.itemType === "Service") {
+ return !!data.itemReadableId;
+ }
+ return true;
+ },
+ {
+ message: "Service ID is required",
+ path: ["itemId"],
+ }
+ );
export const methodOperationValidator = z.object({
id: zfd.text(z.string().optional()),
diff --git a/apps/carbon/app/modules/items/items.service.ts b/apps/carbon/app/modules/items/items.service.ts
index ee7a1333c6..ce5ace12a9 100644
--- a/apps/carbon/app/modules/items/items.service.ts
+++ b/apps/carbon/app/modules/items/items.service.ts
@@ -1396,7 +1396,7 @@ export async function upsertMethodMaterial(
const makeMethod = await client
.from("makeMethod")
.select("id")
- .eq("itemId", methodMaterial.itemId)
+ .eq("itemId", methodMaterial.itemId!)
.single();
if (makeMethod.error) return makeMethod;
@@ -1409,6 +1409,8 @@ export async function upsertMethodMaterial(
.insert([
{
...methodMaterial,
+ itemId: methodMaterial.itemId!,
+ itemReadableId: methodMaterial.itemReadableId!,
materialMakeMethodId,
},
])
diff --git a/apps/carbon/app/modules/items/ui/Consumables/ConsumableHeader.tsx b/apps/carbon/app/modules/items/ui/Consumables/ConsumableHeader.tsx
index 958cdaed77..97446e2e72 100644
--- a/apps/carbon/app/modules/items/ui/Consumables/ConsumableHeader.tsx
+++ b/apps/carbon/app/modules/items/ui/Consumables/ConsumableHeader.tsx
@@ -17,7 +17,7 @@ const ConsumableHeader = () => {
);
return (
- <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card">
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border">
<VStack spacing={0} className="flex-grow">
<HStack>
<Heading size="h2">{routeData?.consumableSummary?.id}</Heading>
diff --git a/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx b/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx
index 217be93145..f2c205c6ac 100644
--- a/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx
+++ b/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx
@@ -16,8 +16,8 @@ import Assignee from "~/components/Assignee";
import { useRouteData } from "~/hooks";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
-import type { BuyMethod, Consumable, PickMethod } from "../../types";
-import { MethodIcon, TrackingTypeIcon } from "../Item";
+import type { BuyMethod, Consumable, ItemFile, PickMethod } from "../../types";
+import { FileBadge, MethodIcon, TrackingTypeIcon } from "../Item";
import { MethodBadge } from "../Item/MethodBadge";
const ConsumableProperties = () => {
@@ -29,6 +29,7 @@ const ConsumableProperties = () => {
);
const routeData = useRouteData<{
consumableSummary: Consumable;
+ files: ItemFile[];
buyMethods: BuyMethod[];
pickMethods: PickMethod[];
}>(path.to.consumable(itemId));
@@ -143,14 +144,16 @@ const ConsumableProperties = () => {
<HStack className="w-full justify-between">
<h3 className="text-xs text-muted-foreground">Methods</h3>
</HStack>
- {buyMethods.map((method) => (
- <MethodBadge
- key={method.id}
- type="Buy"
- text={method?.supplier?.name ?? ""}
- to={path.to.consumablePurchasing(itemId)}
- />
- ))}
+
+ {routeData?.consumableSummary?.replenishmentSystem?.includes("Buy") &&
+ buyMethods.map((method) => (
+ <MethodBadge
+ key={method.id}
+ type="Buy"
+ text={method?.supplier?.name ?? ""}
+ to={path.to.partPurchasing(itemId)}
+ />
+ ))}
{pickMethods.map((method) => (
<MethodBadge
key={method.locationId}
@@ -160,10 +163,20 @@ const ConsumableProperties = () => {
locations.find((l) => l.id === method.locationId)?.name ??
""
}
- to={path.to.consumableInventoryLocation(itemId, method.locationId)}
+ to={path.to.partInventoryLocation(itemId, method.locationId)}
/>
))}
</VStack>
+
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">Files</h3>
+ </HStack>
+
+ {routeData?.files.map((file) => {
+ return <FileBadge key={file.id} file={file} itemId={itemId} />;
+ })}
+ </VStack>
</VStack>
);
};
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixtureHeader.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixtureHeader.tsx
index 4007174c34..0dc45dbf33 100644
--- a/apps/carbon/app/modules/items/ui/Fixtures/FixtureHeader.tsx
+++ b/apps/carbon/app/modules/items/ui/Fixtures/FixtureHeader.tsx
@@ -17,7 +17,7 @@ const FixtureHeader = () => {
);
return (
- <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card">
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border">
<VStack spacing={0} className="flex-grow">
<HStack>
<Heading size="h2">{routeData?.fixtureSummary?.id}</Heading>
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx
index 4206bfd1c7..e1386ae6c5 100644
--- a/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx
+++ b/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx
@@ -9,15 +9,21 @@ import {
VStack,
cn,
} from "@carbon/react";
-import { useParams } from "@remix-run/react";
-import { LuCopy, LuLink } from "react-icons/lu";
+import { Link, useParams } from "@remix-run/react";
+import { LuCopy, LuExternalLink, LuLink, LuMove3D } from "react-icons/lu";
import { CustomerAvatar, useOptimisticAssignment } from "~/components";
import Assignee from "~/components/Assignee";
import { useRouteData } from "~/hooks";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
-import type { BuyMethod, Fixture, PickMethod } from "../../types";
-import { MethodIcon, TrackingTypeIcon } from "../Item";
+import type {
+ BuyMethod,
+ Fixture,
+ ItemFile,
+ ModelUpload,
+ PickMethod,
+} from "../../types";
+import { FileBadge, MethodIcon, TrackingTypeIcon } from "../Item";
import { MethodBadge } from "../Item/MethodBadge";
const FixtureProperties = () => {
@@ -29,6 +35,8 @@ const FixtureProperties = () => {
);
const routeData = useRouteData<{
fixtureSummary: Fixture;
+ files: ItemFile[];
+ modelUpload?: ModelUpload;
buyMethods: BuyMethod[];
pickMethods: PickMethod[];
}>(path.to.fixture(itemId));
@@ -155,14 +163,22 @@ const FixtureProperties = () => {
<HStack className="w-full justify-between">
<h3 className="text-xs text-muted-foreground">Methods</h3>
</HStack>
- {buyMethods.map((method) => (
+ {routeData?.fixtureSummary?.replenishmentSystem?.includes("Make") && (
<MethodBadge
- key={method.id}
- type="Buy"
- text={method?.supplier?.name ?? ""}
- to={path.to.fixturePurchasing(itemId)}
+ type="Make"
+ text={routeData?.fixtureSummary?.id ?? ""}
+ to={path.to.fixtureManufacturing(itemId)}
/>
- ))}
+ )}
+ {routeData?.fixtureSummary?.replenishmentSystem?.includes("Buy") &&
+ buyMethods.map((method) => (
+ <MethodBadge
+ key={method.id}
+ type="Buy"
+ text={method?.supplier?.name ?? ""}
+ to={path.to.fixturePurchasing(itemId)}
+ />
+ ))}
{pickMethods.map((method) => (
<MethodBadge
key={method.locationId}
@@ -176,6 +192,30 @@ const FixtureProperties = () => {
/>
))}
</VStack>
+
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">Files</h3>
+ </HStack>
+ {routeData?.modelUpload && (
+ <HStack className="group" spacing={1}>
+ <Badge variant="secondary">
+ <LuMove3D className="w-3 h-3 mr-1 text-green-500" />
+ 3D Model
+ </Badge>
+ <Link
+ className="group-hover:opacity-100 opacity-0 transition-opacity duration-200 w-4 h-4 text-foreground"
+ to={path.to.file.cadModel(routeData?.modelUpload.autodeskUrn!)}
+ target="_blank"
+ >
+ <LuExternalLink />
+ </Link>
+ </HStack>
+ )}
+ {routeData?.files.map((file) => {
+ return <FileBadge key={file.id} file={file} itemId={itemId} />;
+ })}
+ </VStack>
</VStack>
);
};
diff --git a/apps/carbon/app/modules/items/ui/Item/FileBadge.tsx b/apps/carbon/app/modules/items/ui/Item/FileBadge.tsx
index 2504e95d84..cce53febb5 100644
--- a/apps/carbon/app/modules/items/ui/Item/FileBadge.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/FileBadge.tsx
@@ -16,22 +16,24 @@ export function FileBadge({ file, itemId, className }: FileBadgeProps) {
const type = getDocumentType(file.name);
return (
<HStack className="group" spacing={1}>
- <Badge variant="secondary" className={cn(className)}>
- <DocumentIcon type={type} className="w-3 h-3 mr-1" />
-
- {["PDF", "Image"].includes(type) ? (
- <DocumentPreview
- bucket="private"
- pathToFile={getPath(file)}
- // @ts-ignore
- type={type}
- >
+ {["PDF", "Image"].includes(type) ? (
+ <DocumentPreview
+ bucket="private"
+ pathToFile={getPath(file)}
+ // @ts-ignore
+ type={type}
+ >
+ <Badge variant="secondary" className={cn("max-w-[240px]", className)}>
+ <DocumentIcon type={type} className="flex-shrink-0 w-3 h-3 mr-1" />
{file.name}
- </DocumentPreview>
- ) : (
- file.name
- )}
- </Badge>
+ </Badge>
+ </DocumentPreview>
+ ) : (
+ <Badge variant="secondary" className={cn("max-w-[240px]", className)}>
+ <DocumentIcon type={type} className="flex-shrink-0 w-3 h-3 mr-1" />
+ {file.name}
+ </Badge>
+ )}
<LuDownload
onClick={() => download(file)}
diff --git a/apps/carbon/app/modules/items/ui/Item/ItemDocuments/ItemDocuments.tsx b/apps/carbon/app/modules/items/ui/Item/ItemDocuments/ItemDocuments.tsx
index 79d4e201c7..fb7eec6fa2 100644
--- a/apps/carbon/app/modules/items/ui/Item/ItemDocuments/ItemDocuments.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/ItemDocuments/ItemDocuments.tsx
@@ -18,7 +18,6 @@ import {
Tr,
} from "@carbon/react";
import { convertKbToString } from "@carbon/utils";
-import { Outlet } from "@remix-run/react";
import { LuAxis3D } from "react-icons/lu";
import { MdMoreVert } from "react-icons/md";
import { DocumentPreview, Hyperlink } from "~/components";
@@ -46,43 +45,98 @@ const ItemDocuments = ({
});
return (
- <>
- <Card>
- <HStack className="justify-between items-start">
- <CardHeader>
- <CardTitle>Files</CardTitle>
- </CardHeader>
- <CardAction>
- <ItemDocumentForm type={type} itemId={itemId} />
- </CardAction>
- </HStack>
- <CardContent>
- <Table>
- <Thead>
- <Tr>
- <Th>Name</Th>
- <Th>Size</Th>
+ <Card className="flex-grow">
+ <HStack className="justify-between items-start">
+ <CardHeader>
+ <CardTitle>Files</CardTitle>
+ </CardHeader>
+ <CardAction>
+ <ItemDocumentForm type={type} itemId={itemId} />
+ </CardAction>
+ </HStack>
+ <CardContent>
+ <Table>
+ <Thead>
+ <Tr>
+ <Th>Name</Th>
+ <Th>Size</Th>
- <Th></Th>
+ <Th></Th>
+ </Tr>
+ </Thead>
+ <Tbody>
+ {modelUpload && (
+ <Tr>
+ <Td>
+ <HStack>
+ <LuAxis3D className="text-green-500 w-6 h-6" />
+ <Hyperlink
+ target="_blank"
+ onClick={() => viewModel(modelUpload)}
+ >
+ {modelUpload.name}
+ </Hyperlink>
+ </HStack>
+ </Td>
+ <Td>
+ {convertKbToString(
+ Math.floor((modelUpload.size ?? 0) / 1024)
+ )}
+ </Td>
+ <Td>
+ <div className="flex justify-end w-full">
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ aria-label="More"
+ icon={<MdMoreVert />}
+ variant="secondary"
+ />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent>
+ <DropdownMenuItem
+ onClick={() => viewModel(modelUpload)}
+ >
+ View
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ disabled={!canDelete}
+ onClick={() => deleteModel(modelUpload)}
+ >
+ Delete
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </Td>
</Tr>
- </Thead>
- <Tbody>
- {modelUpload && (
- <Tr>
+ )}
+ {files.map((file) => {
+ const type = getDocumentType(file.name);
+ return (
+ <Tr key={file.id}>
<Td>
<HStack>
- <LuAxis3D className="text-green-500 w-6 h-6" />
- <Hyperlink
- target="_blank"
- onClick={() => viewModel(modelUpload)}
- >
- {modelUpload.name}
+ <DocumentIcon type={type} />
+ <Hyperlink onClick={() => download(file)}>
+ {["PDF", "Image"].includes(type) ? (
+ <DocumentPreview
+ bucket="private"
+ pathToFile={getPath(file)}
+ // @ts-ignore
+ type={type}
+ >
+ {file.name}
+ </DocumentPreview>
+ ) : (
+ file.name
+ )}
</Hyperlink>
</HStack>
</Td>
<Td>
{convertKbToString(
- Math.floor((modelUpload.size ?? 0) / 1024)
+ Math.floor((file.metadata?.size ?? 0) / 1024)
)}
</Td>
<Td>
@@ -96,14 +150,12 @@ const ItemDocuments = ({
/>
</DropdownMenuTrigger>
<DropdownMenuContent>
- <DropdownMenuItem
- onClick={() => viewModel(modelUpload)}
- >
- View
+ <DropdownMenuItem onClick={() => download(file)}>
+ Download
</DropdownMenuItem>
<DropdownMenuItem
disabled={!canDelete}
- onClick={() => deleteModel(modelUpload)}
+ onClick={() => deleteFile(file)}
>
Delete
</DropdownMenuItem>
@@ -112,79 +164,22 @@ const ItemDocuments = ({
</div>
</Td>
</Tr>
- )}
- {files.length ? (
- files.map((file) => {
- const type = getDocumentType(file.name);
- return (
- <Tr key={file.id}>
- <Td>
- <HStack>
- <DocumentIcon type={type} />
- <Hyperlink onClick={() => download(file)}>
- {["PDF", "Image"].includes(type) ? (
- <DocumentPreview
- bucket="private"
- pathToFile={getPath(file)}
- // @ts-ignore
- type={type}
- >
- {file.name}
- </DocumentPreview>
- ) : (
- file.name
- )}
- </Hyperlink>
- </HStack>
- </Td>
- <Td>
- {convertKbToString(
- Math.floor((file.metadata?.size ?? 0) / 1024)
- )}
- </Td>
- <Td>
- <div className="flex justify-end w-full">
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <IconButton
- aria-label="More"
- icon={<MdMoreVert />}
- variant="secondary"
- />
- </DropdownMenuTrigger>
- <DropdownMenuContent>
- <DropdownMenuItem onClick={() => download(file)}>
- Download
- </DropdownMenuItem>
- <DropdownMenuItem
- disabled={!canDelete}
- onClick={() => deleteFile(file)}
- >
- Delete
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
- </Td>
- </Tr>
- );
- })
- ) : (
- <Tr>
- <Td
- colSpan={24}
- className="py-8 text-muted-foreground text-center"
- >
- No files
- </Td>
- </Tr>
- )}
- </Tbody>
- </Table>
- </CardContent>
- </Card>
- <Outlet />
- </>
+ );
+ })}
+ {files.length === 0 && !modelUpload && (
+ <Tr>
+ <Td
+ colSpan={24}
+ className="py-8 text-muted-foreground text-center"
+ >
+ No files
+ </Td>
+ </Tr>
+ )}
+ </Tbody>
+ </Table>
+ </CardContent>
+ </Card>
);
};
diff --git a/apps/carbon/app/modules/items/ui/Item/index.ts b/apps/carbon/app/modules/items/ui/Item/index.ts
index ea9fdf0747..cfd999234d 100644
--- a/apps/carbon/app/modules/items/ui/Item/index.ts
+++ b/apps/carbon/app/modules/items/ui/Item/index.ts
@@ -6,6 +6,7 @@ import BuyMethods from "./BuyMethods";
import CadModel from "./CadModel";
import { FileBadge } from "./FileBadge";
import ItemCostingForm from "./ItemCostingForm";
+import ItemDocuments from "./ItemDocuments";
import ItemForm from "./ItemForm";
import ItemPlanningForm from "./ItemPlanningForm";
import ItemPurchasingForm from "./ItemPurchasingForm";
@@ -22,6 +23,7 @@ export {
CadModel,
FileBadge,
ItemCostingForm,
+ ItemDocuments,
ItemForm,
ItemPlanningForm,
ItemPurchasingForm,
diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialHeader.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialHeader.tsx
index bc0bb19b6a..101c99da3f 100644
--- a/apps/carbon/app/modules/items/ui/Materials/MaterialHeader.tsx
+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialHeader.tsx
@@ -17,7 +17,7 @@ const MaterialHeader = () => {
);
return (
- <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card">
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border">
<VStack spacing={0} className="flex-grow">
<HStack>
<Heading size="h2">{routeData?.materialSummary?.id}</Heading>
diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx
index f43ee8780a..dce075fd1c 100644
--- a/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx
+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx
@@ -16,8 +16,8 @@ import Assignee from "~/components/Assignee";
import { useRouteData } from "~/hooks";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
-import type { BuyMethod, Material, PickMethod } from "../../types";
-import { MethodIcon, TrackingTypeIcon } from "../Item";
+import type { BuyMethod, ItemFile, Material, PickMethod } from "../../types";
+import { FileBadge, MethodIcon, TrackingTypeIcon } from "../Item";
import { MethodBadge } from "../Item/MethodBadge";
const MaterialProperties = () => {
@@ -29,6 +29,7 @@ const MaterialProperties = () => {
);
const routeData = useRouteData<{
materialSummary: Material;
+ files: ItemFile[];
buyMethods: BuyMethod[];
pickMethods: PickMethod[];
}>(path.to.material(itemId));
@@ -153,14 +154,16 @@ const MaterialProperties = () => {
<HStack className="w-full justify-between">
<h3 className="text-xs text-muted-foreground">Methods</h3>
</HStack>
- {buyMethods.map((method) => (
- <MethodBadge
- key={method.id}
- type="Buy"
- text={method?.supplier?.name ?? ""}
- to={path.to.materialPurchasing(itemId)}
- />
- ))}
+
+ {routeData?.materialSummary?.replenishmentSystem?.includes("Buy") &&
+ buyMethods.map((method) => (
+ <MethodBadge
+ key={method.id}
+ type="Buy"
+ text={method?.supplier?.name ?? ""}
+ to={path.to.partPurchasing(itemId)}
+ />
+ ))}
{pickMethods.map((method) => (
<MethodBadge
key={method.locationId}
@@ -170,10 +173,20 @@ const MaterialProperties = () => {
locations.find((l) => l.id === method.locationId)?.name ??
""
}
- to={path.to.materialInventoryLocation(itemId, method.locationId)}
+ to={path.to.partInventoryLocation(itemId, method.locationId)}
/>
))}
</VStack>
+
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">Files</h3>
+ </HStack>
+
+ {routeData?.files.map((file) => {
+ return <FileBadge key={file.id} file={file} itemId={itemId} />;
+ })}
+ </VStack>
</VStack>
);
};
diff --git a/apps/carbon/app/modules/items/ui/Parts/PartHeader.tsx b/apps/carbon/app/modules/items/ui/Parts/PartHeader.tsx
index 7cb18928de..45154c7464 100644
--- a/apps/carbon/app/modules/items/ui/Parts/PartHeader.tsx
+++ b/apps/carbon/app/modules/items/ui/Parts/PartHeader.tsx
@@ -17,7 +17,7 @@ const PartHeader = () => {
);
return (
- <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card">
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border">
<VStack spacing={0} className="flex-grow">
<HStack>
<Heading size="h2">{routeData?.partSummary?.id}</Heading>
diff --git a/apps/carbon/app/modules/items/ui/Services/ServiceHeader.tsx b/apps/carbon/app/modules/items/ui/Services/ServiceHeader.tsx
index 80e597d2d5..5b79fc5c8a 100644
--- a/apps/carbon/app/modules/items/ui/Services/ServiceHeader.tsx
+++ b/apps/carbon/app/modules/items/ui/Services/ServiceHeader.tsx
@@ -18,7 +18,7 @@ const ServiceHeader = () => {
);
return (
- <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card">
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border">
<VStack spacing={0} className="flex-grow">
<HStack>
<Heading size="h2">{routeData?.service?.id}</Heading>
diff --git a/apps/carbon/app/modules/items/ui/Services/ServiceProperties.tsx b/apps/carbon/app/modules/items/ui/Services/ServiceProperties.tsx
index 39206a4a47..07acc188e3 100644
--- a/apps/carbon/app/modules/items/ui/Services/ServiceProperties.tsx
+++ b/apps/carbon/app/modules/items/ui/Services/ServiceProperties.tsx
@@ -15,8 +15,8 @@ import { useOptimisticAssignment } from "~/components";
import Assignee from "~/components/Assignee";
import { useRouteData } from "~/hooks";
import { path } from "~/utils/path";
-import type { BuyMethod, PickMethod, Service } from "../../types";
-import { MethodIcon } from "../Item";
+import type { BuyMethod, ItemFile, PickMethod, Service } from "../../types";
+import { FileBadge, MethodIcon } from "../Item";
import { MethodBadge } from "../Item/MethodBadge";
const ServiceProperties = () => {
@@ -25,6 +25,7 @@ const ServiceProperties = () => {
const routeData = useRouteData<{
service: Service;
+ files: ItemFile[];
buyMethods: BuyMethod[];
pickMethods: PickMethod[];
}>(path.to.service(itemId));
@@ -119,14 +120,26 @@ const ServiceProperties = () => {
<HStack className="w-full justify-between">
<h3 className="text-xs text-muted-foreground">Methods</h3>
</HStack>
- {buyMethods.map((method) => (
- <MethodBadge
- key={method.id}
- type="Buy"
- text={method?.supplier?.name ?? ""}
- to={path.to.servicePurchasing(itemId)}
- />
- ))}
+
+ {routeData?.service?.replenishmentSystem?.includes("Buy") &&
+ buyMethods.map((method) => (
+ <MethodBadge
+ key={method.id}
+ type="Buy"
+ text={method?.supplier?.name ?? ""}
+ to={path.to.partPurchasing(itemId)}
+ />
+ ))}
+ </VStack>
+
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">Files</h3>
+ </HStack>
+
+ {routeData?.files.map((file) => {
+ return <FileBadge key={file.id} file={file} itemId={itemId} />;
+ })}
</VStack>
</VStack>
);
diff --git a/apps/carbon/app/modules/items/ui/Tools/ToolHeader.tsx b/apps/carbon/app/modules/items/ui/Tools/ToolHeader.tsx
index 8cd57fc3db..b262e27402 100644
--- a/apps/carbon/app/modules/items/ui/Tools/ToolHeader.tsx
+++ b/apps/carbon/app/modules/items/ui/Tools/ToolHeader.tsx
@@ -15,7 +15,7 @@ const ToolHeader = () => {
const routeData = useRouteData<{ toolSummary: Tool }>(path.to.tool(itemId));
return (
- <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card">
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border">
<VStack spacing={0} className="flex-grow">
<HStack>
<Heading size="h2">{routeData?.toolSummary?.id}</Heading>
diff --git a/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx b/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx
index f35f35df13..6a3be7791d 100644
--- a/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx
+++ b/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx
@@ -16,8 +16,8 @@ import Assignee from "~/components/Assignee";
import { useRouteData } from "~/hooks";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
-import type { BuyMethod, PickMethod, Tool } from "../../types";
-import { MethodIcon, TrackingTypeIcon } from "../Item";
+import type { BuyMethod, ItemFile, PickMethod, Tool } from "../../types";
+import { FileBadge, MethodIcon, TrackingTypeIcon } from "../Item";
import { MethodBadge } from "../Item/MethodBadge";
const ToolProperties = () => {
@@ -29,6 +29,7 @@ const ToolProperties = () => {
);
const routeData = useRouteData<{
toolSummary: Tool;
+ files: ItemFile[];
buyMethods: BuyMethod[];
pickMethods: PickMethod[];
}>(path.to.tool(itemId));
@@ -141,14 +142,16 @@ const ToolProperties = () => {
<HStack className="w-full justify-between">
<h3 className="text-xs text-muted-foreground">Methods</h3>
</HStack>
- {buyMethods.map((method) => (
- <MethodBadge
- key={method.id}
- type="Buy"
- text={method?.supplier?.name ?? ""}
- to={path.to.toolPurchasing(itemId)}
- />
- ))}
+
+ {routeData?.toolSummary?.replenishmentSystem?.includes("Buy") &&
+ buyMethods.map((method) => (
+ <MethodBadge
+ key={method.id}
+ type="Buy"
+ text={method?.supplier?.name ?? ""}
+ to={path.to.partPurchasing(itemId)}
+ />
+ ))}
{pickMethods.map((method) => (
<MethodBadge
key={method.locationId}
@@ -158,10 +161,20 @@ const ToolProperties = () => {
locations.find((l) => l.id === method.locationId)?.name ??
""
}
- to={path.to.toolInventoryLocation(itemId, method.locationId)}
+ to={path.to.partInventoryLocation(itemId, method.locationId)}
/>
))}
</VStack>
+
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">Files</h3>
+ </HStack>
+
+ {routeData?.files.map((file) => {
+ return <FileBadge key={file.id} file={file} itemId={itemId} />;
+ })}
+ </VStack>
</VStack>
);
};
diff --git a/apps/carbon/app/modules/shared/ui/CadModelUpload.tsx b/apps/carbon/app/modules/shared/ui/CadModelUpload.tsx
index 3af6077073..ac1a35b6d8 100644
--- a/apps/carbon/app/modules/shared/ui/CadModelUpload.tsx
+++ b/apps/carbon/app/modules/shared/ui/CadModelUpload.tsx
@@ -64,7 +64,7 @@ const CadModelUpload = ({ file, onFileChange }: CadModelUploadProps) => {
<div
{...getRootProps()}
className={cn(
- "group flex flex-col flex-grow rounded-lg border border-border bg-gradient-to-bl from-card to-background text-card-foreground shadow-sm w-full",
+ "group flex flex-col flex-grow rounded-lg border border-border bg-gradient-to-tr from-background to-card text-card-foreground shadow-sm w-full",
!hasFile &&
"cursor-pointer hover:border-primary/30 hover:border-dashed hover:to-primary/10 hover:via-card"
)}
diff --git a/apps/carbon/app/routes/x+/consumable+/$itemId.details.tsx b/apps/carbon/app/routes/x+/consumable+/$itemId.details.tsx
index 393bd8652e..3fcb494945 100644
--- a/apps/carbon/app/routes/x+/consumable+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/consumable+/$itemId.details.tsx
@@ -3,10 +3,11 @@ import { validationError, validator } from "@carbon/remix-validated-form";
import type { ActionFunctionArgs } from "@remix-run/node";
import { redirect } from "@remix-run/node";
import { useParams } from "@remix-run/react";
-import { useRouteData } from "~/hooks";
-import type { Consumable } from "~/modules/items";
+import { usePermissions, useRouteData } from "~/hooks";
+import type { Consumable, ItemFile } from "~/modules/items";
import {
ConsumableForm,
+ ItemDocuments,
consumableValidator,
upsertConsumable,
} from "~/modules/items";
@@ -56,11 +57,15 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
export default function ConsumableDetailsRoute() {
+ const permissions = usePermissions();
+
const { itemId } = useParams();
if (!itemId) throw new Error("Could not find itemId");
- const consumableData = useRouteData<{ consumableSummary: Consumable }>(
- path.to.consumable(itemId)
- );
+
+ const consumableData = useRouteData<{
+ consumableSummary: Consumable;
+ files: ItemFile[];
+ }>(path.to.consumable(itemId));
if (!consumableData) throw new Error("Could not find consumable data");
const consumableInitialValues = {
@@ -81,11 +86,18 @@ export default function ConsumableDetailsRoute() {
};
return (
- <VStack spacing={4}>
+ <VStack spacing={2} className="w-full h-full">
<ConsumableForm
key={consumableInitialValues.id}
initialValues={consumableInitialValues}
/>
+ {permissions.is("employee") && (
+ <ItemDocuments
+ files={consumableData?.files ?? []}
+ itemId={itemId}
+ type="Consumable"
+ />
+ )}
</VStack>
);
}
diff --git a/apps/carbon/app/routes/x+/consumable+/$itemId.tsx b/apps/carbon/app/routes/x+/consumable+/$itemId.tsx
index aed7b8c6e4..d6ae7e6f0d 100644
--- a/apps/carbon/app/routes/x+/consumable+/$itemId.tsx
+++ b/apps/carbon/app/routes/x+/consumable+/$itemId.tsx
@@ -7,6 +7,7 @@ import {
ConsumableProperties,
getBuyMethods,
getConsumable,
+ getItemFiles,
getPickMethods,
} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
@@ -29,11 +30,14 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const [consumableSummary, buyMethods, pickMethods] = await Promise.all([
- getConsumable(client, itemId, companyId),
- getBuyMethods(client, itemId, companyId),
- getPickMethods(client, itemId, companyId),
- ]);
+ const [consumableSummary, files, buyMethods, pickMethods] = await Promise.all(
+ [
+ getConsumable(client, itemId, companyId),
+ getItemFiles(client, itemId, companyId),
+ getBuyMethods(client, itemId, companyId),
+ getPickMethods(client, itemId, companyId),
+ ]
+ );
if (consumableSummary.error) {
throw redirect(
@@ -47,6 +51,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return json({
consumableSummary: consumableSummary.data,
+ files: files.data ?? [],
buyMethods: buyMethods.data ?? [],
pickMethods: pickMethods.data ?? [],
});
@@ -58,7 +63,7 @@ export default function ConsumableRoute() {
<ConsumableHeader />
<div className="flex h-[calc(100vh-99px)] w-full">
<div className="flex h-full w-full overflow-y-auto">
- <VStack spacing={2} className="p-2">
+ <VStack spacing={2} className="p-2 w-full h-full">
<Outlet />
</VStack>
</div>
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx
index 861a5394e2..d5c1ba4159 100644
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/fixture+/$itemId.details.tsx
@@ -3,9 +3,15 @@ import { validationError, validator } from "@carbon/remix-validated-form";
import type { ActionFunctionArgs } from "@remix-run/node";
import { redirect } from "@remix-run/node";
import { useParams } from "@remix-run/react";
-import { useRouteData } from "~/hooks";
-import type { Fixture } from "~/modules/items";
-import { FixtureForm, fixtureValidator, upsertFixture } from "~/modules/items";
+import { usePermissions, useRouteData } from "~/hooks";
+import type { Fixture, ItemFile, ModelUpload } from "~/modules/items";
+import {
+ CadModel,
+ FixtureForm,
+ ItemDocuments,
+ fixtureValidator,
+ upsertFixture,
+} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import { getCustomFields, setCustomFields } from "~/utils/form";
@@ -52,11 +58,16 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
export default function FixtureDetailsRoute() {
+ const permissions = usePermissions();
+
const { itemId } = useParams();
if (!itemId) throw new Error("Could not find itemId");
- const fixtureData = useRouteData<{ fixtureSummary: Fixture }>(
- path.to.fixture(itemId)
- );
+
+ const fixtureData = useRouteData<{
+ fixtureSummary: Fixture;
+ modelUpload?: ModelUpload;
+ files: ItemFile[];
+ }>(path.to.fixture(itemId));
if (!fixtureData) throw new Error("Could not find fixture data");
const fixtureInitialValues = {
@@ -81,6 +92,19 @@ export default function FixtureDetailsRoute() {
key={fixtureInitialValues.id}
initialValues={fixtureInitialValues}
/>
+ {permissions.is("employee") && (
+ <div className="grid grid-cols-1 md:grid-cols-2 w-full flex-grow gap-2">
+ <CadModel
+ autodeskUrn={fixtureData?.modelUpload?.autodeskUrn ?? null}
+ />
+ <ItemDocuments
+ files={fixtureData?.files ?? []}
+ modelUpload={fixtureData.modelUpload}
+ itemId={itemId}
+ type="Fixture"
+ />
+ </div>
+ )}
</VStack>
);
}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.tsx
index fe49041d57..8675b4aaa4 100644
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.tsx
+++ b/apps/carbon/app/routes/x+/fixture+/$itemId.tsx
@@ -6,6 +6,8 @@ import {
FixtureProperties,
getBuyMethods,
getFixture,
+ getItemFiles,
+ getModelUploadByItemId,
getPickMethods,
} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
@@ -27,11 +29,14 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const [fixtureSummary, buyMethods, pickMethods] = await Promise.all([
- getFixture(client, itemId, companyId),
- getBuyMethods(client, itemId, companyId),
- getPickMethods(client, itemId, companyId),
- ]);
+ const [fixtureSummary, files, modelUpload, buyMethods, pickMethods] =
+ await Promise.all([
+ getFixture(client, itemId, companyId),
+ getItemFiles(client, itemId, companyId),
+ getModelUploadByItemId(client, itemId, companyId),
+ getBuyMethods(client, itemId, companyId),
+ getPickMethods(client, itemId, companyId),
+ ]);
if (fixtureSummary.error) {
throw redirect(
@@ -45,6 +50,8 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return json({
fixtureSummary: fixtureSummary.data,
+ files: files.data ?? [],
+ modelUpload: modelUpload.data,
buyMethods: buyMethods.data ?? [],
pickMethods: pickMethods.data ?? [],
});
diff --git a/apps/carbon/app/routes/x+/material+/$itemId.details.tsx b/apps/carbon/app/routes/x+/material+/$itemId.details.tsx
index 6e36e5f28f..bd06d929b3 100644
--- a/apps/carbon/app/routes/x+/material+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/material+/$itemId.details.tsx
@@ -3,9 +3,10 @@ import { validationError, validator } from "@carbon/remix-validated-form";
import type { ActionFunctionArgs } from "@remix-run/node";
import { redirect } from "@remix-run/node";
import { useParams } from "@remix-run/react";
-import { useRouteData } from "~/hooks";
-import type { Material } from "~/modules/items";
+import { usePermissions, useRouteData } from "~/hooks";
+import type { ItemFile, Material } from "~/modules/items";
import {
+ ItemDocuments,
MaterialForm,
materialValidator,
upsertMaterial,
@@ -57,10 +58,14 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
export default function MaterialDetailsRoute() {
+ const permissions = usePermissions();
+
const { itemId } = useParams();
if (!itemId) throw new Error("Could not find itemId");
+
const materialData = useRouteData<{
materialSummary: Material;
+ files: ItemFile[];
forms: ListItem[];
substances: ListItem[];
}>(path.to.material(itemId));
@@ -89,11 +94,18 @@ export default function MaterialDetailsRoute() {
};
return (
- <VStack spacing={4}>
+ <VStack spacing={2} className="w-full h-full">
<MaterialForm
key={materialInitialValues.id}
initialValues={materialInitialValues}
/>
+ {permissions.is("employee") && (
+ <ItemDocuments
+ files={materialData?.files ?? []}
+ itemId={itemId}
+ type="Material"
+ />
+ )}
</VStack>
);
}
diff --git a/apps/carbon/app/routes/x+/material+/$itemId.tsx b/apps/carbon/app/routes/x+/material+/$itemId.tsx
index 06cefc3bb6..43f2e43f8d 100644
--- a/apps/carbon/app/routes/x+/material+/$itemId.tsx
+++ b/apps/carbon/app/routes/x+/material+/$itemId.tsx
@@ -6,6 +6,7 @@ import {
MaterialHeader,
MaterialProperties,
getBuyMethods,
+ getItemFiles,
getMaterial,
getPickMethods,
} from "~/modules/items";
@@ -29,8 +30,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const [materialSummary, buyMethods, pickMethods] = await Promise.all([
+ const [materialSummary, files, buyMethods, pickMethods] = await Promise.all([
getMaterial(client, itemId, companyId),
+ getItemFiles(client, itemId, companyId),
getBuyMethods(client, itemId, companyId),
getPickMethods(client, itemId, companyId),
]);
@@ -47,6 +49,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return json({
materialSummary: materialSummary.data,
+ files: files.data ?? [],
buyMethods: buyMethods.data ?? [],
pickMethods: pickMethods.data ?? [],
});
@@ -58,7 +61,7 @@ export default function MaterialRoute() {
<MaterialHeader />
<div className="flex h-[calc(100vh-99px)] w-full">
<div className="flex h-full w-full overflow-y-auto">
- <VStack spacing={2} className="p-2">
+ <VStack spacing={2} className="p-2 w-full h-full">
<Outlet />
</VStack>
</div>
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.details.tsx b/apps/carbon/app/routes/x+/part+/$itemId.details.tsx
index c817d290a1..9f77a65348 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.details.tsx
@@ -5,8 +5,13 @@ import { redirect } from "@remix-run/node";
import { useParams } from "@remix-run/react";
import { usePermissions, useRouteData } from "~/hooks";
import type { ItemFile, ModelUpload, PartSummary } from "~/modules/items";
-import { CadModel, PartForm, partValidator, upsertPart } from "~/modules/items";
-import ItemDocuments from "~/modules/items/ui/Item/ItemDocuments/ItemDocuments";
+import {
+ CadModel,
+ ItemDocuments,
+ PartForm,
+ partValidator,
+ upsertPart,
+} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import { getCustomFields, setCustomFields } from "~/utils/form";
diff --git a/apps/carbon/app/routes/x+/service+/$itemId.details.tsx b/apps/carbon/app/routes/x+/service+/$itemId.details.tsx
index 7c502652f4..97f35cd8ef 100644
--- a/apps/carbon/app/routes/x+/service+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/service+/$itemId.details.tsx
@@ -3,9 +3,14 @@ import { validationError, validator } from "@carbon/remix-validated-form";
import type { ActionFunctionArgs } from "@remix-run/node";
import { redirect } from "@remix-run/node";
import { useParams } from "@remix-run/react";
-import { useRouteData } from "~/hooks";
-import type { Service } from "~/modules/items";
-import { ServiceForm, serviceValidator, upsertService } from "~/modules/items";
+import { usePermissions, useRouteData } from "~/hooks";
+import type { ItemFile, Service } from "~/modules/items";
+import {
+ ItemDocuments,
+ ServiceForm,
+ serviceValidator,
+ upsertService,
+} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import { getCustomFields, setCustomFields } from "~/utils/form";
@@ -50,9 +55,14 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
export default function ServiceDetailsRoute() {
+ const permissions = usePermissions();
+
const { itemId } = useParams();
if (!itemId) throw new Error("Could not find itemId");
- const routeData = useRouteData<{ service: Service }>(path.to.service(itemId));
+
+ const routeData = useRouteData<{ service: Service; files: ItemFile[] }>(
+ path.to.service(itemId)
+ );
if (!routeData) throw new Error("Could not find part data");
const serviceInitialValues = {
@@ -69,11 +79,18 @@ export default function ServiceDetailsRoute() {
};
return (
- <VStack spacing={4}>
+ <VStack spacing={2} className="w-full h-full">
<ServiceForm
key={serviceInitialValues.id}
initialValues={serviceInitialValues}
/>
+ {permissions.is("employee") && (
+ <ItemDocuments
+ files={routeData?.files ?? []}
+ itemId={itemId}
+ type="Material"
+ />
+ )}
</VStack>
);
}
diff --git a/apps/carbon/app/routes/x+/service+/$itemId.tsx b/apps/carbon/app/routes/x+/service+/$itemId.tsx
index 71c65c3358..42de805aaa 100644
--- a/apps/carbon/app/routes/x+/service+/$itemId.tsx
+++ b/apps/carbon/app/routes/x+/service+/$itemId.tsx
@@ -6,6 +6,7 @@ import {
ServiceHeader,
ServiceProperties,
getBuyMethods,
+ getItemFiles,
getPickMethods,
getService,
} from "~/modules/items";
@@ -28,8 +29,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const [service, buyMethods, pickMethods] = await Promise.all([
+ const [service, files, buyMethods, pickMethods] = await Promise.all([
getService(client, itemId, companyId),
+ getItemFiles(client, itemId, companyId),
getBuyMethods(client, itemId, companyId),
getPickMethods(client, itemId, companyId),
]);
@@ -43,6 +45,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return json({
service: service.data,
+ files: files.data ?? [],
buyMethods: buyMethods.data ?? [],
pickMethods: pickMethods.data ?? [],
});
@@ -54,7 +57,7 @@ export default function ServiceRoute() {
<ServiceHeader />
<div className="flex h-[calc(100vh-99px)] w-full">
<div className="flex h-full w-full overflow-y-auto">
- <VStack spacing={2} className="p-2">
+ <VStack spacing={2} className="p-2 w-full h-full">
<Outlet />
</VStack>
</div>
diff --git a/apps/carbon/app/routes/x+/tool+/$itemId.details.tsx b/apps/carbon/app/routes/x+/tool+/$itemId.details.tsx
index 4eccb4bb44..a85cafb4b1 100644
--- a/apps/carbon/app/routes/x+/tool+/$itemId.details.tsx
+++ b/apps/carbon/app/routes/x+/tool+/$itemId.details.tsx
@@ -3,9 +3,14 @@ import { validationError, validator } from "@carbon/remix-validated-form";
import type { ActionFunctionArgs } from "@remix-run/node";
import { redirect } from "@remix-run/node";
import { useParams } from "@remix-run/react";
-import { useRouteData } from "~/hooks";
-import type { ToolSummary } from "~/modules/items";
-import { ToolForm, toolValidator, upsertTool } from "~/modules/items";
+import { usePermissions, useRouteData } from "~/hooks";
+import type { ItemFile, ToolSummary } from "~/modules/items";
+import {
+ ItemDocuments,
+ ToolForm,
+ toolValidator,
+ upsertTool,
+} from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
import { getCustomFields, setCustomFields } from "~/utils/form";
@@ -49,11 +54,15 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
export default function ToolDetailsRoute() {
+ const permissions = usePermissions();
+
const { itemId } = useParams();
if (!itemId) throw new Error("Could not find itemId");
- const toolData = useRouteData<{ toolSummary: ToolSummary }>(
- path.to.tool(itemId)
- );
+
+ const toolData = useRouteData<{
+ toolSummary: ToolSummary;
+ files: ItemFile[];
+ }>(path.to.tool(itemId));
if (!toolData) throw new Error("Could not find tool data");
const toolInitialValues = {
@@ -70,8 +79,15 @@ export default function ToolDetailsRoute() {
};
return (
- <VStack spacing={4}>
+ <VStack spacing={2} className="w-full h-full">
<ToolForm key={toolInitialValues.id} initialValues={toolInitialValues} />
+ {permissions.is("employee") && (
+ <ItemDocuments
+ files={toolData?.files ?? []}
+ itemId={itemId}
+ type="Tool"
+ />
+ )}
</VStack>
);
}
diff --git a/apps/carbon/app/routes/x+/tool+/$itemId.tsx b/apps/carbon/app/routes/x+/tool+/$itemId.tsx
index 1b24a970d8..24765a1787 100644
--- a/apps/carbon/app/routes/x+/tool+/$itemId.tsx
+++ b/apps/carbon/app/routes/x+/tool+/$itemId.tsx
@@ -6,6 +6,7 @@ import {
ToolHeader,
ToolProperties,
getBuyMethods,
+ getItemFiles,
getPickMethods,
getTool,
} from "~/modules/items";
@@ -29,8 +30,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const [toolSummary, buyMethods, pickMethods] = await Promise.all([
+ const [toolSummary, files, buyMethods, pickMethods] = await Promise.all([
getTool(client, itemId, companyId),
+ getItemFiles(client, itemId, companyId),
getBuyMethods(client, itemId, companyId),
getPickMethods(client, itemId, companyId),
]);
@@ -47,6 +49,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return json({
toolSummary: toolSummary.data,
+ files: files.data ?? [],
buyMethods: buyMethods.data ?? [],
pickMethods: pickMethods.data ?? [],
});
@@ -58,7 +61,7 @@ export default function ToolRoute() {
<ToolHeader />
<div className="flex h-[calc(100vh-99px)] w-full">
<div className="flex h-full w-full overflow-y-auto">
- <VStack spacing={2} className="p-2">
+ <VStack spacing={2} className="p-2 w-full h-full">
<Outlet />
</VStack>
</div>