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
feat: refactor resend integration to generic email (#656)
Sid8c2247c1a19d
diff --git a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoicePostModal.tsx b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoicePostModal.tsxindex 49a0f354d1..c29579d506 100644--- a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoicePostModal.tsx+++ b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoicePostModal.tsx@@ -59,7 +59,7 @@ const SalesInvoicePostModal = ({const { t } = useLingui();const hasLinesToShip = linesToShip.length > 0;const integrations = useIntegrations();- const canEmail = integrations.has("resend");+ const canEmail = integrations.has("email");const [notificationType, setNotificationType] = useState(canEmail ? "Email" : "None"diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderApprovalModal.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderApprovalModal.tsxindex 951062ef19..9871ce5a8c 100644--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderApprovalModal.tsx+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderApprovalModal.tsx@@ -47,7 +47,7 @@ const PurchaseOrderApprovalModal = ({const { t } = useLingui();const integrations = useIntegrations();- const canEmail = integrations.has("resend");+ const canEmail = integrations.has("email");const isApproving = decision === "Approved";const [notificationType, setNotificationType] = useState(diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderFinalizeModal.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderFinalizeModal.tsxindex 20a01d0ef5..1a8ba9151e 100644--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderFinalizeModal.tsx+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderFinalizeModal.tsx@@ -42,7 +42,7 @@ const PurchaseOrderFinalizeModal = ({const { t } = useLingui();const integrations = useIntegrations();- const canEmail = integrations.has("resend");+ const canEmail = integrations.has("email");const [notificationType, setNotificationType] = useState(canEmail ? "Email" : "Download"diff --git a/apps/erp/app/modules/purchasing/ui/PurchasingRfq/FinalizeRFQModal.tsx b/apps/erp/app/modules/purchasing/ui/PurchasingRfq/FinalizeRFQModal.tsxindex e49659da76..2e8fbcf5ba 100644--- a/apps/erp/app/modules/purchasing/ui/PurchasingRfq/FinalizeRFQModal.tsx+++ b/apps/erp/app/modules/purchasing/ui/PurchasingRfq/FinalizeRFQModal.tsx@@ -44,7 +44,7 @@ const FinalizeRFQModal = ({}: FinalizeRFQModalProps) => {const { t } = useLingui();const integrations = useIntegrations();- const canEmail = integrations.has("resend");+ const canEmail = integrations.has("email");const fetcher = useFetcher<{ error: string | null }>();const isLoading = fetcher.state !== "idle";diff --git a/apps/erp/app/modules/purchasing/ui/PurchasingRfq/PurchasingRFQHeader.tsx b/apps/erp/app/modules/purchasing/ui/PurchasingRfq/PurchasingRFQHeader.tsxindex 59ebab7120..08af3662bf 100644--- a/apps/erp/app/modules/purchasing/ui/PurchasingRfq/PurchasingRFQHeader.tsx+++ b/apps/erp/app/modules/purchasing/ui/PurchasingRfq/PurchasingRFQHeader.tsx@@ -61,7 +61,7 @@ const PurchasingRFQHeader = () => {const permissions = usePermissions();const integrations = useIntegrations();- const canEmail = integrations.has("resend");+ const canEmail = integrations.has("email");const finalizeFetcher = useFetcher<{ error: string | null }>();const routeData = useRouteData<{diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteFinalizeModal.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteFinalizeModal.tsxindex 0ad5b8ad82..65621a58c2 100644--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteFinalizeModal.tsx+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteFinalizeModal.tsx@@ -33,7 +33,7 @@ const SupplierQuoteFinalizeModal = ({}: SupplierQuoteFinalizeModalProps) => {const { t } = useLingui();const integrations = useIntegrations();- const canEmail = integrations.has("resend");+ const canEmail = integrations.has("email");const [notificationType, setNotificationType] = useState(canEmail ? "Email" : "None"diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteSendModal.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteSendModal.tsxindex afaba5579d..083d70d119 100644--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteSendModal.tsx+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteSendModal.tsx@@ -45,7 +45,7 @@ const SupplierQuoteSendModal = ({}: SupplierQuoteSendModalProps) => {const { t } = useLingui();const integrations = useIntegrations();- const canEmail = integrations.has("resend");+ const canEmail = integrations.has("email");const [notificationType, setNotificationType] = useState(canEmail ? "Email" : "Share"diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteFinalizeModal.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteFinalizeModal.tsxindex 6234e4e135..459e9dfa38 100644--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteFinalizeModal.tsx+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteFinalizeModal.tsx@@ -62,7 +62,7 @@ const QuotationFinalizeModal = ({if (!quoteId) throw new Error("quoteId not found");const integrations = useIntegrations();- const canEmail = integrations.has("resend");+ const canEmail = integrations.has("email");const { carbon } = useCarbon();const [loading, setLoading] = useState(true);diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteToOrderDrawer.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteToOrderDrawer.tsxindex c3691750b8..176a42a520 100644--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteToOrderDrawer.tsx+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteToOrderDrawer.tsx@@ -1027,7 +1027,7 @@ function NotificationOptionsForm({ quote }: { quote: Quotation }) {const { t } = useLingui();const [isExpanded, setIsExpanded] = useState(true);const integrations = useIntegrations();- const canEmail = integrations.has("resend");+ const canEmail = integrations.has("email");const [notificationType, setNotificationType] = useState(canEmail ? "Email" : "None");diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsxindex 1271268d2a..518cbba57d 100644--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx@@ -80,7 +80,7 @@ const SalesOrderConfirmModal = ({if (!orderId) throw new Error("orderId not found");const integrations = useIntegrations();- const canEmail = integrations.has("resend");+ const canEmail = integrations.has("email");const [notificationType, setNotificationType] = useState<"Email" | "None">(canEmail ? "Email" : "None"diff --git a/apps/erp/app/modules/settings/settings.server.ts b/apps/erp/app/modules/settings/settings.server.tsindex e02495686a..2c8d89894f 100644--- a/apps/erp/app/modules/settings/settings.server.ts+++ b/apps/erp/app/modules/settings/settings.server.ts@@ -412,3 +412,12 @@ export async function getIntegrationsWithHealth(error: null};}++export async function invalidateIntegrationHealthCache(+ integrationId: string,+ companyId: string+) {+ const key = `integrations:${companyId}:${integrationId}:health`;++ return await redis.del(key);+}diff --git a/apps/erp/app/modules/settings/ui/Integrations/IntegrationForm.tsx b/apps/erp/app/modules/settings/ui/Integrations/IntegrationForm.tsxindex bb57babe3e..c61dc50861 100644--- a/apps/erp/app/modules/settings/ui/Integrations/IntegrationForm.tsx+++ b/apps/erp/app/modules/settings/ui/Integrations/IntegrationForm.tsx@@ -6,19 +6,19 @@ import type {} from "@carbon/ee";import { integrations as availableIntegrations } from "@carbon/ee";import {- Array,- Boolean,+ ChoiceCardGroup,+ Array as FormArray,Input,+ Number as NumberInput,+ Password,Select,Submit,+ useControlField,ValidatedForm} from "@carbon/form";import {Badge,Button,- Collapsible,- CollapsibleContent,- CollapsibleTrigger,Drawer,DrawerBody,DrawerContent,@@ -27,13 +27,13 @@ import {Heading,HStack,ScrollArea,+ Switch,toast,VStack} from "@carbon/react";import { SUPPORT_EMAIL } from "@carbon/utils";import { Trans, useLingui } from "@lingui/react/macro";import { useCallback, useMemo, useState } from "react";-import { LuChevronDown } from "react-icons/lu";import { useParams } from "react-router";import { Processes } from "~/components/Form";import { MethodIcon, TrackingTypeIcon } from "~/components/Icons";@@ -99,11 +99,7 @@ function IntegrationActionButton({/*** Helper to normalize option to consistent format*/-function normalizeOption(option: IntegrationSettingOption): {- value: string;- label: string;- description?: string;-} {+function normalizeOption(option: IntegrationSettingOption) {if (typeof option === "string") {return { value: option, label: option };}@@ -111,9 +107,35 @@ function normalizeOption(option: IntegrationSettingOption): {}/**- * Renders a single setting field based on its type+ * Wrapper that hides a setting field when its `visibleWhen` condition+ * does not match the current value of the referenced field.+ *+ * Must be mounted as a dedicated component so `useControlField` is only+ * called when `visibleWhen` is defined (satisfies the rules of hooks).+ */+function ConditionalSettingField({ setting }: { setting: IntegrationSetting }) {+ const condition = setting.visibleWhen!;+ const [value] = useControlField<unknown>(condition.field);+ const current = value == null ? "" : String(value);+ const equals = Array.isArray(condition.equals)+ ? condition.equals+ : [condition.equals];+ if (!equals.includes(current)) return null;+ return <SettingFieldInner setting={setting} />;+}++/**+ * Renders a single setting field based on its type,+ * honouring any `visibleWhen` gating.*/function SettingField({ setting }: { setting: IntegrationSetting }) {+ if (setting.visibleWhen) {+ return <ConditionalSettingField setting={setting} />;+ }+ return <SettingFieldInner setting={setting} />;+}++function SettingFieldInner({ setting }: { setting: IntegrationSetting }) {switch (setting.type) {case "text":return (@@ -124,30 +146,47 @@ function SettingField({ setting }: { setting: IntegrationSetting }) {isOptional={!setting.required}/>{setting.description && (- <p className="text-xs text-muted-foreground mt-1">+ <p className="text-xs text-muted-foreground mt-1.5">{setting.description}</p>)}</div>);- case "switch":+ case "number":return (- <div className="flex items-center justify-between gap-4 w-full py-2">- <div className="flex flex-col flex-1">- <span className="text-sm font-medium">{setting.label}</span>- {setting.description && (- <span className="text-xs text-muted-foreground">- {setting.description}- </span>- )}- </div>- <div className="shrink-0">- <Boolean name={setting.name} />- </div>+ <div className="w-full">+ <NumberInput+ name={setting.name}+ label={setting.label}+ isRequired={setting.required}+ />+ {setting.description && (+ <p className="text-xs text-muted-foreground mt-1.5">+ {setting.description}+ </p>+ )}</div>);+ case "password":+ return (+ <div className="w-full">+ <Password name={setting.name} label={setting.label} />+ {setting.description && (+ <p className="text-xs text-muted-foreground mt-1.5">+ {setting.description}+ </p>+ )}+ </div>+ );++ case "cards":+ return <CardSelector setting={setting} />;++ case "switch":+ return <SwitchField setting={setting} />;+case "processes":return (<div className="w-full">@@ -163,7 +202,7 @@ function SettingField({ setting }: { setting: IntegrationSetting }) {case "array":return (<div className="w-full">- <Array name={setting.name} label={setting.label} />+ <FormArray name={setting.name} label={setting.label} />{setting.description && (<p className="text-xs text-muted-foreground mt-1">{setting.description}@@ -173,36 +212,40 @@ function SettingField({ setting }: { setting: IntegrationSetting }) {);case "options": {- const options =- setting.listOptions?.map((option) => {- const normalized = normalizeOption(option);- let icon: JSX.Element | null = null;-- // Legacy icon support for specific field names- if (setting.name === "methodType") {- icon = <MethodIcon type={normalized.value} />;- } else if (setting.name === "trackingType") {- icon = <TrackingTypeIcon type={normalized.value} />;- }-- // Build a simpler label that works well with Radix Select- const label = (- <span key={normalized.value} className="flex items-center gap-2">- {icon}- <span className="font-medium">{normalized.label}</span>- {normalized.description && (- <span className="text-muted-foreground text-xs">- — {normalized.description}- </span>- )}- </span>- );+ const listOptions = setting.listOptions ?? [];++ // Small static enums render as Choice cards (the same affordance as+ // the explicit `cards` type). Long / dynamically-loaded lists keep+ // the dropdown so things like Xero account pickers stay usable.+ if (+ listOptions.length > 0 &&+ listOptions.length <= CHOICE_CARD_MAX_OPTIONS+ ) {+ return <CardSelector setting={setting} />;+ }- return {- label,- value: normalized.value- };- }) ?? [];+ const options = listOptions.map((option) => {+ const normalized = normalizeOption(option);+ const icon = getOptionIcon(setting.name, normalized.value);++ // Build a simpler label that works well with Radix Select+ const label = (+ <span key={normalized.value} className="flex items-center gap-2">+ {icon}+ <span className="font-medium">{normalized.label}</span>+ {normalized.description && (+ <span className="text-muted-foreground text-xs">+ — {normalized.description}+ </span>+ )}+ </span>+ );++ return {+ label,+ value: normalized.value+ };+ });return (<div className="w-full">@@ -222,9 +265,152 @@ function SettingField({ setting }: { setting: IntegrationSetting }) {}/**- * Renders a collapsible group of settings+ * Card-style picker for mutually-exclusive options. Wraps the shared+ * `ChoiceCardGroup` and binds it into the surrounding ValidatedForm via+ * `useControlField` + a hidden input so the value gets serialized on submit.+ *+ * Used for both the explicit `cards` setting type and for small (≤5) static+ * `options` lists, so the integration form picks the right affordance based+ * on payload size — Choice cards for tight enums, dropdowns for long /+ * dynamically-loaded lists (e.g. Xero account codes).*/-function SettingsGroup({+function CardSelector({ setting }: { setting: IntegrationSetting }) {+ const [value, setValue] = useControlField<string>(setting.name);+ const options = (setting.listOptions ?? []).map(normalizeOption);+ const current = value == null ? "" : String(value);++ return (+ <div className="w-full">+ {setting.label && (+ <div className="flex flex-col gap-0.5 pb-2">+ <div className="text-sm font-medium text-foreground">+ {setting.label}+ </div>+ {setting.description && (+ <p className="text-xs text-muted-foreground">+ {setting.description}+ </p>+ )}+ </div>+ )}+ <ChoiceCardGroup+ value={current}+ onChange={setValue}+ options={options.map((option) => ({+ value: option.value,+ title: option.label,+ description: option.description,+ icon: getOptionIcon(setting.name, option.value) ?? option.icon+ }))}+ />+ {/* Hidden input keeps the value in form data on submit */}+ <input type="hidden" name={setting.name} value={current} />+ </div>+ );+}++/**+ * Boolean toggle bound to the surrounding ValidatedForm.+ *+ * We deliberately don't reuse `@carbon/form`'s `Boolean`, because that one+ * leans on Radix's built-in hidden checkbox — which only posts a value when+ * *checked*, so an unchecked switch sends nothing and any `.default(true)`+ * in the Zod schema quietly reasserts `true` on save. Users then can't turn+ * the field off (e.g. the Email integration's "Use TLS" switch stayed stuck+ * on).+ *+ * Instead, we drive the `Switch` as a controlled component via+ * `useControlField` and emit our own hidden input that *always* contains+ * either `"true"` or `"false"`, so the posted form data is unambiguous.+ * Schemas consuming these fields need to preprocess the string into a+ * boolean (see `packages/ee/src/email/config.tsx`).+ */+function SwitchField({ setting }: { setting: IntegrationSetting }) {+ const [value, setValue] = useControlField<boolean>(setting.name);+ const checked = value === true;++ return (+ <div className="flex items-center justify-between gap-4 w-full py-2">+ <div className="flex flex-col flex-1">+ <span className="text-sm font-medium">{setting.label}</span>+ {setting.description && (+ <span className="text-xs text-muted-foreground">+ {setting.description}+ </span>+ )}+ </div>+ <div className="shrink-0">+ <Switch+ checked={checked}+ onCheckedChange={setValue}+ aria-label={setting.label}+ />+ <input+ type="hidden"+ name={setting.name}+ value={checked ? "true" : "false"}+ />+ </div>+ </div>+ );+}++/**+ * Legacy icon support for specific field names that historically rendered+ * a leading glyph in the Select dropdown. Returns null when there's no+ * registered icon so ChoiceCardGroup just omits the icon slot.+ */+function getOptionIcon(+ settingName: string,+ optionValue: string+): JSX.Element | null {+ if (settingName === "methodType") {+ return <MethodIcon type={optionValue} />;+ }+ if (settingName === "trackingType") {+ return <TrackingTypeIcon type={optionValue} />;+ }++ return null;+}++/** Threshold for switching `options` from a Select dropdown to ChoiceCardGroup. */+const CHOICE_CARD_MAX_OPTIONS = 5;++/**+ * Wrapper that hides an entire group when every setting in it is gated+ * by the same `visibleWhen` field and none of them are currently visible.+ * Only mounted when the group actually shares a single `visibleWhen` field.+ */+function GatedSettingsGroup({+ name,+ description,+ settings,+ controlledField+}: {+ name: string;+ description?: string;+ settings: IntegrationSetting[];+ controlledField: string;+}) {+ const [value] = useControlField<unknown>(controlledField);+ const current = value == null ? "" : String(value);+ const anyVisible = settings.some((s) => {+ const eq = s.visibleWhen!.equals;+ const equals = Array.isArray(eq) ? eq : [eq];+ return equals.includes(current);+ });+ if (!anyVisible) return null;+ return (+ <SettingsGroup name={name} description={description} settings={settings} />+ );+}++/**+ * Decides whether a group should be gated behind a shared `visibleWhen`+ * condition, and renders the appropriate component.+ */+function ConditionalSettingsGroup({name,description,settings@@ -233,31 +419,59 @@ function SettingsGroup({description?: string;settings: IntegrationSetting[];}) {- const [isOpen, setIsOpen] = useState(true);+ const firstCondition = settings[0]?.visibleWhen;+ const sharesCondition =+ firstCondition !== undefined &&+ settings.every(+ (s) => s.visibleWhen && s.visibleWhen.field === firstCondition.field+ );+ if (sharesCondition) {+ return (+ <GatedSettingsGroup+ name={name}+ description={description}+ settings={settings}+ controlledField={firstCondition!.field}+ />+ );+ }++ return (+ <SettingsGroup name={name} description={description} settings={settings} />+ );+}++/**+ * Renders a group of related settings under a subtle section header.+ * Previously this was a collapsible, but every consumer always opened it+ * by default and never closed it, so the chrome was pure noise.+ */+function SettingsGroup({+ name,+ description,+ settings+}: {+ name: string;+ description?: string;+ settings: IntegrationSetting[];+}) {return (- <Collapsible open={isOpen} onOpenChange={setIsOpen} className="w-full">- <CollapsibleTrigger className="flex items-center justify-between w-full py-2 group">- <Heading size="h4" className="text-left">+ <div className="w-full border-t border-border pt-4">+ <div className="flex flex-col gap-1 pb-3">+ <div className="text-[0.6875rem] font-semibold uppercase tracking-wider text-foreground/70">{name}- </Heading>- <LuChevronDown- className={`h-4 w-4 text-muted-foreground transition-transform duration-200 ${- isOpen ? "rotate-180" : ""- }`}- />- </CollapsibleTrigger>- {description && (- <p className="text-sm text-muted-foreground">{description}</p>- )}- <CollapsibleContent>- <VStack spacing={4} className="pt-2">- {settings.map((setting) => (- <SettingField key={setting.name} setting={setting} />- ))}- </VStack>- </CollapsibleContent>- </Collapsible>+ </div>+ {description && (+ <p className="text-xs text-muted-foreground">{description}</p>+ )}+ </div>+ <VStack spacing={4}>+ {settings.map((setting) => (+ <SettingField key={setting.name} setting={setting} />+ ))}+ </VStack>+ </div>);}@@ -384,50 +598,53 @@ export function IntegrationForm({className="flex flex-col h-full"><DrawerHeader>- <VStack spacing={2}>- <integration.logo className="h-10 w-auto" />- <div>- <div className="flex items-center space-x-2">- <Heading size="h3">{integration.name}</Heading>-- {installed && <Badge variant="green">Installed</Badge>}-- <span className="text-xs text-[#878787] text-right">- <Badge variant="secondary">{integration.category}</Badge> •- <Trans>Published by Carbon</Trans>- </span>+ <div className="flex flex-col gap-3">+ <div className="flex items-center gap-3">+ <div className="flex size-10 items-center justify-center rounded-lg border border-border bg-card p-1.5">+ <integration.logo className="h-full w-auto" /></div>-- {installed && connectedOrgName && (- <div className="text-sm text-muted-foreground">- Connected to{" "}- <span className="font-medium text-foreground">- {connectedOrgName}+ <div className="flex min-w-0 flex-1 flex-col gap-0.5">+ <div className="flex items-center gap-2">+ <Heading size="h3" className="truncate">+ {integration.name}+ </Heading>+ {installed && <Badge variant="green">Installed</Badge>}+ </div>+ <div className="flex items-center gap-1.5 text-xs text-muted-foreground">+ <Badge variant="secondary">{integration.category}</Badge>+ <span aria-hidden>•</span>+ <span>+ <Trans>Published by Carbon</Trans></span></div>- )}+ </div></div>- </VStack>+ {installed && connectedOrgName && (+ <div className="text-sm text-muted-foreground">+ <Trans>Connected to</Trans>{" "}+ <span className="font-medium text-foreground">+ {connectedOrgName}+ </span>+ </div>+ )}+ </div></DrawerHeader><DrawerBody><ScrollArea className="h-[calc(100dvh-240px)] -mx-2 pb-8"><VStack spacing={4} className="px-2">- <Heading size="h3">- <Trans>How it works</Trans>- </Heading>- <div className="text-sm text-muted-foreground">+ <p className="text-xs leading-relaxed text-muted-foreground">{integration.description}- </div>+ </p>{/* @ts-expect-error TS2339 */}{integration.setupInstructions && (- <>- <Heading size="h3">- <Trans>Setup Instructions</Trans>- </Heading>+ <div className="flex flex-col gap-2">+ <div className="text-[0.6875rem] font-semibold uppercase tracking-wider text-foreground/70">+ <Trans>Setup instructions</Trans>+ </div>{/* @ts-expect-error TS2339 */}<integration.setupInstructions companyId={companyId} />- </>+ </div>)}{/* Ungrouped settings appear first */}@@ -439,9 +656,9 @@ export function IntegrationForm({</VStack>)}- {/* Grouped settings in collapsible sections */}+ {/* Grouped settings in flat sections */}{groupNames.map((groupName) => (- <SettingsGroup+ <ConditionalSettingsGroupkey={groupName}name={groupName}description={groupDescriptions.get(groupName)}@@ -454,10 +671,10 @@ export function IntegrationForm({integration.actions &&// @ts-expect-error TS2339 - TODO: fix typeintegration.actions.length > 0 && (- <>- <Heading size="h3">+ <div className="flex w-full flex-col gap-3 border-t border-border pt-4">+ <div className="text-[0.6875rem] font-semibold uppercase tracking-wider text-foreground/70"><Trans>Actions</Trans>- </Heading>+ </div><VStack spacing={2} className="w-full">{/* @ts-expect-error TS7006 */}{integration.actions.map((action) => (@@ -468,21 +685,23 @@ export function IntegrationForm({/>))}</VStack>- </>+ </div>)}</VStack></ScrollArea>- <p className="text-sm text-muted-foreground">- Carbon Manufacturing Systems does not endorse any third-party- software. Report any concerns about app content or behavior.- </p>-- <a- href={`mailto:${SUPPORT_EMAIL}`}- className="text-sm text-red-500"- >- Report integration- </a>+ <div className="mt-2">+ <p className="text-[0.6875rem] leading-relaxed text-muted-foreground">+ Carbon Manufacturing Systems does not endorse any third-party+ software.{" "}+ <a+ href={`mailto:${SUPPORT_EMAIL}`}+ className="underline decoration-dotted underline-offset-2 hover:text-foreground"+ >+ Report integration+ </a>+ .+ </p>+ </div></DrawerBody><DrawerFooter><HStack>diff --git a/apps/erp/app/modules/shared/shared.server.ts b/apps/erp/app/modules/shared/shared.server.tsindex 84d730c7c9..20f72805bd 100644--- a/apps/erp/app/modules/shared/shared.server.ts+++ b/apps/erp/app/modules/shared/shared.server.ts@@ -269,12 +269,11 @@ export async function sendSalesOrderEmail(args: {const html = await renderAsync(emailTemplate);const text = await renderAsync(emailTemplate, { plainText: true });-const { data: signedUrlData } = await serviceRole.storage.from("private").createSignedUrl(documentFilePath, 3600);- await trigger("send-email-resend", {+ await trigger("send-email", {to: [seller.data.email, customer.data.contact.email!],cc: ccSelections?.length ? ccSelections : undefined,from: seller.data.email,diff --git a/apps/erp/app/routes/x+/purchase-order+/$orderId.finalize.tsx b/apps/erp/app/routes/x+/purchase-order+/$orderId.finalize.tsxindex 72f9634481..5b11f2f6f9 100644--- a/apps/erp/app/routes/x+/purchase-order+/$orderId.finalize.tsx+++ b/apps/erp/app/routes/x+/purchase-order+/$orderId.finalize.tsx@@ -337,7 +337,7 @@ export async function action(args: ActionFunctionArgs) {.createSignedUrl(documentFilePath, 3600);await Promise.all([- trigger("send-email-resend", {+ trigger("send-email", {to: [buyer.data.email, supplier.data.contact.email],cc: ccSelections?.length ? ccSelections : undefined,from: buyer.data.email,diff --git a/apps/erp/app/routes/x+/purchase-order+/$orderId.tsx b/apps/erp/app/routes/x+/purchase-order+/$orderId.tsxindex bef9bbf461..7a651ce666 100644--- a/apps/erp/app/routes/x+/purchase-order+/$orderId.tsx+++ b/apps/erp/app/routes/x+/purchase-order+/$orderId.tsx@@ -265,7 +265,7 @@ export async function action(args: ActionFunctionArgs) {.from("private").createSignedUrl(documentFilePath!, 3600);- await trigger("send-email-resend", {+ await trigger("send-email", {to: [buyer.data.email, supplierEmail],cc: ccSelections?.length ? ccSelections : undefined,from: buyer.data.email,diff --git a/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.finalize.tsx b/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.finalize.tsxindex a0e82b8ce9..ab78d5f1d3 100644--- a/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.finalize.tsx+++ b/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.finalize.tsx@@ -292,7 +292,7 @@ export async function action({ request, params }: ActionFunctionArgs) {htmlParts.push(`<br><br>${emailSignature.replace(/\n/g, "<br>")}`);- await trigger("send-email-resend", {+ await trigger("send-email", {to: [user.data.email, email.contactEmail],from: user.data.email,subject: emailSubject,diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.finalize.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.finalize.tsxindex 66e76d46d3..c965944e6d 100644--- a/apps/erp/app/routes/x+/quote+/$quoteId.finalize.tsx+++ b/apps/erp/app/routes/x+/quote+/$quoteId.finalize.tsx@@ -191,12 +191,11 @@ export async function action(args: ActionFunctionArgs) {const html = await renderAsync(emailTemplate);const text = await renderAsync(emailTemplate, { plainText: true });-const { data: signedUrlData } = await client.storage.from("private").createSignedUrl(documentFilePath, 3600);- await trigger("send-email-resend", {+ await trigger("send-email", {to: [user.data.email, customerContact.data.contact!.email!],cc: ccSelections?.length ? ccSelections : undefined,from: user.data.email,diff --git a/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.post.tsx b/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.post.tsxindex 3ce3700eee..b7c37916cb 100644--- a/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.post.tsx+++ b/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.post.tsx@@ -295,12 +295,11 @@ export async function action(args: ActionFunctionArgs) {const html = await renderAsync(emailTemplate);const text = await renderAsync(emailTemplate, { plainText: true });-const { data: signedUrlData } = await serviceRole.storage.from("private").createSignedUrl(documentFilePath, 3600);- await trigger("send-email-resend", {+ await trigger("send-email", {to: [seller.data.email, customer.data.contact.email!],cc: ccSelections?.length ? ccSelections : undefined,from: seller.data.email,diff --git a/apps/erp/app/routes/x+/settings+/integrations.$id.tsx b/apps/erp/app/routes/x+/settings+/integrations.$id.tsxindex fd2389c78b..9f832f1d41 100644--- a/apps/erp/app/routes/x+/settings+/integrations.$id.tsx+++ b/apps/erp/app/routes/x+/settings+/integrations.$id.tsx@@ -8,11 +8,15 @@ import {ProviderID,type XeroProvider} from "@carbon/ee/accounting";+import { getIntegrationServerHooks } from "@carbon/ee/hooks.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";import { redirect, useLoaderData, useNavigate } from "react-router";import { getIntegration, IntegrationForm } from "~/modules/settings";-import { upsertCompanyIntegration } from "~/modules/settings/settings.server";+import {+ invalidateIntegrationHealthCache,+ upsertCompanyIntegration+} from "~/modules/settings/settings.server";import { path } from "~/utils/path";/**@@ -221,9 +225,12 @@ export async function action({ request, params }: ActionFunctionArgs) {if (!integration) throw new Error("Integration not found");- const validation = await validator(integration.schema).validate(- await request.formData()- );+ const validation = await validator(+ // integration.schema is a union across all integrations (incl. a+ // discriminated union for Email). Cast to a generic ZodType so the+ // validator signature accepts it.+ integration.schema as unknown as Parameters<typeof validator>[0]+ ).validate(await request.formData());if (validation.error) {return validationError(validation.error);@@ -241,6 +248,8 @@ export async function action({ request, params }: ActionFunctionArgs) {// Build metadata, transforming owner settings into syncConfig structureconst metadata = buildIntegrationMetadata(existingMetadata, d);+ const wasInstalled = existing.data?.active === true;+const update = await upsertCompanyIntegration(client, {id: integrationId,active: true,@@ -256,6 +265,41 @@ export async function action({ request, params }: ActionFunctionArgs) {);}+ // Fire `onInstall` on the transition from uninstalled → installed.+ // Prefer the server-hooks registry (used by integrations whose install+ // logic needs server-only modules, e.g. Xero), fall back to any inline+ // hook defined via `defineIntegration({ onInstall })`. Run it best-effort:+ // the row is already persisted, so a hook failure shouldn't roll that+ // back — just surface it as a flashed error and let the user retry.+ if (!wasInstalled) {+ const serverHooks = getIntegrationServerHooks(integrationId);+ const onInstall = (serverHooks?.onInstall ?? integration.onInstall) as+ | ((companyId: string) => void | Promise<void>)+ | undefined;+ if (onInstall) {+ try {+ await onInstall(companyId);+ } catch (hookError) {+ console.error(+ `onInstall hook failed for integration '${integrationId}'`,+ hookError+ );+ throw redirect(+ path.to.integrations,+ await flash(+ request,+ error(+ hookError,+ `Installed ${integration.name}, but setup hook failed`+ )+ )+ );+ }+ }+ }++ await invalidateIntegrationHealthCache(integrationId, companyId);+throw redirect(path.to.integrations,await flash(request, success(`Installed ${integration.name} integration`))diff --git a/apps/erp/app/routes/x+/settings+/integrations.deactivate.$id.tsx b/apps/erp/app/routes/x+/settings+/integrations.deactivate.$id.tsxindex aba92644b3..94bcd53f45 100644--- a/apps/erp/app/routes/x+/settings+/integrations.deactivate.$id.tsx+++ b/apps/erp/app/routes/x+/settings+/integrations.deactivate.$id.tsx@@ -5,7 +5,10 @@ import { integrations as availableIntegrations } from "@carbon/ee";import { getIntegrationServerHooks } from "@carbon/ee/hooks.server";import type { ActionFunctionArgs } from "react-router";import { redirect } from "react-router";-import { deactivateIntegration } from "~/modules/settings/settings.server";+import {+ deactivateIntegration,+ invalidateIntegrationHealthCache+} from "~/modules/settings/settings.server";import { path } from "~/utils/path";export async function action({ request, params }: ActionFunctionArgs) {@@ -43,6 +46,8 @@ export async function action({ request, params }: ActionFunctionArgs) {await hooks.onUninstall(companyId);}+ await invalidateIntegrationHealthCache(integrationId, companyId);+throw redirect(path.to.integrations,await flash(diff --git a/apps/erp/app/routes/x+/supplier-quote+/$id.send.tsx b/apps/erp/app/routes/x+/supplier-quote+/$id.send.tsxindex e468b472c2..b253ac9b0d 100644--- a/apps/erp/app/routes/x+/supplier-quote+/$id.send.tsx+++ b/apps/erp/app/routes/x+/supplier-quote+/$id.send.tsx@@ -177,7 +177,7 @@ export async function action(args: ActionFunctionArgs) {},\n\nPlease provide pricing and lead time(s) for the linked quote:`;const emailSignature = `Thanks,\n${user.data.firstName} ${user.data.lastName}\n${company.data.name}`;- await trigger("send-email-resend", {+ await trigger("send-email", {to: [user.data.email, supplierContact.data.contact?.email].filter(Boolean) as string[],diff --git a/llm/tasks/todo.md b/llm/tasks/todo.mddeleted file mode 100644index 93376162a2..0000000000--- a/llm/tasks/todo.md+++ /dev/null@@ -1,24 +0,0 @@-# MES Translations--## Infrastructure-- [x] Update `lingui.config.js` with MES catalog entry-- [x] Create `apps/mes/app/services/lingui.server.ts`-- [x] Wire up `LocaleProvider` in `apps/mes/app/root.tsx`--## Wrap MES strings with lingui macros-- [x] Components batch 1: AppSidebar, AdjustInventory, EndShift, Suggestion, TimeCardButton, TimeCardWarning, ConsolePill, PinInOverlay-- [x] Components batch 2: Feedback, SearchFilter, OperationsList, FilePreview, FileDropzone, Hyperlink, Filter/Filter, Filter/ActiveFilters-- [x] Components batch 3: JobOperation, Controls, Parameter, ScrapReason, SerialSelectorModal, Step, Chat, QuantityModal, TableSkeleton-- [x] Components batch 4: Kanban, ColumnCard, ItemCard, MaintenanceOeeImpact, MaintenanceSeverity, MaintenanceAddPartModal-- [x] Routes batch 1: _layout, _index, active, assigned, complete, operations, recent, rework, maintenance-- [x] Routes batch 2: event, feedback, finish, scrap, issue, record, record.delete, start, end, steps.inspection (all server-side only, skipped)-- [x] Routes batch 3: timecard, location, acknowledge, console.*, adjustment, dispatch.*, entity.*, unconsume, maintenance-event, issue-tracked-entity-- [x] Routes batch 4: login, _public/_layout--## Extract and translate-- [x] Run `lingui extract` to generate .po source files-- [x] Create translated .po files for all 10 languages (en, es, de, it, ja, zh, fr, pl, pt, ru)-- [x] Run `lingui compile` to verify--## Review-- [x] Verify no hardcoded English strings remaindiff --git a/package-lock.json b/package-lock.jsonindex 9a05cd8a7a..24d149ceab 100644--- a/package-lock.json+++ b/package-lock.json@@ -18576,6 +18576,16 @@"undici-types": "~6.21.0"}},+ "node_modules/@types/nodemailer": {+ "version": "6.4.23",+ "resolved": "https://registry.npmjs.org/@types/nodemailer/-/nodemailer-6.4.23.tgz",+ "integrity": "sha512-aFV3/NsYFLSx9mbb5gtirBSXJnAlrusoKNuPbxsASWc7vrKLmIrTQRpdcxNcSFL3VW2A2XpeLEavwb2qMi6nlQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@types/node": "*"+ }+ },"node_modules/@types/nprogress": {"version": "0.2.3","resolved": "https://registry.npmjs.org/@types/nprogress/-/nprogress-0.2.3.tgz",@@ -27650,6 +27660,15 @@"integrity": "sha512-1h5gKZCF+pO/o3Iqt5Jp7wc9rH3eJJ0+nh/CIoiRwjRxde/hAHyLPXYN4V3CqKAbiZPSeJFSWHmJsbkicta0Eg==","license": "MIT"},+ "node_modules/nodemailer": {+ "version": "6.10.1",+ "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.10.1.tgz",+ "integrity": "sha512-Z+iLaBGVaSjbIzQ4pX6XV41HrooLsQ10ZWPUehGmuantvzWoDVBnmsdUcOIDM1t+yPor5pDhVlDESgOMEGxhHA==",+ "license": "MIT-0",+ "engines": {+ "node": ">=6.0.0"+ }+ },"node_modules/nodemon": {"version": "3.1.14","resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.14.tgz",@@ -35359,6 +35378,7 @@"inngest": "^3.52.7","kysely": "^0.28.10","nanoid": "^5.1.7",+ "nodemailer": "^6.9.16","react-pdf": "10.4.1","resend": "^3.1.0","sst": "4.6.9",@@ -35368,6 +35388,7 @@},"devDependencies": {"@carbon/config": "*",+ "@types/nodemailer": "^6.4.17","tsx": "^4.7.0","typescript": "^5.2.2"}diff --git a/packages/database/src/types.ts b/packages/database/src/types.tsindex 2d16ce53a5..1aa4de18d7 100644--- a/packages/database/src/types.ts+++ b/packages/database/src/types.ts@@ -49955,14 +49955,14 @@ export type Database = {Relationships: [{foreignKeyName: "address_countryCode_fkey"- columns: ["supplierCountryCode"]+ columns: ["customerCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]},{foreignKeyName: "address_countryCode_fkey"- columns: ["customerCountryCode"]+ columns: ["supplierCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]@@ -53098,7 +53098,7 @@ export type Database = {Relationships: [{foreignKeyName: "address_countryCode_fkey"- columns: ["shipmentCountryCode"]+ columns: ["customerCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]@@ -53112,7 +53112,7 @@ export type Database = {},{foreignKeyName: "address_countryCode_fkey"- columns: ["customerCountryCode"]+ columns: ["shipmentCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]@@ -53657,14 +53657,14 @@ export type Database = {Relationships: [{foreignKeyName: "address_countryCode_fkey"- columns: ["paymentCountryCode"]+ columns: ["customerCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]},{foreignKeyName: "address_countryCode_fkey"- columns: ["customerCountryCode"]+ columns: ["paymentCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.tsindex 2d16ce53a5..1aa4de18d7 100644--- a/packages/database/supabase/functions/lib/types.ts+++ b/packages/database/supabase/functions/lib/types.ts@@ -49955,14 +49955,14 @@ export type Database = {Relationships: [{foreignKeyName: "address_countryCode_fkey"- columns: ["supplierCountryCode"]+ columns: ["customerCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]},{foreignKeyName: "address_countryCode_fkey"- columns: ["customerCountryCode"]+ columns: ["supplierCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]@@ -53098,7 +53098,7 @@ export type Database = {Relationships: [{foreignKeyName: "address_countryCode_fkey"- columns: ["shipmentCountryCode"]+ columns: ["customerCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]@@ -53112,7 +53112,7 @@ export type Database = {},{foreignKeyName: "address_countryCode_fkey"- columns: ["customerCountryCode"]+ columns: ["shipmentCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]@@ -53657,14 +53657,14 @@ export type Database = {Relationships: [{foreignKeyName: "address_countryCode_fkey"- columns: ["paymentCountryCode"]+ columns: ["customerCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]},{foreignKeyName: "address_countryCode_fkey"- columns: ["customerCountryCode"]+ columns: ["paymentCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]diff --git a/packages/database/supabase/migrations/20260410040000_email-smtp-support.sql b/packages/database/supabase/migrations/20260410040000_email-smtp-support.sqlnew file mode 100644index 0000000000..0e356a011c--- /dev/null+++ b/packages/database/supabase/migrations/20260410040000_email-smtp-support.sql@@ -0,0 +1,40 @@+-- Generalize the legacy "resend" integration into a generic "email" integration+-- that supports both Resend and Custom SMTP delivery methods.+--+-- Execution order matters: companyIntegration.id has ON UPDATE CASCADE against+-- integration.id (see 20240119095150_integrations.sql), and the+-- sync_verify_integration BEFORE trigger+-- (20260410031811_remaining-interceptors.sql) re-validates metadata against+-- whatever jsonschema the integration currently has. If we rename + tighten+-- the schema first, the cascaded UPDATE on companyIntegration fails for+-- active installs whose legacy metadata lacks `provider`. So we:+-- 1. Backfill provider='resend' on existing rows (passes the OLD schema).+-- 2. Rename integration id to 'email' and swap in the new schema.+--+-- Field-level validation for SMTP vs. Resend now lives in the app action via+-- the Zod discriminatedUnion exported from @carbon/ee (same pattern as the+-- Jira integration, see 20260215000000_add_jira_integration.sql).+--+-- Note: title/description/logoPath/visible were dropped from "integration" in+-- 20241006185904_integration-refactor.sql. The display name now lives entirely+-- in the integration config (packages/ee/src/email/config.tsx).++-- 1. Backfill provider on existing installs while id is still 'resend'.+UPDATE "companyIntegration"+SET "metadata" =+ jsonb_set(+ "metadata"::jsonb,+ '{provider}',+ '"resend"'::jsonb,+ true+ )::json+WHERE "id" = 'resend'+ AND ("metadata"->>'provider') IS NULL;++-- 2. Rename integration row from 'resend' to 'email' and loosen the schema.+-- ON UPDATE CASCADE propagates the id to companyIntegration; the trigger+-- re-validates and now passes because provider is present.+UPDATE "integration"+SET "id" = 'email',+ "jsonschema" = '{"type": "object", "properties": {"provider": {"type": "string"}}, "required": ["provider"]}'::json+WHERE "id" = 'resend';diff --git a/packages/ee/src/email/config.tsx b/packages/ee/src/email/config.tsxnew file mode 100644index 0000000000..6cb4ee89d6--- /dev/null+++ b/packages/ee/src/email/config.tsx@@ -0,0 +1,149 @@+import { HiEnvelope } from "react-icons/hi2";+import { z } from "zod";+import { defineIntegration } from "../fns";++export const Email = defineIntegration({+ name: "Email",+ id: "email",+ active: true,+ category: "Email",+ logo: HiEnvelope,+ description:+ "Send transactional emails — quotes, purchase orders, invoices, and more — from your own domain. Pick Resend for a managed email API, or Custom SMTP to use your own mail server.",+ shortDescription:+ "Deliver transactional emails via Resend or a custom SMTP server.",+ images: [],++ settingGroups: [+ {+ name: "Resend",+ description: "API credentials for your Resend account."+ },+ {+ name: "SMTP",+ description: "Credentials for your custom SMTP server."+ }+ ],+ settings: [+ {+ name: "provider",+ label: "Delivery method",+ description: "How transactional emails are delivered for this company.",+ type: "cards",++ required: true,+ value: "resend",+ listOptions: [+ {+ value: "resend",+ label: "Resend",+ description: "Managed email API with domain verification."+ },+ {+ value: "smtp",+ label: "Custom SMTP",+ description: "Bring your own SMTP server."+ }+ ]+ },+ {+ name: "fromEmail",+ label: "From email",+ description:+ "The sender address your customers will see. Must be a domain you control.",+ type: "text",+ required: true,+ value: ""+ },+ // Resend group+ {+ name: "apiKey",+ label: "API key",+ description: "Create one in the Resend dashboard under API Keys.",+ type: "password",+ required: true,+ value: "",+ group: "Resend",+ visibleWhen: { field: "provider", equals: "resend" }+ },+ // SMTP group+ {+ name: "host",+ label: "Host",+ type: "text",+ required: true,+ value: "",+ group: "SMTP",+ visibleWhen: { field: "provider", equals: "smtp" }+ },+ {+ name: "port",+ label: "Port",+ type: "number",+ required: true,+ value: 587,+ group: "SMTP",+ visibleWhen: { field: "provider", equals: "smtp" }+ },+ {+ name: "username",+ label: "Username",+ type: "text",+ required: true,+ value: "",+ group: "SMTP",+ visibleWhen: { field: "provider", equals: "smtp" }+ },+ {+ name: "password",+ label: "Password",+ type: "password",+ required: true,+ value: "",+ group: "SMTP",+ visibleWhen: { field: "provider", equals: "smtp" }+ },+ {+ name: "secure",+ label: "Use TLS",+ description:+ "For implicit TLS (SMTPS) — ports 465 or 2465. Leave off for STARTTLS — ports 25, 587, 2525, or 2587.",+ type: "switch",+ required: false,+ value: false,+ group: "SMTP",+ visibleWhen: { field: "provider", equals: "smtp" }+ }+ ],+ schema: z.discriminatedUnion("provider", [+ z.object({+ provider: z.literal("resend"),+ fromEmail: z.string().email(),+ apiKey: z.string().min(1, { message: "API Key is required" })+ }),+ z.object({+ provider: z.literal("smtp"),+ fromEmail: z.string().email(),+ host: z.string().min(1, { message: "Host is required" }),+ port: z.coerce+ .number()+ .int()+ .min(1, { message: "Port must be between 1 and 65535" })+ .max(65535, { message: "Port must be between 1 and 65535" }),+ username: z.string().min(1, { message: "Username is required" }),+ password: z.string().min(1, { message: "Password is required" }),+ // `SwitchField` in the integration form always posts a literal+ // "true"/"false" string, and `z.coerce.boolean()` would treat both as+ // truthy (non-empty strings). Preprocess explicitly so unchecking the+ // switch actually sticks.+ secure: z+ .preprocess((v) => {+ if (typeof v === "boolean") return v;+ if (v === "true") return true;+ if (v === "false") return false;+ return v;+ }, z.boolean())+ .default(false)+ })+ ])+});diff --git a/packages/ee/src/email/hooks.server.ts b/packages/ee/src/email/hooks.server.tsnew file mode 100644index 0000000000..5791330a99--- /dev/null+++ b/packages/ee/src/email/hooks.server.ts@@ -0,0 +1,68 @@+import { Email } from "./config";++/**+ * Server-side healthcheck for the Email integration.+ *+ * Validates the stored credentials for the company's chosen delivery+ * provider without actually sending a message:+ *+ * - `resend`: hits `GET https://api.resend.com/domains` with the API key.+ * A 2xx means the key is valid and has read access; anything else means+ * the credentials are wrong or the account is suspended.+ * - `smtp`: dynamically imports `nodemailer`, builds a transport from the+ * stored host/port/username/password/secure and calls `.verify()`, which+ * performs a handshake without sending mail.+ *+ * Returns `true` on success and `false` on any failure (invalid metadata,+ * network error, bad credentials). Never throws — the settings page caches+ * a boolean and we don't want a transient SMTP outage to surface as a 500+ * in the integrations list.+ */+export async function emailHealthcheck(+ _companyId: string,+ metadata: Record<string, unknown>+): Promise<boolean> {+ // Legacy installs predate the `provider` field — default them to Resend+ // the same way `send-email.ts` does so existing configs stay healthy.+ const withProvider =+ metadata && typeof metadata === "object" && !("provider" in metadata)+ ? { provider: "resend", ...metadata }+ : metadata;++ const parsed = Email.schema.safeParse(withProvider);+ if (!parsed.success) return false;++ const data = parsed.data;++ try {+ if (data.provider === "resend") {+ const response = await fetch("https://api.resend.com/domains", {+ method: "GET",+ headers: {+ Authorization: `Bearer ${data.apiKey}`+ }+ });+ return response.ok;+ }++ if (data.provider === "smtp") {+ const nodemailer = await import("nodemailer");+ const transporter = nodemailer.createTransport({+ host: data.host,+ port: data.port,+ secure: data.secure,+ auth: {+ user: data.username,+ pass: data.password+ }+ });+ await transporter.verify();+ return true;+ }++ return false;+ } catch (error) {+ console.error("Email integration healthcheck failed", error);+ return false;+ }+}diff --git a/packages/ee/src/hooks.server.ts b/packages/ee/src/hooks.server.tsindex 29e1a152b7..cf35dd56c7 100644--- a/packages/ee/src/hooks.server.ts+++ b/packages/ee/src/hooks.server.ts@@ -1,3 +1,4 @@+import { emailHealthcheck } from "./email/hooks.server";import { jiraHealthcheck } from "./jira/hooks.server";import { linearHealthcheck } from "./linear/hooks.server";import type { IntegrationServerHooks } from "./types";@@ -16,6 +17,9 @@ import {* their server-only lifecycle hooks.*/const serverHooks: Record<string, IntegrationServerHooks> = {+ email: {+ onHealthcheck: emailHealthcheck+ },jira: {onHealthcheck: jiraHealthcheck},diff --git a/packages/ee/src/index.ts b/packages/ee/src/index.tsindex 6e34289220..075d073bdb 100644--- a/packages/ee/src/index.ts+++ b/packages/ee/src/index.ts@@ -1,3 +1,4 @@+import { Email } from "./email/config";import { ExchangeRates } from "./exchange-rates/config";import { Jira } from "./jira/config";import { Linear } from "./linear/config";@@ -5,15 +6,14 @@ import { Onshape } from "./onshape/config";import { PaperlessParts } from "./paperless-parts/config";import { QuickBooks } from "./quickbooks/config";// import { Radan } from "./radan/config";-import { Resend } from "./resend/config";import { Sage } from "./sage/config";import { Slack } from "./slack/config";import { Xero } from "./xero/config";import { Zapier } from "./zapier/config";+export { Email } from "./email/config";export { defineIntegration } from "./fns";-export { Resend } from "./resend/config";export type {Integration,IntegrationAction,@@ -29,13 +29,13 @@ export type {export const integrations = [// Radan,+ Email,ExchangeRates,Jira,Linear,Onshape,PaperlessParts,QuickBooks,- Resend,Sage,Slack,Xero,diff --git a/packages/ee/src/resend/config.tsx b/packages/ee/src/resend/config.tsxdeleted file mode 100644index af5b92c26e..0000000000--- a/packages/ee/src/resend/config.tsx+++ /dev/null@@ -1,56 +0,0 @@-import { cn } from "@carbon/react";-import type { SVGProps } from "react";-import { z } from "zod";-import { defineIntegration } from "../fns";--export const Resend = defineIntegration({- name: "Resend",- id: "resend",- active: true,- category: "Email",- logo: Logo,- description:- "Resend is a powerful email delivery service that allows you to send emails from your own domain. You'll need to provide your API key to use this integration. To send emails from your own domain, you'll need to set up a custom domain in Resend and verify it through DNS.",- shortDescription: "Send transactional emails from your own domain.",- images: [],-- settings: [- {- name: "apiKey",- label: "API Key",- type: "text",- required: true,- value: ""- },- {- name: "fromEmail",- label: "From Email",- type: "text",- required: true,- value: ""- }- ],- schema: z.object({- apiKey: z.string().min(1, { message: "API Key is required" }),- fromEmail: z.string().email()- })-});--function Logo(props: SVGProps<SVGSVGElement>) {- return (- <svg- {...props}- xmlns="http://www.w3.org/2000/svg"- width="1500"- height="489"- viewBox="0 0 1500 489"- fill="none"- className={cn("text-foreground", props.className)}- >- <path- d="M25.4092 393.747H88.9323V294.228H142.292L192.263 393.747H262.562L204.121 279.406C235.035 264.584 254.939 234.093 254.939 195.979C254.939 135.844 211.32 97.3065 146.103 97.3065H25.4092V393.747ZM141.021 150.242C171.089 150.242 190.146 168.029 190.146 195.979C190.146 223.506 171.089 241.292 141.021 241.292H88.9323V150.242H141.021ZM388.86 396.288C446.878 396.288 484.568 362.409 491.344 320.061H432.479C427.398 340.388 410.458 350.975 386.319 350.975C356.252 350.975 336.348 332.342 335.077 301.427V298.463H493.038C494.308 291.687 494.732 284.488 494.732 278.135C493.885 214.189 449.842 173.534 384.625 173.534C317.291 173.534 272.825 217.577 272.825 285.335C272.825 352.669 316.444 396.288 388.86 396.288ZM336.348 259.502C339.736 233.669 359.216 218 385.049 218C412.152 218 430.362 232.822 434.597 259.502H336.348ZM515.546 321.331C518.087 367.915 559.165 396.288 619.723 396.288C678.165 396.288 718.819 368.762 718.819 325.566C718.819 276.441 677.318 265.007 627.346 259.925C596.008 256.114 577.375 254.42 577.375 237.904C577.375 223.929 592.62 215.459 615.912 215.459C640.051 215.459 656.567 226.046 658.261 243.409H715.431C712.467 198.943 672.236 173.111 613.795 173.111C557.894 172.687 520.204 201.061 520.204 244.256C520.204 289.146 559.588 300.58 610.407 306.509C645.556 311.167 660.378 312.438 660.378 330.224C660.378 345.47 645.133 353.516 620.147 353.516C590.926 353.516 574.41 340.388 572.293 321.331H515.546ZM857.839 396.288C915.857 396.288 953.547 362.409 960.323 320.061H901.458C896.376 340.388 879.437 350.975 855.298 350.975C825.23 350.975 805.326 332.342 804.056 301.427V298.463H962.017C963.287 291.687 963.711 284.488 963.711 278.135C962.864 214.189 918.821 173.534 853.604 173.534C786.27 173.534 741.803 217.577 741.803 285.335C741.803 352.669 785.423 396.288 857.839 396.288ZM805.326 259.502C808.714 233.669 828.195 218 854.027 218C881.131 218 899.341 232.822 903.575 259.502H805.326ZM1121.27 173.534C1087.82 173.534 1067.91 186.239 1053.94 203.178L1048.43 176.075H996.342V393.747H1056.05V282.37C1056.05 244.68 1073.84 222.659 1104.75 222.659C1134.82 222.659 1148.8 242.139 1148.8 278.982V393.747H1208.51V273.054C1208.51 198.52 1168.28 173.534 1121.27 173.534ZM1403.27 203.178C1389.29 185.392 1367.69 173.534 1337.63 173.534C1279.61 173.534 1236.84 217.153 1236.84 284.488C1236.84 353.516 1279.61 396.288 1338.05 396.288C1369.39 396.288 1390.56 382.313 1404.96 363.68L1410.89 393.747H1462.98V97.3065H1403.27V203.178ZM1351.18 347.587C1318.57 347.587 1297.82 322.178 1297.82 284.911C1297.82 247.644 1318.57 222.235 1351.18 222.235C1383.79 222.235 1404.11 248.068 1404.11 285.335C1404.11 322.178 1383.79 347.587 1351.18 347.587Z"- fill="currentColor"- />- </svg>- );-}diff --git a/packages/ee/src/types.ts b/packages/ee/src/types.tsindex 30e60dc3d8..56b6f1557c 100644--- a/packages/ee/src/types.ts+++ b/packages/ee/src/types.ts@@ -16,6 +16,7 @@ export type IntegrationSettingOption =| {value: string;label: string;+ icon?: React.ReactNode;description?: string;};@@ -32,13 +33,26 @@ export type IntegrationSetting = {/** Optional group name for organizing settings into collapsible sections */group?: string;/** Field input type */- type: "text" | "switch" | "processes" | "options" | "array";+ type:+ | "text"+ | "number"+ | "password"+ | "switch"+ | "processes"+ | "options"+ | "cards"+ | "array";/** Options for 'options' type fields */listOptions?: IntegrationSettingOption[];/** Whether the field is required */required: boolean;/** Default value for the field */value: unknown;+ /**+ * Conditionally render this field only when another field's value matches.+ * Used for provider-based form branching (e.g. show SMTP fields only when provider === "smtp").+ */+ visibleWhen?: { field: string; equals: string | string[] };};/**diff --git a/packages/form/src/components/Choice.tsx b/packages/form/src/components/Choice.tsxnew file mode 100644index 0000000000..48a98f91e3--- /dev/null+++ b/packages/form/src/components/Choice.tsx@@ -0,0 +1,110 @@+import { cn, RadioGroup, RadioGroupItem } from "@carbon/react";+import type { ReactNode } from "react";++/**+ * A single option in a {@link ChoiceCardGroup}.+ *+ * - `value` — the underlying string value submitted/stored.+ * - `title` — the bold label rendered in the card.+ * - `description` — optional secondary line for context.+ * - `icon` — optional left-aligned glyph (e.g. a `react-icons` component).+ * - `disabled` — greys the card out and blocks selection.+ */+export type ChoiceCardOption<V extends string = string> = {+ value: V;+ title: string;+ description?: string;+ icon?: ReactNode;+ disabled?: boolean;+};++type ChoiceCardGroupProps<V extends string = string> = {+ /** Optional small label rendered above the stack of cards. */+ label?: string;+ /** Currently selected value. */+ value: V;+ /** Called with the new value when the user picks a different card. */+ onChange: (value: V) => void;+ /** Choices to render. Rendered as a vertical stack. */+ options: ChoiceCardOption<V>[];+ /** Extra classes for the wrapping `<div>`. */+ className?: string;+};++/**+ * A reusable card-style radio group, generic over a string-enum value type.+ *+ * Mirrors shadcn/ui's choice card pattern: the radio indicator stays+ * visible on the right edge of each card, and the card's selected state+ * is driven by a CSS `:has([data-state=checked])` selector on the label.+ * No JavaScript-level "is this selected?" comparison is needed — Radix+ * flips `data-state="checked"` on the `RadioGroupItem` when selection+ * changes, and Tailwind's `has-[]` variant picks that up automatically.+ *+ * Cards are stacked vertically by design — each card is a full-width+ * row so the title and description have room to breathe. If you need a+ * grid, wrap the component in one at the call site.+ *+ * Generic over `V extends string` so callers can pass a tighter union+ * than `string` (e.g. `"all" | "item" | "category"`) and have `onChange`+ * infer the same type. Pure controlled component — callers own the state.+ */+export function ChoiceCardGroup<V extends string = string>({+ label,+ value,+ onChange,+ options,+ className+}: ChoiceCardGroupProps<V>) {+ return (+ <div className={cn("space-y-2 w-full", className)}>+ {label && (+ <span className="text-xs font-medium text-muted-foreground">+ {label}+ </span>+ )}+ <RadioGroup+ value={value}+ onValueChange={(v) => onChange(v as V)}+ className="flex flex-col gap-2"+ >+ {options.map((opt) => {+ const inputId = `choice-${opt.value}`;+ return (+ <label+ key={opt.value}+ htmlFor={inputId}+ className={cn(+ "flex cursor-pointer items-start gap-3 rounded-md border border-border bg-card p-3 transition-colors",+ "hover:bg-accent/40",+ "has-[[data-state=checked]]:border-primary has-[[data-state=checked]]:bg-primary/5",+ "has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring",+ opt.disabled && "cursor-not-allowed opacity-50"+ )}+ >+ {opt.icon && (+ <span className="flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground mt-0.5">+ {opt.icon}+ </span>+ )}+ <div className="flex flex-1 flex-col gap-0.5">+ <span className="text-sm font-medium">{opt.title}</span>+ {opt.description && (+ <span className="text-xs text-muted-foreground leading-snug">+ {opt.description}+ </span>+ )}+ </div>+ <RadioGroupItem+ id={inputId}+ value={opt.value}+ disabled={opt.disabled}+ className="mt-1 flex-shrink-0"+ />+ </label>+ );+ })}+ </RadioGroup>+ </div>+ );+}diff --git a/packages/form/src/components/index.ts b/packages/form/src/components/index.tsindex 5684e68877..b1961f09a1 100644--- a/packages/form/src/components/index.ts+++ b/packages/form/src/components/index.ts@@ -1,6 +1,8 @@import Array from "./Array";import ArrayNumeric from "./ArrayNumeric";import Boolean from "./Boolean";+import type { ChoiceCardOption } from "./Choice";+import { ChoiceCardGroup } from "./Choice";import type { ComboboxProps } from "./Combobox";import Combobox from "./Combobox";import type { CreatableComboboxProps } from "./CreatableCombobox";@@ -33,6 +35,7 @@ export {Array,ArrayNumeric,Boolean,+ ChoiceCardGroup,Combobox,CreatableCombobox,CreatableMultiSelect,@@ -59,6 +62,7 @@ export {};export type {+ ChoiceCardOption,ComboboxProps,CreatableComboboxProps,CreatableMultiSelectProps,diff --git a/packages/jobs/package.json b/packages/jobs/package.jsonindex f244a6d223..0b6431ba70 100644--- a/packages/jobs/package.json+++ b/packages/jobs/package.json@@ -32,6 +32,7 @@"inngest": "^3.52.7","kysely": "^0.28.10","nanoid": "^5.1.7",+ "nodemailer": "^6.9.16","react-pdf": "10.4.1","resend": "^3.1.0","sst": "4.6.9",@@ -41,6 +42,7 @@},"devDependencies": {"@carbon/config": "*",+ "@types/nodemailer": "^6.4.17","tsx": "^4.7.0","typescript": "^5.2.2"}diff --git a/packages/jobs/src/inngest/functions/notifications/send-email.ts b/packages/jobs/src/inngest/functions/notifications/send-email.tsindex 51688f2d1b..6955a4b5a8 100644--- a/packages/jobs/src/inngest/functions/notifications/send-email.ts+++ b/packages/jobs/src/inngest/functions/notifications/send-email.ts@@ -1,12 +1,12 @@import { getCarbonServiceRole } from "@carbon/auth/client.server";-import { Resend as ResendConfig } from "@carbon/ee";+import { Email as EmailConfig } from "@carbon/ee";import { NonRetriableError, serializeError } from "inngest";import { Resend } from "resend";import { inngest } from "../../client";export const sendEmailFunction = inngest.createFunction({- id: "send-email-resend",+ id: "send-email",retries: 3},{ event: "carbon/send-email" },@@ -26,7 +26,7 @@ export const sendEmailFunction = inngest.createFunction(.from("companyIntegration").select("active, metadata").eq("companyId", payload.companyId)- .eq("id", "resend")+ .eq("id", "email").maybeSingle()]);@@ -37,21 +37,75 @@ export const sendEmailFunction = inngest.createFunction(};});- const parsedMetadata = ResendConfig.schema.safeParse(integrationMetadata);+ // Legacy installs predate the provider field — default them to Resend so+ // existing configs keep working without any migration step on the caller.+ const metadataWithProvider =+ integrationMetadata && typeof integrationMetadata === "object"+ ? {+ provider: "resend",+ ...(integrationMetadata as Record<string, unknown>)+ }+ : integrationMetadata;- console.info(parsedMetadata.data?.fromEmail ?? "No email found");+ const parsedMetadata = EmailConfig.schema.safeParse(metadataWithProvider);if (!parsedMetadata.success || !integrationActive) {return { success: false, message: "Invalid or inactive integration" };}+ const data = parsedMetadata.data as {+ provider: "resend" | "smtp";+ fromEmail: string;+ apiKey?: string;+ host?: string;+ port?: number;+ username?: string;+ password?: string;+ secure?: boolean;+ };++ const fromAddress = `${companyName} <${data.fromEmail}>`;++ if (data.provider === "smtp") {+ const result = await step.run("send-email", async () => {+ const nodemailer = await import("nodemailer");+ const transporter = nodemailer.createTransport({+ host: data.host!,+ port: data.port!,+ secure: data.secure === true,+ auth: {+ user: data.username!,+ pass: data.password!+ }+ });++ console.info(`SMTP Email Job`);+ return transporter.sendMail({+ from: fromAddress,+ to: payload.to,+ cc: payload.cc,+ replyTo: payload.from,+ subject: payload.subject,+ html: payload.html,+ text: payload.text,+ attachments: payload.attachments?.map(+ (a: { filename: string; content: string }) => ({+ filename: a.filename,+ content: a.content,+ encoding: "base64" as const+ })+ )+ });+ });++ return { success: true, result };+ }+const result = await step.run("send-email", async () => {- const resend = new Resend(parsedMetadata.data.apiKey);+ const resend = new Resend(data.apiKey!);const email = {- from: `${companyName} <${- parsedMetadata.data.fromEmail ?? "[email protected]"- }>`,+ from: fromAddress,to: payload.to,cc: payload.cc,reply_to: payload.from,diff --git a/packages/jobs/src/trigger.ts b/packages/jobs/src/trigger.tsindex cd950d951e..6700c0d7d8 100644--- a/packages/jobs/src/trigger.ts+++ b/packages/jobs/src/trigger.ts@@ -8,7 +8,7 @@ import { inngest } from "./inngest/client.ts";*/const taskToEvent = {notify: "carbon/notify",- "send-email-resend": "carbon/send-email",+ "send-email": "carbon/send-email","model-thumbnail": "carbon/model-thumbnail","update-permissions": "carbon/update-permissions",recalculate: "carbon/recalculate",diff --git a/packages/react/src/Toast.tsx b/packages/react/src/Toast.tsxindex 006fdcb963..3cb6abc8f3 100644--- a/packages/react/src/Toast.tsx+++ b/packages/react/src/Toast.tsx@@ -8,6 +8,7 @@ const Toaster = ({ ...props }: ToasterProps) => {return (<SonnerclassName="toaster group"+ closeButtontoastOptions={{classNames: {toast:@@ -17,6 +18,8 @@ const Toaster = ({ ...props }: ToasterProps) => {"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",+ closeButton:+ "group-[.toast]:!bg-background group-[.toast]:!text-foreground group-[.toast]:!border-border group-[.toast]:!rounded-full group-[.toast]:!size-5 group-[.toast]:!left-auto group-[.toast]:!right-0 group-[.toast]:!top-0 group-[.toast]:!-translate-y-1/2 group-[.toast]:!translate-x-1/2 group-[.toast]:hover:!bg-muted group-[.toast]:transition-colors group-[.toast]:shadow-sm",success:"group-[.toaster]:bg-blue-700 group-[.toaster]:text-white group-[.toaster]:border-blue-700 ",error: