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: closing modal drawers

Brad Barbin1c9d746da24f
diff --git a/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermForm.tsx b/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermForm.tsx
index c03144280a..5c1200ca26 100644
--- a/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermForm.tsx
+++ b/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermForm.tsx
@@ -35,7 +35,7 @@ type PaymentTermFormProps = {
initialValues: z.infer<typeof paymentTermValidator>;
type?: "modal" | "drawer";
open?: boolean;
- onClose?: (data?: { id: string; name: string }) => void;
+ onClose: (data?: { id: string; name: string }) => void;
};
const PaymentTermForm = ({
diff --git a/apps/carbon/app/modules/accounting/ui/useAccountingSubmodules.tsx b/apps/carbon/app/modules/accounting/ui/useAccountingSubmodules.tsx
index de238634a6..2d4461eed7 100644
--- a/apps/carbon/app/modules/accounting/ui/useAccountingSubmodules.tsx
+++ b/apps/carbon/app/modules/accounting/ui/useAccountingSubmodules.tsx
@@ -1,3 +1,4 @@
+import { LuDollarSign, LuList } from "react-icons/lu";
import { usePermissions } from "~/hooks";
import type { AuthenticatedRouteGroup } from "~/types";
import { path } from "~/utils/path";
@@ -60,6 +61,7 @@ const accountingRoutes: AuthenticatedRouteGroup[] = [
name: "Currencies",
to: path.to.currencies,
role: "employee",
+ icon: <LuDollarSign />,
},
// {
// name: "Default Accounts",
@@ -71,11 +73,12 @@ const accountingRoutes: AuthenticatedRouteGroup[] = [
// to: path.to.fiscalYears,
// role: "employee",
// },
- // {
- // name: "Payment Terms",
- // to: path.to.paymentTerms,
- // role: "employee",
- // },
+ {
+ name: "Payment Terms",
+ to: path.to.paymentTerms,
+ role: "employee",
+ icon: <LuList />,
+ },
],
},
];
diff --git a/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodForm.tsx b/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodForm.tsx
index e336e571c1..0e2d0d034d 100644
--- a/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodForm.tsx
+++ b/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodForm.tsx
@@ -34,7 +34,7 @@ type ShippingMethodFormProps = {
initialValues: z.infer<typeof shippingMethodValidator>;
type?: "modal" | "drawer";
open?: boolean;
- onClose?: (data?: { id: string; name: string }) => void;
+ onClose: (data?: { id: string; name: string }) => void;
};
const ShippingMethodForm = ({
diff --git a/apps/carbon/app/modules/inventory/ui/useInventorySubmodules.tsx b/apps/carbon/app/modules/inventory/ui/useInventorySubmodules.tsx
index 2f05afdb3e..f7568e2b19 100644
--- a/apps/carbon/app/modules/inventory/ui/useInventorySubmodules.tsx
+++ b/apps/carbon/app/modules/inventory/ui/useInventorySubmodules.tsx
@@ -1,4 +1,4 @@
-import { LuBox } from "react-icons/lu";
+import { LuBox, LuTruck } from "react-icons/lu";
import { usePermissions } from "~/hooks";
import type { AuthenticatedRouteGroup } from "~/types";
import { path } from "~/utils/path";
@@ -23,16 +23,17 @@ const inventoryRoutes: AuthenticatedRouteGroup[] = [
// },
],
},
- // {
- // name: "Configure",
- // routes: [
- // {
- // name: "Shipping Methods",
- // to: path.to.shippingMethods,
- // role: "employee",
- // },
- // ],
- // },
+ {
+ name: "Configure",
+ routes: [
+ {
+ name: "Shipping Methods",
+ to: path.to.shippingMethods,
+ role: "employee",
+ icon: <LuTruck />,
+ },
+ ],
+ },
];
export default function useAccountingSubmodules() {
diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierProcessForm.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierProcessForm.tsx
index 5f7507c8a3..ceea70c632 100644
--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierProcessForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierProcessForm.tsx
@@ -33,7 +33,7 @@ type SupplierProcessFormProps = {
initialValues: z.infer<typeof supplierProcessValidator>;
type?: "drawer" | "modal";
open?: boolean;
- onClose?: () => void;
+ onClose: () => void;
};
const SupplierProcessForm = ({
diff --git a/apps/carbon/app/routes/x+/accounting+/payment-terms.$paymentTermId.tsx b/apps/carbon/app/routes/x+/accounting+/payment-terms.$paymentTermId.tsx
index f057aaa195..3f9d3307fd 100644
--- a/apps/carbon/app/routes/x+/accounting+/payment-terms.$paymentTermId.tsx
+++ b/apps/carbon/app/routes/x+/accounting+/payment-terms.$paymentTermId.tsx
@@ -2,7 +2,7 @@ import { assertIsPost, error, notFound, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
-import { useLoaderData } from "@remix-run/react";
+import { useLoaderData, useNavigate } from "@remix-run/react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
import { json, redirect } from "@vercel/remix";
import type { PaymentTermCalculationMethod } from "~/modules/accounting";
@@ -72,6 +72,7 @@ export async function action({ request }: ActionFunctionArgs) {
export default function EditPaymentTermsRoute() {
const { paymentTerm } = useLoaderData<typeof loader>();
+ const navigate = useNavigate();
const initialValues = {
id: paymentTerm?.id ?? undefined,
@@ -85,6 +86,10 @@ export default function EditPaymentTermsRoute() {
};
return (
- <PaymentTermForm key={initialValues.id} initialValues={initialValues} />
+ <PaymentTermForm
+ key={initialValues.id}
+ initialValues={initialValues}
+ onClose={() => navigate(-1)}
+ />
);
}
diff --git a/apps/carbon/app/routes/x+/accounting+/payment-terms.new.tsx b/apps/carbon/app/routes/x+/accounting+/payment-terms.new.tsx
index a3c46c74da..7245dc4688 100644
--- a/apps/carbon/app/routes/x+/accounting+/payment-terms.new.tsx
+++ b/apps/carbon/app/routes/x+/accounting+/payment-terms.new.tsx
@@ -2,6 +2,7 @@ import { assertIsPost, error, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
+import { useNavigate } from "@remix-run/react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
import { json, redirect } from "@vercel/remix";
import type { PaymentTermCalculationMethod } from "~/modules/accounting";
@@ -63,6 +64,7 @@ export async function action({ request }: ActionFunctionArgs) {
}
export default function NewPaymentTermsRoute() {
+ const navigate = useNavigate();
const initialValues = {
name: "",
daysDue: 0,
@@ -71,5 +73,10 @@ export default function NewPaymentTermsRoute() {
calculationMethod: "Net" as PaymentTermCalculationMethod,
};
- return <PaymentTermForm initialValues={initialValues} />;
+ return (
+ <PaymentTermForm
+ initialValues={initialValues}
+ onClose={() => navigate(-1)}
+ />
+ );
}
diff --git a/apps/carbon/app/routes/x+/inventory+/shipping-methods.$shippingMethodId.tsx b/apps/carbon/app/routes/x+/inventory+/shipping-methods.$shippingMethodId.tsx
index e4c9cc6195..4b3a29a191 100644
--- a/apps/carbon/app/routes/x+/inventory+/shipping-methods.$shippingMethodId.tsx
+++ b/apps/carbon/app/routes/x+/inventory+/shipping-methods.$shippingMethodId.tsx
@@ -2,7 +2,7 @@ import { assertIsPost, error, notFound, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
-import { useLoaderData } from "@remix-run/react";
+import { useLoaderData, useNavigate } from "@remix-run/react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
import { json, redirect } from "@vercel/remix";
import type { ShippingCarrier } from "~/modules/inventory";
@@ -74,6 +74,7 @@ export async function action({ request }: ActionFunctionArgs) {
export default function EditShippingMethodsRoute() {
const { shippingMethod } = useLoaderData<typeof loader>();
+ const navigate = useNavigate();
const initialValues = {
id: shippingMethod?.id ?? undefined,
@@ -85,6 +86,10 @@ export default function EditShippingMethodsRoute() {
};
return (
- <ShippingMethodForm key={initialValues.id} initialValues={initialValues} />
+ <ShippingMethodForm
+ key={initialValues.id}
+ initialValues={initialValues}
+ onClose={() => navigate(-1)}
+ />
);
}
diff --git a/apps/carbon/app/routes/x+/inventory+/shipping-methods.new.tsx b/apps/carbon/app/routes/x+/inventory+/shipping-methods.new.tsx
index c09ded5209..65f9a59e75 100644
--- a/apps/carbon/app/routes/x+/inventory+/shipping-methods.new.tsx
+++ b/apps/carbon/app/routes/x+/inventory+/shipping-methods.new.tsx
@@ -2,6 +2,7 @@ import { assertIsPost, error, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
+import { useNavigate } from "@remix-run/react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
import { json, redirect } from "@vercel/remix";
import type { ShippingCarrier } from "~/modules/inventory";
@@ -65,10 +66,17 @@ export async function action({ request }: ActionFunctionArgs) {
}
export default function NewShippingMethodsRoute() {
+ const navigate = useNavigate();
+
const initialValues = {
name: "",
carrier: "" as ShippingCarrier,
};
- return <ShippingMethodForm initialValues={initialValues} />;
+ return (
+ <ShippingMethodForm
+ initialValues={initialValues}
+ onClose={() => navigate(-1)}
+ />
+ );
}
diff --git a/apps/carbon/app/routes/x+/supplier+/$supplierId.processes.$id.tsx b/apps/carbon/app/routes/x+/supplier+/$supplierId.processes.$id.tsx
index 029cb73de1..dbd2ab42c9 100644
--- a/apps/carbon/app/routes/x+/supplier+/$supplierId.processes.$id.tsx
+++ b/apps/carbon/app/routes/x+/supplier+/$supplierId.processes.$id.tsx
@@ -2,7 +2,7 @@ import { assertIsPost, error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
-import { useParams } from "@remix-run/react";
+import { useNavigate, useParams } from "@remix-run/react";
import type { ActionFunctionArgs } from "@vercel/remix";
import { redirect } from "@vercel/remix";
import { useRouteData } from "~/hooks";
@@ -68,6 +68,8 @@ export default function SupplierProcessRoute() {
const process = routeData?.processes.find((process) => process.id === id);
if (!process) throw new Error("Could not find process");
+ const navigate = useNavigate();
+
const initialValues = {
id: process.id ?? undefined,
supplierId: process.supplierId ?? "",
@@ -77,5 +79,10 @@ export default function SupplierProcessRoute() {
leadTime: process.leadTime ?? 0,
};
- return <SupplierProcessForm initialValues={initialValues} />;
+ return (
+ <SupplierProcessForm
+ initialValues={initialValues}
+ onClose={() => navigate(-1)}
+ />
+ );
}
diff --git a/apps/carbon/app/routes/x+/supplier+/$supplierId.processes.new.tsx b/apps/carbon/app/routes/x+/supplier+/$supplierId.processes.new.tsx
index c079213974..a37166562e 100644
--- a/apps/carbon/app/routes/x+/supplier+/$supplierId.processes.new.tsx
+++ b/apps/carbon/app/routes/x+/supplier+/$supplierId.processes.new.tsx
@@ -2,7 +2,7 @@ import { assertIsPost, error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
-import { useParams } from "@remix-run/react";
+import { useNavigate, useParams } from "@remix-run/react";
import type { ActionFunctionArgs } from "@vercel/remix";
import { json, redirect } from "@vercel/remix";
import {
@@ -59,6 +59,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
export default function NewSupplierProcessRoute() {
const { supplierId } = useParams();
+ const navigate = useNavigate();
if (!supplierId) throw new Error("Could not find supplier id");
@@ -70,5 +71,10 @@ export default function NewSupplierProcessRoute() {
leadTime: 0,
};
- return <SupplierProcessForm initialValues={initialValues} />;
+ return (
+ <SupplierProcessForm
+ initialValues={initialValues}
+ onClose={() => navigate(-1)}
+ />
+ );
}
diff --git a/packages/react/src/Button.tsx b/packages/react/src/Button.tsx
index 57990edc30..1b52621d86 100644
--- a/packages/react/src/Button.tsx
+++ b/packages/react/src/Button.tsx
@@ -139,15 +139,15 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
leftIcon &&
cloneElement(leftIcon, {
className: !leftIcon.props?.size
- ? cn("mr-2 h-4 w-4", leftIcon.props.className)
- : cn("mr-2", leftIcon.props.className),
+ ? cn("mr-2 h-4 w-4 flex-shrink-0", leftIcon.props.className)
+ : cn("mr-2 flex-shrink-0", leftIcon.props.className),
})}
<Slottable>{children}</Slottable>
{rightIcon &&
cloneElement(rightIcon, {
className: !rightIcon.props?.size
- ? cn("ml-2 h-4 w-4", rightIcon.props.className)
- : cn("ml-2", rightIcon.props.className),
+ ? cn("ml-2 h-4 w-4 flex-shrink-0", rightIcon.props.className)
+ : cn("ml-2 flex-shrink-0", rightIcon.props.className),
})}
</Comp>
);
diff --git a/packages/react/src/ModalDrawer.tsx b/packages/react/src/ModalDrawer.tsx
index 5db20f439c..c985ae99af 100644
--- a/packages/react/src/ModalDrawer.tsx
+++ b/packages/react/src/ModalDrawer.tsx
@@ -44,30 +44,16 @@ const useModalDrawerType = () => {
const ModalDrawer = forwardRef<
ElementRef<typeof Modal> | ElementRef<typeof Drawer>,
- | (ComponentPropsWithoutRef<typeof Modal> & {
- onClose?: () => void;
- })
- | (ComponentPropsWithoutRef<typeof Drawer> & {
- onClose?: () => void;
- })
->(({ onClose, ...props }, ref) => {
+ | ComponentPropsWithoutRef<typeof Modal>
+ | ComponentPropsWithoutRef<typeof Drawer>
+>((props, ref) => {
const type = useModalDrawerType();
if (type === "drawer") {
return <Drawer {...props} />;
}
- return (
- <Modal
- {...props}
- onOpenChange={(open) => {
- if (!open) {
- onClose?.();
- }
- }}
- open
- />
- );
+ return <Modal {...props} />;
});
ModalDrawer.displayName = "ModalDrawer";