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.

refactor: fix drawer redirect bug in customer types crud

Brad Barbin9cb97cd483ea
diff --git a/apps/carbon/app/routes/x+/sales+/customer-types.$customerTypeId.tsx b/apps/carbon/app/routes/x+/sales+/customer-types.$customerTypeId.tsx
index cab0479a4d..0e1c0e7384 100644
--- a/apps/carbon/app/routes/x+/sales+/customer-types.$customerTypeId.tsx
+++ b/apps/carbon/app/routes/x+/sales+/customer-types.$customerTypeId.tsx
@@ -12,7 +12,7 @@ import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session.server";
import { getCustomFields, setCustomFields } from "~/utils/form";
import { assertIsPost, notFound } from "~/utils/http";
-import { path } from "~/utils/path";
+import { getParams, path } from "~/utils/path";
import { error, success } from "~/utils/result";
export async function loader({ request, params }: LoaderFunctionArgs) {
@@ -28,7 +28,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (customerType?.data?.protected) {
return redirect(
- path.to.customerTypes,
+ `${path.to.customerTypes}?${getParams(request)}`,
await flash(request, error(null, "Cannot edit a protected customer type"))
);
}
@@ -72,7 +72,7 @@ export async function action({ request }: ActionFunctionArgs) {
}
return redirect(
- path.to.customerTypes,
+ `${path.to.customerTypes}?${getParams(request)}`,
await flash(request, success("Updated customer type"))
);
}
diff --git a/apps/carbon/app/routes/x+/sales+/customer-types.delete.$customerTypeId.tsx b/apps/carbon/app/routes/x+/sales+/customer-types.delete.$customerTypeId.tsx
index d26ec9295a..35a7635f58 100644
--- a/apps/carbon/app/routes/x+/sales+/customer-types.delete.$customerTypeId.tsx
+++ b/apps/carbon/app/routes/x+/sales+/customer-types.delete.$customerTypeId.tsx
@@ -6,7 +6,7 @@ import { deleteCustomerType, getCustomerType } from "~/modules/sales";
import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session.server";
import { notFound } from "~/utils/http";
-import { path } from "~/utils/path";
+import { getParams, path } from "~/utils/path";
import { error, success } from "~/utils/result";
export async function loader({ request, params }: LoaderFunctionArgs) {
@@ -19,7 +19,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const customerType = await getCustomerType(client, customerTypeId);
if (customerType.error) {
return redirect(
- path.to.customerTypes,
+ `${path.to.customerTypes}?${getParams(request)}`,
await flash(
request,
error(customerType.error, "Failed to get customer type")
@@ -38,7 +38,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
const { customerTypeId } = params;
if (!customerTypeId) {
return redirect(
- path.to.customerTypes,
+ `${path.to.customerTypes}?${getParams(request)}`,
await flash(request, error(params, "Failed to get an customer type id"))
);
}
@@ -49,7 +49,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
if (deleteTypeError) {
return redirect(
- path.to.customerTypes,
+ `${path.to.customerTypes}?${getParams(request)}`,
await flash(
request,
error(deleteTypeError, "Failed to delete customer type")
@@ -58,7 +58,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
return redirect(
- path.to.customerTypes,
+ `${path.to.customerTypes}?${getParams(request)}`,
await flash(request, success("Successfully deleted customer type"))
);
}
diff --git a/apps/carbon/app/routes/x+/sales+/customer-types.new.tsx b/apps/carbon/app/routes/x+/sales+/customer-types.new.tsx
index b969dfed47..a1046b9a92 100644
--- a/apps/carbon/app/routes/x+/sales+/customer-types.new.tsx
+++ b/apps/carbon/app/routes/x+/sales+/customer-types.new.tsx
@@ -11,7 +11,7 @@ import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session.server";
import { setCustomFields } from "~/utils/form";
import { assertIsPost } from "~/utils/http";
-import { path, requestReferrer } from "~/utils/path";
+import { getParams, path } from "~/utils/path";
import { error, success } from "~/utils/result";
export async function loader({ request }: LoaderFunctionArgs) {
@@ -48,7 +48,7 @@ export async function action({ request }: ActionFunctionArgs) {
return modal
? json(insertCustomerType)
: redirect(
- requestReferrer(request) ?? path.to.customerTypes,
+ `${path.to.customerTypes}?${getParams(request)}`,
await flash(
request,
error(insertCustomerType.error, "Failed to insert customer type")
@@ -59,7 +59,7 @@ export async function action({ request }: ActionFunctionArgs) {
return modal
? json(insertCustomerType, { status: 201 })
: redirect(
- path.to.customerTypes,
+ `${path.to.customerTypes}?${getParams(request)}`,
await flash(request, success("Customer type created"))
);
}