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(stripe-connect): add collapsible setup instructions UI
Samay Gandhi7e3298a869cd
diff --git a/packages/ee/src/stripe-connect/config.tsx b/packages/ee/src/stripe-connect/config.tsxindex b1eee2c668..0d24b8d693 100644--- a/packages/ee/src/stripe-connect/config.tsx+++ b/packages/ee/src/stripe-connect/config.tsx@@ -1,9 +1,8 @@import { STRIPE_CONNECT_ENABLED } from "@carbon/env";-import { Badge, Button, toast } from "@carbon/react";import type { ComponentProps } from "react";-import { useCallback, useState } from "react";import { z } from "zod";import { defineIntegration } from "../fns";+import { StripeConnectSetupInstructions } from "./setup-instructions";export const StripeConnectSettingsSchema = z.object({stripeAccountId: z.string().optional(),@@ -27,7 +26,7 @@ export const StripeConnect = defineIntegration({"Connect your Stripe account to send invoices with direct online payment options to your customers, automatically updating payment statuses and AR ledger entries.",shortDescription: "Accept card and ACH payments directly on sales invoices.",images: [],- setupInstructions: StripeConnectStatus,+ setupInstructions: StripeConnectSetupInstructions,schema: StripeConnectSettingsSchema,settingGroups: [{@@ -57,254 +56,6 @@ export const StripeConnect = defineIntegration({]});-function ConnectStripeAccountButton({- label,- onPlatformError-}: {- label: string;- onPlatformError: (message: string) => void;-}) {- const [isLoading, setIsLoading] = useState(false);-- const handleClick = useCallback(async () => {- setIsLoading(true);- try {- const response = await fetch("/api/integrations/stripe-connect/connect", {- method: "POST"- });- const data = await response.json();-- if (data?.redirectUrl) {- window.open(data.redirectUrl, "_blank", "noopener,noreferrer");- return;- }-- // A platform-level misconfiguration (e.g. this Stripe account was- // never set up as a Connect platform) isn't something retrying fixes —- // switch the panel to a persistent "ask your administrator" state- // instead of just a one-off toast the user could miss.- if (data?.isPlatformConfigError) {- onPlatformError(- data.error || "Stripe Connect isn't set up on this platform yet."- );- return;- }-- toast.error(data?.error || "Failed to start Stripe Connect onboarding");- } catch {- toast.error("Failed to start Stripe Connect onboarding");- } finally {- setIsLoading(false);- }- }, [onPlatformError]);-- return (- <Button- variant="secondary"- size="sm"- onClick={handleClick}- isLoading={isLoading}- isDisabled={isLoading}- >- {label}- </Button>- );-}--function AccountingAccountRow({- label,- value-}: {- label: string;- value: string | null;-}) {- return (- <div className="flex items-center justify-between gap-2 py-1.5">- <span className="text-xs text-muted-foreground">{label}</span>- <span className="text-xs font-medium text-foreground truncate max-w-[60%] text-right">- {value ?? "Not configured"}- </span>- </div>- );-}--function StripeConnectStatus({- metadata-}: {- companyId: string;- metadata?: Record<string, unknown>;- installed?: boolean;-}) {- const [platformError, setPlatformError] = useState<string | null>(null);-- // The loader always sets this for stripe-connect (even before any row- // exists — see integrations.$id.tsx), so treat a missing value as- // configured rather than silently showing State A on a loader hiccup.- const platformConfigured = metadata?.platformConfigured !== false;- const stripeAccountId = metadata?.stripeAccountId as string | undefined;- const chargesEnabled = metadata?.chargesEnabled === true;- const payoutsEnabled = metadata?.payoutsEnabled === true;- const onboardingComplete = chargesEnabled && payoutsEnabled;- const requirementErrors =- (metadata?.requirementErrors as string[] | undefined) ?? [];- const hasIssue = requirementErrors.length > 0;- const email = metadata?.email as string | undefined;- const displayName = metadata?.displayName as string | undefined;- // A linked account already existing counts as "started" even if the flag- // predates this field being introduced.- const onboardingStarted =- metadata?.onboardingStarted === true || !!stripeAccountId;-- const showPlatformIssue = !platformConfigured || !!platformError;-- const status = showPlatformIssue- ? { label: "Not available", variant: "gray" as const }- : !stripeAccountId- ? { label: "Not connected", variant: "gray" as const }- : onboardingComplete- ? { label: "Active", variant: "green" as const }- : hasIssue- ? { label: "Needs attention", variant: "red" as const }- : { label: "Pending onboarding", variant: "yellow" as const };-- const accountingAccounts = metadata?.accountingAccounts as- | {- bankCash: string | null;- receivables: string | null;- customerPaymentDiscount: string | null;- customerWriteOff: string | null;- fxGain: string | null;- fxLoss: string | null;- serviceCharge: string | null;- rounding: string | null;- }- | undefined;-- return (- <div className="flex flex-col gap-4">- <input- type="hidden"- name="onboardingStarted"- value={onboardingStarted ? "true" : "false"}- />- <div className="flex items-center gap-2">- <span className="text-sm font-medium">Connection status</span>- <Badge variant={status.variant}>{status.label}</Badge>- </div>-- {showPlatformIssue ? (- // State A: nothing the installing user can do here — retrying won't- // help until an administrator fixes the platform-level Stripe setup.- <p className="text-xs text-muted-foreground">- {platformError ??- "Stripe isn't configured on this platform yet. Ask your administrator to add a Stripe secret key with Connect enabled."}- </p>- ) : !stripeAccountId ? (- <div className="flex flex-col gap-2">- <p className="text-xs text-muted-foreground">- Connecting creates a Stripe Express account for this company from- your Company Settings details — no extra info needed here — then- sends you to Stripe to finish onboarding.- </p>- <div>- <ConnectStripeAccountButton- label="Connect Stripe Account"- onPlatformError={setPlatformError}- />- </div>- </div>- ) : !onboardingComplete ? (- <div className="flex flex-col gap-2">- <p className="text-xs text-muted-foreground">- {hasIssue- ? "Stripe flagged an issue with this account:"- : "Your Stripe account has been created, but onboarding isn't complete — card payments and payouts won't work until it is."}- </p>- {hasIssue && (- <ul className="list-disc pl-4 text-xs text-muted-foreground">- {requirementErrors.map((message) => (- <li key={message}>{message}</li>- ))}- </ul>- )}- <div>- <ConnectStripeAccountButton- label={hasIssue ? "Fix on Stripe" : "Finish Onboarding"}- onPlatformError={setPlatformError}- />- </div>- </div>- ) : (- <div className="flex flex-col gap-1">- <p className="text-xs text-muted-foreground">- Onboarding is complete. Use "Open Express Dashboard" below to view- payouts and transactions on Stripe.- </p>- {(displayName || email) && (- <p className="text-xs text-muted-foreground">- Connected as {displayName || email}- {displayName && email ? ` (${email})` : ""}.- </p>- )}- </div>- )}-- {accountingAccounts && (- <div className="border-t border-border pt-4 flex flex-col gap-2">- <div className="flex items-center justify-between">- <span className="text-[0.6875rem] font-semibold uppercase tracking-wider text-foreground/70">- Accounting- </span>- <a- href="/x/accounting/defaults"- className="text-[0.6875rem] text-primary hover:underline"- >- Change in Account Defaults- </a>- </div>- <p className="text-xs text-muted-foreground">- GL accounts used when recording Stripe payments and fees.- </p>- <div className="flex flex-col divide-y divide-border/50">- <AccountingAccountRow- label="Bank / Cash"- value={accountingAccounts.bankCash}- />- <AccountingAccountRow- label="Accounts Receivable"- value={accountingAccounts.receivables}- />- <AccountingAccountRow- label="Customer Payment Discount"- value={accountingAccounts.customerPaymentDiscount}- />- <AccountingAccountRow- label="Customer Write-Off (Bad Debt)"- value={accountingAccounts.customerWriteOff}- />- <AccountingAccountRow- label="Realized FX Gain"- value={accountingAccounts.fxGain}- />- <AccountingAccountRow- label="Realized FX Loss"- value={accountingAccounts.fxLoss}- />- <AccountingAccountRow- label="Processing Fees"- value={accountingAccounts.serviceCharge}- />- <AccountingAccountRow- label="Rounding"- value={accountingAccounts.rounding}- />- </div>- </div>- )}- </div>- );-}-function StripeLogo(props: ComponentProps<"svg">) {return (<svgdiff --git a/packages/ee/src/stripe-connect/setup-instructions.tsx b/packages/ee/src/stripe-connect/setup-instructions.tsxnew file mode 100644index 0000000000..60236963c4--- /dev/null+++ b/packages/ee/src/stripe-connect/setup-instructions.tsx@@ -0,0 +1,129 @@+import { useState } from "react";+import { MdExpandMore } from "react-icons/md";++export function StripeConnectSetupInstructions() {+ const [isExpanded, setIsExpanded] = useState(false);++ const condensedSteps = [+ {+ number: 1,+ title: "Navigate to Stripe Connect Settings",+ description: "Open Settings → Integrations in Carbon OS"+ },+ {+ number: 2,+ title: "Click Connect with Stripe",+ description: "Carbon redirects you to Stripe's secure onboarding flow"+ },+ {+ number: 3,+ title: "Complete Verification",+ description: "Fill business details and link your bank account"+ }+ ];++ const fullSteps = [+ {+ number: 1,+ title: "Navigate to Billing / Integrations",+ description:+ "Log in to your Carbon OS workspace with administrator permissions."+ },+ {+ number: 2,+ title: "Open Settings → Integrations",+ description:+ "Open the main navigation menu and go to Settings → Integrations"+ },+ {+ number: 3,+ title: "Locate Stripe Connect Module",+ description:+ "Find the Stripe Connect module card in the integrations list."+ },+ {+ number: 4,+ title: "Start Onboarding Flow",+ description:+ "Click 'Connect with Stripe' on the Carbon OS dashboard. Carbon initiates an API request using Stripe's Account Links API to generate a temporary onboarding URL."+ },+ {+ number: 5,+ title: "Redirect to Stripe Hosted Flow",+ description:+ "You will be redirected to the secure, Stripe-hosted onboarding flow."+ },+ {+ number: 6,+ title: "Complete Account Verification",+ description:+ "Fill out your business details, tax identification numbers (EIN/SSN), and representative details."+ },+ {+ number: 7,+ title: "Link Your Bank Account",+ description: "Link your payout external bank account or debit card."+ },+ {+ number: 8,+ title: "Submit Verification Form",+ description: "Submit the verification form to return to Carbon OS."+ },+ {+ number: 9,+ title: "Verify Active Status",+ description:+ "Once redirected back to Carbon OS, confirm that the Stripe Connect status shows as Active / Connected."+ },+ {+ number: 10,+ title: "Test Webhooks",+ description:+ "Send a test transaction or process a test payout to confirm webhook events are syncing properly with your local Carbon OS ledger."+ }+ ];++ const displaySteps = isExpanded ? fullSteps : condensedSteps;++ return (+ <div className="space-y-4">+ <div className="space-y-3">+ {displaySteps.map((step) => (+ <div key={step.number} className="flex gap-3">+ <div className="flex h-6 w-6 min-w-6 items-center justify-center rounded-full bg-primary/10">+ <span className="text-xs font-semibold text-primary">+ {step.number}+ </span>+ </div>+ <div className="flex-1">+ <p className="font-medium text-sm">{step.title}</p>+ <p className="text-sm text-muted-foreground">+ {step.description}+ </p>+ </div>+ </div>+ ))}+ </div>++ {!isExpanded && (+ <button+ onClick={() => setIsExpanded(true)}+ className="inline-flex items-center gap-2 text-sm font-medium text-primary hover:underline"+ >+ View full guide+ <MdExpandMore className="h-4 w-4" />+ </button>+ )}++ {isExpanded && (+ <button+ onClick={() => setIsExpanded(false)}+ className="inline-flex items-center gap-2 text-sm font-medium text-primary hover:underline"+ >+ Hide full guide+ <MdExpandMore className="h-4 w-4 rotate-180 transition-transform" />+ </button>+ )}+ </div>+ );+}