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: delete parts, materials, etc.

Brad Barbin19b01c1438f0
diff --git a/apps/carbon/app/jobs.server/autodesk-poll.server.ts b/apps/carbon/app/jobs.server/autodesk-poll.server.ts
new file mode 100644
index 0000000000..459d97241e
--- /dev/null
+++ b/apps/carbon/app/jobs.server/autodesk-poll.server.ts
@@ -0,0 +1,65 @@
+import { eventTrigger } from "@trigger.dev/sdk";
+import { z } from "zod";
+import { getAutodeskToken, getManifest } from "~/lib/autodesk/autodesk.server";
+
+import { getSupabaseServiceRole } from "~/lib/supabase";
+import { triggerClient } from "~/lib/trigger.server";
+import { upsertModelUpload } from "~/modules/shared";
+
+const supabaseClient = getSupabaseServiceRole();
+
+const job = triggerClient.defineJob({
+ id: "autodesk-poll",
+ name: "Poll for completed file translation in Autodesk",
+ version: "0.0.1",
+ trigger: eventTrigger({
+ name: "autodesk.poll",
+ schema: z.object({
+ id: z.string(),
+ name: z.string(),
+ size: z.number(),
+ autodeskUrn: z.string(),
+ }),
+ }),
+
+ run: async (payload, io, ctx) => {
+ let success = false;
+
+ const { id, name, size, autodeskUrn } = payload;
+ setTimeout(async () => {
+ if (!success) {
+ // in case of a timeout -- we still want to record the upload
+ await upsertModelUpload(supabaseClient, {
+ id,
+ name,
+ size,
+ autodeskUrn,
+ });
+ }
+ }, 13000);
+
+ const token = await getAutodeskToken();
+ if (token.error) {
+ throw new Error("Failed to get Autodesk token: " + token.error.message);
+ }
+
+ const manifest = await getManifest(autodeskUrn, token.data.token);
+ if (manifest.error) {
+ throw new Error("Failed to get manifest: " + manifest.error.message);
+ }
+
+ success = true;
+ const modelRecord = await upsertModelUpload(supabaseClient, {
+ id,
+ name,
+ size,
+ autodeskUrn,
+ });
+
+ if (modelRecord.error) {
+ throw new Error("Failed to record upload: " + modelRecord.error.message);
+ }
+ },
+});
+
+export default job;
diff --git a/apps/carbon/app/jobs.server/upload-autodesk.server.ts b/apps/carbon/app/jobs.server/autodesk-upload.server.ts
similarity index 80%
rename from apps/carbon/app/jobs.server/upload-autodesk.server.ts
rename to apps/carbon/app/jobs.server/autodesk-upload.server.ts
index d25e56a34a..f449fed022 100644
--- a/apps/carbon/app/jobs.server/upload-autodesk.server.ts
+++ b/apps/carbon/app/jobs.server/autodesk-upload.server.ts
@@ -4,23 +4,21 @@ import {
finalizeAutodeskUpload,
getAutodeskSignedUrl,
getAutodeskToken,
- getManifest,
translateFile,
uploadToAutodesk,
} from "~/lib/autodesk/autodesk.server";
import { getSupabaseServiceRole } from "~/lib/supabase";
import { triggerClient } from "~/lib/trigger.server";
-import { upsertModelUpload } from "~/modules/shared";
const supabaseClient = getSupabaseServiceRole();
const job = triggerClient.defineJob({
- id: "upload-autodesk",
+ id: "autodesk-upload",
name: "Upload CAD Model to Autodesk",
version: "0.0.1",
trigger: eventTrigger({
- name: "upload.autodesk",
+ name: "autodesk.upload",
schema: z.object({
name: z.string(),
modelPath: z.string(),
@@ -75,21 +73,15 @@ const job = triggerClient.defineJob({
throw new Error("Failed to translate file: " + translation.error.message);
}
- const manifest = await getManifest(autodeskUrn, token);
- if (manifest.error) {
- throw new Error("Failed to get manifest: " + manifest.error.message);
- }
-
- const modelRecord = await upsertModelUpload(supabaseClient, {
- id: fileId,
- name,
- size: file.size,
- autodeskUrn,
+ triggerClient.sendEvent({
+ name: "autodesk.poll",
+ payload: {
+ id: fileId,
+ name,
+ size: file.size,
+ autodeskUrn,
+ },
});
-
- if (modelRecord.error) {
- throw new Error("Failed to record upload: " + modelRecord.error.message);
- }
},
});
diff --git a/apps/carbon/app/jobs.server/index.ts b/apps/carbon/app/jobs.server/index.ts
index 574c7fe401..a6ccfbf58a 100644
--- a/apps/carbon/app/jobs.server/index.ts
+++ b/apps/carbon/app/jobs.server/index.ts
@@ -1,15 +1,17 @@
+import autodeskPoll from "./autodesk-poll.server";
+import autodeskUpload from "./autodesk-upload.server";
import postTransaction from "./post-transaction.server";
import sendEmailResend from "./send-email-resend.server";
import updateExchangeRates from "./update-exchange-rates.server";
import updatePermissions from "./update-permissions.server";
-import uploadAutodesk from "./upload-autodesk.server";
import userAdminServer from "./user-admin.server";
export {
+ autodeskPoll,
+ autodeskUpload,
postTransaction,
sendEmailResend,
updateExchangeRates,
updatePermissions,
- uploadAutodesk,
userAdminServer,
};
diff --git a/apps/carbon/app/lib/autodesk/autodesk.server.ts b/apps/carbon/app/lib/autodesk/autodesk.server.ts
index a19a591311..aeb7601c3b 100644
--- a/apps/carbon/app/lib/autodesk/autodesk.server.ts
+++ b/apps/carbon/app/lib/autodesk/autodesk.server.ts
@@ -327,9 +327,6 @@ export async function translateFile(urn: string, token: string) {
type: "svf2",
views: ["3d"],
},
- {
- type: "thumbnail",
- },
],
},
};
diff --git a/apps/carbon/app/modules/items/items.service.ts b/apps/carbon/app/modules/items/items.service.ts
index ce5ace12a9..76f10cdd39 100644
--- a/apps/carbon/app/modules/items/items.service.ts
+++ b/apps/carbon/app/modules/items/items.service.ts
@@ -28,6 +28,10 @@ import type {
unitOfMeasureValidator,
} from "./items.models";
+export async function deleteItem(client: SupabaseClient<Database>, id: string) {
+ return client.from("item").update({ active: false }).eq("id", id);
+}
+
export async function deleteItemPostingGroup(
client: SupabaseClient<Database>,
id: string
@@ -110,6 +114,7 @@ export async function getConsumables(
.select("*", {
count: "exact",
})
+ .eq("active", true)
.eq("companyId", companyId);
if (args.search) {
@@ -168,6 +173,7 @@ export async function getFixtures(
.select("*", {
count: "exact",
})
+ .eq("active", true)
.eq("companyId", companyId);
if (args.search) {
@@ -376,6 +382,7 @@ export async function getMaterials(
.select("*", {
count: "exact",
})
+ .eq("active", true)
.or(`companyId.eq.${companyId},companyId.is.null`);
if (args.search) {
@@ -624,6 +631,7 @@ export async function getParts(
.select("*", {
count: "exact",
})
+ .eq("active", true)
.eq("companyId", companyId);
if (args.search) {
@@ -698,6 +706,7 @@ export async function getServices(
.select("*", {
count: "exact",
})
+ .eq("active", true)
.eq("companyId", companyId);
if (args.search) {
@@ -790,6 +799,7 @@ export async function getTools(
.select("*", {
count: "exact",
})
+ .eq("active", true)
.eq("companyId", companyId);
if (args.search) {
diff --git a/apps/carbon/app/modules/items/ui/Consumables/ConsumablesTable.tsx b/apps/carbon/app/modules/items/ui/Consumables/ConsumablesTable.tsx
index ee661701f4..3f8f96e59a 100644
--- a/apps/carbon/app/modules/items/ui/Consumables/ConsumablesTable.tsx
+++ b/apps/carbon/app/modules/items/ui/Consumables/ConsumablesTable.tsx
@@ -1,10 +1,17 @@
-import { Badge, Checkbox, MenuIcon, MenuItem } from "@carbon/react";
+import {
+ Badge,
+ Checkbox,
+ MenuIcon,
+ MenuItem,
+ useDisclosure,
+} from "@carbon/react";
import { formatDate } from "@carbon/utils";
import { useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
-import { memo, useMemo } from "react";
-import { LuPencil } from "react-icons/lu";
+import { memo, useMemo, useState } from "react";
+import { LuPencil, LuTrash } from "react-icons/lu";
import { EmployeeAvatar, Hyperlink, New, Table } from "~/components";
+import { ConfirmDelete } from "~/components/Modals";
import { usePermissions } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Consumable } from "~/modules/items";
@@ -29,6 +36,9 @@ const ConsumablesTable = memo(
const navigate = useNavigate();
const permissions = usePermissions();
+ const deleteItemModal = useDisclosure();
+ const [selectedItem, setSelectedItem] = useState<Consumable | null>(null);
+
const [people] = usePeople();
const customColumns = useCustomColumns<Consumable>("consumable");
@@ -184,12 +194,24 @@ const ConsumablesTable = memo(
const renderContextMenu = useMemo(() => {
// eslint-disable-next-line react/display-name
return (row: Consumable) => (
- <MenuItem onClick={() => navigate(path.to.consumable(row.itemId!))}>
- <MenuIcon icon={<LuPencil />} />
- Edit Consumable
- </MenuItem>
+ <>
+ <MenuItem onClick={() => navigate(path.to.consumable(row.itemId!))}>
+ <MenuIcon icon={<LuPencil />} />
+ Edit Consumable
+ </MenuItem>
+ <MenuItem
+ disabled={!permissions.can("delete", "parts")}
+ onClick={() => {
+ setSelectedItem(row);
+ deleteItemModal.onOpen();
+ }}
+ >
+ <MenuIcon icon={<LuTrash />} />
+ Delete Consumable
+ </MenuItem>
+ </>
);
- }, [navigate]);
+ }, [deleteItemModal, navigate, permissions]);
return (
<>
@@ -216,6 +238,22 @@ const ConsumablesTable = memo(
renderContextMenu={renderContextMenu}
withColumnOrdering
/>
+ {selectedItem && selectedItem.id && (
+ <ConfirmDelete
+ action={path.to.deleteItem(selectedItem.itemId!)}
+ isOpen={deleteItemModal.isOpen}
+ name={selectedItem.id!}
+ text={`Are you sure you want to delete ${selectedItem.id!}? This cannot be undone.`}
+ onCancel={() => {
+ deleteItemModal.onClose();
+ setSelectedItem(null);
+ }}
+ onSubmit={() => {
+ deleteItemModal.onClose();
+ setSelectedItem(null);
+ }}
+ />
+ )}
</>
);
}
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixturesTable.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixturesTable.tsx
index 436d43cdb2..ce0c38c2cf 100644
--- a/apps/carbon/app/modules/items/ui/Fixtures/FixturesTable.tsx
+++ b/apps/carbon/app/modules/items/ui/Fixtures/FixturesTable.tsx
@@ -1,9 +1,16 @@
-import { Badge, Checkbox, Enumerable, MenuIcon, MenuItem } from "@carbon/react";
+import {
+ Badge,
+ Checkbox,
+ Enumerable,
+ MenuIcon,
+ MenuItem,
+ useDisclosure,
+} from "@carbon/react";
import { formatDate } from "@carbon/utils";
import { useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
-import { memo, useMemo } from "react";
-import { LuPencil } from "react-icons/lu";
+import { memo, useMemo, useState } from "react";
+import { LuPencil, LuTrash } from "react-icons/lu";
import {
CustomerAvatar,
EmployeeAvatar,
@@ -11,6 +18,7 @@ import {
New,
Table,
} from "~/components";
+import { ConfirmDelete } from "~/components/Modals";
import { usePermissions } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Fixture } from "~/modules/items";
@@ -36,6 +44,9 @@ const FixturesTable = memo(
const navigate = useNavigate();
const permissions = usePermissions();
+ const deleteItemModal = useDisclosure();
+ const [selectedItem, setSelectedItem] = useState<Fixture | null>(null);
+
const [customers] = useCustomers();
const [people] = usePeople();
const customColumns = useCustomColumns<Fixture>("fixture");
@@ -223,12 +234,24 @@ const FixturesTable = memo(
const renderContextMenu = useMemo(() => {
// eslint-disable-next-line react/display-name
return (row: Fixture) => (
- <MenuItem onClick={() => navigate(path.to.fixture(row.itemId!))}>
- <MenuIcon icon={<LuPencil />} />
- Edit Fixture
- </MenuItem>
+ <>
+ <MenuItem onClick={() => navigate(path.to.fixture(row.itemId!))}>
+ <MenuIcon icon={<LuPencil />} />
+ Edit Fixture
+ </MenuItem>
+ <MenuItem
+ disabled={!permissions.can("delete", "parts")}
+ onClick={() => {
+ setSelectedItem(row);
+ deleteItemModal.onOpen();
+ }}
+ >
+ <MenuIcon icon={<LuTrash />} />
+ Delete Fixture
+ </MenuItem>
+ </>
);
- }, [navigate]);
+ }, [deleteItemModal, navigate, permissions]);
return (
<>
@@ -255,6 +278,22 @@ const FixturesTable = memo(
renderContextMenu={renderContextMenu}
withColumnOrdering
/>
+ {selectedItem && selectedItem.id && (
+ <ConfirmDelete
+ action={path.to.deleteItem(selectedItem.itemId!)}
+ isOpen={deleteItemModal.isOpen}
+ name={selectedItem.id!}
+ text={`Are you sure you want to delete ${selectedItem.id!}? This cannot be undone.`}
+ onCancel={() => {
+ deleteItemModal.onClose();
+ setSelectedItem(null);
+ }}
+ onSubmit={() => {
+ deleteItemModal.onClose();
+ setSelectedItem(null);
+ }}
+ />
+ )}
</>
);
}
diff --git a/apps/carbon/app/modules/items/ui/Item/CadModel.tsx b/apps/carbon/app/modules/items/ui/Item/CadModel.tsx
index 26d4462381..9987484d82 100644
--- a/apps/carbon/app/modules/items/ui/Item/CadModel.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/CadModel.tsx
@@ -1,4 +1,4 @@
-import { AutodeskViewer, ClientOnly, toast } from "@carbon/react";
+import { AutodeskViewer, ClientOnly, Spinner, toast } from "@carbon/react";
import { useFetcher, useParams } from "@remix-run/react";
import { nanoid } from "nanoid";
import { useEffect, useState } from "react";
@@ -66,7 +66,9 @@ const CadModel = ({ autodeskUrn, modelPath }: CadModelProps) => {
return (
<ClientOnly
fallback={
- <div className="w-full h-full rounded bg-gradient-to-tr from-[#979797] to-[#BEBEBE]" />
+ <div className="flex w-full h-full rounded bg-gradient-to-tr from-background to-card items-center justify-center">
+ <Spinner className="h-10 w-10" />
+ </div>
}
>
{() => {
diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialsTable.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialsTable.tsx
index 1fc8a192c2..d21a13f16e 100644
--- a/apps/carbon/app/modules/items/ui/Materials/MaterialsTable.tsx
+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialsTable.tsx
@@ -1,10 +1,18 @@
-import { Badge, Checkbox, Enumerable, MenuIcon, MenuItem } from "@carbon/react";
+import {
+ Badge,
+ Checkbox,
+ Enumerable,
+ MenuIcon,
+ MenuItem,
+ useDisclosure,
+} from "@carbon/react";
import { formatDate } from "@carbon/utils";
import { useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
-import { memo, useMemo } from "react";
-import { LuPencil } from "react-icons/lu";
+import { memo, useMemo, useState } from "react";
+import { LuPencil, LuTrash } from "react-icons/lu";
import { EmployeeAvatar, Hyperlink, New, Table } from "~/components";
+import { ConfirmDelete } from "~/components/Modals";
import { usePermissions } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Material } from "~/modules/items";
@@ -24,249 +32,275 @@ type MaterialsTableProps = {
count: number;
};
-const MaterialsTable = memo(
- ({ data, count, itemPostingGroups }: MaterialsTableProps) => {
- const navigate = useNavigate();
- const permissions = usePermissions();
+const MaterialsTable = memo(({ data, count }: MaterialsTableProps) => {
+ const navigate = useNavigate();
+ const permissions = usePermissions();
- const [people] = usePeople();
- const customColumns = useCustomColumns<Material>("material");
+ const deleteItemModal = useDisclosure();
+ const [selectedItem, setSelectedItem] = useState<Material | null>(null);
- const columns = useMemo<ColumnDef<Material>[]>(() => {
- const defaultColumns: ColumnDef<Material>[] = [
- {
- accessorKey: "id",
- header: "Material ID",
- cell: ({ row }) => (
- <Hyperlink to={path.to.materialDetails(row.original.itemId!)}>
- {row.original.id}
- </Hyperlink>
- ),
- },
- {
- accessorKey: "name",
- header: "Name",
- cell: (item) => item.getValue(),
- },
- {
- accessorKey: "description",
- header: "Description",
- cell: (item) => item.getValue(),
- },
- {
- accessorKey: "materialSubstance",
- header: "Substance",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
- meta: {
- filter: {
- type: "fetcher",
- endpoint: path.to.api.materialSubstances,
- transform: (data: { id: string; name: string }[] | null) =>
- data?.map(({ name }) => ({
- value: name,
- label: <Enumerable value={name} />,
- })) ?? [],
- },
+ const [people] = usePeople();
+ const customColumns = useCustomColumns<Material>("material");
+
+ const columns = useMemo<ColumnDef<Material>[]>(() => {
+ const defaultColumns: ColumnDef<Material>[] = [
+ {
+ accessorKey: "id",
+ header: "Material ID",
+ cell: ({ row }) => (
+ <Hyperlink to={path.to.materialDetails(row.original.itemId!)}>
+ {row.original.id}
+ </Hyperlink>
+ ),
+ },
+ {
+ accessorKey: "name",
+ header: "Name",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "description",
+ header: "Description",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "materialSubstance",
+ header: "Substance",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ filter: {
+ type: "fetcher",
+ endpoint: path.to.api.materialSubstances,
+ transform: (data: { id: string; name: string }[] | null) =>
+ data?.map(({ name }) => ({
+ value: name,
+ label: <Enumerable value={name} />,
+ })) ?? [],
},
},
- {
- accessorKey: "materialForm",
- header: "Form",
- cell: (item) => <Enumerable value={item.getValue<string>()} />,
- meta: {
- filter: {
- type: "fetcher",
- endpoint: path.to.api.materialForms,
- transform: (data: { id: string; name: string }[] | null) =>
- data?.map(({ name }) => ({
- value: name,
- label: <Enumerable value={name} />,
- })) ?? [],
- },
+ },
+ {
+ accessorKey: "materialForm",
+ header: "Form",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ filter: {
+ type: "fetcher",
+ endpoint: path.to.api.materialForms,
+ transform: (data: { id: string; name: string }[] | null) =>
+ data?.map(({ name }) => ({
+ value: name,
+ label: <Enumerable value={name} />,
+ })) ?? [],
},
},
- {
- accessorKey: "finish",
- header: "Finish",
- cell: (item) => item.getValue(),
- },
- {
- accessorKey: "grade",
- header: "Grade",
- cell: (item) => item.getValue(),
- },
- {
- accessorKey: "dimensions",
- header: "Dimensions",
- cell: (item) => item.getValue(),
- },
- {
- accessorKey: "itemTrackingType",
- header: "Tracking",
- cell: (item) => (
- <Badge variant="secondary">
- <TrackingTypeIcon
- type={item.getValue<string>()}
- className="mr-2"
- />
- <span>{item.getValue<string>()}</span>
- </Badge>
- ),
- meta: {
- filter: {
- type: "static",
- options: itemTrackingTypes.map((type) => ({
- value: type,
- label: (
- <Badge variant="secondary">
- <TrackingTypeIcon type={type} className="mr-2" />
- <span>{type}</span>
- </Badge>
- ),
- })),
- },
+ },
+ {
+ accessorKey: "finish",
+ header: "Finish",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "grade",
+ header: "Grade",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "dimensions",
+ header: "Dimensions",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "itemTrackingType",
+ header: "Tracking",
+ cell: (item) => (
+ <Badge variant="secondary">
+ <TrackingTypeIcon type={item.getValue<string>()} className="mr-2" />
+ <span>{item.getValue<string>()}</span>
+ </Badge>
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: itemTrackingTypes.map((type) => ({
+ value: type,
+ label: (
+ <Badge variant="secondary">
+ <TrackingTypeIcon type={type} className="mr-2" />
+ <span>{type}</span>
+ </Badge>
+ ),
+ })),
},
},
- {
- accessorKey: "defaultMethodType",
- header: "Default Method",
- cell: (item) => (
- <Badge variant="secondary">
- <MethodIcon type={item.getValue<string>()} className="mr-2" />
- <span>{item.getValue<string>()}</span>
- </Badge>
- ),
- meta: {
- filter: {
- type: "static",
- options: methodType.map((value) => ({
- value,
- label: (
- <Badge variant="secondary">
- <MethodIcon type={value} className="mr-2" />
- <span>{value}</span>
- </Badge>
- ),
- })),
- },
+ },
+ {
+ accessorKey: "defaultMethodType",
+ header: "Default Method",
+ cell: (item) => (
+ <Badge variant="secondary">
+ <MethodIcon type={item.getValue<string>()} className="mr-2" />
+ <span>{item.getValue<string>()}</span>
+ </Badge>
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: methodType.map((value) => ({
+ value,
+ label: (
+ <Badge variant="secondary">
+ <MethodIcon type={value} className="mr-2" />
+ <span>{value}</span>
+ </Badge>
+ ),
+ })),
},
},
- {
- accessorKey: "active",
- header: "Active",
- cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,
- meta: {
- filter: {
- type: "static",
- options: [
- { value: "true", label: "Active" },
- { value: "false", label: "Inactive" },
- ],
- },
- pluralHeader: "Active Statuses",
+ },
+ {
+ accessorKey: "active",
+ header: "Active",
+ cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: [
+ { value: "true", label: "Active" },
+ { value: "false", label: "Inactive" },
+ ],
},
+ pluralHeader: "Active Statuses",
},
- {
- id: "assignee",
- header: "Assignee",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.assignee} />
- ),
- meta: {
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
- },
+ },
+ {
+ id: "assignee",
+ header: "Assignee",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.assignee} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
},
},
- {
- id: "createdBy",
- header: "Created By",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.createdBy} />
- ),
- meta: {
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
- },
+ },
+ {
+ id: "createdBy",
+ header: "Created By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.createdBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
},
},
- {
- accessorKey: "createdAt",
- header: "Created At",
- cell: (item) => formatDate(item.getValue<string>()),
- },
- {
- id: "updatedBy",
- header: "Updated By",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.updatedBy} />
- ),
- meta: {
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
- },
+ },
+ {
+ accessorKey: "createdAt",
+ header: "Created At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ },
+ {
+ id: "updatedBy",
+ header: "Updated By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.updatedBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
},
},
- {
- accessorKey: "updatedAt",
- header: "Created At",
- cell: (item) => formatDate(item.getValue<string>()),
- },
- ];
- return [...defaultColumns, ...customColumns];
- }, [customColumns, people]);
+ },
+ {
+ accessorKey: "updatedAt",
+ header: "Created At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ },
+ ];
+ return [...defaultColumns, ...customColumns];
+ }, [customColumns, people]);
- const renderContextMenu = useMemo(() => {
- // eslint-disable-next-line react/display-name
- return (row: Material) => (
+ const renderContextMenu = useMemo(() => {
+ // eslint-disable-next-line react/display-name
+ return (row: Material) => (
+ <>
<MenuItem onClick={() => navigate(path.to.material(row.itemId!))}>
<MenuIcon icon={<LuPencil />} />
Edit Material
</MenuItem>
- );
- }, [navigate]);
+ <MenuItem
+ disabled={!permissions.can("delete", "parts")}
+ onClick={() => {
+ setSelectedItem(row);
+ deleteItemModal.onOpen();
+ }}
+ >
+ <MenuIcon icon={<LuTrash />} />
+ Delete Part
+ </MenuItem>
+ </>
+ );
+ }, [deleteItemModal, navigate, permissions]);
- return (
- <>
- <Table<Material>
- count={count}
- columns={columns}
- data={data}
- defaultColumnPinning={{
- left: ["id"],
+ return (
+ <>
+ <Table<Material>
+ count={count}
+ columns={columns}
+ data={data}
+ defaultColumnPinning={{
+ left: ["id"],
+ }}
+ defaultColumnVisibility={{
+ description: false,
+ active: false,
+ createdBy: false,
+ createdAt: false,
+ updatedBy: false,
+ updatedAt: false,
+ }}
+ primaryAction={
+ permissions.can("create", "parts") && (
+ <New label="Material" to={path.to.newMaterial} />
+ )
+ }
+ renderContextMenu={renderContextMenu}
+ withColumnOrdering
+ />
+ {selectedItem && selectedItem.id && (
+ <ConfirmDelete
+ action={path.to.deleteItem(selectedItem.itemId!)}
+ isOpen={deleteItemModal.isOpen}
+ name={selectedItem.id!}
+ text={`Are you sure you want to delete ${selectedItem.id!}? This cannot be undone.`}
+ onCancel={() => {
+ deleteItemModal.onClose();
+ setSelectedItem(null);
}}
- defaultColumnVisibility={{
- description: false,
- active: false,
- createdBy: false,
- createdAt: false,
- updatedBy: false,
- updatedAt: false,
+ onSubmit={() => {
+ deleteItemModal.onClose();
+ setSelectedItem(null);
}}
- primaryAction={
- permissions.can("create", "parts") && (
- <New label="Material" to={path.to.newMaterial} />
- )
- }
- renderContextMenu={renderContextMenu}
- withColumnOrdering
/>
- </>
- );
- }
-);
+ )}
+ </>
+ );
+});
MaterialsTable.displayName = "MaterialTable";
diff --git a/apps/carbon/app/modules/items/ui/Parts/PartsTable.tsx b/apps/carbon/app/modules/items/ui/Parts/PartsTable.tsx
index e690fc8983..46446a1b99 100644
--- a/apps/carbon/app/modules/items/ui/Parts/PartsTable.tsx
+++ b/apps/carbon/app/modules/items/ui/Parts/PartsTable.tsx
@@ -1,10 +1,18 @@
-import { Badge, Checkbox, Enumerable, MenuIcon, MenuItem } from "@carbon/react";
+import {
+ Badge,
+ Checkbox,
+ Enumerable,
+ MenuIcon,
+ MenuItem,
+ useDisclosure,
+} from "@carbon/react";
import { formatDate } from "@carbon/utils";
import { useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
-import { memo, useMemo } from "react";
-import { LuPencil } from "react-icons/lu";
+import { memo, useMemo, useState } from "react";
+import { LuPencil, LuTrash } from "react-icons/lu";
import { EmployeeAvatar, Hyperlink, New, Table } from "~/components";
+import { ConfirmDelete } from "~/components/Modals";
import { usePermissions } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Part } from "~/modules/items";
@@ -30,6 +38,9 @@ const PartsTable = memo(
const navigate = useNavigate();
const permissions = usePermissions();
+ const deleteItemModal = useDisclosure();
+ const [selectedItem, setSelectedItem] = useState<Part | null>(null);
+
const [people] = usePeople();
const customColumns = useCustomColumns<Part>("part");
@@ -200,12 +211,24 @@ const PartsTable = memo(
const renderContextMenu = useMemo(() => {
// eslint-disable-next-line react/display-name
return (row: Part) => (
- <MenuItem onClick={() => navigate(path.to.part(row.itemId!))}>
- <MenuIcon icon={<LuPencil />} />
- Edit Part
- </MenuItem>
+ <>
+ <MenuItem onClick={() => navigate(path.to.part(row.itemId!))}>
+ <MenuIcon icon={<LuPencil />} />
+ Edit Part
+ </MenuItem>
+ <MenuItem
+ disabled={!permissions.can("delete", "parts")}
+ onClick={() => {
+ setSelectedItem(row);
+ deleteItemModal.onOpen();
+ }}
+ >
+ <MenuIcon icon={<LuTrash />} />
+ Delete Part
+ </MenuItem>
+ </>
);
- }, [navigate]);
+ }, [deleteItemModal, navigate, permissions]);
return (
<>
@@ -232,6 +255,22 @@ const PartsTable = memo(
renderContextMenu={renderContextMenu}
withColumnOrdering
/>
+ {selectedItem && selectedItem.id && (
+ <ConfirmDelete
+ action={path.to.deleteItem(selectedItem.itemId!)}
+ isOpen={deleteItemModal.isOpen}
+ name={selectedItem.id!}
+ text={`Are you sure you want to delete ${selectedItem.id!}? This cannot be undone.`}
+ onCancel={() => {
+ deleteItemModal.onClose();
+ setSelectedItem(null);
+ }}
+ onSubmit={() => {
+ deleteItemModal.onClose();
+ setSelectedItem(null);
+ }}
+ />
+ )}
</>
);
}
diff --git a/apps/carbon/app/modules/items/ui/Services/ServicesTable.tsx b/apps/carbon/app/modules/items/ui/Services/ServicesTable.tsx
index fae22d8363..e26c1b86ef 100644
--- a/apps/carbon/app/modules/items/ui/Services/ServicesTable.tsx
+++ b/apps/carbon/app/modules/items/ui/Services/ServicesTable.tsx
@@ -1,10 +1,18 @@
-import { Badge, Checkbox, Enumerable, MenuIcon, MenuItem } from "@carbon/react";
+import {
+ Badge,
+ Checkbox,
+ Enumerable,
+ MenuIcon,
+ MenuItem,
+ useDisclosure,
+} from "@carbon/react";
import { formatDate } from "@carbon/utils";
import { useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
-import { memo, useMemo } from "react";
-import { LuPencil } from "react-icons/lu";
+import { memo, useMemo, useState } from "react";
+import { LuPencil, LuTrash } from "react-icons/lu";
import { EmployeeAvatar, Hyperlink, New, Table } from "~/components";
+import { ConfirmDelete } from "~/components/Modals";
import { usePermissions } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Service } from "~/modules/items";
@@ -20,6 +28,10 @@ type ServicesTableProps = {
const ServicesTable = memo(({ data, count }: ServicesTableProps) => {
const navigate = useNavigate();
const permissions = usePermissions();
+
+ const deleteItemModal = useDisclosure();
+ const [selectedItem, setSelectedItem] = useState<Service | null>(null);
+
const customColumns = useCustomColumns<Service>("part");
const [people] = usePeople();
@@ -162,12 +174,24 @@ const ServicesTable = memo(({ data, count }: ServicesTableProps) => {
const renderContextMenu = useMemo(() => {
// eslint-disable-next-line react/display-name
return (row: Service) => (
- <MenuItem onClick={() => navigate(path.to.part(row.itemId!))}>
- <MenuIcon icon={<LuPencil />} />
- Edit Service
- </MenuItem>
+ <>
+ <MenuItem onClick={() => navigate(path.to.part(row.itemId!))}>
+ <MenuIcon icon={<LuPencil />} />
+ Edit Service
+ </MenuItem>
+ <MenuItem
+ disabled={!permissions.can("delete", "parts")}
+ onClick={() => {
+ setSelectedItem(row);
+ deleteItemModal.onOpen();
+ }}
+ >
+ <MenuIcon icon={<LuTrash />} />
+ Delete Service
+ </MenuItem>
+ </>
);
- }, [navigate]);
+ }, [deleteItemModal, navigate, permissions]);
return (
<>
@@ -194,6 +218,22 @@ const ServicesTable = memo(({ data, count }: ServicesTableProps) => {
renderContextMenu={renderContextMenu}
withColumnOrdering
/>
+ {selectedItem && selectedItem.id && (
+ <ConfirmDelete
+ action={path.to.deleteItem(selectedItem.itemId!)}
+ isOpen={deleteItemModal.isOpen}
+ name={selectedItem.id!}
+ text={`Are you sure you want to delete ${selectedItem.id!}? This cannot be undone.`}
+ onCancel={() => {
+ deleteItemModal.onClose();
+ setSelectedItem(null);
+ }}
+ onSubmit={() => {
+ deleteItemModal.onClose();
+ setSelectedItem(null);
+ }}
+ />
+ )}
</>
);
});
diff --git a/apps/carbon/app/modules/items/ui/Tools/ToolsTable.tsx b/apps/carbon/app/modules/items/ui/Tools/ToolsTable.tsx
index f1b086c325..e1fa743f08 100644
--- a/apps/carbon/app/modules/items/ui/Tools/ToolsTable.tsx
+++ b/apps/carbon/app/modules/items/ui/Tools/ToolsTable.tsx
@@ -1,10 +1,17 @@
-import { Badge, Checkbox, MenuIcon, MenuItem } from "@carbon/react";
+import {
+ Badge,
+ Checkbox,
+ MenuIcon,
+ MenuItem,
+ useDisclosure,
+} from "@carbon/react";
import { formatDate } from "@carbon/utils";
import { useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
-import { memo, useMemo } from "react";
-import { LuPencil } from "react-icons/lu";
+import { memo, useMemo, useState } from "react";
+import { LuPencil, LuTrash } from "react-icons/lu";
import { EmployeeAvatar, Hyperlink, New, Table } from "~/components";
+import { ConfirmDelete } from "~/components/Modals";
import { usePermissions } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { Tool } from "~/modules/items";
@@ -24,202 +31,228 @@ type ToolsTableProps = {
count: number;
};
-const ToolsTable = memo(
- ({ data, count, itemPostingGroups }: ToolsTableProps) => {
- const navigate = useNavigate();
- const permissions = usePermissions();
+const ToolsTable = memo(({ data, count }: ToolsTableProps) => {
+ const navigate = useNavigate();
+ const permissions = usePermissions();
- const [people] = usePeople();
- const customColumns = useCustomColumns<Tool>("tool");
+ const deleteItemModal = useDisclosure();
+ const [selectedItem, setSelectedItem] = useState<Tool | null>(null);
- const columns = useMemo<ColumnDef<Tool>[]>(() => {
- const defaultColumns: ColumnDef<Tool>[] = [
- {
- accessorKey: "id",
- header: "Tool ID",
- cell: ({ row }) => (
- <Hyperlink to={path.to.toolDetails(row.original.itemId!)}>
- {row.original.id}
- </Hyperlink>
- ),
- },
- {
- accessorKey: "name",
- header: "Name",
- cell: (item) => item.getValue(),
- },
- {
- accessorKey: "description",
- header: "Description",
- cell: (item) => item.getValue(),
- },
- {
- accessorKey: "itemTrackingType",
- header: "Tracking",
- cell: (item) => (
- <Badge variant="secondary">
- <TrackingTypeIcon
- type={item.getValue<string>()}
- className="mr-2"
- />
- <span>{item.getValue<string>()}</span>
- </Badge>
- ),
- meta: {
- filter: {
- type: "static",
- options: itemTrackingTypes.map((type) => ({
- value: type,
- label: (
- <Badge variant="secondary">
- <TrackingTypeIcon type={type} className="mr-2" />
- <span>{type}</span>
- </Badge>
- ),
- })),
- },
+ const [people] = usePeople();
+ const customColumns = useCustomColumns<Tool>("tool");
+
+ const columns = useMemo<ColumnDef<Tool>[]>(() => {
+ const defaultColumns: ColumnDef<Tool>[] = [
+ {
+ accessorKey: "id",
+ header: "Tool ID",
+ cell: ({ row }) => (
+ <Hyperlink to={path.to.toolDetails(row.original.itemId!)}>
+ {row.original.id}
+ </Hyperlink>
+ ),
+ },
+ {
+ accessorKey: "name",
+ header: "Name",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "description",
+ header: "Description",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "itemTrackingType",
+ header: "Tracking",
+ cell: (item) => (
+ <Badge variant="secondary">
+ <TrackingTypeIcon type={item.getValue<string>()} className="mr-2" />
+ <span>{item.getValue<string>()}</span>
+ </Badge>
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: itemTrackingTypes.map((type) => ({
+ value: type,
+ label: (
+ <Badge variant="secondary">
+ <TrackingTypeIcon type={type} className="mr-2" />
+ <span>{type}</span>
+ </Badge>
+ ),
+ })),
},
},
- {
- accessorKey: "defaultMethodType",
- header: "Default Method",
- cell: (item) => (
- <Badge variant="secondary">
- <MethodIcon type={item.getValue<string>()} className="mr-2" />
- <span>{item.getValue<string>()}</span>
- </Badge>
- ),
- meta: {
- filter: {
- type: "static",
- options: methodType.map((value) => ({
- value,
- label: (
- <Badge variant="secondary">
- <MethodIcon type={value} className="mr-2" />
- <span>{value}</span>
- </Badge>
- ),
- })),
- },
+ },
+ {
+ accessorKey: "defaultMethodType",
+ header: "Default Method",
+ cell: (item) => (
+ <Badge variant="secondary">
+ <MethodIcon type={item.getValue<string>()} className="mr-2" />
+ <span>{item.getValue<string>()}</span>
+ </Badge>
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: methodType.map((value) => ({
+ value,
+ label: (
+ <Badge variant="secondary">
+ <MethodIcon type={value} className="mr-2" />
+ <span>{value}</span>
+ </Badge>
+ ),
+ })),
},
},
- {
- accessorKey: "active",
- header: "Active",
- cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,
- meta: {
- filter: {
- type: "static",
- options: [
- { value: "true", label: "Active" },
- { value: "false", label: "Inactive" },
- ],
- },
- pluralHeader: "Active Statuses",
+ },
+ {
+ accessorKey: "active",
+ header: "Active",
+ cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: [
+ { value: "true", label: "Active" },
+ { value: "false", label: "Inactive" },
+ ],
},
+ pluralHeader: "Active Statuses",
},
- {
- id: "assignee",
- header: "Assignee",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.assignee} />
- ),
- meta: {
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
- },
+ },
+ {
+ id: "assignee",
+ header: "Assignee",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.assignee} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
},
},
- {
- id: "createdBy",
- header: "Created By",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.createdBy} />
- ),
- meta: {
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
- },
+ },
+ {
+ id: "createdBy",
+ header: "Created By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.createdBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
},
},
- {
- accessorKey: "createdAt",
- header: "Created At",
- cell: (item) => formatDate(item.getValue<string>()),
- },
- {
- id: "updatedBy",
- header: "Updated By",
- cell: ({ row }) => (
- <EmployeeAvatar employeeId={row.original.updatedBy} />
- ),
- meta: {
- filter: {
- type: "static",
- options: people.map((employee) => ({
- value: employee.id,
- label: employee.name,
- })),
- },
+ },
+ {
+ accessorKey: "createdAt",
+ header: "Created At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ },
+ {
+ id: "updatedBy",
+ header: "Updated By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.updatedBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
},
},
- {
- accessorKey: "updatedAt",
- header: "Created At",
- cell: (item) => formatDate(item.getValue<string>()),
- },
- ];
- return [...defaultColumns, ...customColumns];
- }, [customColumns, people]);
+ },
+ {
+ accessorKey: "updatedAt",
+ header: "Created At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ },
+ ];
+ return [...defaultColumns, ...customColumns];
+ }, [customColumns, people]);
- const renderContextMenu = useMemo(() => {
- // eslint-disable-next-line react/display-name
- return (row: Tool) => (
+ const renderContextMenu = useMemo(() => {
+ // eslint-disable-next-line react/display-name
+ return (row: Tool) => (
+ <>
<MenuItem onClick={() => navigate(path.to.tool(row.itemId!))}>
<MenuIcon icon={<LuPencil />} />
Edit Tool
</MenuItem>
- );
- }, [navigate]);
+ <MenuItem
+ disabled={!permissions.can("delete", "parts")}
+ onClick={() => {
+ setSelectedItem(row);
+ deleteItemModal.onOpen();
+ }}
+ >
+ <MenuIcon icon={<LuTrash />} />
+ Delete Tool
+ </MenuItem>
+ </>
+ );
+ }, [deleteItemModal, navigate, permissions]);
- return (
- <>
- <Table<Tool>
- count={count}
- columns={columns}
- data={data}
- defaultColumnPinning={{
- left: ["id"],
+ return (
+ <>
+ <Table<Tool>
+ count={count}
+ columns={columns}
+ data={data}
+ defaultColumnPinning={{
+ left: ["id"],
+ }}
+ defaultColumnVisibility={{
+ description: false,
+ active: false,
+ createdBy: false,
+ createdAt: false,
+ updatedBy: false,
+ updatedAt: false,
+ }}
+ primaryAction={
+ permissions.can("create", "parts") && (
+ <New label="Tool" to={path.to.newTool} />
+ )
+ }
+ renderContextMenu={renderContextMenu}
+ withColumnOrdering
+ />
+ {selectedItem && selectedItem.id && (
+ <ConfirmDelete
+ action={path.to.deleteItem(selectedItem.itemId!)}
+ isOpen={deleteItemModal.isOpen}
+ name={selectedItem.id!}
+ text={`Are you sure you want to delete ${selectedItem.id!}? This cannot be undone.`}
+ onCancel={() => {
+ deleteItemModal.onClose();
+ setSelectedItem(null);
}}
- defaultColumnVisibility={{
- description: false,
- active: false,
- createdBy: false,
- createdAt: false,
- updatedBy: false,
- updatedAt: false,
+ onSubmit={() => {
+ deleteItemModal.onClose();
+ setSelectedItem(null);
}}
- primaryAction={
- permissions.can("create", "parts") && (
- <New label="Tool" to={path.to.newTool} />
- )
- }
- renderContextMenu={renderContextMenu}
- withColumnOrdering
/>
- </>
- );
- }
-);
+ )}
+ </>
+ );
+});
ToolsTable.displayName = "ToolTable";
diff --git a/apps/carbon/app/routes/api+/autodesk.upload.ts b/apps/carbon/app/routes/api+/autodesk.upload.ts
index 6779252b1f..86d2a5da21 100644
--- a/apps/carbon/app/routes/api+/autodesk.upload.ts
+++ b/apps/carbon/app/routes/api+/autodesk.upload.ts
@@ -25,16 +25,13 @@ export async function action({ request }: ActionFunctionArgs) {
createdBy: userId,
});
- console.log("modelRecord", modelRecord);
-
if (modelRecord.error) {
throw new Error("Failed to record upload: " + modelRecord.error.message);
}
- console.log("sending event");
try {
await triggerClient.sendEvent({
- name: "upload.autodesk",
+ name: "autodesk.upload",
payload: {
name,
modelPath,
diff --git a/apps/carbon/app/routes/x+/items+/delete.$itemId.tsx b/apps/carbon/app/routes/x+/items+/delete.$itemId.tsx
new file mode 100644
index 0000000000..5ef3987874
--- /dev/null
+++ b/apps/carbon/app/routes/x+/items+/delete.$itemId.tsx
@@ -0,0 +1,30 @@
+import { redirect, type ActionFunctionArgs } from "@remix-run/node";
+import { deleteItem } from "~/modules/items";
+import { requirePermissions } from "~/services/auth/auth.server";
+import { flash } from "~/services/session.server";
+import { assertIsPost } from "~/utils/http";
+import { path, requestReferrer } from "~/utils/path";
+import { error, success } from "~/utils/result";
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client } = await requirePermissions(request, {
+ delete: "parts",
+ });
+
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
+
+ const deletion = await deleteItem(client, itemId);
+ if (deletion.error) {
+ throw redirect(
+ requestReferrer(request) ?? path.to.items,
+ await flash(request, error(deletion.error, "Failed to delete item"))
+ );
+ }
+
+ throw redirect(
+ requestReferrer(request) ?? path.to.items,
+ await flash(request, success("Successfully deleted item"))
+ );
+}
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index da37974a4e..0d48e5934c 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -208,7 +208,7 @@ export const path = {
generatePath(`${x}/resources/holidays/delete/${id}`),
deleteLocation: (id: string) =>
generatePath(`${x}/resources/locations/delete/${id}`),
- deleteNote: (id: string) => generatePath(`${x}/shared/notes/${id}/delete`),
+ deleteItem: (id: string) => generatePath(`${x}/items/delete/${id}`),
deleteItemPostingGroup: (id: string) =>
generatePath(`${x}/items/groups/delete/${id}`),
deleteMaterialForm: (id: string) =>
@@ -217,6 +217,7 @@ export const path = {
generatePath(`${x}/items/substances/delete/${id}`),
deleteMethodMaterial: (makeMethodId: string, id: string) =>
generatePath(`${x}/items/methods/${makeMethodId}/material/delete/${id}`),
+ deleteNote: (id: string) => generatePath(`${x}/shared/notes/${id}/delete`),
deletePartner: (id: string) =>
generatePath(`${x}/resources/partners/delete/${id}`),
deletePaymentTerm: (id: string) =>