Add connection state and helpers

cgen-f722e28e219742c8b445108a4e02400d
This commit is contained in:
Builder.io 2025-09-30 08:32:17 +00:00
parent c403336816
commit e896438f46

View file

@ -83,6 +83,43 @@ export default function Dashboard() {
});
const [userPosts, setUserPosts] = useState<any[]>([]);
const [applications, setApplications] = useState<any[]>([]);
const [connectionAction, setConnectionAction] = useState<string | null>(null);
type ProviderKey = "google" | "github";
const linkedProviderSet = useMemo(
() => new Set(linkedProviders.map((item) => item.provider)),
[linkedProviders],
);
const linkedProviderMap = useMemo(() => {
const map: Record<string, (typeof linkedProviders)[number]> = {};
linkedProviders.forEach((lp) => {
map[lp.provider] = lp;
});
return map;
}, [linkedProviders]);
const oauthConnections = useMemo(
() =>
[
{
provider: "google" as ProviderKey,
name: "Google",
description: "Link your Google account for one-click access.",
Icon: Globe,
gradient: "from-red-500 to-yellow-500",
},
{
provider: "github" as ProviderKey,
name: "GitHub",
description: "Connect your GitHub account to sync contributions.",
Icon: Github,
gradient: "from-gray-600 to-gray-900",
},
] as const,
[],
);
useEffect(() => {
console.log("Dashboard useEffect:", {