Created
November 7, 2023 01:29
-
-
Save kmjones1979/0eaa3751a240c390d8d585d467aa8e44 to your computer and use it in GitHub Desktop.
Example index.ts with table format for Unchain readme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { NextPage } from "next"; | |
import { MetaHeader } from "~~/components/MetaHeader"; | |
import { gql } from "@apollo/client"; | |
import { useQuery } from "@apollo/client"; | |
import { Address } from "~~/components/scaffold-eth"; | |
export const GET_MESSAGES = gql` | |
{ | |
sendMessages(first: 5) { | |
id | |
_from | |
_to | |
message | |
} | |
} | |
`; | |
const Home: NextPage = () => { | |
const { loading, error, data: messagesData } = useQuery(GET_MESSAGES); | |
const messages = messagesData?.sendMessages || []; | |
return ( | |
<> | |
<MetaHeader /> | |
<h1>Messages</h1> | |
<table className="min-w-[70%]"> | |
<thead> | |
<tr> | |
<th>From</th> | |
<th>To</th> | |
<th>Message</th> | |
</tr> | |
</thead> | |
<tbody> | |
{messages.map((message) => ( | |
<tr key={message.id}> | |
<td><Address address={message._from}/></td> | |
<td><Address address={message._to}/></td> | |
<td>{message.message}</td> | |
</tr> | |
))} | |
</tbody> | |
</table> | |
</> | |
); | |
}; | |
export default Home; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment