generated from scaffold-eth/scaffold-eth-2
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/ETHPrague-BRX/think2earn
- Loading branch information
Showing
80 changed files
with
3,082 additions
and
104 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,8 @@ node_modules | |
|
||
# cli | ||
dist | ||
|
||
# subgraph | ||
subgraph/build/* | ||
subgraph/generated/* | ||
subgraph/graph-node/data/* |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,8 @@ | |
"workspaces": { | ||
"packages": [ | ||
"packages/hardhat", | ||
"packages/nextjs" | ||
"packages/nextjs", | ||
"packages/subgraph" | ||
] | ||
}, | ||
"scripts": { | ||
|
@@ -33,7 +34,15 @@ | |
"postinstall": "husky install", | ||
"precommit": "lint-staged", | ||
"vercel": "yarn workspace @se-2/nextjs vercel", | ||
"vercel:yolo": "yarn workspace @se-2/nextjs vercel:yolo" | ||
"vercel:yolo": "yarn workspace @se-2/nextjs vercel:yolo", | ||
"subgraph:test": "yarn workspace @se-2/subgraph test", | ||
"stop-node": "yarn workspace @se-2/subgraph stop-node", | ||
"clean-node": "yarn workspace @se-2/subgraph clean-node", | ||
"run-node": "yarn workspace @se-2/subgraph run-node", | ||
"local-create": "yarn workspace @se-2/subgraph local-create", | ||
"local-ship": "yarn workspace @se-2/subgraph local-ship", | ||
"abi-copy": "yarn workspace @se-2/subgraph abi-copy", | ||
"codegen": "yarn workspace @se-2/subgraph codegen" | ||
}, | ||
"packageManager": "[email protected]", | ||
"devDependencies": { | ||
|
This file contains 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
This file contains 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
61 changes: 61 additions & 0 deletions
61
packages/nextjs/app/subgraph/_components/GreetingsTable.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
"use client"; | ||
|
||
import { gql, useQuery } from "@apollo/client"; | ||
import { Address } from "~~/components/scaffold-eth"; | ||
|
||
const GreetingsTable = () => { | ||
const GREETINGS_GRAPHQL = ` | ||
{ | ||
greetings(first: 25, orderBy: createdAt, orderDirection: desc) { | ||
id | ||
greeting | ||
premium | ||
value | ||
createdAt | ||
sender { | ||
address | ||
greetingCount | ||
} | ||
} | ||
} | ||
`; | ||
|
||
const GREETINGS_GQL = gql(GREETINGS_GRAPHQL); | ||
const { data: greetingsData, error } = useQuery(GREETINGS_GQL, { fetchPolicy: "network-only" }); | ||
|
||
// Subgraph maybe not yet configured | ||
if (error) { | ||
return <></>; | ||
} | ||
|
||
return ( | ||
<div className="flex justify-center items-center mt-10"> | ||
<div className="overflow-x-auto shadow-2xl rounded-xl"> | ||
<table className="table bg-base-100 table-zebra"> | ||
<thead> | ||
<tr className="rounded-xl"> | ||
<th className="bg-primary"></th> | ||
<th className="bg-primary">Sender</th> | ||
<th className="bg-primary">Greetings</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{greetingsData?.greetings?.map((greeting: any, index: number) => { | ||
return ( | ||
<tr key={greeting.id}> | ||
<th>{index + 1}</th> | ||
<td> | ||
<Address address={greeting?.sender?.address} /> | ||
</td> | ||
<td>{greeting.greeting}</td> | ||
</tr> | ||
); | ||
})} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default GreetingsTable; |
Oops, something went wrong.