"use client"; // import React from "react"; import { useState } from "react"; import Benchmarks from "./Benchmarks"; import CommunityMetrics from "./CommunityMetrics"; import Ecosystem from "./Ecosystem"; import NetworkMetrics from "./NetworkMetrics"; import Overview from "./Overview"; import Timeline from "./Timeline"; import { useEffect } from "react"; import Npm from "@/utils/npm"; import Discord from "@/utils/discord"; import Github from "@/utils/github"; import Twitter from "@/utils/twitter"; import Rust from "@/utils/rust_package"; import Docker from "@/utils/docker"; import { createClientComponentClient } from "@supabase/auth-helpers-nextjs"; import { useRouter } from "next/navigation"; // Logos Design System imports import { ThemeProvider, defaultThemes } from '@acid-info/lsd-react' export default function Router() { const [mobileMenu, setMobileMenu] = useState(false); const [screen, setScreen] = useState(0); const [session, setSession] = useState(false); const [stats, setStats] = useState({}); const [isLoading, setIsLoading] = useState(true); const [overviewLoading, setOverviewLoading] = useState(true); const [isLoggedIn, setIsLoggedIn] = useState(false); const [saves, setSaves] = useState({}); const supabase = createClientComponentClient(); supabase.auth.onAuthStateChange((event, session) => { if (event === "SIGNED_OUT") { setSession(false); } }); useEffect(() => { (async () => { if (isLoading) { const { data: { session }, } = await supabase.auth.getSession(); if (!session) { setSession(false); } else { setSession(session); setIsLoggedIn(true); } const discord = await Discord.getServerMembers("gMPAzmcDER"); const github = await Github.getOrganizationFollowers("waku-org"); const repos = [ "nwaku", "js-waku", "go-waku", "waku-react-native", "js-waku-examples", "waku-rust-bindings", ]; const github_repos = await Github.getReposStats("waku-org", repos); // const twitter = await Twitter.getFollowers(); const twitter = 2; setOverviewLoading(false); console.log("loading...") setStats({ twitter, discord, github, github_repos, }); await (async () => { const npm = await Npm.getDownloadsLastWeek("@waku/core"); // console.log(Golang.getDownloads("waku-org/go-waku@v0.5.2/waku")); const rust = await Rust.getDownloads("waku-bindings"); const docker = await Docker.getPulls(); const data = await supabase .from("saves") .select() .order("created_at", { ascending: false }); setSaves(data.data); setStats({ ...stats, npm, discord, github, github_repos, rust, twitter, docker, }); setIsLoading(false); })(); } })(); }, []); const router = useRouter(); const handleSignIn = async () => { await supabase.auth.signInWithOAuth({ provider: "google", options: { queryParams: { access_type: "offline", prompt: "consent", }, }, }); }; const handleSignOut = async () => { await supabase.auth.signOut(); router.push("/"); }; return (
{mobileMenu === true ? (
  • { setScreen(0); setMobileMenu(false); }} className={ screen === 0 ? "block border-l-4 px-4 py-2 text-sm font-medium text-white" : "block rounded-lg px-4 py-2 text-sm font-medium text-white opacity-70" } > Overview
  • Metrics
    • { setScreen(1); setMobileMenu(false); }} className={ screen === 1 ? "block border-l-4 px-4 py-2 text-sm font-medium text-white" : "block rounded-lg px-4 py-2 text-sm font-medium text-white opacity-70" } > Community
    • { setScreen(2); setMobileMenu(false); }} className={ screen === 2 ? "block border-l-4 px-4 py-2 text-sm font-medium text-white" : "block rounded-lg px-4 py-2 text-sm font-medium text-white opacity-70" } > Network
  • Growth
    • { setScreen(3); setMobileMenu(false); }} className={ screen === 3 ? "block border-l-4 px-4 py-2 text-sm font-medium text-white" : "block rounded-lg px-4 py-2 text-sm font-medium text-white opacity-70" } > Timeline
    • { setScreen(4); setMobileMenu(false); }} className={ screen === 4 ? "block border-l-4 px-4 py-2 text-sm font-medium text-white" : "block rounded-lg px-4 py-2 text-sm font-medium text-white opacity-70" } > Ecosystem
  • { setScreen(5); setMobileMenu(false); }} className={ screen === 5 ? "block border-l-4 px-4 py-2 text-sm font-medium text-white" : "block rounded-lg px-4 py-2 text-sm font-medium text-white opacity-70" } > Benchmarks
{ session === false ? handleSignIn() : handleSignOut(); }} className="flex space-x-3 items-center gap-2 bg-[#ffffff] text-black p-3" >
{session && session?.user?.user_metadata?.avatar_url ? ( ) : ( )}

{session === false ? "Login as core contributor" : "Sign Out"}

) : (
{(screen === 0 && ( )) || (screen === 1 && ( )) || (screen === 2 && ) || (screen === 3 && ( )) || (screen === 4 && ) || (screen === 5 && )}
)}
  • setScreen(0)} className={ screen === 0 ? "block border-l-4 px-4 py-2 text-sm font-medium text-white" : "block rounded-lg px-4 py-2 text-sm font-medium text-white opacity-70" } > Overview
  • Metrics
    • setScreen(1)} className={ screen === 1 ? "block border-l-4 px-4 py-2 text-sm font-medium text-white" : "block rounded-lg px-4 py-2 text-sm font-medium text-white opacity-70" } > Community
    • setScreen(2)} className={ screen === 2 ? "block border-l-4 px-4 py-2 text-sm font-medium text-white" : "block rounded-lg px-4 py-2 text-sm font-medium text-white opacity-70" } > Network
  • Growth
    • setScreen(3)} className={ screen === 3 ? "block border-l-4 px-4 py-2 text-sm font-medium text-white" : "block rounded-lg px-4 py-2 text-sm font-medium text-white opacity-70" } > Timeline
    • setScreen(4)} className={ screen === 4 ? "block border-l-4 px-4 py-2 text-sm font-medium text-white" : "block rounded-lg px-4 py-2 text-sm font-medium text-white opacity-70" } > Ecosystem
  • setScreen(5)} className={ screen === 5 ? "block border-l-4 px-4 py-2 text-sm font-medium text-white" : "block rounded-lg px-4 py-2 text-sm font-medium text-white opacity-70" } > Benchmarks
{ session === false ? handleSignIn() : handleSignOut(); }} className="flex space-x-3 items-center gap-2 bg-[#000000] p-4 hover:bg-gray-50 hover:text-black" >
{session && session?.user?.user_metadata?.avatar_url ? ( ) : ( )}

{session === false ? "Login as core contributor" : "Sign Out"}

{(screen === 0 && ( )) || (screen === 1 && ( )) || (screen === 2 && ) || (screen === 3 && ( )) || (screen === 4 && ) || (screen === 5 && )}
); }