11import { Button } from '@/components/ui/button' ;
2- import { Address } from '@/schema' ;
2+ import { Project } from '@/schema' ;
33import {
44 HypergraphSpaceProvider ,
55 useCreateEntity ,
6+ usePublishToPublicSpace ,
67 useQuery ,
78 useSpace ,
89 useSpaces ,
9- usePublishToPublicSpace ,
1010} from '@graphprotocol/hypergraph-react' ;
1111import { createFileRoute } from '@tanstack/react-router' ;
1212import { useState } from 'react' ;
@@ -27,14 +27,15 @@ function RouteComponent() {
2727
2828function PrivateSpace ( ) {
2929 const { name, ready } = useSpace ( { mode : 'private' } ) ;
30- const { data : addresses } = useQuery ( Address , { mode : 'private' } ) ;
30+ const { data : projects } = useQuery ( Project , { mode : 'private' } ) ;
3131 const { data : publicSpaces } = useSpaces ( { mode : 'public' } ) ;
3232 const [ selectedSpace , setSelectedSpace ] = useState < string > ( '' ) ;
33- const createAddress = useCreateEntity ( Address ) ;
34- const [ addressName , setAddressName ] = useState ( '' ) ;
33+ const createProject = useCreateEntity ( Project ) ;
34+ const [ projectName , setProjectName ] = useState ( '' ) ;
35+ const [ projectDescription , setProjectDescription ] = useState ( '' ) ;
3536 const { mutate : publishToPublicSpace , isPending } = usePublishToPublicSpace ( {
36- onSuccess : ( ) => alert ( 'Address published to public space' ) ,
37- onError : ( ) => alert ( 'Error publishing address to public space' ) ,
37+ onSuccess : ( ) => alert ( 'Project published to your public space' ) ,
38+ onError : ( ) => alert ( 'Error publishing project to your public space' ) ,
3839 } ) ;
3940
4041 if ( ! ready ) {
@@ -50,8 +51,9 @@ function PrivateSpace() {
5051
5152 const handleSubmit = ( e : React . FormEvent < HTMLFormElement > ) => {
5253 e . preventDefault ( ) ;
53- createAddress ( { name : addressName , description : 'Beautiful address' } ) ;
54- setAddressName ( '' ) ;
54+ createProject ( { name : projectName , description : projectDescription } ) ;
55+ setProjectName ( '' ) ;
56+ setProjectDescription ( '' ) ;
5557 } ;
5658
5759 return (
@@ -60,52 +62,70 @@ function PrivateSpace() {
6062 { /* Header */ }
6163 < div className = "mb-8" >
6264 < h1 className = "text-3xl font-bold text-foreground mb-2" > { name } </ h1 >
63- < p className = "text-muted-foreground" > Manage your private addresses and publish them to public spaces</ p >
65+ < p className = "text-muted-foreground" > Manage your private projects and publish them to public spaces</ p >
6466 </ div >
6567
6668 < div className = "grid gap-8 lg:grid-cols-2" >
67- { /* Create Address Form */ }
69+ { /* Create Project Form */ }
6870 < div className = "space-y-6" >
6971 < div className = "bg-card border rounded-lg p-6 shadow-sm" >
70- < h2 className = "text-xl font-semibold text-card-foreground mb-4" > Create New Address </ h2 >
72+ < h2 className = "text-xl font-semibold text-card-foreground mb-4" > Create New Project </ h2 >
7173 < form onSubmit = { handleSubmit } className = "space-y-4" >
7274 < div className = "space-y-2" >
73- < label htmlFor = "address -name" className = "text-sm font-medium text-card-foreground" >
74- Address Name
75+ < label htmlFor = "project -name" className = "text-sm font-medium text-card-foreground" >
76+ Project Name
7577 </ label >
7678 < input
77- id = "address -name"
79+ id = "project -name"
7880 type = "text"
79- value = { addressName }
80- onChange = { ( e ) => setAddressName ( e . target . value ) }
81- placeholder = "Enter address name..."
81+ value = { projectName }
82+ onChange = { ( e ) => setProjectName ( e . target . value ) }
83+ placeholder = "Enter project name..."
8284 className = "w-full px-3 py-2 border border-input bg-background rounded-md text-sm transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"
8385 required
8486 />
8587 </ div >
86- < Button type = "submit" className = "w-full" disabled = { ! addressName . trim ( ) } >
87- Create Address
88+ < div className = "space-y-2" >
89+ < label htmlFor = "project-description" className = "text-sm font-medium text-card-foreground" >
90+ Project Description
91+ </ label >
92+ < input
93+ id = "project-description"
94+ type = "text"
95+ value = { projectDescription }
96+ onChange = { ( e ) => setProjectDescription ( e . target . value ) }
97+ placeholder = "Enter project description..."
98+ className = "w-full px-3 py-2 border border-input bg-background rounded-md text-sm transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"
99+ />
100+ </ div >
101+ < Button type = "submit" className = "w-full" disabled = { ! projectName . trim ( ) } >
102+ Create Project
88103 </ Button >
89104 </ form >
90105 </ div >
91106 </ div >
92107
93- { /* Addresses List */ }
108+ { /* Projects List */ }
94109 < div className = "space-y-6" >
95110 < div className = "bg-card border rounded-lg p-6 shadow-sm" >
96111 < h2 className = "text-xl font-semibold text-card-foreground mb-4" >
97- Your Addresses ({ addresses ?. length || 0 } )
112+ Your Projects ({ projects ?. length || 0 } )
98113 </ h2 >
99114
100- { addresses && addresses . length > 0 ? (
115+ { projects && projects . length > 0 ? (
101116 < div className = "space-y-4" >
102- { addresses . map ( ( address ) => (
103- < div key = { address . id } className = "border border-border rounded-lg p-4 bg-background" >
117+ { projects . map ( ( project ) => (
118+ < div key = { project . id } className = "border border-border rounded-lg p-4 bg-background" >
119+ < div className = "flex items-center justify-between mb-3" >
120+ < h3 className = "font-medium text-foreground" > { project . name } </ h3 >
121+ </ div >
122+
123+ < div className = "flex items-center justify-between mb-3" >
124+ < p className = "text-xs text-muted-foreground" > ID: { project . id } </ p >
125+ </ div >
126+
104127 < div className = "flex items-center justify-between mb-3" >
105- < h3 className = "font-medium text-foreground" > { address . name } </ h3 >
106- < span className = "text-xs text-muted-foreground bg-muted px-2 py-1 rounded" >
107- ID: { address . id . slice ( 0 , 8 ) } ...
108- </ span >
128+ < p className = "text-sm text-muted-foreground" > { project . description } </ p >
109129 </ div >
110130
111131 < div className = "space-y-3" >
@@ -129,7 +149,7 @@ function PrivateSpace() {
129149 </ div >
130150
131151 < Button
132- onClick = { ( ) => publishToPublicSpace ( { entity : address , spaceId : selectedSpace } ) }
152+ onClick = { ( ) => publishToPublicSpace ( { entity : project , spaceId : selectedSpace } ) }
133153 disabled = { ! selectedSpace || isPending }
134154 variant = "outline"
135155 size = "sm"
@@ -158,8 +178,8 @@ function PrivateSpace() {
158178 />
159179 </ svg >
160180 </ div >
161- < p className = "text-muted-foreground" > No addresses created yet</ p >
162- < p className = "text-sm text-muted-foreground mt-1" > Create your first address using the form</ p >
181+ < p className = "text-muted-foreground" > No projects created yet</ p >
182+ < p className = "text-sm text-muted-foreground mt-1" > Create your first project using the form</ p >
163183 </ div >
164184 ) }
165185 </ div >
0 commit comments