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.

type fixes

Gaurav Bhatt4fbb8cfe4766
diff --git a/apps/erp/app/components/CompanyDefaultAttachmentsCard.tsx b/apps/erp/app/components/CompanyDefaultAttachmentsCard.tsx
index 78f25869ef..64937f39f0 100644
--- a/apps/erp/app/components/CompanyDefaultAttachmentsCard.tsx
+++ b/apps/erp/app/components/CompanyDefaultAttachmentsCard.tsx
@@ -1,10 +1,9 @@
import { Trans } from "@lingui/react/macro";
-import DefaultAttachmentsPanel, {
- type StorageFile
-} from "./DefaultAttachmentsPanel";
+import type { FileObject } from "@supabase/storage-js";
+import DefaultAttachmentsPanel from "./DefaultAttachmentsPanel";
type Props = {
- files: StorageFile[];
+ files: FileObject[];
};
export default function CompanyDefaultAttachmentsCard({ files }: Props) {
diff --git a/apps/erp/app/components/DefaultAttachmentsPanel.tsx b/apps/erp/app/components/DefaultAttachmentsPanel.tsx
index 5646e7aa3a..42531ef244 100644
--- a/apps/erp/app/components/DefaultAttachmentsPanel.tsx
+++ b/apps/erp/app/components/DefaultAttachmentsPanel.tsx
@@ -22,6 +22,7 @@ import {
} from "@carbon/react";
import { convertKbToString } from "@carbon/utils";
import { Trans, useLingui } from "@lingui/react/macro";
+import type { FileObject } from "@supabase/storage-js";
import type { ReactNode } from "react";
import { useCallback, useState } from "react";
import { LuDownload, LuEllipsisVertical, LuTrash } from "react-icons/lu";
@@ -34,14 +35,8 @@ import { getDocumentType } from "~/modules/shared";
import { path } from "~/utils/path";
import { stripSpecialCharacters } from "~/utils/string";
-export type StorageFile = {
- name: string;
- created_at?: string | null;
- metadata?: { size?: number } | null;
-};
-
type Props = {
- files: StorageFile[];
+ files: FileObject[];
storagePathPrefix: string;
title: ReactNode;
description: ReactNode;
@@ -62,8 +57,10 @@ export default function DefaultAttachmentsPanel({
const revalidator = useRevalidator();
const [deletingPath, setDeletingPath] = useState<string | null>(null);
- const fullPath = (name: string) =>
- `${company.id}/${storagePathPrefix}/${name}`;
+ const fullPath = useCallback(
+ (name: string) => `${company.id}/${storagePathPrefix}/${name}`,
+ [company.id, storagePathPrefix]
+ );
const onDrop = useCallback(
async (acceptedFiles: File[]) => {
@@ -83,8 +80,7 @@ export default function DefaultAttachmentsPanel({
}
revalidator.revalidate();
},
- // eslint-disable-next-line react-hooks/exhaustive-deps
- [carbon, company.id, storagePathPrefix, revalidator, t]
+ [carbon, fullPath, revalidator, t]
);
const onDownload = useCallback(
@@ -106,8 +102,7 @@ export default function DefaultAttachmentsPanel({
console.error(err);
}
},
- // eslint-disable-next-line react-hooks/exhaustive-deps
- [company.id, storagePathPrefix, t]
+ [fullPath, t]
);
const onDelete = useCallback(
@@ -132,8 +127,7 @@ export default function DefaultAttachmentsPanel({
setDeletingPath(null);
}
},
- // eslint-disable-next-line react-hooks/exhaustive-deps
- [carbon, company.id, storagePathPrefix, revalidator, t]
+ [carbon, fullPath, revalidator, t]
);
return (
diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx
index 0f45a67d61..6a45734cf5 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader.tsx
@@ -35,6 +35,7 @@ import {
LuX
} from "react-icons/lu";
import { Link, useFetcher, useNavigation, useParams } from "react-router";
+import type { ResolvedAttachmentItem } from "~/components/AttachmentsList";
import { useAuditLog } from "~/components/AuditLog";
import { usePanels } from "~/components/Layout";
import ConfirmDelete from "~/components/Modals/ConfirmDelete";
@@ -78,6 +79,7 @@ const PurchaseOrderHeader = () => {
canDelete: boolean;
defaultCc: string[];
supplier: { status: string | null } | null;
+ resolvedAttachments: ResolvedAttachmentItem[];
}>(path.to.purchaseOrder(orderId));
const [suppliers] = useSuppliers();
diff --git a/apps/erp/app/routes/x+/part+/$itemId.details.tsx b/apps/erp/app/routes/x+/part+/$itemId.details.tsx
index 2a7e69372f..606952bdd2 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.details.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.details.tsx
@@ -14,9 +14,7 @@ import type {
} from "react-router";
import { Await, redirect, useLoaderData, useParams } from "react-router";
import { CadModel, DeferredFiles } from "~/components";
-import DefaultAttachmentsPanel, {
- type StorageFile
-} from "~/components/DefaultAttachmentsPanel";
+import DefaultAttachmentsPanel from "~/components/DefaultAttachmentsPanel";
import { usePermissions, useRouteData } from "~/hooks";
import type { ItemFile, MakeMethod, PartSummary } from "~/modules/items";
import {
@@ -340,7 +338,7 @@ export default function PartDetailsRoute() {
</DeferredFiles>
<DefaultAttachmentsPanel
- files={(defaultAttachments ?? []) as StorageFile[]}
+ files={defaultAttachments ?? []}
storagePathPrefix={`default-attachments/item/${itemId}`}
title={t`Default Attachments on Purchase Orders`}
description={t`Files attached here ride along whenever this item appears on a purchase order email.`}
diff --git a/apps/erp/app/routes/x+/supplier+/$supplierId.default-attachments.tsx b/apps/erp/app/routes/x+/supplier+/$supplierId.default-attachments.tsx
index b354896487..67b9b488b5 100644
--- a/apps/erp/app/routes/x+/supplier+/$supplierId.default-attachments.tsx
+++ b/apps/erp/app/routes/x+/supplier+/$supplierId.default-attachments.tsx
@@ -2,9 +2,7 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { Trans } from "@lingui/react/macro";
import type { LoaderFunctionArgs } from "react-router";
import { useLoaderData } from "react-router";
-import DefaultAttachmentsPanel, {
- type StorageFile
-} from "~/components/DefaultAttachmentsPanel";
+import DefaultAttachmentsPanel from "~/components/DefaultAttachmentsPanel";
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
@@ -19,7 +17,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return {
supplierId,
- files: (result.data ?? []) as StorageFile[]
+ files: result.data ?? []
};
}