1+ 'use client' ;
2+
3+ import { useHypergraphApp , useHypergraphAuth } from '@graphprotocol/hypergraph-react' ;
14import Image from 'next/image' ;
25import Link from 'next/link' ;
36
4- import { LoginButton } from '@/Components/Login/LoginButton' ;
57import { Button } from '@/Components/ui/button' ;
68
79export default function HomePage ( ) {
10+ const { redirectToConnect } = useHypergraphApp ( ) ;
11+ const { authenticated } = useHypergraphAuth ( ) ;
12+
13+ const handleSignIn = ( ) => {
14+ redirectToConnect ( {
15+ storage : localStorage ,
16+ connectUrl : 'https://connect.geobrowser.io/' ,
17+ successUrl : `${ window . location . origin } /authenticate-success` ,
18+ redirectFn : ( url : URL ) => {
19+ window . location . href = url . toString ( ) ;
20+ } ,
21+ } ) ;
22+ } ;
23+
824 return (
925 < div className = "container mx-auto px-4 py-8" >
1026 < div className = "text-center mb-12" >
@@ -25,6 +41,7 @@ export default function HomePage() {
2541 fill = "none"
2642 stroke = "currentColor"
2743 viewBox = "0 0 24 24"
44+ aria-hidden = "true"
2845 >
2946 < path
3047 strokeLinecap = "round"
@@ -46,7 +63,7 @@ export default function HomePage() {
4663 </ div >
4764 </ div >
4865
49- { /* Section 2: Sign in with Geo Connect */ }
66+ { /* Section 2: Conditional content based on authentication */ }
5067 < div className = "bg-white dark:bg-gray-800 rounded-lg p-6 shadow-lg border border-gray-200 dark:border-gray-700" >
5168 < div className = "text-center" >
5269 < div className = "w-12 h-12 bg-gray-100 dark:bg-gray-800 rounded-lg flex items-center justify-center mx-auto mb-4" >
@@ -55,6 +72,7 @@ export default function HomePage() {
5572 fill = "none"
5673 stroke = "currentColor"
5774 viewBox = "0 0 24 24"
75+ aria-hidden = "true"
5876 >
5977 < path
6078 strokeLinecap = "round"
@@ -64,11 +82,27 @@ export default function HomePage() {
6482 />
6583 </ svg >
6684 </ div >
67- < h3 className = "text-xl font-semibold mb-3" > Manage Your Data</ h3 >
68- < p className = "text-gray-600 dark:text-gray-300 mb-4" >
69- Sign in with Geo Connect to manage your private data and publish it to the public Knowledge Graph.
70- </ p >
71- < LoginButton />
85+ { authenticated ? (
86+ < >
87+ < h3 className = "text-xl font-semibold mb-3" > Go to Geo Connect</ h3 >
88+ < p className = "text-gray-600 dark:text-gray-300 mb-4" >
89+ Go to Geo Connect to manage your private data and publish it to the public Knowledge Graph.
90+ </ p >
91+ < Button onClick = { handleSignIn } className = "w-full bg-primary hover:bg-primary/90" >
92+ Go to Geo Connect
93+ </ Button >
94+ </ >
95+ ) : (
96+ < >
97+ < h3 className = "text-xl font-semibold mb-3" > Manage Your Data</ h3 >
98+ < p className = "text-gray-600 dark:text-gray-300 mb-4" >
99+ Sign in with Geo Connect to manage your private data and publish it to the public Knowledge Graph.
100+ </ p >
101+ < Button onClick = { handleSignIn } className = "w-full bg-primary hover:bg-primary/90" >
102+ Sign in with Geo Connect
103+ </ Button >
104+ </ >
105+ ) }
72106 </ div >
73107 </ div >
74108
@@ -81,6 +115,7 @@ export default function HomePage() {
81115 fill = "none"
82116 stroke = "currentColor"
83117 viewBox = "0 0 24 24"
118+ aria-hidden = "true"
84119 >
85120 < path
86121 strokeLinecap = "round"
0 commit comments