Skip to content

Commit

Permalink
Merge pull request #373 from jordanlesich/dashboard
Browse files Browse the repository at this point in the history
Dashboard
  • Loading branch information
jordanlesich authored Oct 9, 2023
2 parents 137d653 + 97799f2 commit b2cc4bf
Show file tree
Hide file tree
Showing 32 changed files with 1,426 additions and 51 deletions.
8 changes: 5 additions & 3 deletions apps/web/src/components/ContractButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useBridgeModal } from 'src/hooks/useBridgeModal'
import { useChainStore } from 'src/stores/useChainStore'

interface ContractButtonProps extends ButtonProps {
handleClick: () => void
handleClick: (e?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void
}

export const ContractButton = ({
Expand All @@ -28,11 +28,13 @@ export const ContractButton = ({

const handleSwitchNetwork = () => switchNetwork?.(appChain.id)

const handleClickWithValidation = () => {
const handleClickWithValidation = (
e?: React.MouseEvent<HTMLButtonElement, MouseEvent>
) => {
if (!userAddress) return openConnectModal?.()
if (canUserBridge && userBalance?.decimals === 0) return openBridgeModal()
if (userChain?.id !== appChain.id) return handleSwitchNetwork()
handleClick()
handleClick(e)
}

return (
Expand Down
File renamed without changes.
22 changes: 17 additions & 5 deletions apps/web/src/components/Home/RecentlyCreated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,31 @@ import { homeSectionHeader, homeSectionWrapper } from 'src/styles/home.css'

const RecentlyCreated: React.FC<{
children: ReactNode
}> = ({ children }) => {
isDashboard?: boolean
}> = ({ children, isDashboard }) => {
const chain = useChainStore((x) => x.chain)
return (
<Stack
w={'100%'}
mx={'auto'}
mb={isDashboard ? 'x16' : 'auto'}
justify={'flex-start'}
mt={{ '@initial': 'x16', '@768': 'x32' }}
mt={
isDashboard
? { '@initial': 'x12', '@768': 'x24' }
: { '@initial': 'x16', '@768': 'x32' }
}
className={homeSectionWrapper}
>
<Text fontWeight={'label'} className={homeSectionHeader}>
Recent DAOs on <span style={{ textDecoration: 'underline' }}>{chain.name}</span>
</Text>
{isDashboard ? (
<Text fontSize={28} fontWeight={'display'} mb={'x6'}>
Explore
</Text>
) : (
<Text fontWeight={'label'} className={homeSectionHeader}>
Recent DAOs on <span style={{ textDecoration: 'underline' }}>{chain.name}</span>
</Text>
)}
{children}
<Flex align={'center'} justify={'center'} mt={'x6'}>
<Link href={'/explore'} passHref legacyBehavior>
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/Icon/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './Icon'
export * from './icons'
1 change: 1 addition & 0 deletions apps/web/src/constants/swrKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const SWR_KEYS = {
DAO_FEED: 'dao-feed',
MEMBERS: 'members',
TOKEN_IMAGE: 'token-image',
DASHBOARD: 'dashboard',
DYNAMIC: {
MY_DAOS(str: string) {
return `my-daos-${str}`
Expand Down
12 changes: 12 additions & 0 deletions apps/web/src/data/subgraph/fragments/CurrentAuction.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
fragment CurrentAuction on Auction {
endTime
highestBid {
amount
bidder
}
token {
name
image
tokenId
}
}
27 changes: 27 additions & 0 deletions apps/web/src/data/subgraph/queries/dashboardQuery.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
query dashboard($where: DAOTokenOwner_filter, $first: Int, $skip: Int) {
daotokenOwners(where: $where, first: $first, skip: $skip) {
dao {
...DAO
contractImage
auctionConfig {
minimumBidIncrement
reservePrice
}
proposals(
where: { executed_not: true, canceled_not: true, vetoed_not: true }
first: 10
skip: 0
orderBy: proposalNumber
orderDirection: desc
) {
...Proposal
voteEnd
voteStart
expiresAt
}
currentAuction {
...CurrentAuction
}
}
}
}
22 changes: 6 additions & 16 deletions apps/web/src/data/subgraph/requests/daoQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ export type MyDaosResponse = Array<{
chainId: CHAIN_ID
}>

const DAOS_TO_EXCLUDE = [
'0x9c8ff314c9bc7f6e59a9d9225fb22946427edc03',
'0x4b10701bfd7bfedc47d50562b76b436fbb5bdb3b',
]

export const myDaosRequest = async (
memberAddress: string
): Promise<MyDaosResponse | undefined> => {
Expand All @@ -39,17 +34,12 @@ export const myDaosRequest = async (

return data
.map((queries) =>
queries.daotokenOwners
.map((x) => {
return x.dao
})
.filter((dao) => !DAOS_TO_EXCLUDE.includes(dao.tokenAddress))
.map((dao) => ({
name: dao.name || '',
collectionAddress: dao.tokenAddress,
auctionAddress: dao?.auctionAddress || '',
chainId: queries.chainId,
}))
queries.daotokenOwners.map(({ dao }) => ({
name: dao.name || '',
collectionAddress: dao.tokenAddress,
auctionAddress: dao?.auctionAddress || '',
chainId: queries.chainId,
}))
)
.flat()
.sort((a, b) => a.name.localeCompare(b.name))
Expand Down
42 changes: 42 additions & 0 deletions apps/web/src/data/subgraph/requests/dashboardQuery.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import * as Sentry from '@sentry/nextjs'

import { PUBLIC_DEFAULT_CHAINS } from 'src/constants/defaultChains'
import { SDK } from 'src/data/subgraph/client'

export const dashboardRequest = async (memberAddress: string) => {
try {
if (!memberAddress) throw new Error('No user address provided')
const data = await Promise.all(
PUBLIC_DEFAULT_CHAINS.map((chain) =>
SDK.connect(chain.id)
.dashboard({
where: {
owner: memberAddress.toLowerCase(),
},
first: 30,
})
.then((x) => ({ ...x, chainId: chain.id }))
)
)

return data
.map((queries) =>
queries.daotokenOwners.map(({ dao }) => ({
...dao,
name: dao.name || '',
tokenAddress: dao.tokenAddress,
auctionAddress: dao?.auctionAddress || '',
proposals: dao.proposals,
currentAuction: dao.currentAuction,
chainId: queries.chainId,
daoImage: dao.contractImage,
}))
)
.flat()
.sort((a, b) => a.name.localeCompare(b.name))
} catch (e: any) {
console.error(e)
Sentry.captureException(e)
await Sentry.flush(2000)
}
}
125 changes: 124 additions & 1 deletion apps/web/src/data/subgraph/sdk.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1855,6 +1855,13 @@ export type AuctionBidFragment = {
bidder: any
}

export type CurrentAuctionFragment = {
__typename?: 'Auction'
endTime: any
highestBid?: { __typename?: 'AuctionBid'; amount: any; bidder: any } | null
token: { __typename?: 'Token'; name: string; image: string; tokenId: any }
}

export type DaoFragment = {
__typename?: 'DAO'
name: string
Expand Down Expand Up @@ -2041,6 +2048,62 @@ export type DaoTokenOwnersQuery = {
}>
}

export type DashboardQueryVariables = Exact<{
where?: InputMaybe<DaoTokenOwner_Filter>
first?: InputMaybe<Scalars['Int']>
skip?: InputMaybe<Scalars['Int']>
}>

export type DashboardQuery = {
__typename?: 'Query'
daotokenOwners: Array<{
__typename?: 'DAOTokenOwner'
dao: {
__typename?: 'DAO'
contractImage: string
name: string
tokenAddress: any
auctionAddress: any
auctionConfig: {
__typename?: 'AuctionConfig'
minimumBidIncrement: any
reservePrice: any
}
proposals: Array<{
__typename?: 'Proposal'
voteEnd: any
voteStart: any
expiresAt?: any | null
abstainVotes: number
againstVotes: number
calldatas?: string | null
description?: string | null
descriptionHash: any
executableFrom?: any | null
forVotes: number
proposalId: any
proposalNumber: number
proposalThreshold: any
proposer: any
quorumVotes: any
targets: Array<any>
timeCreated: any
title?: string | null
values: Array<any>
snapshotBlockNumber: any
transactionHash: any
dao: { __typename?: 'DAO'; governorAddress: any; tokenAddress: any }
}>
currentAuction?: {
__typename?: 'Auction'
endTime: any
highestBid?: { __typename?: 'AuctionBid'; amount: any; bidder: any } | null
token: { __typename?: 'Token'; name: string; image: string; tokenId: any }
} | null
}
}>
}

export type ExploreDaosPageQueryVariables = Exact<{
orderBy?: InputMaybe<Auction_OrderBy>
orderDirection?: InputMaybe<OrderDirection>
Expand Down Expand Up @@ -2286,6 +2349,20 @@ export const AuctionBidFragmentDoc = gql`
bidder
}
`
export const CurrentAuctionFragmentDoc = gql`
fragment CurrentAuction on Auction {
endTime
highestBid {
amount
bidder
}
token {
name
image
tokenId
}
}
`
export const DaoFragmentDoc = gql`
fragment DAO on DAO {
name
Expand Down Expand Up @@ -2363,7 +2440,7 @@ export const TokenFragmentDoc = gql`
`
export const ActiveAuctionsDocument = gql`
query activeAuctions($first: Int!, $where: Auction_filter!) {
auctions(orderBy: endTime, orderDirection: asc, first: $first, where: $where) {
auctions(orderBy: endTime, orderDirection: desc, first: $first, where: $where) {
...Auction
}
}
Expand Down Expand Up @@ -2470,6 +2547,38 @@ export const DaoTokenOwnersDocument = gql`
}
${DaoFragmentDoc}
`
export const DashboardDocument = gql`
query dashboard($where: DAOTokenOwner_filter, $first: Int, $skip: Int) {
daotokenOwners(where: $where, first: $first, skip: $skip) {
dao {
...DAO
contractImage
auctionConfig {
minimumBidIncrement
reservePrice
}
proposals(
where: { executed_not: true, canceled_not: true, vetoed_not: true }
first: 10
skip: 0
orderBy: proposalNumber
orderDirection: desc
) {
...Proposal
voteEnd
voteStart
expiresAt
}
currentAuction {
...CurrentAuction
}
}
}
}
${DaoFragmentDoc}
${ProposalFragmentDoc}
${CurrentAuctionFragmentDoc}
`
export const ExploreDaosPageDocument = gql`
query exploreDaosPage(
$orderBy: Auction_orderBy
Expand Down Expand Up @@ -2727,6 +2836,20 @@ export function getSdk(
'query'
)
},
dashboard(
variables?: DashboardQueryVariables,
requestHeaders?: Dom.RequestInit['headers']
): Promise<DashboardQuery> {
return withWrapper(
(wrappedRequestHeaders) =>
client.request<DashboardQuery>(DashboardDocument, variables, {
...requestHeaders,
...wrappedRequestHeaders,
}),
'dashboard',
'query'
)
},
exploreDaosPage(
variables?: ExploreDaosPageQueryVariables,
requestHeaders?: Dom.RequestInit['headers']
Expand Down
3 changes: 3 additions & 0 deletions apps/web/src/layouts/DefaultLayout/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export const Nav = () => {
<Link href={'/about'}>
<Label className={navMenuItem}>About</Label>
</Link>
<Link href={'/dashboard'}>
<Label className={navMenuItem}>Dashboard</Label>
</Link>
<Link href={'/explore'}>
<Label className={navMenuItem}>Explore</Label>
</Link>
Expand Down
7 changes: 7 additions & 0 deletions apps/web/src/layouts/DefaultLayout/NavMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,13 @@ export const NavMenu = () => {
</Text>
</Flex>
</Link>
<Link href={'/dashboard'}>
<Flex display="flex" align="center" justify={'center'} py={'x2'}>
<Text cursor={'pointer'} fontWeight={'display'}>
Dashboard
</Text>
</Flex>
</Link>
<Link href={'/explore'}>
<Flex display="flex" align="center" justify={'center'} py={'x2'}>
<Text cursor={'pointer'} fontWeight={'display'}>
Expand Down
Loading

1 comment on commit b2cc4bf

@vercel
Copy link

@vercel vercel bot commented on b2cc4bf Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

testnet-nouns-builder – ./apps/web

testnet-nouns-builder-nouns-builder.vercel.app
testnet-nouns-builder-git-main-nouns-builder.vercel.app
testnet.nouns.build

Please sign in to comment.