diff --git a/apps/web/app/(app)/connect/page.tsx b/apps/web/app/(app)/connect/page.tsx new file mode 100644 index 000000000..ff9692504 --- /dev/null +++ b/apps/web/app/(app)/connect/page.tsx @@ -0,0 +1,250 @@ +"use client" + +import { dmSans125ClassName } from "@/lib/fonts" +import { OAUTH_PLUGINS } from "@/lib/oauth-plugins" +import { cn } from "@lib/utils" +import { Building2, ExternalLink, LoaderIcon, Plug, Trash2 } from "lucide-react" +import Image from "next/image" +import { useCallback, useEffect, useState } from "react" + +const API_URL = + process.env.NEXT_PUBLIC_BACKEND_URL ?? "https://api.supermemory.ai" + +interface Connection { + clientId: string + name: string + icon: string | null + isFirstParty: boolean + workspaceId: string | null + workspaceName: string | null + scopes: string[] + connectedAt: string | null + lastUsedAt: string | null +} + +function relativeTime(iso: string | null): string | null { + if (!iso) return null + const then = new Date(iso).getTime() + if (Number.isNaN(then)) return null + const diff = Date.now() - then + const mins = Math.round(diff / 60000) + if (mins < 1) return "just now" + if (mins < 60) return `${mins}m ago` + const hrs = Math.round(mins / 60) + if (hrs < 24) return `${hrs}h ago` + const days = Math.round(hrs / 24) + if (days < 30) return `${days}d ago` + const months = Math.round(days / 30) + if (months < 12) return `${months}mo ago` + return `${Math.round(months / 12)}y ago` +} + +const cardClass = cn( + "rounded-[14px] bg-[#14161A] p-5", + "shadow-[inset_2.42px_2.42px_4.263px_rgba(11,15,21,0.7)]", +) + +function PluginIcon({ src, alt }: { src: string | null; alt: string }) { + const [failed, setFailed] = useState(false) + if (!src || failed) { + return ( +
+ Apps and plugins you've connected to your Supermemory account. +
+ +No apps connected yet
++ Connect a plugin below — anything you authorize will show up here. +
++ {c.name} +
+ {!c.isFirstParty && ( + + external + + )} +{error}
} ++ {p.name} +
+ {isConnected && ( + + Connected + + )} ++ {p.description} +
+ + Setup guide +- {session.user.email} -
- {canSwitchOrg ? ( -- {activeOrgName} -
- ) : null} -+ {session.user.email} +
)}- An application wants to connect to your Supermemory account. + {appLabel} wants to connect to your Supermemory account.
{error}
}
App ID · {shortClientId(clientId)}