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.

feat: add loading state to quote finalize button

Brad Barbin9620ad00fb81
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteFinalizeModal.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteFinalizeModal.tsx
index 8fb223bf56..cd4b8dafc1 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteFinalizeModal.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteFinalizeModal.tsx
@@ -10,6 +10,7 @@ import {
ModalTitle,
VStack,
} from "@carbon/react";
+import type { FetcherWithComponents } from "@remix-run/react";
import { useParams } from "@remix-run/react";
import { useState } from "react";
import { CustomerContact, SelectControlled } from "~/components/Form";
@@ -21,11 +22,13 @@ import type { Quotation } from "../../types";
type QuotationReleaseModalProps = {
onClose: () => void;
quote?: Quotation;
+ fetcher: FetcherWithComponents<{}>;
};
const QuotationReleaseModal = ({
quote,
onClose,
+ fetcher,
}: QuotationReleaseModalProps) => {
const { quoteId } = useParams();
if (!quoteId) throw new Error("quoteId not found");
@@ -56,6 +59,7 @@ const QuotationReleaseModal = ({
notification: notificationType as "Email" | "None",
customerContact: quote?.customerContactId ?? undefined,
}}
+ fetcher={fetcher}
>
<ModalHeader>
<ModalTitle>{`Release ${quote?.quoteId}`}</ModalTitle>
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx
index a75135c890..e91732774e 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx
@@ -1,6 +1,6 @@
import { Button, HStack, Heading, useDisclosure } from "@carbon/react";
-import { Form, Link, useParams } from "@remix-run/react";
+import { Form, Link, useFetcher, useParams } from "@remix-run/react";
import {
LuCheckCheck,
LuEye,
@@ -42,6 +42,8 @@ const QuoteHeader = () => {
? optimisticAssignment
: routeData?.quote?.assignee;
+ const finalizeFetcher = useFetcher<{}>();
+
return (
<>
<div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border shadow-md">
@@ -88,7 +90,9 @@ const QuoteHeader = () => {
</Form>
<Button
onClick={finalizeModal.onOpen}
+ isLoading={finalizeFetcher.state !== "idle"}
isDisabled={
+ finalizeFetcher.state !== "idle" ||
!permissions.can("update", "sales") ||
!routeData?.lines?.length
}
@@ -187,6 +191,7 @@ const QuoteHeader = () => {
<QuoteFinalizeModal
quote={routeData?.quote}
onClose={finalizeModal.onClose}
+ fetcher={finalizeFetcher}
/>
)}
{/* we use isOpen so we don't lose state */}