1- import {
2- _useCreateEntityPublic ,
3- _useDeleteEntityPublic ,
4- useHypergraphApp ,
5- useQuery ,
6- useSpace ,
7- } from '@graphprotocol/hypergraph-react' ;
1+ import { _useDeleteEntityPublic , useHypergraphApp , useQuery , useSpace } from '@graphprotocol/hypergraph-react' ;
82import { useState } from 'react' ;
93import { Event } from '../schema' ;
104import { Button } from './ui/button' ;
@@ -24,13 +18,11 @@ export const Playground = ({ spaceId }: { spaceId: string }) => {
2418 space : spaceId ,
2519 } ) ;
2620 const [ isDeleting , setIsDeleting ] = useState ( false ) ;
27- const [ isCreating , setIsCreating ] = useState ( false ) ;
2821 const { getSmartSessionClient } = useHypergraphApp ( ) ;
2922
3023 const { name } = useSpace ( { mode : 'public' , space : spaceId } ) ;
3124
3225 const deleteEntity = _useDeleteEntityPublic ( Event , { space : spaceId } ) ;
33- const createEntity = _useCreateEntityPublic ( Event , { space : spaceId } ) ;
3426
3527 console . log ( { isLoading, isError, data } ) ;
3628
@@ -39,29 +31,6 @@ export const Playground = ({ spaceId }: { spaceId: string }) => {
3931 < h2 className = "text-lg font-bold" > Space: { name } </ h2 >
4032 { isLoading && < div > Loading...</ div > }
4133 { isError && < div > Error</ div > }
42- < Button
43- disabled = { isCreating }
44- onClick = { async ( ) => {
45- setIsCreating ( true ) ;
46- const walletClient = await getSmartSessionClient ( ) ;
47- if ( ! walletClient ) {
48- alert ( 'Wallet client not found' ) ;
49- setIsCreating ( false ) ;
50- return ;
51- }
52- const { success, cid, txResult } = await createEntity (
53- {
54- name : 'Test Event 42 by Nik' ,
55- sponsors : [ ] ,
56- } ,
57- { walletClient } ,
58- ) ;
59- console . log ( 'created' , { success, cid, txResult } ) ;
60- setIsCreating ( false ) ;
61- } }
62- >
63- Create
64- </ Button >
6534 { data ?. map ( ( event ) => (
6635 < div key = { event . id } >
6736 < h2 > { event . name } </ h2 >
0 commit comments