import React, { useState } from "react";
import { ConnectModal } from "@databite/connect";
export default function Page() {
const [open, setOpen] = useState(false);
return (
<>
<button onClick={() => setOpen(true)}>Connect to Service</button>
<ConnectModal
open={open}
onOpenChange={setOpen}
integrationId="your-integration-id"
baseUrl={process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001"}
onAuthSuccess={async (integration, connectionConfig) => {
await fetch("/api/save-connection", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
integrationId: integration.id,
connectionConfig,
}),
});
}}
onAuthError={(e) => console.error(e)}
/>
</>
);
}