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.

- final changes - Replacing Active with Draft everywhere

Gaurav Bhattef272c2c2185
diff --git a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
index 3060b0a98f..c86bae8ac2 100644
--- a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
+++ b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
@@ -20,7 +20,7 @@ import { ValidatedForm } from "@carbon/form";
import { getItemReadableId } from "@carbon/utils";
import { useParams } from "@remix-run/react";
import { useEffect, useState } from "react";
-import type { z } from 'zod/v3';
+import type { z } from "zod/v3";
import {
ConversionFactor,
CustomFormFields,
@@ -292,9 +292,11 @@ const PurchaseInvoiceLineForm = ({
)}{" "}
{initialValues?.purchaseUnitOfMeasureCode}
</Badge>
- {initialValues?.taxPercent > 0 ? (
+ {(initialValues?.taxPercent ?? 0) > 0 ? (
<Badge variant="red">
- {percentFormatter.format(initialValues?.taxPercent)}{" "}
+ {percentFormatter.format(
+ initialValues?.taxPercent ?? 0
+ )}{" "}
Tax
</Badge>
) : null}
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteExplorer.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteExplorer.tsx
index 1e29d857ee..670a7a384a 100644
--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteExplorer.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteExplorer.tsx
@@ -57,7 +57,7 @@ export default function SupplierQuoteExplorer() {
const [deleteLine, setDeleteLine] = useState<SupplierQuoteLine | null>(null);
const isDisabled =
!permissions.can("delete", "purchasing") ||
- routeData?.quote?.status !== "Active";
+ routeData?.quote?.status !== "Draft";
const onDeleteLine = (line: SupplierQuoteLine) => {
setDeleteLine(line);
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteFinalizeModal.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteFinalizeModal.tsx
deleted file mode 100644
index 5d5777264e..0000000000
--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteFinalizeModal.tsx
+++ /dev/null
@@ -1,204 +0,0 @@
-import { useCarbon } from "@carbon/auth";
-import { ValidatedForm } from "@carbon/form";
-import {
- Alert,
- AlertDescription,
- AlertTitle,
- Button,
- Modal,
- ModalBody,
- ModalContent,
- ModalDescription,
- ModalFooter,
- ModalHeader,
- ModalTitle,
- useMount,
- VStack,
-} from "@carbon/react";
-import type { FetcherWithComponents } from "@remix-run/react";
-import { useParams } from "@remix-run/react";
-import { useState } from "react";
-import { LuTriangleAlert } from "react-icons/lu";
-import { SelectControlled, SupplierContact } from "~/components/Form";
-import { useIntegrations } from "~/hooks/useIntegrations";
-import { path } from "~/utils/path";
-import { supplierQuoteFinalizeValidator } from "../../purchasing.models";
-import {
- getSupplierQuoteLinePricesByQuoteId,
- getSupplierQuoteLines,
-} from "../../purchasing.service";
-import type {
- SupplierQuote,
- SupplierQuoteLine,
- SupplierQuoteLinePrice,
-} from "../../types";
-
-type SupplierQuoteFinalizeModalProps = {
- onClose: () => void;
- quote?: SupplierQuote;
- lines: SupplierQuoteLine[];
- pricing: SupplierQuoteLinePrice[];
- fetcher: FetcherWithComponents<{}>;
- action?: string;
-};
-
-const SupplierQuoteFinalizeModal = ({
- quote,
- onClose,
- fetcher,
- pricing,
- action,
-}: SupplierQuoteFinalizeModalProps) => {
- const { id } = useParams();
- if (!id) throw new Error("id not found");
-
- const integrations = useIntegrations();
- const canEmail = integrations.has("resend");
- const { carbon } = useCarbon();
-
- const [loading, setLoading] = useState(true);
- const [lines, setLines] = useState<SupplierQuoteLine[]>([]);
- const [prices, setPrices] = useState<SupplierQuoteLinePrice[]>([]);
-
- const fetchQuoteData = async () => {
- if (!carbon) return;
-
- const [linesData, pricesData] = await Promise.all([
- getSupplierQuoteLines(carbon, id),
- getSupplierQuoteLinePricesByQuoteId(carbon, id),
- ]);
- setLines(linesData.data ?? []);
- setPrices(pricesData.data ?? []);
-
- setLoading(false);
- };
-
- useMount(() => {
- fetchQuoteData();
- });
-
- const [notificationType, setNotificationType] = useState(
- canEmail ? "Email" : "Download"
- );
-
- const linesMissingQuoteLinePrices = lines
- .filter((line) => {
- if (!line.quantity || !Array.isArray(line.quantity)) return false;
- return line.quantity.some(
- (qty) =>
- !prices.some(
- (price) =>
- price.supplierQuoteLineId === line.id && price.quantity === qty
- )
- );
- })
- .map((line) => line.itemReadableId)
- .filter((id): id is string => id !== undefined);
-
- const linesWithZeroPriceOrLeadTime = prices
- .filter((price) => price.supplierUnitPrice === 0 || price.leadTime === 0)
- .map((price) => {
- const line = lines.find((line) => line.id === price.supplierQuoteLineId);
- return line?.itemReadableId;
- })
- .filter((id): id is string => id !== undefined);
-
- const warningLineReadableIds = [
- ...new Set([
- ...linesMissingQuoteLinePrices,
- ...linesWithZeroPriceOrLeadTime,
- ]),
- ];
-
- return (
- <Modal
- open
- onOpenChange={(open) => {
- if (!open) {
- onClose();
- }
- }}
- >
- <ModalContent>
- <ValidatedForm
- method="post"
- validator={supplierQuoteFinalizeValidator}
- action={action ?? path.to.supplierQuoteFinalize(id)}
- onSubmit={onClose}
- defaultValues={{
- notification: notificationType as "Email" | "None",
- supplierContact: quote?.supplierContactId ?? undefined,
- }}
- fetcher={fetcher}
- >
- <ModalHeader>
- <ModalTitle>
- {action === path.to.supplierQuoteSend(id)
- ? `Send ${quote?.supplierQuoteId}`
- : `Finalize ${quote?.supplierQuoteId}`}
- </ModalTitle>
- <ModalDescription>
- {action === path.to.supplierQuoteSend(id)
- ? "Send the supplier quote to the supplier via email."
- : "Are you sure you want to finalize the supplier quote?"}
- </ModalDescription>
- </ModalHeader>
- <ModalBody>
- <VStack spacing={4}>
- {warningLineReadableIds.length > 0 && (
- <Alert variant="destructive">
- <LuTriangleAlert className="h-4 w-4" />
- <AlertTitle>Lines need prices or lead times</AlertTitle>
- <AlertDescription>
- The following line items are missing prices or lead times:
- <ul className="list-disc py-2 pl-4">
- {warningLineReadableIds.map((readableId) => (
- <li key={readableId}>{readableId}</li>
- ))}
- </ul>
- </AlertDescription>
- </Alert>
- )}
- {canEmail && (
- <SelectControlled
- label="Send Via"
- name="notification"
- options={[
- {
- label: "None",
- value: "None",
- },
- {
- label: "Email",
- value: "Email",
- },
- ]}
- value={notificationType}
- onChange={(t) => {
- if (t) setNotificationType(t.value);
- }}
- />
- )}
- {notificationType === "Email" && (
- <SupplierContact
- name="supplierContact"
- supplier={quote?.supplierId ?? undefined}
- />
- )}
- </VStack>
- </ModalBody>
- <ModalFooter>
- <Button variant="secondary" onClick={onClose}>
- Cancel
- </Button>
- <Button isDisabled={loading} type="submit">
- Finalize
- </Button>
- </ModalFooter>
- </ValidatedForm>
- </ModalContent>
- </Modal>
- );
-};
-
-export default SupplierQuoteFinalizeModal;
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteForm.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteForm.tsx
index 3951be6e80..f64200e245 100644
--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteForm.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteForm.tsx
@@ -16,7 +16,7 @@ import { useFetcher } from "@remix-run/react";
import type { ReactNode } from "react";
import { useState } from "react";
import { flushSync } from "react-dom";
-import type { z } from 'zod/v3';
+import type { z } from "zod/v3";
import {
Currency,
CustomFormFields,
@@ -55,7 +55,7 @@ const SupplierQuoteForm = ({ initialValues }: SupplierQuoteFormProps) => {
currencyCode: initialValues.currencyCode,
});
- const isDisabled = initialValues?.status !== "Active";
+ const isDisabled = initialValues?.status !== "Draft";
const isEditing = initialValues.id !== undefined;
const exchangeRateFetcher = useFetcher<{ exchangeRate: number }>();
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteHeader.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteHeader.tsx
index 0e7c58b577..6be3c1b62a 100644
--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteHeader.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteHeader.tsx
@@ -1,4 +1,7 @@
import {
+ Alert,
+ AlertDescription,
+ AlertTitle,
Badge,
Button,
Copy,
@@ -21,9 +24,11 @@ import {
InputGroup,
Input,
InputRightElement,
+ VStack,
} from "@carbon/react";
import { Link, useFetcher, useParams } from "@remix-run/react";
+import type { FetcherWithComponents } from "@remix-run/react";
import {
LuEllipsisVertical,
LuPanelLeft,
@@ -37,6 +42,8 @@ import {
LuCheckCheck,
LuCircleStop,
LuLoaderCircle,
+ LuSend,
+ LuTriangleAlert,
} from "react-icons/lu";
import { usePanels } from "~/components/Layout";
import ConfirmDelete from "~/components/Modals/ConfirmDelete";
@@ -53,7 +60,7 @@ import type {
} from "../../types";
import SupplierQuoteStatus from "./SupplierQuoteStatus";
import SupplierQuoteToOrderDrawer from "./SupplierQuoteToOrderDrawer";
-import SupplierQuoteFinalizeModal from "./SupplierQuoteFinalizeModal";
+import SupplierQuoteSendModal from "./SupplierQuoteSendModal";
const SupplierQuoteHeader = () => {
const { id } = useParams();
@@ -81,9 +88,45 @@ const SupplierQuoteHeader = () => {
const finalizeFetcher = useFetcher<{}>();
const sendFetcher = useFetcher<{}>();
const statusFetcher = useFetcher<{}>();
+ const canShare =
+ routeData?.quote.externalLinkId &&
+ ["Draft", "Active"].includes(routeData?.quote?.status ?? "");
const hasLines = routeData?.lines && routeData.lines.length > 0;
+ // Validation logic for missing prices and leadtimes
+ const lines = routeData?.lines ?? [];
+ const prices = routeData?.prices ?? [];
+
+ const linesMissingQuoteLinePrices = lines
+ .filter((line) => {
+ if (!line.quantity || !Array.isArray(line.quantity)) return false;
+ return line.quantity.some(
+ (qty) =>
+ !prices.some(
+ (price) =>
+ price.supplierQuoteLineId === line.id && price.quantity === qty
+ )
+ );
+ })
+ .map((line) => line.itemReadableId)
+ .filter((id): id is string => id !== undefined);
+
+ const linesWithZeroPriceOrLeadTime = prices
+ .filter((price) => price.supplierUnitPrice === 0 || price.leadTime === 0)
+ .map((price) => {
+ const line = lines.find((line) => line.id === price.supplierQuoteLineId);
+ return line?.itemReadableId;
+ })
+ .filter((id): id is string => id !== undefined);
+
+ const warningLineReadableIds = [
+ ...new Set([
+ ...linesMissingQuoteLinePrices,
+ ...linesWithZeroPriceOrLeadTime,
+ ]),
+ ];
+
return (
<>
<div className="flex flex-shrink-0 items-center justify-between p-2 bg-card border-b h-[50px] overflow-x-auto scrollbar-hide">
@@ -132,7 +175,16 @@ const SupplierQuoteHeader = () => {
)}
</HStack>
<HStack>
- {(routeData?.quote as any)?.externalLinkId && (
+ {canShare && (
+ <Button
+ leftIcon={<LuShare />}
+ variant="secondary"
+ onClick={shareModal.onOpen}
+ >
+ Share
+ </Button>
+ )}
+ {canShare && (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
@@ -170,7 +222,7 @@ const SupplierQuoteHeader = () => {
!hasLines
}
variant="primary"
- leftIcon={<LuShare />}
+ leftIcon={<LuSend />}
>
Send
</Button>
@@ -203,7 +255,7 @@ const SupplierQuoteHeader = () => {
</Button>
)}
- {routeData?.quote?.status === "Active" && (
+ {routeData?.quote?.status === "Draft" && (
<statusFetcher.Form
method="post"
action={path.to.supplierQuoteStatus(id)}
@@ -227,30 +279,29 @@ const SupplierQuoteHeader = () => {
</statusFetcher.Form>
)}
- {routeData?.quote?.status !== "Draft" &&
- routeData?.quote?.status !== "Active" && (
- <statusFetcher.Form
- method="post"
- action={path.to.supplierQuoteStatus(id)}
+ {routeData?.quote?.status !== "Draft" && (
+ <statusFetcher.Form
+ method="post"
+ action={path.to.supplierQuoteStatus(id)}
+ >
+ <input type="hidden" name="status" value="Draft" />
+ <Button
+ isDisabled={
+ statusFetcher.state !== "idle" ||
+ !permissions.can("update", "purchasing")
+ }
+ isLoading={
+ statusFetcher.state !== "idle" &&
+ statusFetcher.formData?.get("status") === "Draft"
+ }
+ leftIcon={<LuLoaderCircle />}
+ type="submit"
+ variant="secondary"
>
- <input type="hidden" name="status" value="Draft" />
- <Button
- isDisabled={
- statusFetcher.state !== "idle" ||
- !permissions.can("update", "purchasing")
- }
- isLoading={
- statusFetcher.state !== "idle" &&
- statusFetcher.formData?.get("status") === "Draft"
- }
- leftIcon={<LuLoaderCircle />}
- type="submit"
- variant="secondary"
- >
- Reopen
- </Button>
- </statusFetcher.Form>
- )}
+ Reopen
+ </Button>
+ </statusFetcher.Form>
+ )}
<IconButton
aria-label="Toggle Properties"
@@ -286,20 +337,24 @@ const SupplierQuoteHeader = () => {
{finalizeModal.isOpen && (
<SupplierQuoteFinalizeModal
quote={routeData?.quote}
- lines={routeData?.lines ?? []}
- pricing={routeData?.prices ?? []}
onClose={finalizeModal.onClose}
fetcher={finalizeFetcher}
+ warningLineReadableIds={warningLineReadableIds}
/>
)}
{sendModal.isOpen && (
- <SupplierQuoteFinalizeModal
+ <SupplierQuoteSendModal
quote={routeData?.quote}
- lines={routeData?.lines ?? []}
- pricing={routeData?.prices ?? []}
onClose={sendModal.onClose}
fetcher={sendFetcher}
- action={path.to.supplierQuoteSend(id)}
+ />
+ )}
+ {finalizeModal.isOpen && (
+ <SupplierQuoteFinalizeModal
+ quote={routeData?.quote}
+ onClose={finalizeModal.onClose}
+ fetcher={sendFetcher}
+ warningLineReadableIds={warningLineReadableIds}
/>
)}
<ShareQuoteModal
@@ -312,6 +367,79 @@ const SupplierQuoteHeader = () => {
);
};
+function SupplierQuoteFinalizeModal({
+ quote,
+ onClose,
+ fetcher,
+ warningLineReadableIds,
+}: {
+ quote?: SupplierQuote;
+ onClose: () => void;
+ fetcher: FetcherWithComponents<{}>;
+ warningLineReadableIds: string[];
+}) {
+ const { id } = useParams();
+ if (!id) throw new Error("id not found");
+
+ const hasErrors = warningLineReadableIds.length > 0;
+
+ return (
+ <Modal
+ open
+ onOpenChange={(open) => {
+ if (!open) {
+ onClose();
+ }
+ }}
+ >
+ <ModalContent>
+ <ModalHeader>
+ <ModalTitle>Finalize {quote?.supplierQuoteId}</ModalTitle>
+ <ModalDescription>
+ Are you sure you want to finalize the supplier quote?
+ </ModalDescription>
+ </ModalHeader>
+ <ModalBody>
+ <VStack spacing={4}>
+ {hasErrors && (
+ <Alert variant="destructive">
+ <LuTriangleAlert className="h-4 w-4" />
+ <AlertTitle>Lines need prices or lead times</AlertTitle>
+ <AlertDescription>
+ The following line items are missing prices or lead times:
+ <ul className="list-disc py-2 pl-4">
+ {warningLineReadableIds.map((readableId) => (
+ <li key={readableId}>{readableId}</li>
+ ))}
+ </ul>
+ </AlertDescription>
+ </Alert>
+ )}
+ </VStack>
+ </ModalBody>
+ <ModalFooter>
+ <Button variant="secondary" onClick={onClose}>
+ Cancel
+ </Button>
+ <fetcher.Form
+ method="post"
+ action={path.to.supplierQuoteFinalize(id)}
+ onSubmit={onClose}
+ >
+ <Button
+ type="submit"
+ isDisabled={hasErrors || fetcher.state !== "idle"}
+ isLoading={fetcher.state !== "idle"}
+ >
+ Finalize
+ </Button>
+ </fetcher.Form>
+ </ModalFooter>
+ </ModalContent>
+ </Modal>
+ );
+}
+
function ShareQuoteModal({
id,
externalLinkId,
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLineForm.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLineForm.tsx
index 9e93b6872b..58d6cac990 100644
--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLineForm.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLineForm.tsx
@@ -27,7 +27,7 @@ import { useParams } from "@remix-run/react";
import { useState } from "react";
import { BsThreeDotsVertical } from "react-icons/bs";
import { LuTrash } from "react-icons/lu";
-import type { z } from 'zod/v3';
+import type { z } from "zod/v3";
import {
ArrayNumeric,
ConversionFactor,
@@ -71,7 +71,7 @@ const SupplierQuoteLineForm = ({
quote: SupplierQuote;
}>(path.to.supplierQuote(id));
- const isEditable = ["Active"].includes(routeData?.quote?.status ?? "");
+ const isEditable = ["Draft"].includes(routeData?.quote?.status ?? "");
const isEditing = initialValues.id !== undefined;
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLinePricing.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLinePricing.tsx
index 023f7e8783..897866d9f7 100644
--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLinePricing.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLinePricing.tsx
@@ -67,7 +67,7 @@ const SupplierQuoteLinePricing = ({
}>(path.to.supplierQuote(id));
const isEditable =
permissions.can("update", "purchasing") &&
- ["Active"].includes(routeData?.quote?.status ?? "");
+ ["Draft"].includes(routeData?.quote?.status ?? "");
const { carbon } = useCarbon();
const { id: userId, company } = useUser();
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteProperties.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteProperties.tsx
index 22309a00ea..2498d77d0b 100644
--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteProperties.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteProperties.tsx
@@ -14,7 +14,7 @@ import { useLocale } from "@react-aria/i18n";
import { useFetcher, useParams } from "@remix-run/react";
import { useCallback, useEffect, useMemo } from "react";
import { LuCopy, LuInfo, LuLink, LuRefreshCcw } from "react-icons/lu";
-import { z } from 'zod/v3';
+import { z } from "zod/v3";
import { zfd } from "zod-form-data";
import { Assignee, useOptimisticAssignment } from "~/components";
import {
@@ -106,7 +106,7 @@ const SupplierQuoteProperties = () => {
const isDisabled =
!permissions.can("update", "purchasing") ||
- !["Active"].includes(routeData?.quote?.status ?? "");
+ !["Draft", "Active"].includes(routeData?.quote?.status ?? "");
return (
<VStack
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteSendModal.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteSendModal.tsx
new file mode 100644
index 0000000000..3876aa9aa5
--- /dev/null
+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteSendModal.tsx
@@ -0,0 +1,108 @@
+import { ValidatedForm } from "@carbon/form";
+import {
+ Button,
+ Modal,
+ ModalBody,
+ ModalContent,
+ ModalDescription,
+ ModalFooter,
+ ModalHeader,
+ ModalTitle,
+ VStack,
+} from "@carbon/react";
+import type { FetcherWithComponents } from "@remix-run/react";
+import { useState } from "react";
+import { SelectControlled, SupplierContact } from "~/components/Form";
+import { useIntegrations } from "~/hooks/useIntegrations";
+import { supplierQuoteFinalizeValidator } from "../../purchasing.models";
+import type { SupplierQuote } from "../../types";
+import { path } from "~/utils/path";
+
+type SupplierQuoteSendModalProps = {
+ onClose: () => void;
+ quote?: SupplierQuote;
+ fetcher: FetcherWithComponents<{}>;
+};
+
+const SupplierQuoteSendModal = ({
+ quote,
+ onClose,
+ fetcher,
+}: SupplierQuoteSendModalProps) => {
+ const integrations = useIntegrations();
+ const canEmail = integrations.has("resend");
+
+ const [notificationType, setNotificationType] = useState(
+ canEmail ? "Email" : "None"
+ );
+
+ return (
+ <Modal
+ open
+ onOpenChange={(open) => {
+ if (!open) {
+ onClose();
+ }
+ }}
+ >
+ <ModalContent>
+ <ValidatedForm
+ method="post"
+ validator={supplierQuoteFinalizeValidator}
+ action={path.to.supplierQuoteSend(quote?.id)}
+ onSubmit={onClose}
+ defaultValues={{
+ notification: notificationType as "Email" | "None",
+ supplierContact: quote?.supplierContactId ?? undefined,
+ }}
+ fetcher={fetcher}
+ >
+ <ModalHeader>
+ <ModalTitle>Send {quote?.supplierQuoteId}</ModalTitle>
+ <ModalDescription>
+ Send the supplier quote to the supplier via email.
+ </ModalDescription>
+ </ModalHeader>
+ <ModalBody>
+ <VStack spacing={4}>
+ {canEmail && (
+ <SelectControlled
+ label="Send Via"
+ name="notification"
+ options={[
+ {
+ label: "None",
+ value: "None",
+ },
+ {
+ label: "Email",
+ value: "Email",
+ },
+ ]}
+ value={notificationType}
+ onChange={(t) => {
+ if (t) setNotificationType(t.value);
+ }}
+ />
+ )}
+ {notificationType === "Email" && (
+ <SupplierContact
+ name="supplierContact"
+ supplier={quote?.supplierId ?? undefined}
+ />
+ )}
+ </VStack>
+ </ModalBody>
+ <ModalFooter>
+ <Button variant="secondary" onClick={onClose}>
+ Cancel
+ </Button>
+ <Button type="submit">Send</Button>
+ </ModalFooter>
+ </ValidatedForm>
+ </ModalContent>
+ </Modal>
+ );
+};
+
+export default SupplierQuoteSendModal;
diff --git a/apps/erp/app/routes/share+/supplier-quote.$id.tsx b/apps/erp/app/routes/share+/supplier-quote.$id.tsx
index 0c118fb240..89d1fe69f6 100644
--- a/apps/erp/app/routes/share+/supplier-quote.$id.tsx
+++ b/apps/erp/app/routes/share+/supplier-quote.$id.tsx
@@ -1,6 +1,5 @@
import { getCarbonServiceRole } from "@carbon/auth";
import { Input, TextArea, ValidatedForm } from "@carbon/form";
-import type { JSONContent } from "@carbon/react";
import {
Badge,
Button,
@@ -9,7 +8,6 @@ import {
CardHeader,
CardTitle,
Checkbox,
- generateHTML,
Heading,
HStack,
Modal,
@@ -39,7 +37,6 @@ import { useFetcher, useLoaderData, useParams } from "@remix-run/react";
import type { LoaderFunctionArgs } from "@vercel/remix";
import { json } from "@vercel/remix";
import { motion } from "framer-motion";
-import MotionNumber from "motion-number";
import { useEffect, useRef, useState } from "react";
import { LuChevronRight, LuImage, LuPencil } from "react-icons/lu";
import type { Company } from "~/modules/settings";
@@ -272,33 +269,6 @@ const LineItems = ({
<div className="flex items-center gap-x-4 justify-between flex-grow">
<Heading>{line.itemReadableId}</Heading>
<HStack spacing={4}>
- {(() => {
- const lineSelections = selectedLines[line.id!] || {};
- const selectedCount =
- Object.keys(lineSelections).length;
- // Only show sum if there's a single quantity selected
- if (selectedCount === 1) {
- const sel = Object.values(lineSelections)[0];
- if (sel && sel.quantity > 0) {
- const total =
- sel.supplierUnitPrice * sel.quantity +
- sel.supplierShippingCost +
- sel.supplierTaxAmount;
- return total > 0 ? (
- <MotionNumber
- className="font-bold text-xl"
- value={total}
- format={{
- style: "currency",
- currency: currencyCode,
- }}
- locales={locale}
- />
- ) : null;
- }
- }
- return null;
- })()}
<motion.div
animate={{
rotate: openItems.includes(line.id!) ? 90 : 0,
@@ -312,14 +282,6 @@ const LineItems = ({
<span className="text-muted-foreground text-base truncate">
{line.description}
</span>
- {Object.keys(line.externalNotes ?? {}).length > 0 && (
- <div
- className="prose dark:prose-invert mt-2 text-muted-foreground"
- dangerouslySetInnerHTML={{
- __html: generateHTML(line.externalNotes as JSONContent),
- }}
- />
- )}
</div>
</VStack>
</HStack>
@@ -775,21 +737,6 @@ const Quote = ({
quoteStatus={quote.status}
quoteLinePrices={quoteLinePrices}
/>
-
- {/* <div className="mt-8 border-t pt-4">
- <HStack className="justify-between text-xl font-bold w-full">
- <span>Estimated Total:</span>
- <MotionNumber
- value={grandTotal}
- format={{
- style: "currency",
- currency: quote.currencyCode ?? "USD",
- }}
- locales={locale}
- />
- </HStack>
- </div> */}
-
<div className="flex flex-col gap-2">
{(quote?.status as string) === "Draft" && (
<VStack className="w-full mt-8 gap-4">
diff --git a/apps/erp/app/routes/x+/supplier-quote+/$id.finalize.tsx b/apps/erp/app/routes/x+/supplier-quote+/$id.finalize.tsx
index 82fc8042bd..a7ea50baf9 100644
--- a/apps/erp/app/routes/x+/supplier-quote+/$id.finalize.tsx
+++ b/apps/erp/app/routes/x+/supplier-quote+/$id.finalize.tsx
@@ -199,31 +199,16 @@ export async function action(args: ActionFunctionArgs) {
)}`;
const emailSubject = `Supplier Quote ${supplierQuote.data.supplierQuoteId} from ${company.data.name}`;
- const emailBody = `
- Hi ${supplierContact.data.contact.firstName ?? ""},
+ const emailBody = `This link is for supplier quote ${supplierQuote.data.supplierQuoteId}. Please go to the link below to fill out the supplier code.`;
- Please review the supplier quote ${
- supplierQuote.data.supplierQuoteId
- }.
-
- You can view and respond to this quote at: ${externalQuoteUrl}
-
- ${
- quote.data.expirationDate
- ? `This quote expires on ${quote.data.expirationDate}.`
- : ""
- }
-
- Best regards,
- ${user.data.firstName} ${user.data.lastName}
- `;
+ const emailBodyHtml = `This link is for supplier quote ${supplierQuote.data.supplierQuoteId}. Please go to the link below to fill out the supplier code.<br><br><a href="${externalQuoteUrl}">${externalQuoteUrl}</a>`;
await tasks.trigger<typeof sendEmailResendTask>("send-email-resend", {
to: [user.data.email, supplierContact.data.contact.email],
from: user.data.email,
subject: emailSubject,
- html: emailBody.replace(/\n/g, "<br>"),
- text: emailBody,
+ html: emailBodyHtml,
+ text: `${emailBody}\n\n${externalQuoteUrl}`,
companyId,
});
} catch (err) {
diff --git a/apps/erp/app/routes/x+/supplier-quote+/$id.send.tsx b/apps/erp/app/routes/x+/supplier-quote+/$id.send.tsx
index af978fbd3b..d41c896ac7 100644
--- a/apps/erp/app/routes/x+/supplier-quote+/$id.send.tsx
+++ b/apps/erp/app/routes/x+/supplier-quote+/$id.send.tsx
@@ -114,31 +114,16 @@ export async function action(args: ActionFunctionArgs) {
)}`;
const emailSubject = `Supplier Quote ${supplierQuote.data.supplierQuoteId} from ${company.data.name}`;
- const emailBody = `
- Hi ${supplierContact.data.contact.firstName ?? ""},
+ const emailBody = `This link is for supplier quote ${supplierQuote.data.supplierQuoteId}. Please go to the link below to fill out the supplier code.`;
- Please review the supplier quote ${
- supplierQuote.data.supplierQuoteId
- }.
-
- You can view and respond to this quote at: ${externalQuoteUrl}
-
- ${
- quote.data.expirationDate
- ? `This quote expires on ${quote.data.expirationDate}.`
- : ""
- }
-
- Best regards,
- ${user.data.firstName} ${user.data.lastName}
- `;
+ const emailBodyHtml = `This link is for supplier quote ${supplierQuote.data.supplierQuoteId}. Please go to the link below to fill out the supplier code.<br><br><a href="${externalQuoteUrl}">${externalQuoteUrl}</a>`;
await tasks.trigger<typeof sendEmailResendTask>("send-email-resend", {
to: [user.data.email, supplierContact.data.contact.email],
from: user.data.email,
subject: emailSubject,
- html: emailBody.replace(/\n/g, "<br>"),
- text: emailBody,
+ html: emailBodyHtml,
+ text: `${emailBody}\n\n${externalQuoteUrl}`,
companyId,
});
} catch (err) {