-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from HausDAO/update-metadata
Update GitHub Actions workflow for Next.js project
- Loading branch information
Showing
10 changed files
with
206 additions
and
159 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
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 |
---|---|---|
|
@@ -46,4 +46,6 @@ Brewfile.lock.json | |
.eslintcache | ||
|
||
# IDE configs | ||
.idea/ | ||
.idea/ | ||
|
||
.next/cache/ |
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
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
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,65 @@ | ||
import { GraphQLClient } from "graphql-request"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
|
||
import { DaoItem, DaoProfile, RecordItem } from "@/lib/types"; | ||
import { getGraphUrl } from "@/lib/endpoints"; | ||
import { FIND_DAO } from "@/lib/graph-queries"; | ||
import { useDaoHooksConfig } from "@/providers/DaoHooksProvider"; | ||
|
||
export const addParsedContent = <T>(record?: RecordItem): T | undefined => { | ||
if (record?.contentType === "json") { | ||
try { | ||
const obj = JSON.parse(record.content); | ||
return obj; | ||
} catch (e) { | ||
console.log("err", e); | ||
return; | ||
} | ||
} | ||
}; | ||
|
||
export const useDao = ({ | ||
chainid, | ||
daoid, | ||
}: { | ||
chainid?: string; | ||
daoid?: string; | ||
}) => { | ||
const { config } = useDaoHooksConfig(); | ||
|
||
if (!config || !config.graphKey) { | ||
throw new Error("DaoHooksContext must be used within a DaoHooksProvider"); | ||
} | ||
|
||
const dhUrl = getGraphUrl({ | ||
chainid: chainid || "", | ||
graphKey: config.graphKey, | ||
subgraphKey: "DAOHAUS", | ||
}); | ||
|
||
const graphQLClient = new GraphQLClient(dhUrl); | ||
|
||
const { data, ...rest } = useQuery({ | ||
queryKey: [`get-dao-${chainid}-${daoid}`, { chainid, daoid }], | ||
queryFn: async (): Promise<{ | ||
dao: DaoItem; | ||
}> => { | ||
const daores = (await graphQLClient.request(FIND_DAO, { | ||
daoid, | ||
})) as { | ||
dao: DaoItem; | ||
}; | ||
const profile = addParsedContent<DaoProfile>(daores.dao.rawProfile[0]); | ||
|
||
return { | ||
dao: { ...daores.dao, profile }, | ||
}; | ||
}, | ||
enabled: !!daoid && !!chainid, | ||
}); | ||
|
||
return { | ||
dao: data?.dao, | ||
...rest, | ||
}; | ||
}; |
Oops, something went wrong.