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.

- added success toasts

Gaurav Bhattf6f3089e88f1
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
index 92f178bdaa..85844a6068 100644
--- a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
@@ -571,7 +571,11 @@ function MaterialForm({
onConfigure: (configuration: Configuration) => void;
}) {
const { carbon } = useCarbon();
- const methodMaterialFetcher = useFetcher<{ id: string }>();
+ const methodMaterialFetcher = useFetcher<{
+ id: string;
+ success: boolean;
+ message: string;
+ }>();
const params = useParams();
const { company, defaults } = useUser();
const [locationId, setLocationId] = useState<string | undefined>(
@@ -602,6 +606,10 @@ function MaterialForm({
return rest;
});
setSelectedItemId(null);
+
+ if (methodMaterialFetcher.data.success) {
+ toast.success(methodMaterialFetcher.data.message);
+ }
}
}, [
item.id,
@@ -1002,7 +1010,12 @@ function MaterialForm({
)}
<div className="flex items-center gap-2">
- <Submit isDisabled={isReadOnly}>Save</Submit>
+ <Submit
+ isDisabled={isReadOnly || methodMaterialFetcher.state !== "idle"}
+ isLoading={methodMaterialFetcher.state === "submitting"}
+ >
+ Save
+ </Submit>
</div>
</motion.div>
</motion.div>
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
index b2462725b8..52453c83c3 100644
--- a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
@@ -863,7 +863,11 @@ function OperationForm({
setWorkInstructions,
setTemporaryItems,
}: OperationFormProps) {
- const methodOperationFetcher = useFetcher<{ id: string }>();
+ const methodOperationFetcher = useFetcher<{
+ id: string;
+ success: boolean;
+ message: string;
+ }>();
const { company } = useUser();
const { carbon } = useCarbon();
@@ -878,6 +882,10 @@ function OperationForm({
return rest;
});
setSelectedItemId(null);
+
+ if (methodOperationFetcher.data.success) {
+ toast.success(methodOperationFetcher.data.message);
+ }
}
}, [
item.id,
@@ -1640,7 +1648,12 @@ function OperationForm({
}}
>
<motion.div layout className="ml-auto mr-1 pt-2">
- <Submit isDisabled={isReadOnly}>Save</Submit>
+ <Submit
+ isDisabled={isReadOnly || methodOperationFetcher.state !== "idle"}
+ isLoading={methodOperationFetcher.state === "submitting"}
+ >
+ Save
+ </Submit>
</motion.div>
</motion.div>
</ValidatedForm>
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
index 39395bfbfd..5d347b7bfe 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
@@ -618,7 +618,11 @@ function MaterialForm({
}>(path.to.job(jobId));
const { carbon } = useCarbon();
- const methodMaterialFetcher = useFetcher<{ id: string }>();
+ const methodMaterialFetcher = useFetcher<{
+ id: string;
+ success: boolean;
+ message: string;
+ }>();
const params = useParams();
const { company } = useUser();
@@ -633,6 +637,10 @@ function MaterialForm({
return rest;
});
setSelectedItemId(null);
+
+ if (methodMaterialFetcher.data?.success) {
+ toast.success(methodMaterialFetcher.data.message);
+ }
}
}, [
item.id,
@@ -1014,7 +1022,12 @@ function MaterialForm({
<div />
)}
- <Submit isDisabled={isDisabled}>Save</Submit>
+ <Submit
+ isDisabled={isDisabled || methodMaterialFetcher.state !== "idle"}
+ isLoading={methodMaterialFetcher.state === "submitting"}
+ >
+ Save
+ </Submit>
</motion.div>
</motion.div>
</ValidatedForm>
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
index 9dc8fe977a..17301fc869 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
@@ -1991,7 +1991,11 @@ function OperationForm({
const { company } = useUser();
if (!jobId) throw new Error("jobId not found");
- const fetcher = useFetcher<{ id: string }>();
+ const fetcher = useFetcher<{
+ id: string;
+ success: boolean;
+ message: string;
+ }>();
const { carbon } = useCarbon();
const baseCurrency = company?.baseCurrencyCode ?? "USD";
@@ -2005,6 +2009,10 @@ function OperationForm({
// Close form on submit
setSelectedItemId(null);
+
+ if (fetcher.data?.success) {
+ toast.success(fetcher.data.message);
+ }
}
}, [item.id, fetcher.data, setSelectedItemId, setTemporaryItems]);
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
index 97fe894035..65b2623b74 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
@@ -609,7 +609,11 @@ function MaterialForm({
if (!lineId) throw new Error("lineId not found");
const { carbon } = useCarbon();
- const methodMaterialFetcher = useFetcher<{ id: string }>();
+ const methodMaterialFetcher = useFetcher<{
+ id: string;
+ success: boolean;
+ message: string;
+ }>();
const params = useParams();
const { company } = useUser();
const routeData = useRouteData<{ quote: Quotation }>(path.to.quote(quoteId));
@@ -625,6 +629,10 @@ function MaterialForm({
return rest;
});
setSelectedItemId(null);
+
+ if (methodMaterialFetcher.data.success) {
+ toast.success(methodMaterialFetcher.data.message);
+ }
}
}, [
item.id,
@@ -972,7 +980,12 @@ function MaterialForm({
<div />
)}
- <Submit isDisabled={isDisabled}>Save</Submit>
+ <Submit
+ isDisabled={isDisabled || methodMaterialFetcher.state !== "idle"}
+ isLoading={methodMaterialFetcher.state === "submitting"}
+ >
+ Save
+ </Submit>
</motion.div>
</motion.div>
</ValidatedForm>
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
index 590f0b5f05..6b632a58ad 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
@@ -1653,7 +1653,11 @@ function OperationForm({
if (!quoteId) throw new Error("quoteId not found");
if (!lineId) throw new Error("lineId not found");
- const fetcher = useFetcher<{ id: string }>();
+ const fetcher = useFetcher<{
+ id: string;
+ success: boolean;
+ message: string;
+ }>();
const { carbon } = useCarbon();
const baseCurrency = company?.baseCurrencyCode ?? "USD";
@@ -1666,6 +1670,10 @@ function OperationForm({
return rest;
});
setSelectedItemId(null);
+
+ if (fetcher.data?.success) {
+ toast.success(fetcher.data.message);
+ }
}
}, [item.id, fetcher.data, setTemporaryItems, setSelectedItemId]);
@@ -2352,7 +2360,12 @@ function OperationForm({
}}
>
<motion.div layout className="ml-auto mr-1 pt-2">
- <Submit isDisabled={isDisabled}>Save</Submit>
+ <Submit
+ isDisabled={isDisabled || fetcher.state !== "idle"}
+ isLoading={fetcher.state === "submitting"}
+ >
+ Save
+ </Submit>
</motion.div>
</motion.div>
</ValidatedForm>
diff --git a/apps/erp/app/routes/x+/items+/methods+/material.$id.tsx b/apps/erp/app/routes/x+/items+/methods+/material.$id.tsx
index ba9e9e4773..bda0137159 100644
--- a/apps/erp/app/routes/x+/items+/methods+/material.$id.tsx
+++ b/apps/erp/app/routes/x+/items+/methods+/material.$id.tsx
@@ -58,5 +58,9 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- return json({ id: methodMaterialId });
+ return json({
+ id: methodMaterialId,
+ success: true,
+ message: "Material updated",
+ });
}
diff --git a/apps/erp/app/routes/x+/items+/methods+/material.new.tsx b/apps/erp/app/routes/x+/items+/methods+/material.new.tsx
index 937f21f74b..ddd6e0375d 100644
--- a/apps/erp/app/routes/x+/items+/methods+/material.new.tsx
+++ b/apps/erp/app/routes/x+/items+/methods+/material.new.tsx
@@ -53,5 +53,9 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- return json({ id: methodMaterialId });
+ return json({
+ id: methodMaterialId,
+ success: true,
+ message: "Material created",
+ });
}
diff --git a/apps/erp/app/routes/x+/items+/methods+/operation.$id.tsx b/apps/erp/app/routes/x+/items+/methods+/operation.$id.tsx
index 511830c4e7..6ec3fde3f3 100644
--- a/apps/erp/app/routes/x+/items+/methods+/operation.$id.tsx
+++ b/apps/erp/app/routes/x+/items+/methods+/operation.$id.tsx
@@ -61,5 +61,9 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- return json({ id: methodOperationId });
+ return json({
+ id: methodOperationId,
+ success: true,
+ message: "Operation updated",
+ });
}
diff --git a/apps/erp/app/routes/x+/items+/methods+/operation.new.tsx b/apps/erp/app/routes/x+/items+/methods+/operation.new.tsx
index b124792a74..c1f81245ca 100644
--- a/apps/erp/app/routes/x+/items+/methods+/operation.new.tsx
+++ b/apps/erp/app/routes/x+/items+/methods+/operation.new.tsx
@@ -55,5 +55,9 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- return json({ id: methodOperationId });
+ return json({
+ id: methodOperationId,
+ success: true,
+ message: "Operation created",
+ });
}
diff --git a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.$id.tsx b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.$id.tsx
index a569246326..739bc6bcc9 100644
--- a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.$id.tsx
+++ b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.$id.tsx
@@ -142,5 +142,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
return json({
id: jobMaterialId,
methodType: updateJobMaterial.data.methodType,
+ success: true,
+ message: "Material updated",
});
}
diff --git a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx
index bee27e3c48..8c5df067dc 100644
--- a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx
+++ b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx
@@ -148,5 +148,9 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
}
- return json({ id: jobMaterialId });
+ return json({
+ id: jobMaterialId,
+ success: true,
+ message: "Material created",
+ });
}
diff --git a/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.$id.tsx b/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.$id.tsx
index ef501ea9ab..4d5f88bb8a 100644
--- a/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.$id.tsx
+++ b/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.$id.tsx
@@ -63,5 +63,9 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- return json({ id: jobOperationId });
+ return json({
+ id: jobOperationId,
+ success: true,
+ message: "Operation updated",
+ });
}
diff --git a/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.new.tsx b/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.new.tsx
index 3da85c2128..70ad923d55 100644
--- a/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.new.tsx
+++ b/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.new.tsx
@@ -101,5 +101,9 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- return json({ id: jobOperationId });
+ return json({
+ id: jobOperationId,
+ success: true,
+ message: "Operation created",
+ });
}
diff --git a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.$id.tsx b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.$id.tsx
index 135c2dca8c..d8868ee137 100644
--- a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.$id.tsx
+++ b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.$id.tsx
@@ -68,5 +68,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
return json({
id: quoteMaterialId,
methodType: updateQuoteMaterial.data.methodType,
+ success: true,
+ message: "Material updated",
});
}
diff --git a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.new.tsx b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.new.tsx
index 956080e8d4..14e467a5be 100644
--- a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.new.tsx
+++ b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.new.tsx
@@ -102,5 +102,9 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
}
- return json({ id: quoteMaterialId });
+ return json({
+ id: quoteMaterialId,
+ success: true,
+ message: "Material created",
+ });
}
diff --git a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.operation.$id.tsx b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.operation.$id.tsx
index e86826b308..2ec0d5368e 100644
--- a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.operation.$id.tsx
+++ b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.operation.$id.tsx
@@ -66,5 +66,9 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- return json({ id: quoteOperationId });
+ return json({
+ id: quoteOperationId,
+ success: true,
+ message: "Operation updated",
+ });
}
diff --git a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.operation.new.tsx b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.operation.new.tsx
index 622ca7e48d..40bb6e8c23 100644
--- a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.operation.new.tsx
+++ b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.operation.new.tsx
@@ -62,5 +62,9 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
}
- return json({ id: quoteOperationId });
+ return json({
+ id: quoteOperationId,
+ success: true,
+ message: "Operation created",
+ });
}