diff --git a/src/components/chat/DyadAddIntegration.tsx b/src/components/chat/DyadAddIntegration.tsx new file mode 100644 index 0000000..4674828 --- /dev/null +++ b/src/components/chat/DyadAddIntegration.tsx @@ -0,0 +1,73 @@ +import React from "react"; +import { useNavigate } from "@tanstack/react-router"; +import { Button } from "@/components/ui/button"; +import { selectedAppIdAtom } from "@/atoms/appAtoms"; +import { useAtomValue, atom, useAtom } from "jotai"; +import { showError } from "@/lib/toast"; +import { useStreamChat } from "@/hooks/useStreamChat"; +import { selectedChatIdAtom } from "@/atoms/chatAtoms"; + +interface DyadAddIntegrationProps { + node: { + properties: { + provider: string; + }; + }; + children: React.ReactNode; +} + +const isSetupAtom = atom(false); + +export const DyadAddIntegration: React.FC = ({ + node, + children, +}) => { + const { streamMessage } = useStreamChat(); + const [isSetup, setIsSetup] = useAtom(isSetupAtom); + const navigate = useNavigate(); + const { provider } = node.properties; + const appId = useAtomValue(selectedAppIdAtom); + const selectedChatId = useAtomValue(selectedChatIdAtom); + + const handleSetupClick = () => { + if (!appId) { + showError("No app ID found"); + return; + } + navigate({ to: "/app-details", search: { appId } }); + setIsSetup(true); + }; + + if (isSetup) { + return ( + + ); + } + + return ( +
+
+
Integrate with {provider}?
+
{children}
+
+ +
+ ); +}; diff --git a/src/components/chat/DyadMarkdownParser.tsx b/src/components/chat/DyadMarkdownParser.tsx index ab21d97..e7b515e 100644 --- a/src/components/chat/DyadMarkdownParser.tsx +++ b/src/components/chat/DyadMarkdownParser.tsx @@ -6,6 +6,7 @@ import { DyadRename } from "./DyadRename"; import { DyadDelete } from "./DyadDelete"; import { DyadAddDependency } from "./DyadAddDependency"; import { DyadExecuteSql } from "./DyadExecuteSql"; +import { DyadAddIntegration } from "./DyadAddIntegration"; import { CodeHighlight } from "./CodeHighlight"; import { useAtomValue } from "jotai"; import { isStreamingAtom } from "@/atoms/chatAtoms"; @@ -75,6 +76,7 @@ function preprocessUnclosedTags(content: string): { "dyad-delete", "dyad-add-dependency", "dyad-execute-sql", + "dyad-add-integration", ]; let processedContent = content; @@ -134,6 +136,7 @@ function parseCustomTags(content: string): ContentPiece[] { "dyad-delete", "dyad-add-dependency", "dyad-execute-sql", + "dyad-add-integration", ]; const tagPattern = new RegExp( @@ -287,6 +290,19 @@ function renderCustomTag( ); + case "dyad-add-integration": + return ( + + {content} + + ); + default: return null; } diff --git a/src/pages/app-details.tsx b/src/pages/app-details.tsx index 6d778cd..8f6c388 100644 --- a/src/pages/app-details.tsx +++ b/src/pages/app-details.tsx @@ -1,4 +1,4 @@ -import { useNavigate, useSearch } from "@tanstack/react-router"; +import { useNavigate, useRouter, useSearch } from "@tanstack/react-router"; import { useAtom, useAtomValue } from "jotai"; import { appBasePathAtom, appsListAtom } from "@/atoms/appAtoms"; import { IpcClient } from "@/ipc/ipc_client"; @@ -32,6 +32,7 @@ import { SupabaseConnector } from "@/components/SupabaseConnector"; export default function AppDetailsPage() { const navigate = useNavigate(); + const router = useRouter(); const search = useSearch({ from: "/app-details" as const }); const [appsList] = useAtom(appsListAtom); const { refreshApps } = useLoadApps(); @@ -142,7 +143,7 @@ export default function AppDetailsPage() { return (