diff --git a/.changeset/lazy-birds-wait.md b/.changeset/lazy-birds-wait.md new file mode 100644 index 00000000..48fd9890 --- /dev/null +++ b/.changeset/lazy-birds-wait.md @@ -0,0 +1,6 @@ +--- +"create-hypergraph": patch +--- + +improve geo connect box based on authentication state in all templates + \ No newline at end of file diff --git a/apps/template-nextjs/app/page.tsx b/apps/template-nextjs/app/page.tsx index f274e546..0490ee16 100644 --- a/apps/template-nextjs/app/page.tsx +++ b/apps/template-nextjs/app/page.tsx @@ -1,10 +1,26 @@ +'use client'; + +import { useHypergraphApp, useHypergraphAuth } from '@graphprotocol/hypergraph-react'; import Image from 'next/image'; import Link from 'next/link'; -import { LoginButton } from '@/Components/Login/LoginButton'; import { Button } from '@/Components/ui/button'; export default function HomePage() { + const { redirectToConnect } = useHypergraphApp(); + const { authenticated } = useHypergraphAuth(); + + const handleSignIn = () => { + redirectToConnect({ + storage: localStorage, + connectUrl: 'https://connect.geobrowser.io/', + successUrl: `${window.location.origin}/authenticate-success`, + redirectFn: (url: URL) => { + window.location.href = url.toString(); + }, + }); + }; + return (
@@ -25,6 +41,7 @@ export default function HomePage() { fill="none" stroke="currentColor" viewBox="0 0 24 24" + aria-hidden="true" >
- {/* Section 2: Sign in with Geo Connect */} + {/* Section 2: Conditional content based on authentication */}
@@ -55,6 +72,7 @@ export default function HomePage() { fill="none" stroke="currentColor" viewBox="0 0 24 24" + aria-hidden="true" >
-

Manage Your Data

-

- Sign in with Geo Connect to manage your private data and publish it to the public Knowledge Graph. -

- + {authenticated ? ( + <> +

Go to Geo Connect

+

+ Go to Geo Connect to manage your private data and publish it to the public Knowledge Graph. +

+ + + ) : ( + <> +

Manage Your Data

+

+ Sign in with Geo Connect to manage your private data and publish it to the public Knowledge Graph. +

+ + + )}
@@ -81,6 +115,7 @@ export default function HomePage() { fill="none" stroke="currentColor" viewBox="0 0 24 24" + aria-hidden="true" > { redirectToConnect({ @@ -40,6 +41,7 @@ function Index() { fill="none" stroke="currentColor" viewBox="0 0 24 24" + aria-hidden="true" >
- {/* Section 2: Sign in with Geo Connect */} + {/* Section 2: Conditional content based on authentication */}
@@ -70,6 +72,7 @@ function Index() { fill="none" stroke="currentColor" viewBox="0 0 24 24" + aria-hidden="true" >
-

Manage Your Data

-

- Sign in with Geo Connect to manage your private data and publish it to the public Knowledge Graph. -

- + {authenticated ? ( + <> +

Go to Geo Connect

+

+ Go to Geo Connect to manage your private data and publish it to the public Knowledge Graph. +

+ + + ) : ( + <> +

Manage Your Data

+

+ Sign in with Geo Connect to manage your private data and publish it to the public Knowledge Graph. +

+ + + )}
@@ -98,6 +115,7 @@ function Index() { fill="none" stroke="currentColor" viewBox="0 0 24 24" + aria-hidden="true" >