"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"; 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("j5pGbn7MHZ"); 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(); setOverviewLoading(false); 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 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700" : "block rounded-lg px-4 py-2 text-sm font-medium text-gray-500 hover:bg-black hover:text-white" } > Overview
  • Metrics
    • { setScreen(1); setMobileMenu(false); }} className={ screen === 1 ? "block rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700" : "block rounded-lg px-4 py-2 text-sm font-medium text-gray-500 hover:bg-black hover:text-white" } > Community
    • { setScreen(2); setMobileMenu(false); }} className={ screen === 2 ? "block rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700" : "block rounded-lg px-4 py-2 text-sm font-medium text-gray-500 hover:bg-black hover:text-white" } > Network
  • Growth
    • { setScreen(3); setMobileMenu(false); }} className={ screen === 3 ? "block rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700" : "block rounded-lg px-4 py-2 text-sm font-medium text-gray-500 hover:bg-black hover:text-white" } > Timeline
    • { setScreen(4); setMobileMenu(false); }} className={ screen === 4 ? "block rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700" : "block rounded-lg px-4 py-2 text-sm font-medium text-gray-500 hover:bg-black hover:text-white" } > Ecosystem
  • { setScreen(5); setMobileMenu(false); }} className={ screen === 5 ? "block rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700" : "block rounded-lg px-4 py-2 text-sm font-medium text-gray-500 hover:bg-black hover:text-white" } > Benchmarks
{ session === false ? handleSignIn() : handleSignOut(); }} className="flex space-x-3 items-center gap-2 bg-[#000000] p-4 hover:bg-gray-50 rounded-lg" >
{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 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700" : "block rounded-lg px-4 py-2 text-sm font-medium text-gray-500 hover:bg-black hover:text-white" } > Overview
  • Metrics
    • setScreen(1)} className={ screen === 1 ? "block rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700" : "block rounded-lg px-4 py-2 text-sm font-medium text-gray-500 hover:bg-black hover:text-white" } > Community
    • setScreen(2)} className={ screen === 2 ? "block rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700" : "block rounded-lg px-4 py-2 text-sm font-medium text-gray-500 hover:bg-black hover:text-white" } > Network
  • Growth
    • setScreen(3)} className={ screen === 3 ? "block rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700" : "block rounded-lg px-4 py-2 text-sm font-medium text-gray-500 hover:bg-black hover:text-white" } > Timeline
    • setScreen(4)} className={ screen === 4 ? "block rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700" : "block rounded-lg px-4 py-2 text-sm font-medium text-gray-500 hover:bg-black hover:text-white" } > Ecosystem
  • setScreen(5)} className={ screen === 5 ? "block rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700" : "block rounded-lg px-4 py-2 text-sm font-medium text-gray-500 hover:bg-black hover:text-white" } > Benchmarks
{ session === false ? handleSignIn() : handleSignOut(); }} className="flex space-x-3 items-center gap-2 bg-[#000000] p-4 hover:bg-gray-50 rounded-lg" >
{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 && )}
); }