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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
- delete redirection changes
Gaurav Bhatt739dd8a80e42
diff --git a/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegisterForm.tsx b/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegisterForm.tsxindex 30f4c09d84..bba47f74a9 100644--- a/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegisterForm.tsx+++ b/apps/erp/app/modules/quality/ui/RiskRegister/RiskRegisterForm.tsx@@ -48,32 +48,30 @@ const RiskRegisterForm = ({onClose,}: RiskRegisterFormProps) => {const permissions = usePermissions();- const fetcher =- useFetcher<PostgrestResponse<{ id: string; success: boolean }>>();+ const fetcher = useFetcher<PostgrestResponse<{ id: string }>>();const deleteDisclosure = useDisclosure();- const deleteFetcher = useFetcher();-- console.log("zaza", fetcher);+ const deleteFetcher = useFetcher<{ success: boolean; message: string }>();useEffect(() => {- console.log("zaza1", fetcher.state, fetcher.data);-- if (fetcher.state === "idle" && fetcher.data?.data) {- console.log("zaza2", fetcher.data.data);+ if (fetcher.data?.data) {onClose?.();toast.success(`Saved risk`);- } else if (fetcher.state === "idle" && fetcher.data?.error) {+ } else if (fetcher.data?.error) {toast.error(`Failed to save risk: ${fetcher.data.error.message}`);}- }, [fetcher.data, fetcher.state, onClose, type]);+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [fetcher.data]);useEffect(() => {- if (deleteFetcher.state === "idle" && deleteFetcher.data) {+ if (deleteFetcher.data?.success) {deleteDisclosure.onClose();onClose?.();- toast.success(`Deleted risk`);+ toast.success(deleteFetcher.data.message || "Deleted risk");+ } else if (deleteFetcher.data?.success === false) {+ toast.error(deleteFetcher.data.message || "Failed to delete risk");}- }, [deleteFetcher.state, deleteFetcher.data, deleteDisclosure, onClose]);+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [deleteFetcher.data?.success]);const isEditing = !!initialValues.id;const isDisabled = isEditing@@ -181,9 +179,6 @@ const RiskRegisterForm = ({isOpen={deleteDisclosure.isOpen}confirmText="Delete"onCancel={deleteDisclosure.onClose}- onSubmit={() => {- // Handled by form action- }}title="Delete Risk"text="Are you sure you want to delete this risk?"action={path.to.deleteRisk(initialValues.id)}diff --git a/apps/erp/app/routes/x+/quality+/risks.delete.$id.tsx b/apps/erp/app/routes/x+/quality+/risks.delete.$id.tsxindex a6c4970a3f..9267db712c 100644--- a/apps/erp/app/routes/x+/quality+/risks.delete.$id.tsx+++ b/apps/erp/app/routes/x+/quality+/risks.delete.$id.tsx@@ -1,10 +1,11 @@+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";-import { type ActionFunctionArgs, json, redirect } from "@vercel/remix";+import { type ActionFunctionArgs, json } from "@vercel/remix";import invariant from "tiny-invariant";import { deleteRisk } from "~/modules/quality/quality.service";-import { path } from "~/utils/path";export const action = async ({ request, params }: ActionFunctionArgs) => {+ assertIsPost(request);const { client } = await requirePermissions(request, {delete: "quality",role: "employee",@@ -17,11 +18,15 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {if (result.error) {return json({- error: result.error,+ success: false,+ message: "Failed to delete risk",},{ status: 500 });}- return redirect(path.to.risks);+ return json({+ success: true,+ message: "Risk deleted successfully",+ });};diff --git a/apps/erp/app/routes/x+/quality+/risks.new.tsx b/apps/erp/app/routes/x+/quality+/risks.new.tsxindex b6ae4311d9..92704deece 100644--- a/apps/erp/app/routes/x+/quality+/risks.new.tsx+++ b/apps/erp/app/routes/x+/quality+/risks.new.tsx@@ -30,8 +30,6 @@ export const action = async ({ request }: ActionFunctionArgs) => {});if (result.error) {- console.log("this ran2", userId);-return json({data: null,