Skip to content

Commit

Permalink
[PREVIEW] Dev system for blocked projects and block Metakeys copy-cat
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyd-eth committed Sep 14, 2023
1 parent 414f05a commit 247eee6
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/components/ProjectDashboard/ProjectDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Footer } from 'components/Footer'
import { TransactionProvider } from 'contexts/Transaction/TransactionProvider'
import { useHasNftRewards } from 'hooks/JB721Delegate/useHasNftRewards'
import { twMerge } from 'tailwind-merge'
import { BlockedProjectBanner } from './components/BlockedProjectBanner'
import { Cart } from './components/Cart'
import { CoverPhoto } from './components/CoverPhoto'
import { CurrentBalanceCard } from './components/CurrentBalanceCard'
Expand Down Expand Up @@ -34,6 +35,7 @@ export const ProjectDashboard = () => {
<CoverPhoto />
<div className="flex w-full justify-center md:px-6">
<div className="flex w-full max-w-6xl flex-col">
<BlockedProjectBanner />
<ProjectHeader className="mt-12 px-4 md:mt-4 md:px-0" />
<div
className={twMerge(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Trans } from '@lingui/macro'
import Banner from 'components/Banner'
import ExternalLink from 'components/ExternalLink'
import { useBlockedProject } from 'hooks/useBlockedProject'

export function BlockedProjectBanner() {
const isBlockedProject = useBlockedProject()
if (!isBlockedProject) return null

const delistingPolicyLink =
'https://github.com/peeldao/proposals/pull/42/files'
const discordLink = 'https://discord.gg/wFTh4QnDzk'

return (
<Banner
title={<Trans>Delisted project</Trans>}
body={
<Trans>
This project has been <strong>delisted</strong> for breaching our{' '}
<ExternalLink href={delistingPolicyLink}>policy</ExternalLink>.{' '}
<ExternalLink href={discordLink}>Get in touch</ExternalLink>.
</Trans>
}
variant="warning"
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Trans, t } from '@lingui/macro'
import { Button, Tooltip } from 'antd'
import { usePayProjectCard } from 'components/ProjectDashboard/hooks'
import { Formik } from 'formik'
import { useBlockedProject } from 'hooks/useBlockedProject'
import { V2V3CurrencyOption } from 'models/v2v3/currencyOption'
import { twMerge } from 'tailwind-merge'
import { V2V3_CURRENCY_ETH } from 'utils/v2v3/currency'
Expand All @@ -14,6 +15,8 @@ import { PayInput } from './components/PayInput'
import { TokensPerEth } from './components/TokensPerEth'

export const PayProjectCard = ({ className }: { className?: string }) => {
const isBlockedProject = useBlockedProject()

const { validationSchema, paymentsPaused, addPay } = usePayProjectCard()
const determiningIfProjectCanReceivePayments = paymentsPaused === undefined

Expand Down Expand Up @@ -74,7 +77,7 @@ export const PayProjectCard = ({ className }: { className?: string }) => {
>
<Button
loading={determiningIfProjectCanReceivePayments}
disabled={paymentsPaused}
disabled={paymentsPaused || isBlockedProject}
htmlType="submit"
className="h-12 text-base"
style={{ height: '48px' }}
Expand Down
4 changes: 4 additions & 0 deletions src/constants/blocklist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// List of delisted projects
export const BLOCKED_PROJECT_IDS = [
'564', //copycat of 563
]
11 changes: 11 additions & 0 deletions src/hooks/useBlockedProject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { BLOCKED_PROJECT_IDS } from 'constants/blocklist'
import { ProjectMetadataContext } from 'contexts/shared/ProjectMetadataContext'
import { useContext } from 'react'

export const useBlockedProject = () => {
const { projectId } = useContext(ProjectMetadataContext)
const isBlockedProject = projectId
? BLOCKED_PROJECT_IDS.includes(projectId?.toString())
: false
return isBlockedProject
}
13 changes: 11 additions & 2 deletions src/hooks/useProjects.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from 'axios'
import { BLOCKED_PROJECT_IDS } from 'constants/blocklist'
import { BigNumber } from 'ethers'
import { DBProject, DBProjectQueryOpts, DBProjectRow } from 'models/dbProject'
import { Json } from 'models/json'
Expand Down Expand Up @@ -68,7 +69,13 @@ export function useDBProjectsInfiniteQuery(
pageSize,
})}`,
)
.then(res => (res.data ? res.data.map(parseDBProject) : []))
.then(res =>
res.data
? res.data
.map(parseDBProject)
.filter(project => !BLOCKED_PROJECT_IDS.includes(project.id))
: [],
)
},
{
staleTime: DEFAULT_STALE_TIME,
Expand All @@ -93,7 +100,9 @@ export function useTrendingProjects(count: number) {
'/api/projects/trending?count=' + count,
)

return res.data.map(parseDBProjectJson)
return res.data
.map(parseDBProjectJson)
.filter(project => !BLOCKED_PROJECT_IDS.includes(project.id))
})
}

Expand Down
6 changes: 6 additions & 0 deletions src/locales/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,9 @@ msgstr ""
msgid "Custom strategy"
msgstr ""

msgid "Delisted project"
msgstr ""

msgid "If you use the default governance option (no governance), the voting weight will still be accessible on the blockchain for use in Snapshot strategies or any other desired purpose."
msgstr ""

Expand Down Expand Up @@ -3932,6 +3935,9 @@ msgstr ""
msgid "Duration"
msgstr ""

msgid "This project has been <0>delisted</0> for breaching our <1>policy</1>. <2>Get in touch</2>."
msgstr ""

msgid "Supporters will be sent to this page if they click the button on your pop-up. You can preview this below."
msgstr ""

Expand Down

0 comments on commit 247eee6

Please sign in to comment.