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.

refactor: standardize format for integrations

Brad Barbincef2cfefde21
diff --git a/apps/carbon/app/components/CustomerAvatar.tsx b/apps/carbon/app/components/CustomerAvatar.tsx
index 24859eac6c..646f6a6950 100644
--- a/apps/carbon/app/components/CustomerAvatar.tsx
+++ b/apps/carbon/app/components/CustomerAvatar.tsx
@@ -1,5 +1,5 @@
import type { AvatarProps } from "@carbon/react";
-import { cn, HStack } from "@carbon/react";
+import { HStack } from "@carbon/react";
import { useCustomers } from "~/stores";
import Avatar from "./Avatar";
@@ -26,11 +26,7 @@ const CustomerAvatar = ({
return (
<HStack className="truncate no-underline hover:no-underline">
<Avatar size={size ?? "xs"} {...props} name={customer?.name ?? ""} />
- <span
- className={cn("normal-case font-normal tracking-normal", className)}
- >
- {customer.name}
- </span>
+ <span className={className}>{customer.name}</span>
</HStack>
);
};
diff --git a/apps/carbon/app/components/Editable/EditableDateTime.tsx b/apps/carbon/app/components/Editable/EditableDateTime.tsx
deleted file mode 100644
index e7a5fa0ecd..0000000000
--- a/apps/carbon/app/components/Editable/EditableDateTime.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-/* eslint-disable react/display-name */
-
-import { DateTimePicker } from "@carbon/react";
-import type { DateValue } from "@internationalized/date";
-import { getLocalTimeZone, parseAbsolute } from "@internationalized/date";
-import type { PostgrestSingleResponse } from "@supabase/supabase-js";
-import type { EditableTableCellComponentProps } from "~/components/Editable";
-
-const EditableDateTime =
- <T extends object>(
- mutation: (
- accessorKey: string,
- newValue: string,
- row: T
- ) => Promise<PostgrestSingleResponse<unknown>>
- ) =>
- ({
- value,
- row,
- accessorKey,
- onError,
- onUpdate,
- }: EditableTableCellComponentProps<T>) => {
- const defaultValue = (
- typeof value === "string"
- ? parseAbsolute(value, getLocalTimeZone())
- : value
- ) as DateValue | null | undefined;
-
- const updateDate = async (newValue: DateValue) => {
- // this is the optimistic update on the FE
- onUpdate({ [accessorKey]: newValue.toString() });
-
- // this is the actual update on the BE
- mutation(accessorKey, newValue.toString(), row)
- .then(({ error }) => {
- if (error) {
- onError();
- onUpdate({ [accessorKey]: value });
- }
- })
- .catch(() => {
- onError();
- onUpdate({ [accessorKey]: value });
- });
- };
-
- return (
- <DateTimePicker
- className="w-full rounded-none outline-none border-none focus-visible:ring-0"
- defaultValue={defaultValue}
- onChange={updateDate}
- autoFocus
- withButton={false}
- />
- );
- };
-
-export default EditableDateTime;
diff --git a/apps/carbon/app/components/Editable/index.ts b/apps/carbon/app/components/Editable/index.ts
index 06ada8d376..3af30890b1 100644
--- a/apps/carbon/app/components/Editable/index.ts
+++ b/apps/carbon/app/components/Editable/index.ts
@@ -1,4 +1,3 @@
-import EditableDateTime from "./EditableDateTime";
import EditableList from "./EditableList";
import EditableNumber from "./EditableNumber";
import EditablePurchaseInvoiceLineNumber from "./EditablePurchaseInvoiceLineNumber";
@@ -7,7 +6,6 @@ import EditableText from "./EditableText";
export * from "./types";
export {
- EditableDateTime,
EditableList,
EditableNumber,
EditablePurchaseInvoiceLineNumber,
diff --git a/apps/carbon/app/components/EmployeeAvatar.tsx b/apps/carbon/app/components/EmployeeAvatar.tsx
index 5909340278..09c1bf6da9 100644
--- a/apps/carbon/app/components/EmployeeAvatar.tsx
+++ b/apps/carbon/app/components/EmployeeAvatar.tsx
@@ -1,5 +1,5 @@
import type { AvatarProps } from "@carbon/react";
-import { cn, HStack } from "@carbon/react";
+import { HStack } from "@carbon/react";
import { usePeople } from "~/stores";
import Avatar from "./Avatar";
@@ -26,9 +26,7 @@ const EmployeeAvatar = ({
<HStack className="no-underline">
<Avatar size={"xs"} {...props} />
{withName && (
- <span className="text-muted-foreground normal-case font-normal tracking-normal tracking-normal">
- Deactivated user
- </span>
+ <span className="text-muted-foreground">Deactivated user</span>
)}
</HStack>
);
@@ -45,13 +43,7 @@ const EmployeeAvatar = ({
path={person.avatarUrl ?? undefined}
name={person?.name ?? ""}
/>
- {withName && (
- <span
- className={cn("normal-case font-normal tracking-normal", className)}
- >
- {person.name}
- </span>
- )}
+ {withName && <span>{person.name}</span>}
</HStack>
);
};
diff --git a/apps/carbon/app/components/Hyperlink.tsx b/apps/carbon/app/components/Hyperlink.tsx
index f072f37464..10f70dedec 100644
--- a/apps/carbon/app/components/Hyperlink.tsx
+++ b/apps/carbon/app/components/Hyperlink.tsx
@@ -14,7 +14,7 @@ const Hyperlink = ({
<Link
prefetch="intent"
className={cn(
- "text-foreground font-bold uppercase tracking-tighter text-sm hover:underline cursor-pointer ",
+ "text-foreground font-medium text-sm cursor-pointer ",
className
)}
{...props}
@@ -24,7 +24,7 @@ const Hyperlink = ({
) : (
<span
className={cn(
- "text-foreground font-bold uppercase tracking-tighter text-sm cursor-pointer ",
+ "text-foreground font-medium text-sm cursor-pointer ",
className
)}
{...props}
diff --git a/apps/carbon/app/components/SupplierAvatar.tsx b/apps/carbon/app/components/SupplierAvatar.tsx
index e925e971d5..9352aad631 100644
--- a/apps/carbon/app/components/SupplierAvatar.tsx
+++ b/apps/carbon/app/components/SupplierAvatar.tsx
@@ -1,5 +1,5 @@
import type { AvatarProps } from "@carbon/react";
-import { cn, HStack } from "@carbon/react";
+import { HStack } from "@carbon/react";
import { useSuppliers } from "~/stores";
import Avatar from "./Avatar";
@@ -24,13 +24,9 @@ const SupplierAvatar = ({
};
return (
- <HStack className="truncate no-underline hover:no-underline">
+ <HStack className="truncate ">
<Avatar size={size ?? "xs"} {...props} name={supplier?.name ?? ""} />
- <span
- className={cn("normal-case font-normal tracking-normal", className)}
- >
- {supplier.name}
- </span>
+ <span className={className}>{supplier.name}</span>
</HStack>
);
};
diff --git a/apps/carbon/app/integrations/exchange-rates/config.tsx b/apps/carbon/app/integrations/exchange-rates/config.tsx
new file mode 100644
index 0000000000..2689e40064
--- /dev/null
+++ b/apps/carbon/app/integrations/exchange-rates/config.tsx
@@ -0,0 +1,95 @@
+import { cn } from "@carbon/react";
+import type { SVGProps } from "react";
+import { z } from "zod";
+import type { IntegrationConfig } from "../types";
+
+export const ExchangeRates: IntegrationConfig = {
+ name: "Exchange Rates",
+ id: "exchange-rates-v1",
+ active: true,
+ category: "Accounting",
+ logo: Logo,
+ description:
+ "The exchange rates integration allows you to automatically update the exchange rates for your company. Simply install the integration and we'll automatically update the exchange rates for you every day.",
+ shortDescription:
+ "Automatically update the currency exchange rates for your company.",
+ images: [],
+ settings: [],
+ onInitialize: () => {},
+ onUninstall: () => {},
+ schema: z.object({}),
+};
+
+function Logo(props: SVGProps<SVGSVGElement>) {
+ return (
+ <svg
+ {...props}
+ viewBox="-2457.7 882.5 422.8 65"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ className={cn("text-foreground", props.className)}
+ >
+ <path
+ fill="currentColor"
+ d="M-2360.1,926.9c2.6,0,5.4-0.4,8.4-1.3l1.1,5.2c-3.1,1.2-6.8,1.7-10,1.7c-8.6,0-11.6-4-11.6-10.5v-7.2 c0-5.8,2.6-10.7,11.3-10.7c8.8,0,10.7,5.1,10.7,11v5.8h-15.2v1.4C-2365.4,925.6-2364.2,926.9-2360.1,926.9z M-2365.4,915.4h8.7 v-1.3c0-2.6-0.8-4.4-4.2-4.4c-3.4,0-4.5,1.8-4.5,4.4V915.4z"
+ />
+ <path
+ fill="currentColor"
+ d="M-2347,931.9l8.8-13.7l-8.6-13.6h6.8l5.4,8.3l5.4-8.3h6.8l-8.6,13.6l8.9,13.7h-7l-5.4-8.5l-5.5,8.5H-2347z"
+ />
+ <path
+ fill="currentColor"
+ d="M-2318.7,922v-7.5c0-7.3,3.2-10.5,11.8-10.5c1.9,0,4.7,0.3,6.7,1l-0.8,5.6c-1.9-0.5-4.3-0.7-5.7-0.7 c-3.9,0-5.1,1.2-5.1,4.5v7.6c0,3.4,1.2,4.5,5.1,4.5c1.7,0,3.7-0.2,5.7-0.7l0.8,5.6c-1.8,0.6-4.4,1-6.7,1 C-2315.5,932.5-2318.7,929.4-2318.7,922z"
+ />
+ <path
+ fill="currentColor"
+ d="M-2277.8,931.9v-19.1c0-1.5-0.6-2.2-2.2-2.2c-1.7,0-4.7,1-7.1,2.3v19h-6.8v-38.5l6.8-1v14.2 c3-1.6,7.1-2.6,10-2.6c4.5,0,6.2,3.2,6.2,8.1v19.8H-2277.8z"
+ />
+ <path
+ fill="currentColor"
+ d="M-2243.2,931.9h-5.6l-0.5-1.9c-2.5,1.6-5.4,2.4-8.1,2.4c-5,0-7.1-3.4-7.1-8.1c0-5.6,2.4-7.7,8-7.7h6.6v-2.9 c0-3-0.8-4.1-5.2-4.1c-2.5,0-5.2,0.3-7.6,0.8l-0.8-5.2c2.6-0.8,6.3-1.3,9.4-1.3c8.6,0,11.1,3,11.1,9.9V931.9z M-2250,921.6h-5 c-2.2,0-2.9,0.6-2.9,2.7c0,1.9,0.6,2.7,2.7,2.7c2,0,3.9-0.7,5.2-1.4V921.6z"
+ />
+ <path
+ fill="currentColor"
+ d="M-2219.7,931.9v-19.1c0-1.5-0.6-2.2-2.2-2.2c-1.7,0-4.7,1-7.1,2.3v19h-6.8v-27.3h5.2l0.7,2.3 c3.4-1.7,7.7-2.9,10.9-2.9c4.5,0,6.2,3.2,6.2,8.1v19.8H-2219.7z"
+ />
+ <path
+ fill="currentColor"
+ d="M-2197.6,924.6c-0.9,0.6-1.6,1.3-1.6,2.2c0,0.7,0.4,1.1,1.5,1.2c3,0.3,4.7,0.5,7.9,0.8 c4.4,0.5,5.8,2.7,5.8,6.6c0,5.8-2.1,8.1-12.3,8.1c-3.1,0-7.5-0.4-10.5-1.4l0.8-5.1c2.9,0.7,6,1.2,9.2,1.2c5.4,0,6.5-0.4,6.5-2.2 c0-1.7-0.5-2-2.6-2.2c-3.1-0.3-4.4-0.5-7.9-0.9c-3.9-0.4-5.4-1.7-5.4-5.2c0-2.2,1.5-3.7,2.9-4.7c-2.5-1.5-3.7-4-3.7-7.3v-2.6 c0.1-5.7,3.1-9.1,11-9.1c1.9,0,3.3,0.2,4.7,0.6h8.4v3.4c-1,0.3-2.1,0.6-3,0.8c0.6,1.2,1,2.7,1,4.3v2.6c0,5.6-3.4,8.9-11,8.9 C-2196.6,924.7-2197.1,924.7-2197.6,924.6z M-2196,909.6c-3.4,0-4.5,1.2-4.5,3.8v2.1c0,2.7,1.3,3.7,4.5,3.7 c3.3,0,4.6-1.1,4.6-3.7v-2.1C-2191.4,910.8-2192.6,909.6-2196,909.6z"
+ />
+ <path
+ fill="currentColor"
+ d="M-2167,926.9c2.6,0,5.4-0.4,8.4-1.3l1.1,5.2c-3.1,1.2-6.8,1.7-10,1.7c-8.6,0-11.6-4-11.6-10.5v-7.2 c0-5.8,2.6-10.7,11.3-10.7c8.8,0,10.7,5.1,10.7,11v5.8h-15.2v1.4C-2172.3,925.6-2171.1,926.9-2167,926.9z M-2172.3,915.4h8.7 v-1.3c0-2.6-0.8-4.4-4.2-4.4c-3.4,0-4.5,1.8-4.5,4.4V915.4z"
+ />
+ <path
+ fill="currentColor"
+ d="M-2136.8,910.4c-2.6,1.2-4.8,2.4-7.2,4v17.6h-6.8v-27.3h5.8l0.4,3c1.5-1,4.8-2.9,7.2-3.6L-2136.8,910.4z"
+ />
+ <path
+ fill="currentColor"
+ d="M-2112.2,931.9h-5.6l-0.5-1.9c-2.5,1.6-5.4,2.4-8.1,2.4c-5,0-7.1-3.4-7.1-8.1c0-5.6,2.4-7.7,8-7.7h6.6v-2.9 c0-3-0.8-4.1-5.2-4.1c-2.5,0-5.2,0.3-7.6,0.8l-0.8-5.2c2.6-0.8,6.3-1.3,9.4-1.3c8.6,0,11.1,3,11.1,9.9V931.9z M-2119,921.6h-5 c-2.2,0-2.9,0.6-2.9,2.7c0,1.9,0.6,2.7,2.7,2.7c2,0,3.9-0.7,5.2-1.4V921.6z"
+ />
+ <path
+ fill="currentColor"
+ d="M-2090.3,931.4c-1.5,0.6-4.3,1.1-6,1.1c-5,0-7.5-2.4-7.5-7.2v-15.2h-4.1v-5.4h4.1v-6.8l6.8-1v7.7h7l-0.4,5.4 h-6.6v14.3c0,1.5,0.7,2.4,2.5,2.4c1,0,2.2-0.2,3.4-0.6L-2090.3,931.4z"
+ />
+ <path
+ fill="currentColor"
+ d="M-2074,926.9c2.6,0,5.4-0.4,8.4-1.3l1.1,5.2c-3.1,1.2-6.8,1.7-10,1.7c-8.6,0-11.6-4-11.6-10.5v-7.2 c0-5.8,2.6-10.7,11.3-10.7c8.8,0,10.7,5.1,10.7,11v5.8h-15.2v1.4C-2079.3,925.6-2078.2,926.9-2074,926.9z M-2079.3,915.4h8.7 v-1.3c0-2.6-0.8-4.4-4.2-4.4c-3.4,0-4.5,1.8-4.5,4.4V915.4z"
+ />
+ <path
+ fill="currentColor"
+ d="M-2049.5,932.5c-2.9,0-6.9-0.7-9.4-1.6l1-5.2c2.3,0.7,5.3,1.2,8.1,1.2c3,0,3.5-0.7,3.5-2.7 c0-1.7-0.3-2.5-4.8-3.6c-6.7-1.6-7.5-3.3-7.5-8.6c0-5.5,2.4-7.9,10.2-7.9c2.5,0,5.8,0.3,8.2,1l-0.7,5.4c-2.1-0.4-5.4-0.8-7.5-0.8 c-3,0-3.5,0.7-3.5,2.4c0,2.2,0.2,2.4,3.9,3.3c7.6,2,8.4,3,8.4,8.6C-2039.6,929.3-2041.3,932.5-2049.5,932.5z"
+ />
+
+ <path
+ fill="currentColor"
+ d="M-2424.3,914.8c-1.9,1.9-3.8,3.7-5.7,5.6c-5.2,5.2-10.3,10.3-15.5,15.5c-0.2,0.2-0.5,0.4-0.8,0.7 c-7.5-8.1-10.6-17.5-8.1-28.1c2.9-12.6,11-20.6,23.6-23.4c10.6-2.3,19.8,0.8,27.8,8.2c-0.3,0.4-0.6,0.6-0.8,0.9 c-6.5,6.5-12.9,12.9-19.4,19.4c-0.3,0.3-0.6,0.6-0.9,1C-2424.2,914.7-2424.3,914.7-2424.3,914.8z"
+ />
+ <path
+ fill="currentColor"
+ d="M-2424.3,914.8c0.1-0.1,0.1-0.1,0.2-0.2c4.3-0.1,8.6-0.1,12.8-0.2c1.6,0,3.2-0.1,4.7-0.1 c4.1-0.1,8.1-0.1,12.2-0.2c0.5,0,0.9,0,1.6,0c-0.1,1.6-0.2,3.2-0.4,4.7c-1.8,10.2-7.2,17.9-16.3,22.9c-4.1,2.3-8.6,3.4-13.3,3.7 c-0.8,0-1-0.2-1-0.9c-0.1-7.9-0.2-15.7-0.4-23.6C-2424.2,918.9-2424.3,916.9-2424.3,914.8z"
+ />
+ </svg>
+ );
+}
diff --git a/apps/carbon/app/lib/exchange-rates.server.ts b/apps/carbon/app/integrations/exchange-rates/exchange-rates.server.ts
similarity index 100%
rename from apps/carbon/app/lib/exchange-rates.server.ts
rename to apps/carbon/app/integrations/exchange-rates/exchange-rates.server.ts
diff --git a/apps/carbon/app/integrations/index.ts b/apps/carbon/app/integrations/index.ts
new file mode 100644
index 0000000000..d3c62be8de
--- /dev/null
+++ b/apps/carbon/app/integrations/index.ts
@@ -0,0 +1,15 @@
+import { ExchangeRates } from "./exchange-rates/config";
+import { QuickBooks } from "./quickbooks/config";
+import { Resend } from "./resend/config";
+import { Slack } from "./slack/config";
+import { Xero } from "./xero/config";
+import { Zapier } from "./zapier/config";
+
+export const integrations = [
+ ExchangeRates,
+ Resend,
+ Slack,
+ QuickBooks,
+ Xero,
+ Zapier,
+];
diff --git a/apps/carbon/app/integrations/quickbooks/config.tsx b/apps/carbon/app/integrations/quickbooks/config.tsx
new file mode 100644
index 0000000000..4b2e056cae
--- /dev/null
+++ b/apps/carbon/app/integrations/quickbooks/config.tsx
@@ -0,0 +1,42 @@
+import type { ComponentProps } from "react";
+import { z } from "zod";
+import type { IntegrationConfig } from "../types";
+
+export const QuickBooks: IntegrationConfig = {
+ name: "QuickBooks",
+ id: "quick-books",
+ active: false,
+ category: "Accounting",
+ logo: Logo,
+ description:
+ "Integrating CarbonOS with QuickBooks enables you to post transactions from sales invoices and purchase invoices into your existing accounting software, neatly organizing everything in your bookkeeping software.",
+ shortDescription:
+ "Automatically post transactions from sales and purchase invoices.",
+ images: [],
+ onInitialize: () => {},
+ onUninstall: () => {},
+ settings: [],
+ schema: z.object({}),
+};
+
+function Logo(props: ComponentProps<"svg">) {
+ return (
+ <svg
+ {...props}
+ width="41"
+ height="40"
+ viewBox="0 0 41 40"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ d="M20.5 40C31.5456 40 40.5 31.0456 40.5 20C40.5 8.95437 31.5456 0 20.5 0C9.45437 0 0.5 8.95437 0.5 20C0.5 31.0456 9.45437 40 20.5 40Z"
+ fill="#F5F5F3"
+ />
+ <path
+ d="M6.05585 20C6.05585 22.0628 6.8753 24.0411 8.33392 25.4998C9.79255 26.9584 11.7709 27.7778 13.8337 27.7778H14.9446V24.8888H13.8337C13.1884 24.8939 12.5484 24.7713 11.9507 24.5279C11.3531 24.2845 10.8095 23.9252 10.3513 23.4707C9.8932 23.0163 9.52957 22.4756 9.28142 21.8799C9.03328 21.2841 8.90552 20.6452 8.90552 19.9999C8.90552 19.3545 9.03328 18.7156 9.28142 18.1199C9.52957 17.5242 9.8932 16.9835 10.3513 16.529C10.8095 16.0745 11.3531 15.7152 11.9507 15.4718C12.5484 15.2284 13.1884 15.1058 13.8337 15.111H16.5002V30.2222C16.5005 30.9883 16.8049 31.723 17.3466 32.2647C17.8883 32.8064 18.6229 33.1109 19.389 33.1113V12.2222H13.8337C12.8122 12.2222 11.8008 12.4233 10.8571 12.8142C9.91345 13.205 9.05599 13.7779 8.33372 14.5002C7.61145 15.2224 7.03851 16.0798 6.64762 17.0235C6.25673 17.9672 6.05585 18.9786 6.05585 20ZM27.1668 12.2222H26.0559V15.1113H27.1668C28.4538 15.1258 29.6831 15.6473 30.5881 16.5625C31.493 17.4778 32.0006 18.7129 32.0006 20C32.0006 21.2871 31.493 22.5223 30.5881 23.4375C29.6831 24.3527 28.4538 24.8742 27.1668 24.8888H24.5002V9.77815C24.5003 9.39876 24.4256 9.02309 24.2804 8.67257C24.1353 8.32206 23.9225 8.00357 23.6542 7.73529C23.386 7.46701 23.0675 7.2542 22.717 7.10901C22.3665 6.96381 21.9909 6.88908 21.6115 6.88908V27.7781H27.1668C29.2296 27.7781 31.2079 26.9587 32.6665 25.5001C34.1252 24.0415 34.9446 22.0631 34.9446 20.0003C34.9446 17.9375 34.1252 15.9592 32.6665 14.5006C31.2079 13.042 29.2296 12.2222 27.1668 12.2222Z"
+ fill="#121212"
+ />
+ </svg>
+ );
+}
diff --git a/apps/carbon/app/integrations/resend/config.tsx b/apps/carbon/app/integrations/resend/config.tsx
new file mode 100644
index 0000000000..3b617e034f
--- /dev/null
+++ b/apps/carbon/app/integrations/resend/config.tsx
@@ -0,0 +1,58 @@
+import { cn } from "@carbon/react";
+import type { SVGProps } from "react";
+import { z } from "zod";
+import type { IntegrationConfig } from "../types";
+
+export const Resend: IntegrationConfig = {
+ 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(),
+ }),
+ onInitialize: () => {},
+ onUninstall: () => {},
+};
+
+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/apps/carbon/app/integrations/slack/config.tsx b/apps/carbon/app/integrations/slack/config.tsx
new file mode 100644
index 0000000000..ba046b3f77
--- /dev/null
+++ b/apps/carbon/app/integrations/slack/config.tsx
@@ -0,0 +1,64 @@
+import { z } from "zod";
+import type { IntegrationConfig } from "../types";
+
+export const Slack: IntegrationConfig = {
+ name: "Slack",
+ id: "slack",
+ category: "Assistant",
+ active: false,
+ logo: Logo,
+ shortDescription:
+ "Integrating with CarbonOS enables you to use CarbonOS Assistant within your Slack workspace.",
+ description:
+ "Integrating CarbonOS with Slack brings powerful capabilities directly into your team's communication hub. With this integration, you can seamlessly interact with CarbonOS Assistant without leaving your Slack workspace, enabling quick access to insights and actions.",
+ images: [],
+ settings: [],
+ schema: z.object({}),
+ onInitialize: () => {},
+ onUninstall: () => {},
+};
+
+function Logo() {
+ return (
+ <svg
+ width="40"
+ height="40"
+ viewBox="0 0 40 40"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ d="M9.85313 24.6172C9.85251 25.3442 9.63636 26.0547 9.23199 26.6589C8.82763 27.2631 8.25322 27.7339 7.58136 28.0117C6.9095 28.2895 6.17036 28.3618 5.45739 28.2196C4.74441 28.0774 4.0896 27.727 3.57574 27.2127C3.06187 26.6984 2.71203 26.0433 2.57042 25.3302C2.42881 24.6171 2.5018 23.878 2.78016 23.2064C3.05852 22.5348 3.52976 21.9607 4.1343 21.5569C4.73884 21.153 5.44954 20.9375 6.17656 20.9375H9.85313V24.6172Z"
+ fill="currentColor"
+ />
+ <path
+ d="M11.7063 24.6172C11.7063 23.6421 12.0936 22.7069 12.7831 22.0175C13.4726 21.328 14.4078 20.9406 15.3829 20.9406C16.3579 20.9406 17.2931 21.328 17.9826 22.0175C18.6721 22.7069 19.0594 23.6421 19.0594 24.6172V33.8234C19.0594 34.7985 18.6721 35.7337 17.9826 36.4231C17.2931 37.1126 16.3579 37.5 15.3829 37.5C14.4078 37.5 13.4726 37.1126 12.7831 36.4231C12.0936 35.7337 11.7063 34.7985 11.7063 33.8234V24.6172Z"
+ fill="currentColor"
+ />
+ <path
+ d="M15.3829 9.85313C14.6559 9.85251 13.9454 9.63636 13.3412 9.23199C12.737 8.82763 12.2662 8.25322 11.9884 7.58136C11.7106 6.9095 11.6383 6.17036 11.7805 5.45739C11.9227 4.74441 12.2731 4.0896 12.7874 3.57574C13.3017 3.06187 13.9568 2.71203 14.6699 2.57042C15.383 2.42881 16.1221 2.5018 16.7937 2.78016C17.4653 3.05852 18.0394 3.52976 18.4432 4.1343C18.8471 4.73884 19.0626 5.44954 19.0626 6.17656V9.85313H15.3829Z"
+ fill="currentColor"
+ />
+ <path
+ d="M15.3828 11.7062C16.3579 11.7062 17.293 12.0936 17.9825 12.7831C18.672 13.4726 19.0594 14.4077 19.0594 15.3828C19.0594 16.3579 18.672 17.293 17.9825 17.9825C17.293 18.672 16.3579 19.0594 15.3828 19.0594H6.17656C5.20148 19.0594 4.26633 18.672 3.57684 17.9825C2.88735 17.293 2.5 16.3579 2.5 15.3828C2.5 14.4077 2.88735 13.4726 3.57684 12.7831C4.26633 12.0936 5.20148 11.7062 6.17656 11.7062H15.3828Z"
+ fill="currentColor"
+ />
+ <path
+ d="M30.147 15.3828C30.1476 14.6558 30.3637 13.9453 30.7681 13.3411C31.1725 12.7369 31.7469 12.2661 32.4187 11.9883C33.0906 11.7106 33.8297 11.6382 34.5427 11.7804C35.2557 11.9226 35.9105 12.273 36.4244 12.7873C36.9382 13.3016 37.2881 13.9567 37.4297 14.6698C37.5713 15.3829 37.4983 16.122 37.2199 16.7936C36.9416 17.4652 36.4703 18.0393 35.8658 18.4431C35.2613 18.847 34.5506 19.0625 33.8235 19.0625H30.147V15.3828Z"
+ fill="currentColor"
+ />
+ <path
+ d="M28.2938 15.3828C28.2938 16.3579 27.9064 17.293 27.217 17.9825C26.5275 18.672 25.5923 19.0594 24.6172 19.0594C23.6422 19.0594 22.707 18.672 22.0175 17.9825C21.328 17.293 20.9407 16.3579 20.9407 15.3828V6.17656C20.9407 5.20148 21.328 4.26633 22.0175 3.57684C22.707 2.88735 23.6422 2.5 24.6172 2.5C25.5923 2.5 26.5275 2.88735 27.217 3.57684C27.9064 4.26633 28.2938 5.20148 28.2938 6.17656V15.3828Z"
+ fill="currentColor"
+ />
+ <path
+ d="M24.6172 30.1469C25.3442 30.1475 26.0547 30.3637 26.6589 30.768C27.2631 31.1724 27.7339 31.7468 28.0117 32.4186C28.2895 33.0905 28.3618 33.8296 28.2196 34.5426C28.0774 35.2556 27.727 35.9104 27.2127 36.4243C26.6984 36.9381 26.0433 37.288 25.3302 37.4296C24.6171 37.5712 23.878 37.4982 23.2064 37.2198C22.5348 36.9415 21.9607 36.4702 21.5569 35.8657C21.153 35.2612 20.9375 34.5505 20.9375 33.8234V30.1469H24.6172Z"
+ fill="currentColor"
+ />
+ <path
+ d="M24.6172 28.2937C23.6422 28.2937 22.707 27.9064 22.0175 27.2169C21.328 26.5274 20.9407 25.5923 20.9407 24.6172C20.9407 23.6421 21.328 22.7069 22.0175 22.0175C22.707 21.328 23.6422 20.9406 24.6172 20.9406H33.8235C34.7986 20.9406 35.7337 21.328 36.4232 22.0175C37.1127 22.7069 37.5 23.6421 37.5 24.6172C37.5 25.5923 37.1127 26.5274 36.4232 27.2169C35.7337 27.9064 34.7986 28.2937 33.8235 28.2937H24.6172Z"
+ fill="currentColor"
+ />
+ </svg>
+ );
+}
diff --git a/apps/carbon/app/integrations/types.ts b/apps/carbon/app/integrations/types.ts
new file mode 100644
index 0000000000..160caf2ec4
--- /dev/null
+++ b/apps/carbon/app/integrations/types.ts
@@ -0,0 +1,22 @@
+import type { ZodType } from "zod";
+
+export type IntegrationConfig = {
+ name: string;
+ id: string;
+ active: boolean;
+ category: string;
+ logo: React.FC<React.ComponentProps<"svg">>;
+ shortDescription: string;
+ description: string | null;
+ images: string[];
+ settings: {
+ name: string;
+ label: string;
+ type: "text" | "switch";
+ required: boolean;
+ value: unknown;
+ }[];
+ schema: ZodType;
+ onInitialize: () => void | Promise<void>;
+ onUninstall: () => void | Promise<void>;
+};
diff --git a/apps/carbon/app/integrations/xero/config.tsx b/apps/carbon/app/integrations/xero/config.tsx
new file mode 100644
index 0000000000..bb66636b9e
--- /dev/null
+++ b/apps/carbon/app/integrations/xero/config.tsx
@@ -0,0 +1,80 @@
+import type { ComponentProps } from "react";
+import { z } from "zod";
+import type { IntegrationConfig } from "../types";
+
+export const Xero: IntegrationConfig = {
+ name: "Xero",
+ id: "xero",
+ active: false,
+ category: "Accounting",
+ logo: Logo,
+ description:
+ "Integrating CarbonOS with Xero enables you to post transactions from sales invoices and purchase invoices into your existing accounting software, neatly organizing everything in your bookkeeping software.",
+ shortDescription:
+ "Automatically post transactions from sales and purchase invoices.",
+ images: [],
+ onInitialize: () => {},
+ onUninstall: () => {},
+ settings: [],
+ schema: z.object({}),
+};
+
+function Logo(props: ComponentProps<"svg">) {
+ return (
+ <svg
+ {...props}
+ width="40"
+ height="40"
+ viewBox="0 0 40 40"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <g clipPath="url(#clip0_1893_3614)">
+ <mask
+ id="mask0_1893_3614"
+ maskUnits="userSpaceOnUse"
+ x="-9"
+ y="-9"
+ width="58"
+ height="58"
+ >
+ <path
+ d="M-8.80334 -8.84987H48.8393V48.7927H-8.80334V-8.84987Z"
+ fill="white"
+ />
+ </mask>
+ <g mask="url(#mask0_1893_3614)">
+ <path
+ d="M20.0001 39.9237C31.0037 39.9237 39.9238 31.0037 39.9238 20C39.9238 8.99641 31.0037 0.0762529 20.0001 0.0762529C8.99645 0.0762529 0.0762939 8.99641 0.0762939 20C0.0762939 31.0037 8.99645 39.9237 20.0001 39.9237Z"
+ fill="#F5F5F3"
+ />
+ <path
+ d="M9.61353 19.9424L13.0137 16.5339C13.1264 16.419 13.1893 16.2669 13.1893 16.1055C13.1893 15.7693 12.916 15.4963 12.5798 15.4963C12.416 15.4963 12.2625 15.5605 12.1467 15.6777C12.1464 15.6784 8.74963 19.0732 8.74963 19.0732L5.33735 15.6726C5.22205 15.5589 5.06927 15.4963 4.90727 15.4963C4.57147 15.4963 4.2981 15.7692 4.2981 16.1051C4.2981 16.2689 4.36351 16.4226 4.48091 16.5385L7.88058 19.9377L4.48267 23.342C4.36324 23.4596 4.2981 23.6136 4.2981 23.7782C4.2981 24.1143 4.57147 24.387 4.90727 24.387C5.06954 24.387 5.22246 24.3241 5.33735 24.2091L8.74435 20.8067L12.1384 24.1967C12.2588 24.3212 12.4141 24.3874 12.5798 24.3874C12.9157 24.3874 13.189 24.1143 13.189 23.7782C13.189 23.616 13.1261 23.4636 13.0118 23.3487L9.61353 19.9424Z"
+ fill="#121212"
+ />
+ <path
+ d="M29.8268 19.9414C29.8268 20.5519 30.3232 21.0484 30.9344 21.0484C31.5441 21.0484 32.0407 20.5519 32.0407 19.9414C32.0407 19.3308 31.5441 18.8343 30.9344 18.8343C30.3232 18.8343 29.8268 19.3308 29.8268 19.9414Z"
+ fill="#121212"
+ />
+ <path
+ d="M27.7271 19.9419C27.7271 18.1741 29.1652 16.7358 30.9332 16.7358C32.7003 16.7358 34.1388 18.1741 34.1388 19.9419C34.1388 21.7093 32.7003 23.1471 30.9332 23.1471C29.1652 23.1471 27.7271 21.7093 27.7271 19.9419ZM26.4659 19.9419C26.4659 22.4048 28.47 24.4085 30.9332 24.4085C33.3964 24.4085 35.4014 22.4048 35.4014 19.9419C35.4014 17.4788 33.3964 15.4745 30.9332 15.4745C28.47 15.4745 26.4659 17.4788 26.4659 19.9419Z"
+ fill="#121212"
+ />
+ <path
+ d="M26.1489 15.5509L25.9614 15.5503C25.3988 15.5503 24.8561 15.7278 24.4028 16.0771C24.3431 15.8038 24.0988 15.5981 23.8078 15.5981C23.4729 15.5981 23.2045 15.8665 23.2037 16.2021C23.2037 16.2033 23.2058 23.726 23.2058 23.726C23.2066 24.061 23.4799 24.3333 23.815 24.3333C24.1501 24.3333 24.4232 24.061 24.4241 23.7253C24.4241 23.7238 24.4244 19.099 24.4244 19.099C24.4244 17.5571 24.5654 16.9343 25.8862 16.7693C26.0083 16.7541 26.1411 16.7565 26.1416 16.7565C26.503 16.7441 26.7599 16.4957 26.7599 16.16C26.7599 15.8242 26.4857 15.5509 26.1489 15.5509Z"
+ fill="#121212"
+ />
+ <path
+ d="M14.4513 19.2065C14.4513 19.1898 14.4525 19.1725 14.4534 19.1553C14.807 17.7571 16.0733 16.7225 17.5814 16.7225C19.1076 16.7225 20.3855 17.7826 20.7211 19.2065H14.4513ZM21.9686 19.0915C21.7061 17.8485 21.0256 16.8276 19.9894 16.1719C18.4747 15.2103 16.4746 15.2635 15.0116 16.3039C13.8182 17.1529 13.1293 18.5417 13.1293 19.9723C13.1293 20.331 13.1725 20.6931 13.2625 21.0495C13.7132 22.8222 15.2371 24.1641 17.0539 24.3865C17.5931 24.4518 18.1179 24.4205 18.6613 24.2798C19.1282 24.1662 19.5801 23.9768 19.9964 23.71C20.4285 23.4322 20.7895 23.0659 21.1392 22.6275C21.1462 22.6194 21.1533 22.6123 21.1604 22.6038C21.403 22.3028 21.358 21.8749 21.0914 21.6706C20.8665 21.4982 20.4889 21.4283 20.1918 21.8088C20.128 21.8997 20.0567 21.9933 19.9783 22.0869C19.7421 22.348 19.449 22.6009 19.0978 22.797C18.6509 23.0358 18.1417 23.1722 17.6003 23.1753C15.8283 23.1556 14.88 21.9186 14.5428 21.0358C14.4839 20.8709 14.4384 20.6999 14.4068 20.5238C14.4027 20.4908 14.3996 20.4591 14.3984 20.4298C14.7647 20.4298 20.7573 20.4288 20.7573 20.4288C21.629 20.4105 22.0982 19.7951 21.9686 19.0915Z"
+ fill="#121212"
+ />
+ </g>
+ </g>
+ <defs>
+ <clipPath id="clip0_1893_3614">
+ <rect width="40" height="40" fill="white" />
+ </clipPath>
+ </defs>
+ </svg>
+ );
+}
diff --git a/apps/carbon/app/integrations/zapier/config.tsx b/apps/carbon/app/integrations/zapier/config.tsx
new file mode 100644
index 0000000000..5b1a4d9a40
--- /dev/null
+++ b/apps/carbon/app/integrations/zapier/config.tsx
@@ -0,0 +1,41 @@
+import type { ComponentProps } from "react";
+import { z } from "zod";
+import type { IntegrationConfig } from "../types";
+
+export const Zapier: IntegrationConfig = {
+ name: "Zapier",
+ id: "zapier",
+ active: false,
+ category: "Automation",
+ logo: Logo,
+ description:
+ "Integrating with Zapier enables you to automate tasks and workflows in your business by connecting CarbonOS to other apps.",
+ shortDescription: "Automate tasks and workflows in your business.",
+ images: [],
+ onInitialize: () => {},
+ onUninstall: () => {},
+ settings: [],
+ schema: z.object({}),
+};
+
+function Logo(props: ComponentProps<"svg">) {
+ return (
+ <svg
+ {...props}
+ width="79"
+ height="22"
+ viewBox="0 0 79 22"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ d="M18.4996 14.6282L18.4865 14.5888L25.4845 8.18165V5.09623H14.2588V8.18165H20.9679L20.9811 8.20791L14.0487 14.6282V17.7136H25.6158V14.6282H18.4996ZM32.5087 4.79426C31.2089 4.79426 30.1585 4.9912 29.3445 5.38508C28.583 5.72645 27.9397 6.29101 27.5064 7C27.0862 7.70899 26.8237 8.50989 26.7318 9.33704L30.1454 9.8097C30.2636 9.08758 30.513 8.56241 30.8807 8.26043C31.3008 7.94532 31.826 7.78777 32.3512 7.8009C33.047 7.8009 33.5459 7.98471 33.861 8.35233C34.1761 8.71996 34.3337 9.23201 34.3337 9.91474V10.2561H31.0513C29.3839 10.2561 28.1891 10.6237 27.4539 11.3721C26.7186 12.1074 26.3641 13.0921 26.3641 14.3C26.3641 15.5473 26.7318 16.4663 27.4539 17.0703C28.176 17.6742 29.0951 17.9762 30.1979 17.9762C31.5634 17.9762 32.6137 17.5036 33.349 16.5582C33.7823 15.9805 34.0974 15.3241 34.2549 14.6151H34.3731L34.8457 17.7005H37.9312V9.88848C37.9312 8.27356 37.511 7.01313 36.6576 6.13346C35.8042 5.25379 34.4125 4.79426 32.5087 4.79426ZM33.5853 14.4444C33.0995 14.8514 32.4562 15.0615 31.6553 15.0615C30.9988 15.0615 30.5393 14.9433 30.2767 14.7201C30.1454 14.6151 30.0535 14.4707 29.9879 14.3262C29.9222 14.1687 29.8828 14.0111 29.896 13.8404C29.8828 13.6829 29.9091 13.5253 29.9747 13.3809C30.0404 13.2365 30.1192 13.1052 30.2242 12.987C30.3424 12.882 30.4736 12.7901 30.6312 12.7376C30.7888 12.685 30.9463 12.6588 31.1039 12.6719H34.3337V12.882C34.3337 13.184 34.2812 13.4859 34.1499 13.7485C34.0055 14.0111 33.8217 14.2606 33.5853 14.4444ZM56.6144 5.09623H52.9644V17.7268H56.6144V5.09623ZM78.1598 5.09623C77.1226 5.09623 76.3217 5.46386 75.7177 6.18597C75.2976 6.71115 74.9693 7.48579 74.7461 8.50989H74.6411L74.1684 5.09623H71.0568V17.7268H74.7068V11.2539C74.7068 10.4399 74.9037 9.8097 75.2844 9.37643C75.6652 8.94316 76.3742 8.71996 77.3983 8.71996H78.79V5.09623H78.1598ZM67.433 5.50325C66.5796 4.9912 65.503 4.74174 64.2032 4.74174C62.155 4.74174 60.5663 5.31943 59.4109 6.48795C58.2556 7.65647 57.6779 9.25827 57.6779 11.2933C57.6516 12.5275 57.9142 13.7485 58.4656 14.8645C58.9645 15.8492 59.7392 16.6764 60.6976 17.2278C61.6692 17.7924 62.8115 18.0681 64.1507 18.0681C65.3061 18.0681 66.2645 17.8843 67.0392 17.5298C67.7613 17.2147 68.4046 16.7158 68.8773 16.0724C69.3368 15.4554 69.6782 14.7464 69.8751 14.0111L66.724 13.1315C66.5928 13.6172 66.3302 14.0505 65.9888 14.4181C65.6343 14.7726 65.0435 14.9564 64.2032 14.9564C63.2054 14.9564 62.4701 14.6676 61.9843 14.103C61.6298 13.696 61.4066 13.1052 61.3147 12.3437H69.9276C69.967 11.9892 69.9802 11.6872 69.9802 11.4509V10.6631C70.0064 9.61276 69.7832 8.56241 69.3368 7.60396C68.9298 6.72428 68.2602 5.98904 67.433 5.50325ZM64.0982 7.76151C65.5818 7.76151 66.4221 8.48363 66.619 9.94099H61.3804C61.4591 9.45521 61.6692 8.99568 61.9712 8.60179C62.4438 8.03723 63.1528 7.76151 64.0982 7.76151ZM54.8288 0.00201066C54.5531 -0.0111188 54.2773 0.041399 54.0279 0.133305C53.7653 0.238341 53.5421 0.382765 53.3451 0.566577C53.1482 0.763518 53.0038 0.986719 52.8987 1.24931C52.7937 1.49877 52.7543 1.77449 52.7674 2.0502C52.7543 2.32592 52.8068 2.60164 52.9119 2.8511C53.0169 3.11369 53.1613 3.33689 53.3583 3.53383C53.5552 3.73077 53.7915 3.8752 54.041 3.98023C54.2905 4.08527 54.5662 4.12465 54.8419 4.11153C55.1176 4.12465 55.3933 4.07214 55.6428 3.98023C55.8923 3.8752 56.1286 3.73077 56.3255 3.53383C56.5225 3.33689 56.6669 3.10056 56.7588 2.8511C56.8507 2.58851 56.9032 2.32592 56.8901 2.0502C56.9032 1.77449 56.8638 1.49877 56.7588 1.24931C56.6538 0.999848 56.5093 0.763518 56.3124 0.566577C56.1155 0.369635 55.8923 0.225212 55.6297 0.120177C55.3802 0.0414002 55.1045 -0.0111188 54.8288 0.00201066ZM47.2925 4.74174C46.0452 4.74174 45.0473 5.13562 44.299 5.91026C43.7344 6.48796 43.3274 7.3545 43.0648 8.49676H42.9466L42.474 5.0831H39.3623V21.3374H43.0123V14.6413H43.1436C43.2486 15.0877 43.4062 15.521 43.6031 15.9411C43.9182 16.6108 44.4171 17.1884 45.0605 17.5692C45.7169 17.9237 46.4653 18.1075 47.2137 18.0944C48.7367 18.0944 49.9052 17.5036 50.7061 16.3088C51.507 15.114 51.9009 13.4597 51.9009 11.3327C51.9009 9.27139 51.5201 7.65648 50.7455 6.50108C49.9709 5.33256 48.8155 4.74174 47.2925 4.74174ZM47.6601 13.893C47.2399 14.51 46.5703 14.812 45.6644 14.812C45.2968 14.8251 44.916 14.7595 44.5747 14.6019C44.2333 14.4444 43.9313 14.2081 43.7081 13.9192C43.2355 13.3284 42.9991 12.5144 42.9991 11.4771V11.2408C42.9991 10.1905 43.2355 9.38956 43.7081 8.83812C44.1808 8.28669 44.8373 8.01097 45.6644 8.01097C46.5835 8.01097 47.2531 8.29982 47.6732 8.89064C48.0934 9.48146 48.3034 10.2955 48.3034 11.3458C48.3034 12.4356 48.0934 13.289 47.6601 13.893Z"
+ fill="currentColor"
+ />
+ <path
+ d="M12.6305 14.6282H0V17.7268H12.6305V14.6282Z"
+ fill="currentColor"
+ />
+ </svg>
+ );
+}
diff --git a/apps/carbon/app/modules/settings/index.ts b/apps/carbon/app/modules/settings/index.ts
index 531fe68fa9..0c0195d59e 100644
--- a/apps/carbon/app/modules/settings/index.ts
+++ b/apps/carbon/app/modules/settings/index.ts
@@ -1,4 +1,3 @@
-export * from "./integrations.models";
export * from "./settings.models";
export * from "./settings.service";
export * from "./types";
diff --git a/apps/carbon/app/modules/settings/integrations.models.ts b/apps/carbon/app/modules/settings/integrations.models.ts
deleted file mode 100644
index 250f4a25b0..0000000000
--- a/apps/carbon/app/modules/settings/integrations.models.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import { z } from "zod";
-import { zfd } from "zod-form-data";
-
-export const integration = z.object({
- active: zfd.checkbox(),
-});
-
-export const apiKey = z.object({
- apiKey: z.string(),
-});
-
-export const exchangeRatesFormValidator = integration;
-
-export const googlePlacesFormValidator = integration.merge(apiKey).refine(
- (data) => {
- if (data.active) {
- return data.apiKey.length > 0;
- }
- return true;
- },
- {
- message: "API key is required when integration is active",
- path: ["apiKey"],
- }
-);
-
-export const resendFormValidator = integration
- .merge(apiKey)
- .merge(
- z.object({
- fromEmail: zfd.text(z.string().email().optional()),
- })
- )
- .refine(
- (data) => {
- if (data.active) {
- return data.apiKey.length > 0;
- }
- return true;
- },
- {
- message: "API key is required when integration is active",
- path: ["apiKey"],
- }
- );
diff --git a/apps/carbon/app/modules/settings/settings.models.ts b/apps/carbon/app/modules/settings/settings.models.ts
index e0df02fb0b..9dc28cfe16 100644
--- a/apps/carbon/app/modules/settings/settings.models.ts
+++ b/apps/carbon/app/modules/settings/settings.models.ts
@@ -8,7 +8,7 @@ export const modulesType = [
"Invoicing",
"Inventory",
"Items",
- "Jobs",
+ "Production",
// "Messaging",
"Purchasing",
"Resources",
diff --git a/apps/carbon/app/modules/settings/settings.service.ts b/apps/carbon/app/modules/settings/settings.service.ts
index 5730cbb490..6a35c097aa 100644
--- a/apps/carbon/app/modules/settings/settings.service.ts
+++ b/apps/carbon/app/modules/settings/settings.service.ts
@@ -13,6 +13,27 @@ import type {
sequenceValidator,
} from "./settings.models";
+export async function deactivateIntegration(
+ client: SupabaseClient<Database>,
+ args: {
+ id: string;
+ companyId: string;
+ updatedBy: string;
+ }
+) {
+ const { id, companyId, updatedBy } = args;
+
+ return client
+ .from("companyIntegration")
+ .update({
+ active: false,
+ updatedBy,
+ updatedAt: new Date().toISOString(),
+ })
+ .eq("id", id)
+ .eq("companyId", companyId);
+}
+
export async function deleteApiKey(
client: SupabaseClient<Database>,
id: string
@@ -187,12 +208,7 @@ export async function getIntegrations(
client: SupabaseClient<Database>,
companyId: string
) {
- return client
- .from("integrations")
- .select("*")
- .eq("companyId", companyId)
- .eq("visible", true)
- .order("title");
+ return client.from("integrations").select("*").eq("companyId", companyId);
}
export async function getNextSequence(
diff --git a/apps/carbon/app/modules/settings/ui/Integrations/ExchangeRatesForm.tsx b/apps/carbon/app/modules/settings/ui/Integrations/ExchangeRatesForm.tsx
deleted file mode 100644
index 9bbd6295cc..0000000000
--- a/apps/carbon/app/modules/settings/ui/Integrations/ExchangeRatesForm.tsx
+++ /dev/null
@@ -1,73 +0,0 @@
-import { ValidatedForm } from "@carbon/form";
-import {
- Button,
- Drawer,
- DrawerBody,
- DrawerContent,
- DrawerDescription,
- DrawerFooter,
- DrawerHeader,
- DrawerTitle,
- HStack,
- VStack,
-} from "@carbon/react";
-import type { z } from "zod";
-import { Boolean, Submit } from "~/components/Form";
-import { usePermissions } from "~/hooks";
-import { exchangeRatesFormValidator } from "~/modules/settings";
-import { path } from "~/utils/path";
-
-type ExchangeRatesFormProps = {
- initialValues: z.infer<typeof exchangeRatesFormValidator>;
- onClose: () => void;
-};
-
-const ExchangeRatesForm = ({
- initialValues,
- onClose,
-}: ExchangeRatesFormProps) => {
- const permissions = usePermissions();
- const isDisabled = !permissions.can("update", "settings");
-
- return (
- <Drawer
- open
- onOpenChange={(open) => {
- if (!open) onClose();
- }}
- >
- <DrawerContent>
- <ValidatedForm
- validator={exchangeRatesFormValidator}
- method="post"
- action={path.to.integration("exchange-rates-v1")}
- defaultValues={initialValues}
- className="flex flex-col h-full"
- >
- <DrawerHeader>
- <DrawerTitle>Update Exchange Rates</DrawerTitle>
- <DrawerDescription>
- Updates the exchange rates using
- http://api.exchangeratesapi.io/v1/
- </DrawerDescription>
- </DrawerHeader>
- <DrawerBody>
- <VStack spacing={4}>
- <Boolean name="active" label="Active" />
- </VStack>
- </DrawerBody>
- <DrawerFooter>
- <HStack>
- <Submit isDisabled={isDisabled}>Save</Submit>
- <Button size="md" variant="solid" onClick={onClose}>
- Cancel
- </Button>
- </HStack>
- </DrawerFooter>
- </ValidatedForm>
- </DrawerContent>
- </Drawer>
- );
-};
-
-export default ExchangeRatesForm;
diff --git a/apps/carbon/app/modules/settings/ui/Integrations/GooglePlacesForm.tsx b/apps/carbon/app/modules/settings/ui/Integrations/GooglePlacesForm.tsx
deleted file mode 100644
index 6b82e62485..0000000000
--- a/apps/carbon/app/modules/settings/ui/Integrations/GooglePlacesForm.tsx
+++ /dev/null
@@ -1,73 +0,0 @@
-import { ValidatedForm } from "@carbon/form";
-import {
- Button,
- Drawer,
- DrawerBody,
- DrawerContent,
- DrawerDescription,
- DrawerFooter,
- DrawerHeader,
- DrawerTitle,
- HStack,
- VStack,
-} from "@carbon/react";
-import type { z } from "zod";
-import { Boolean, Input, Submit } from "~/components/Form";
-import { usePermissions } from "~/hooks";
-import { resendFormValidator } from "~/modules/settings";
-import { path } from "~/utils/path";
-
-type GooglePlacesFormProps = {
- initialValues: z.infer<typeof resendFormValidator>;
- onClose: () => void;
-};
-
-const GooglePlacesForm = ({
- initialValues,
- onClose,
-}: GooglePlacesFormProps) => {
- const permissions = usePermissions();
- const isDisabled = !permissions.can("update", "settings");
-
- return (
- <Drawer
- open
- onOpenChange={(open) => {
- if (!open) onClose();
- }}
- >
- <DrawerContent>
- <ValidatedForm
- validator={resendFormValidator}
- method="post"
- action={path.to.integration("google-places-v2")}
- defaultValues={initialValues}
- className="flex flex-col h-full"
- >
- <DrawerHeader>
- <DrawerTitle>Google Places</DrawerTitle>
- <DrawerDescription>
- Autocomplete addresses with Google Places API
- </DrawerDescription>
- </DrawerHeader>
- <DrawerBody>
- <VStack spacing={4}>
- <Boolean name="active" label="Active" />
- <Input name="apiKey" label="API Key" />
- </VStack>
- </DrawerBody>
- <DrawerFooter>
- <HStack>
- <Submit isDisabled={isDisabled}>Save</Submit>
- <Button size="md" variant="solid" onClick={onClose}>
- Cancel
- </Button>
- </HStack>
- </DrawerFooter>
- </ValidatedForm>
- </DrawerContent>
- </Drawer>
- );
-};
-
-export default GooglePlacesForm;
diff --git a/apps/carbon/app/modules/settings/ui/Integrations/IntegrationForm.tsx b/apps/carbon/app/modules/settings/ui/Integrations/IntegrationForm.tsx
new file mode 100644
index 0000000000..9fa2389860
--- /dev/null
+++ b/apps/carbon/app/modules/settings/ui/Integrations/IntegrationForm.tsx
@@ -0,0 +1,148 @@
+import { Boolean, Input, Submit, ValidatedForm } from "@carbon/form";
+import {
+ Badge,
+ Button,
+ Drawer,
+ DrawerBody,
+ DrawerContent,
+ DrawerFooter,
+ DrawerHeader,
+ Heading,
+ HStack,
+ ScrollArea,
+ toast,
+ VStack,
+} from "@carbon/react";
+import { useParams } from "@remix-run/react";
+import { usePermissions } from "~/hooks";
+import { integrations as availableIntegrations } from "~/integrations";
+import { path } from "~/utils/path";
+
+interface IntegrationFormProps {
+ metadata: Record<string, unknown>;
+ installed: boolean;
+ onClose: () => void;
+}
+
+export function IntegrationForm({
+ installed,
+ metadata,
+ onClose,
+}: IntegrationFormProps) {
+ const permissions = usePermissions();
+ const isDisabled = !permissions.can("update", "settings");
+
+ const { id: integrationId } = useParams();
+ if (!integrationId) {
+ throw new Error("Integration ID is required");
+ }
+
+ const integration = availableIntegrations.find((i) => i.id === integrationId);
+
+ if (!integration) {
+ toast.error("Integration not found");
+ return null;
+ }
+
+ const initialValues = integration.settings.reduce((acc, setting) => {
+ return {
+ ...acc,
+ [setting.name]: metadata[setting.name],
+ };
+ }, {});
+
+ return (
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={integration.schema}
+ method="post"
+ action={path.to.integration(integration.id)}
+ defaultValues={initialValues}
+ 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>}
+ </div>
+
+ <span className="text-xs text-[#878787]">
+ <Badge variant="secondary">{integration.category}</Badge> •
+ Published by CarbonOS
+ </span>
+ </div>
+ </VStack>
+ </DrawerHeader>
+ <DrawerBody>
+ <ScrollArea className="h-[calc(100vh-240px)]">
+ <VStack spacing={2}>
+ <Heading size="h3">How it works</Heading>
+ <p className="text-sm text-muted-foreground">
+ {integration.description}
+ </p>
+
+ {integration.settings.map((setting) => {
+ switch (setting.type) {
+ case "text":
+ return (
+ <Input
+ key={setting.name}
+ name={setting.name}
+ label={setting.label}
+ isOptional={!setting.required}
+ />
+ );
+ case "switch":
+ return (
+ <Boolean
+ key={setting.name}
+ name={setting.name}
+ label={setting.label}
+ description={setting.label}
+ />
+ );
+ default:
+ return null;
+ }
+ })}
+ </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:[email protected]" className="text-sm text-red-500">
+ Report integration
+ </a>
+ </DrawerBody>
+ <DrawerFooter>
+ <HStack>
+ {integration.settings.length > 0 ? (
+ installed ? (
+ <Submit isDisabled={isDisabled}>Update</Submit>
+ ) : (
+ <Submit isDisabled={isDisabled}>Install</Submit>
+ )
+ ) : null}
+
+ <Button variant="solid" onClick={onClose}>
+ Close
+ </Button>
+ </HStack>
+ </DrawerFooter>
+ </ValidatedForm>
+ </DrawerContent>
+ </Drawer>
+ );
+}
diff --git a/apps/carbon/app/modules/settings/ui/Integrations/IntegrationsList.tsx b/apps/carbon/app/modules/settings/ui/Integrations/IntegrationsList.tsx
index fbea22fc47..20753542cb 100644
--- a/apps/carbon/app/modules/settings/ui/Integrations/IntegrationsList.tsx
+++ b/apps/carbon/app/modules/settings/ui/Integrations/IntegrationsList.tsx
@@ -1,44 +1,122 @@
import {
+ Badge,
+ Button,
Card,
CardContent,
- CardDescription,
+ CardFooter,
CardHeader,
CardTitle,
- Switch,
} from "@carbon/react";
-import { useNavigate } from "@remix-run/react";
-import type { Integration } from "../../types";
+import { Link, useFetcher, useNavigate } from "@remix-run/react";
+import type { IntegrationConfig } from "~/integrations/types";
+import { path } from "~/utils/path";
type IntegrationsListProps = {
- integrations: Integration[];
+ availableIntegrations: IntegrationConfig[];
+ installedIntegrations: string[];
};
-const IntegrationsList = ({ integrations }: IntegrationsListProps) => {
- const navigate = useNavigate();
+const IntegrationsList = ({
+ installedIntegrations,
+ availableIntegrations,
+}: IntegrationsListProps) => {
return (
<div className="grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3 p-4 w-full">
- {integrations.map((integration) => {
+ {availableIntegrations.map((integration) => {
return (
- <Card
+ <IntegrationCard
key={integration.id}
- className="cursor-pointer"
- onClick={() => navigate(integration.id!)}
- >
- <CardHeader>
- <CardTitle className="text-sm md:text-base">
- {integration.title}
- </CardTitle>
- <CardDescription>{integration.description}</CardDescription>
- </CardHeader>
-
- <CardContent>
- <Switch checked={!!integration.active} />
- </CardContent>
- </Card>
+ integration={integration}
+ installed={installedIntegrations.includes(integration.id)}
+ />
);
})}
</div>
);
};
+function IntegrationCard({
+ integration,
+ installed,
+}: {
+ integration: IntegrationConfig;
+ installed: boolean;
+}) {
+ const fetcher = useFetcher<{}>();
+ const navigate = useNavigate();
+
+ const handleInstall = async () => {
+ if (integration.settings.some((setting) => setting.required)) {
+ navigate(path.to.integration(integration.id));
+ } else {
+ integration.onInitialize?.();
+ const formData = new FormData();
+ fetcher.submit(formData, {
+ method: "post",
+ action: path.to.integration(integration.id),
+ });
+ }
+ };
+
+ const handleUninstall = async () => {
+ await integration?.onUninstall?.();
+ };
+
+ return (
+ <Card>
+ <div className="pt-6 px-6 h-16 flex items-center justify-between">
+ <integration.logo className="h-10 w-auto" />
+ {integration.active ? (
+ installed ? (
+ <Badge variant="green">Installed</Badge>
+ ) : null
+ ) : (
+ <Badge variant="gray">Coming soon</Badge>
+ )}
+ </div>
+ <CardHeader className="pb-0">
+ <div className="flex items-center space-x-2 pb-4">
+ <CardTitle className="text-md font-medium leading-none p-0 m-0">
+ {integration.name}
+ </CardTitle>
+ </div>
+ </CardHeader>
+ <CardContent className="text-sm text-muted-foreground pb-4">
+ {integration.description}
+ </CardContent>
+ <CardFooter className="flex flex-end flex-row-reverse gap-2">
+ <Button isDisabled={!installed} variant="secondary" asChild>
+ <Link to={integration.active && installed ? integration.id : "#"}>
+ Details
+ </Link>
+ </Button>
+ {installed ? (
+ <fetcher.Form
+ method="post"
+ action={path.to.integrationDeactivate(integration.id)}
+ onSubmit={handleUninstall}
+ >
+ <Button
+ variant="destructive"
+ type="submit"
+ isDisabled={fetcher.state !== "idle"}
+ isLoading={fetcher.state !== "idle"}
+ >
+ Uninstall
+ </Button>
+ </fetcher.Form>
+ ) : (
+ <Button
+ isDisabled={!integration.active || fetcher.state !== "idle"}
+ isLoading={fetcher.state !== "idle"}
+ onClick={handleInstall}
+ >
+ Install
+ </Button>
+ )}
+ </CardFooter>
+ </Card>
+ );
+}
+
export default IntegrationsList;
diff --git a/apps/carbon/app/modules/settings/ui/Integrations/ResendForm.tsx b/apps/carbon/app/modules/settings/ui/Integrations/ResendForm.tsx
deleted file mode 100644
index d11b1a12c6..0000000000
--- a/apps/carbon/app/modules/settings/ui/Integrations/ResendForm.tsx
+++ /dev/null
@@ -1,75 +0,0 @@
-import { ValidatedForm } from "@carbon/form";
-import {
- Button,
- Drawer,
- DrawerBody,
- DrawerContent,
- DrawerDescription,
- DrawerFooter,
- DrawerHeader,
- DrawerTitle,
- HStack,
- VStack,
-} from "@carbon/react";
-import type { z } from "zod";
-import { Boolean, Input, Submit } from "~/components/Form";
-import { usePermissions } from "~/hooks";
-import { resendFormValidator } from "~/modules/settings";
-import { path } from "~/utils/path";
-
-type ResendFormProps = {
- initialValues: z.infer<typeof resendFormValidator>;
- onClose: () => void;
-};
-
-const ResendForm = ({ initialValues, onClose }: ResendFormProps) => {
- const permissions = usePermissions();
- const isDisabled = !permissions.can("update", "settings");
-
- return (
- <Drawer
- open
- onOpenChange={(open) => {
- if (!open) onClose();
- }}
- >
- <DrawerContent>
- <ValidatedForm
- validator={resendFormValidator}
- method="post"
- action={path.to.integration("resend")}
- defaultValues={initialValues}
- className="flex flex-col h-full"
- >
- <DrawerHeader>
- <DrawerTitle>Resend</DrawerTitle>
- <DrawerDescription>
- Sends transactional emails with Resend API
- </DrawerDescription>
- </DrawerHeader>
- <DrawerBody>
- <VStack spacing={4}>
- <Boolean name="active" label="Active" />
- <Input name="apiKey" label="API Key" />
- <Input
- name="fromEmail"
- label="From Email"
- placeholder="[email protected]"
- />
- </VStack>
- </DrawerBody>
- <DrawerFooter>
- <HStack>
- <Submit isDisabled={isDisabled}>Save</Submit>
- <Button size="md" variant="solid" onClick={onClose}>
- Cancel
- </Button>
- </HStack>
- </DrawerFooter>
- </ValidatedForm>
- </DrawerContent>
- </Drawer>
- );
-};
-
-export default ResendForm;
diff --git a/apps/carbon/app/modules/settings/ui/Integrations/index.ts b/apps/carbon/app/modules/settings/ui/Integrations/index.ts
index 7b6d21c56e..99ea51cda2 100644
--- a/apps/carbon/app/modules/settings/ui/Integrations/index.ts
+++ b/apps/carbon/app/modules/settings/ui/Integrations/index.ts
@@ -1,6 +1,4 @@
-import ExchangeRatesForm from "./ExchangeRatesForm";
-import GooglePlacesForm from "./GooglePlacesForm";
+import { IntegrationForm } from "./IntegrationForm";
import IntegrationsList from "./IntegrationsList";
-import ResendForm from "./ResendForm";
-export { ExchangeRatesForm, GooglePlacesForm, IntegrationsList, ResendForm };
+export { IntegrationForm, IntegrationsList };
diff --git a/apps/carbon/app/routes/x+/settings+/integrations.$id.tsx b/apps/carbon/app/routes/x+/settings+/integrations.$id.tsx
new file mode 100644
index 0000000000..026d71c8c3
--- /dev/null
+++ b/apps/carbon/app/routes/x+/settings+/integrations.$id.tsx
@@ -0,0 +1,102 @@
+import { assertIsPost, error, success } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import { validationError, validator } from "@carbon/form";
+import { redirect, useLoaderData, useNavigate } from "@remix-run/react";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
+import { integrations as availableIntegrations } from "~/integrations";
+import {
+ IntegrationForm,
+ getIntegration,
+ upsertIntegration,
+} from "~/modules/settings";
+import { path } from "~/utils/path";
+
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ const { client, companyId } = await requirePermissions(request, {
+ update: "settings",
+ });
+
+ const { id: integrationId } = params;
+ if (!integrationId) throw new Error("Integration ID not found");
+
+ const integration = availableIntegrations.find((i) => i.id === integrationId);
+ if (!integration) throw new Error("Integration not found");
+
+ const integrationData = await getIntegration(
+ client,
+ integrationId,
+ companyId
+ );
+
+ if (integrationData.error || !integrationData.data) {
+ return {
+ installed: false,
+ metadata: {},
+ };
+ }
+
+ return {
+ installed: integrationData.data.active,
+ metadata: (integrationData.data.metadata ?? {}) as Record<string, unknown>,
+ };
+}
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client, companyId, userId } = await requirePermissions(request, {
+ update: "settings",
+ });
+
+ const { id: integrationId } = params;
+ if (!integrationId) throw new Error("Integration ID not found");
+
+ const integration = availableIntegrations.find((i) => i.id === integrationId);
+
+ if (!integration) throw new Error("Integration not found");
+
+ const validation = await validator(integration.schema).validate(
+ await request.formData()
+ );
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const { active, ...data } = validation.data;
+
+ const update = await upsertIntegration(client, {
+ id: integrationId,
+ active: true,
+ metadata: {
+ ...data,
+ },
+ companyId,
+ updatedBy: userId,
+ });
+ if (update.error) {
+ throw redirect(
+ path.to.integrations,
+ await flash(request, error(update.error, "Failed to install integration"))
+ );
+ }
+
+ throw redirect(
+ path.to.integrations,
+ await flash(request, success(`Installed ${integration.name} integration`))
+ );
+}
+
+export default function IntegrationRoute() {
+ const { installed, metadata } = useLoaderData<typeof loader>();
+
+ const navigate = useNavigate();
+
+ return (
+ <IntegrationForm
+ installed={installed}
+ metadata={metadata}
+ onClose={() => navigate(path.to.integrations)}
+ />
+ );
+}
diff --git a/apps/carbon/app/routes/x+/settings+/integrations.deactivate.$id.tsx b/apps/carbon/app/routes/x+/settings+/integrations.deactivate.$id.tsx
new file mode 100644
index 0000000000..91a84e381c
--- /dev/null
+++ b/apps/carbon/app/routes/x+/settings+/integrations.deactivate.$id.tsx
@@ -0,0 +1,46 @@
+import { assertIsPost, error, success } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import { redirect } from "@remix-run/react";
+import type { ActionFunctionArgs } from "@vercel/remix";
+import { integrations as availableIntegrations } from "~/integrations";
+import { deactivateIntegration } from "~/modules/settings";
+import { path } from "~/utils/path";
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client, companyId, userId } = await requirePermissions(request, {
+ update: "settings",
+ });
+
+ const { id: integrationId } = params;
+ if (!integrationId) throw new Error("Integration ID not found");
+
+ const integration = availableIntegrations.find((i) => i.id === integrationId);
+
+ if (!integration) throw new Error("Integration not found");
+
+ const update = await deactivateIntegration(client, {
+ id: integrationId,
+ companyId,
+ updatedBy: userId,
+ });
+ console.log(update);
+ if (update.error) {
+ throw redirect(
+ path.to.integrations,
+ await flash(
+ request,
+ error(update.error, "Failed to disconnect integration")
+ )
+ );
+ }
+
+ throw redirect(
+ path.to.integrations,
+ await flash(
+ request,
+ success(`Disconnected ${integration.name} integration`)
+ )
+ );
+}
diff --git a/apps/carbon/app/routes/x+/settings+/integrations.exchange-rates-v1.tsx b/apps/carbon/app/routes/x+/settings+/integrations.exchange-rates-v1.tsx
deleted file mode 100644
index e93f7ff1d7..0000000000
--- a/apps/carbon/app/routes/x+/settings+/integrations.exchange-rates-v1.tsx
+++ /dev/null
@@ -1,101 +0,0 @@
-import { assertIsPost, error, success } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { validationError, validator } from "@carbon/form";
-import { useLoaderData, useNavigate } from "@remix-run/react";
-import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
-import { json, redirect } from "@vercel/remix";
-import {
- ExchangeRatesForm,
- apiKey,
- exchangeRatesFormValidator,
- getIntegration,
- upsertIntegration,
-} from "~/modules/settings";
-import { path } from "~/utils/path";
-
-const defaultValue = {
- active: false,
-};
-
-export async function loader({ request }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- update: "settings",
- });
-
- const integration = await getIntegration(
- client,
- "exchange-rates-v1",
- companyId
- );
- if (integration.error) {
- throw redirect(
- path.to.integrations,
- await flash(
- request,
- error(integration.error, "Failed to load integration")
- )
- );
- }
-
- const validIntegration = apiKey.safeParse(integration.data?.metadata);
-
- return json({
- integration: validIntegration.success
- ? {
- active: integration.data?.active ?? false,
- ...validIntegration.data,
- }
- : defaultValue,
- });
-}
-
-export async function action({ request }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, companyId, userId } = await requirePermissions(request, {
- update: "settings",
- });
-
- const validation = await validator(exchangeRatesFormValidator).validate(
- await request.formData()
- );
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- const update = await upsertIntegration(client, {
- id: "exchange-rates-v1",
- active: validation.data.active,
- metadata: {},
- companyId,
- updatedBy: userId,
- });
- if (update.error) {
- throw redirect(
- path.to.integrations,
- await flash(
- request,
- error(update.error, "Failed to update exchange rates integration")
- )
- );
- }
-
- throw redirect(
- path.to.integrations,
- await flash(request, success("Updated exchange rates integration"))
- );
-}
-
-export default function ExchangeRatesIntegrationRoute() {
- const { integration } = useLoaderData<typeof loader>();
-
- const navigate = useNavigate();
-
- return (
- <ExchangeRatesForm
- initialValues={integration}
- onClose={() => navigate(path.to.integrations)}
- />
- );
-}
diff --git a/apps/carbon/app/routes/x+/settings+/integrations.google-places-v2.tsx b/apps/carbon/app/routes/x+/settings+/integrations.google-places-v2.tsx
deleted file mode 100644
index a1c8f81217..0000000000
--- a/apps/carbon/app/routes/x+/settings+/integrations.google-places-v2.tsx
+++ /dev/null
@@ -1,106 +0,0 @@
-import { assertIsPost, error, success } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { validationError, validator } from "@carbon/form";
-import { useLoaderData, useNavigate } from "@remix-run/react";
-import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
-import { json, redirect } from "@vercel/remix";
-import {
- GooglePlacesForm,
- apiKey,
- getIntegration,
- googlePlacesFormValidator,
- upsertIntegration,
-} from "~/modules/settings";
-import { path } from "~/utils/path";
-
-const defaultValue = {
- apiKey: "",
- active: false,
-};
-
-export async function loader({ request }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- update: "settings",
- });
-
- const integration = await getIntegration(
- client,
- "google-places-v2",
- companyId
- );
- if (integration.error) {
- throw redirect(
- path.to.integrations,
- await flash(
- request,
- error(integration.error, "Failed to load Google Places integration")
- )
- );
- }
-
- const validIntegration = apiKey.safeParse(integration.data?.metadata);
-
- return json({
- integration: validIntegration.success
- ? {
- active: integration.data?.active ?? false,
- ...validIntegration.data,
- }
- : defaultValue,
- });
-}
-
-export async function action({ request, params }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, companyId, userId } = await requirePermissions(request, {
- update: "settings",
- });
-
- const validation = await validator(googlePlacesFormValidator).validate(
- await request.formData()
- );
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- const { active, ...data } = validation.data;
-
- const update = await upsertIntegration(client, {
- id: "google-places-v2",
- active,
- metadata: {
- ...data,
- },
- companyId,
- updatedBy: userId,
- });
- if (update.error) {
- throw redirect(
- path.to.integrations,
- await flash(
- request,
- error(update.error, "Failed to update Google Places integration")
- )
- );
- }
-
- throw redirect(
- path.to.integrations,
- await flash(request, success("Updated Google Places integration"))
- );
-}
-
-export default function GooglePlacesIntegrationRoute() {
- const { integration } = useLoaderData<typeof loader>();
-
- const navigate = useNavigate();
-
- return (
- <GooglePlacesForm
- initialValues={integration}
- onClose={() => navigate(path.to.integrations)}
- />
- );
-}
diff --git a/apps/carbon/app/routes/x+/settings+/integrations.resend.tsx b/apps/carbon/app/routes/x+/settings+/integrations.resend.tsx
deleted file mode 100644
index 833e265ddb..0000000000
--- a/apps/carbon/app/routes/x+/settings+/integrations.resend.tsx
+++ /dev/null
@@ -1,95 +0,0 @@
-import { assertIsPost, error, success } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { validationError, validator } from "@carbon/form";
-import { useLoaderData, useNavigate } from "@remix-run/react";
-import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
-import { json, redirect } from "@vercel/remix";
-import {
- ResendForm,
- getIntegration,
- resendFormValidator,
- upsertIntegration,
-} from "~/modules/settings";
-import { path } from "~/utils/path";
-
-const defaultValue = {
- apiKey: "",
- active: false,
-};
-
-export async function loader({ request }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- update: "settings",
- });
-
- const integration = await getIntegration(client, "resend", companyId);
-
- const validIntegration = resendFormValidator.safeParse(
- integration.data?.metadata
- );
-
- return json({
- integration: validIntegration.success
- ? {
- active: integration.data?.active ?? false,
- apiKey: validIntegration.data.apiKey,
- fromEmail: validIntegration.data.fromEmail,
- }
- : defaultValue,
- });
-}
-
-export async function action({ request, params }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, companyId, userId } = await requirePermissions(request, {
- update: "settings",
- });
-
- const validation = await validator(resendFormValidator).validate(
- await request.formData()
- );
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- const { active, ...data } = validation.data;
-
- const update = await upsertIntegration(client, {
- id: "resend",
- active,
- metadata: {
- ...data,
- },
- companyId,
- updatedBy: userId,
- });
- if (update.error) {
- throw redirect(
- path.to.integrations,
- await flash(
- request,
- error(update.error, "Failed to update Resend integration")
- )
- );
- }
-
- throw redirect(
- path.to.integrations,
- await flash(request, success("Updated Resend integration"))
- );
-}
-
-export default function ResendIntegrationRoute() {
- const { integration } = useLoaderData<typeof loader>();
-
- const navigate = useNavigate();
-
- return (
- <ResendForm
- initialValues={integration}
- onClose={() => navigate(path.to.integrations)}
- />
- );
-}
diff --git a/apps/carbon/app/routes/x+/settings+/integrations.tsx b/apps/carbon/app/routes/x+/settings+/integrations.tsx
index 0d9cf84910..50b94362df 100644
--- a/apps/carbon/app/routes/x+/settings+/integrations.tsx
+++ b/apps/carbon/app/routes/x+/settings+/integrations.tsx
@@ -3,6 +3,7 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { Outlet, useLoaderData } from "@remix-run/react";
import { redirect, type LoaderFunctionArgs } from "@vercel/remix";
+import { integrations as availableIntegrations } from "~/integrations";
import { IntegrationsList, getIntegrations } from "~/modules/settings";
import { path } from "~/utils/path";
@@ -23,16 +24,21 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
return {
- integrations: integrations.data ?? [],
+ installedIntegrations: (integrations.data
+ .filter((i) => i.active)
+ .map((i) => i.id) ?? []) as string[],
};
}
export default function IntegrationsRoute() {
- const { integrations } = useLoaderData<typeof loader>();
+ const { installedIntegrations } = useLoaderData<typeof loader>();
return (
<>
- <IntegrationsList integrations={integrations} />
+ <IntegrationsList
+ installedIntegrations={installedIntegrations}
+ availableIntegrations={availableIntegrations}
+ />
<Outlet />
</>
);
diff --git a/apps/carbon/app/trigger/update-exchange-rates.ts b/apps/carbon/app/trigger/update-exchange-rates.ts
index 3fb869ae2d..fa413f1a59 100644
--- a/apps/carbon/app/trigger/update-exchange-rates.ts
+++ b/apps/carbon/app/trigger/update-exchange-rates.ts
@@ -1,7 +1,7 @@
import { EXCHANGE_RATES_API_KEY, getCarbonServiceRole } from "@carbon/auth";
import { schedules } from "@trigger.dev/sdk/v3";
-import type { Rates } from "~/lib/exchange-rates.server";
-import { getExchangeRatesClient } from "~/lib/exchange-rates.server";
+import type { Rates } from "~/integrations/exchange-rates/exchange-rates.server";
+import { getExchangeRatesClient } from "~/integrations/exchange-rates/exchange-rates.server";
import type { CurrencyCode } from "~/modules/accounting";
const serviceRole = getCarbonServiceRole();
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index 6eb0d86507..a48d99c1ae 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -354,8 +354,10 @@ export const path = {
groups: `${x}/users/groups`,
holiday: (id: string) => generatePath(`${x}/people/holidays/${id}`),
holidays: `${x}/people/holidays`,
- integration: (name: string) =>
- generatePath(`${x}/settings/integrations/${name}`),
+ integration: (id: string) =>
+ generatePath(`${x}/settings/integrations/${id}`),
+ integrationDeactivate: (id: string) =>
+ generatePath(`${x}/settings/integrations/deactivate/${id}`),
integrations: `${x}/settings/integrations`,
inventory: `${x}/inventory/quantities`,
inventoryItem: (id: string) =>
diff --git a/packages/database/supabase/migrations/20241006185904_integration-refactor.sql b/packages/database/supabase/migrations/20241006185904_integration-refactor.sql
new file mode 100644
index 0000000000..5e0b452744
--- /dev/null
+++ b/packages/database/supabase/migrations/20241006185904_integration-refactor.sql
@@ -0,0 +1,21 @@
+DROP VIEW IF EXISTS "integrations";
+
+ALTER TABLE "integration"
+ DROP COLUMN "title",
+ DROP COLUMN "description",
+ DROP COLUMN "logoPath",
+ DROP COLUMN "visible";
+
+
+CREATE OR REPLACE VIEW "integrations" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ i.*,
+ c.id AS "companyId",
+ coalesce(ci.metadata, '{}') AS "metadata",
+ coalesce(ci."active", FALSE) AS "active"
+ FROM "integration" i
+ CROSS JOIN "company" c
+ LEFT JOIN (
+ SELECT * FROM "companyIntegration"
+ ) ci
+ ON i.id = ci.id AND c.id = ci."companyId";
\ No newline at end of file