mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-11 09:18:26 +00:00
* Fix: integration account webhooks * Fix: activity webhook * Feat: add integration credentials API * Fix: user rules for integrations * Feat: make self hosting simple * Fix: add init container functionality --------- Co-authored-by: Manoj K <saimanoj58@gmail.com>
70 lines
2.2 KiB
TypeScript
70 lines
2.2 KiB
TypeScript
import { useState, useEffect } from "react";
|
|
import { type LoaderFunctionArgs } from "@remix-run/server-runtime";
|
|
import { requireUserId } from "~/services/session.server";
|
|
import { useTypedLoaderData } from "remix-typedjson";
|
|
|
|
import { GraphVisualizationClient } from "~/components/graph/graph-client";
|
|
import { LoaderCircle } from "lucide-react";
|
|
import { PageHeader } from "~/components/common/page-header";
|
|
|
|
export async function loader({ request }: LoaderFunctionArgs) {
|
|
// Only return userId, not the heavy nodeLinks
|
|
const userId = await requireUserId(request);
|
|
return { userId };
|
|
}
|
|
|
|
export default function Dashboard() {
|
|
const { userId } = useTypedLoaderData<typeof loader>();
|
|
|
|
// State for nodeLinks and loading
|
|
const [nodeLinks, setNodeLinks] = useState<any[] | null>(null);
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
let cancelled = false;
|
|
async function fetchNodeLinks() {
|
|
setLoading(true);
|
|
try {
|
|
const res = await fetch(
|
|
"/node-links?userId=" +
|
|
encodeURIComponent("cmc0x85jv0000nu1wiu1yla73"),
|
|
);
|
|
if (!res.ok) throw new Error("Failed to fetch node links");
|
|
const data = await res.json();
|
|
if (!cancelled) {
|
|
setNodeLinks(data);
|
|
setLoading(false);
|
|
}
|
|
} catch (e) {
|
|
if (!cancelled) {
|
|
setNodeLinks([]);
|
|
setLoading(false);
|
|
}
|
|
}
|
|
}
|
|
fetchNodeLinks();
|
|
return () => {
|
|
cancelled = true;
|
|
};
|
|
}, [userId]);
|
|
|
|
return (
|
|
<>
|
|
<PageHeader title="Memory graph" />
|
|
<div className="home flex h-[calc(100vh_-_56px)] flex-col overflow-y-auto p-3 text-base">
|
|
<div className="flex grow items-center justify-center rounded">
|
|
{loading ? (
|
|
<div className="flex h-full w-full flex-col items-center justify-center">
|
|
<LoaderCircle size={18} className="mr-1 animate-spin" />
|
|
<span className="text-muted-foreground">Loading graph...</span>
|
|
</div>
|
|
) : (
|
|
typeof window !== "undefined" &&
|
|
nodeLinks && <GraphVisualizationClient triplets={nodeLinks} />
|
|
)}
|
|
</div>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|