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.

fix: problems with parts module

Brad Barbinb21075c90464
diff --git a/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm.tsx b/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm.tsx
index 7640577466..b706c8ba4c 100644
--- a/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm.tsx
@@ -9,9 +9,12 @@ import {
ModalDrawerProvider,
ModalDrawerTitle,
VStack,
+ toast,
} from "@carbon/react";
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useFetcher } from "@remix-run/react";
+import type { PostgrestResponse } from "@supabase/supabase-js";
+import { useEffect } from "react";
import type { z } from "zod";
import {
CustomFormFields,
@@ -38,13 +41,26 @@ const PartGroupForm = ({
onClose,
}: PartGroupFormProps) => {
const permissions = usePermissions();
- const fetcher = useFetcher();
+ const fetcher = useFetcher<PostgrestResponse<{ id: string; name: string }>>();
const isEditing = initialValues.id !== undefined;
const isDisabled = isEditing
? !permissions.can("update", "parts")
: !permissions.can("create", "parts");
+ useEffect(() => {
+ if (type !== "modal") return;
+
+ if (fetcher.state === "loading" && fetcher.data?.data) {
+ onClose?.();
+ toast.success(`Created supplier status`);
+ } else if (fetcher.state === "idle" && fetcher.data?.error) {
+ toast.error(
+ `Failed to create supplier status: ${fetcher.data.error.message}`
+ );
+ }
+ }, [fetcher.data, fetcher.state, onClose, type]);
+
return (
<ModalDrawerProvider type={type}>
<ModalDrawer
diff --git a/apps/carbon/app/modules/parts/ui/Service/ServiceForm.tsx b/apps/carbon/app/modules/parts/ui/Service/ServiceForm.tsx
index c016686da9..65b379e8ad 100644
--- a/apps/carbon/app/modules/parts/ui/Service/ServiceForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Service/ServiceForm.tsx
@@ -12,19 +12,17 @@ import { useState } from "react";
import type { z } from "zod";
import {
Boolean,
- Combobox,
CustomFormFields,
Input,
InputControlled,
+ PartGroup,
Select,
Submit,
TextArea,
} from "~/components/Form";
-import { usePermissions, useRouteData, useUser } from "~/hooks";
+import { usePermissions, useUser } from "~/hooks";
import { useSupabase } from "~/lib/supabase";
import { serviceType, serviceValidator } from "~/modules/parts";
-import type { ListItem } from "~/types";
-import { path } from "~/utils/path";
type ServiceFormProps = {
initialValues: z.infer<typeof serviceValidator>;
@@ -79,19 +77,10 @@ const useNextServiceIdShortcut = () => {
const ServiceForm = ({ initialValues }: ServiceFormProps) => {
const { serviceId, onServiceIdChange, loading } = useNextServiceIdShortcut();
- const sharedData = useRouteData<{
- partGroups: ListItem[];
- }>(path.to.serviceRoot);
const permissions = usePermissions();
const isEditing = initialValues.id !== undefined;
- const partGroupOptions =
- sharedData?.partGroups.map((partGroup) => ({
- label: partGroup.name,
- value: partGroup.id,
- })) ?? [];
-
const serviceTypeOptions =
serviceType.map((type) => ({
label: type,
@@ -134,11 +123,7 @@ const ServiceForm = ({ initialValues }: ServiceFormProps) => {
/>
)}
<Input name="name" label="Name" />
- <Combobox
- name="partGroupId"
- label="Part Group"
- options={partGroupOptions}
- />
+ <PartGroup name="partGroupId" label="Part Group" />
<TextArea name="description" label="Description" />
<Select
diff --git a/apps/carbon/app/modules/parts/ui/Services/ServicesTable.tsx b/apps/carbon/app/modules/parts/ui/Services/ServicesTable.tsx
index 3f5baf1a7d..096d1cd02d 100644
--- a/apps/carbon/app/modules/parts/ui/Services/ServicesTable.tsx
+++ b/apps/carbon/app/modules/parts/ui/Services/ServicesTable.tsx
@@ -63,13 +63,13 @@ const ServicesTable = memo(
},
{
accessorKey: "partGroup",
- header: "Service Group",
+ header: "Part Group",
cell: (item) => <Enumerable value={item.getValue<string>()} />,
meta: {
filter: {
type: "static",
options: partGroups.map(({ id, name }) => ({
- value: id,
+ value: name,
label: <Enumerable value={name} />,
})),
},
diff --git a/package.json b/package.json
index bf68d8c395..2b1dcdafcd 100755
--- a/package.json
+++ b/package.json
@@ -7,7 +7,7 @@
"npm-run-all": "^4.1.5",
"prettier": "^2.8.0",
"rimraf": "^5.0.5",
- "supabase": "1.164.1",
+ "supabase": "1.165.0",
"ts-morph": "^22.0.0",
"tsx": "^3.12.1",
"turbo": "^1.13.3"