8000 hotfix: grants info and other post and reward stuff by sajald77 · Pull Request #1913 · geyserfund/geyser-app · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

hotfix: grants info and other post and reward stuff #1913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "geyser-app",
"private": true,
"version": "0.22.13",
"version": "0.22.14",
"type": "module",
"workspaces": [
"packages/*"
Expand Down
2 changes: 1 addition & 1 deletion src/modules/grants/components/GrantWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const GrantWidget = ({ grant, compact = false }: { grant: Grant; compact?: boole
console.log(GrantBalanceCurrency[grant.name])

const grantPool = isSatoshi
? `${getShortAmountLabel(grant.balance, false, true)} Sats`
? `${getShortAmountLabel(grant.balance, false, true)} sats`
: `$${getShortAmountLabel(centsToDollars(grant.balance), false, true)}`
const grantPoolSecondary = isSatoshi ? `(${formatUsdAmount(grant.balance)})` : `(${formatSatsAmount(grant.balance)})`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, IconButton, Link as ChakraLink } from '@chakra-ui/react'
import { useTranslation } from 'react-i18next'
import { PiArrowRight, PiBag, PiFlagBannerFold, PiNewspaper } from 'react-icons/pi'
import { PiArrowUpRight, PiBag, PiFlagBannerFold, PiNewspaper } from 'react-icons/pi'
import { Link } from 'react-router-dom'

import { useMobileMode } from '@/utils'
Expand Down Expand Up @@ -61,24 +61,24 @@ export const CreatorButtons = () => {
{isMobile ? (
<IconButton
aria-label="guide"
size={'lg'}
size={'md'}
as={ChakraLink}
href={GuideStepByStepUrl}
isExternal
variant="outline"
variant="ghost"
colorScheme="neutral1"
icon={<PiArrowRight />}
icon={<PiArrowUpRight />}
/>
) : (
<Button
size={'lg'}
size={'md'}
as={ChakraLink}
href={GuideStepByStepUrl}
isExternal
variant="outline"
variant="ghost"
colorScheme="neutral1"
rightIcon={<PiArrowRight />}
minWidth="120px"
paddingX={2}
rightIcon={<PiArrowUpRight />}
>
{t('Guides')}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { postTypeOptions } from '../../utils/postTypeLabel'
import { LinkedRewardsAndGoals } from './LinkedRewardsAndGoals'

export const PostView = () => {
const { project, isProjectOwner } = useProjectAtom()
const { project, isProjectOwner, loading: projectLoading } = useProjectAtom()
const { postId } = useParams<{ postId: string }>()
const [sourceResource, setSourceResource] = useAtom(sourceResourceAtom)
const navigate = useNavigate()
Expand Down Expand Up @@ -106,6 +106,7 @@ export const PostView = () => {
variant="ghost"
colorScheme="neutral1"
leftIcon={<PiArrowLeft />}
isDisabled={projectLoading}
>
{t('All posts')}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { ProjectRewardShippingEstimate, RewardEditMenu } from './components'
import { RewardShare } from './components/RewardShare'

export const RewardView = () => {
const { project, isProjectOwner } = useProjectAtom()
const { project, isProjectOwner, loading: projectLoading } = useProjectAtom()
const { rewardUUID } = useParams<{ rewardUUID: string }>()
const location = useLocation()
const isMobileMode = useMobileMode()
Expand Down Expand Up @@ -113,6 +113,7 @@ export const RewardView = () => {
variant="ghost"
colorScheme="neutral1"
leftIcon={<PiArrowLeft />}
isDisabled={projectLoading}
>
{t('All products')}
</Button>
Expand Down
83 changes: 54 additions & 29 deletions src/pages/grants/components/ContributionsWidget.tsx
67E6
Original file line number Diff line number Diff line change
@@ -1,36 +1,59 @@
import { Box, Text } from '@chakra-ui/react'
import { useTranslation } from 'react-i18next'
import { t } from 'i18next'
import { useMemo } from 'react'
import { LiaVoteYeaSolid } from 'react-icons/lia'

import { centsToDollars, getShortAmountLabel } from '@/utils/index.ts'

import { BadgeIcon, ContributionsIcon, TimerIcon } from '../../../components/icons'
import { Countdown } from '../../../components/ui/Countdown'
import { primaryColorsLight } from '../../../shared/styles'
import { DistributionSystem, Maybe, Sponsor, VotingSystem } from '../../../types'
import { Grant, VotingSystem } from '../../../types'
import {
GRANT_STATUS_COUNTDOWN_TITLES,
GRANT_STATUS_COUNTDOWN_TITLES_NON_VOTE,
GrantBalanceCurrency,
GrantHasVoting,
} from '../constants.ts'
import { SponsorList } from './SponsorList'
import { WidgetItem } from './WidgetItem'

interface Props {
sponsors?: Maybe<Sponsor>[]
balance?: string
contributions?: string
endDateSubtitle: string
endDateTimestamp: number
hasVoting?: boolean
distributionSystem: DistributionSystem
votingSystem: VotingSystem
grant: Grant
}

export const ContributionsWidget = ({
sponsors,
balance,
contributions,
endDateTimestamp,
endDateSubtitle,
hasVoting,
distributionSystem,
votingSystem,
}: Props) => {
const { t } = useTranslation()
export const ContributionsWidget = ({ grant }: Props) => {
const isSatoshi = !GrantBalanceCurrency[grant.name] || !(GrantBalanceCurrency[grant.name] === 'USDCENT')
console.log(GrantBalanceCurrency[grant.name])

const grantAmount = isSatoshi
? `${getShortAmountLabel(grant.balance, false, true)} sats`
: `$${getShortAmountLabel(centsToDollars(grant.balance), false, true)}`

const contributions = useMemo(() => {
if (grant?.__typename === 'CommunityVoteGrant' && grant.votingSystem === VotingSystem.OneToOne) {
return getShortAmountLabel(
grant.applicants.reduce((prev, curr) => prev + (curr?.funding.communityFunding || 0), 0) || 0,
true,
)
}

if (grant?.__typename === 'CommunityVoteGrant' && grant.votingSystem === VotingSystem.StepLog_10) {
return getShortAmountLabel(grant.votes?.voteCount || 0, true)
}
}, [grant])

const endDateTimestamp = useMemo(() => grant.statuses.find((s) => s.status === grant.status)?.endAt, [grant])

const hasVoting = GrantHasVoting[grant.name]

const endDateSubtitle = hasVoting
? t(GRANT_STATUS_COUNTDOWN_TITLES[grant.status])
: t(GRANT_STATUS_COUNTDOWN_TITLES_NON_VOTE[grant.status])

const votingSystem = grant?.__typename === 'CommunityVoteGrant' ? grant.votingSystem : VotingSystem.OneToOne

const isCommunityVoteGrant = grant?.__typename === 'CommunityVoteGrant'

return (
<Box borderRadius="8px" backgroundColor="neutral.100" pb={4} pt={2} my={4}>
Expand All @@ -39,7 +62,7 @@ export const ContributionsWidget = ({
flexWrap="wrap"
alignItems="center"
gap={10}
justifyContent={distributionSystem === DistributionSystem.None ? 'center' : 'space-around'}
justifyContent={!isCommunityVoteGrant ? 'center' : 'space-around'}
>
<Box
px={2}
Expand All @@ -66,12 +89,14 @@ export const ContributionsWidget = ({
/>
</WidgetItem>
</Box>
{distributionSystem !== DistributionSystem.None && (
<Box px={2} display="flex" alignItems="start" my={2}>
<BadgeIcon mt={1} mr={2} width="36px" height="100%" color="primary.500" />
<WidgetItem subtitle={t('Grant amount')}>{balance}</WidgetItem>
</Box>
)}

<Box px={2} display="flex" alignItems="start" my={2}>
<BadgeIcon mt={1} mr={2} width="36px" height="100%" color="primary.500" />
<WidgetItem isSatLogo={false} subtitle={t('Grant amount')}>
{grantAmount}
</WidgetItem>
</Box>

{hasVoting && (
<Box px={2} display="flex" alignItems="start" my={2}>
{votingSystem === VotingSystem.OneToOne ? (
Expand All @@ -91,7 +116,7 @@ export const ContributionsWidget = ({
)}
</Box>
<Box mt={{ base: 1, lg: 4 }} display="flex" alignItems="center" justifyContent="center">
<SponsorList sponsors={sponsors}>
<SponsorList sponsors={grant.sponsors}>
<Text fontSize="18px">{t('Sponsored by')}</Text>
</SponsorList>
</Box>
Expand Down
41 changes: 3 additions & 38 deletions src/pages/grants/grantsPage/sections/GrantSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@ import { StatusLabel } from '../../../../components/ui/StatusLabel'
import { Tooltip } from '../../../../components/ui/Tooltip'
import { VideoPlayer } from '../../../../shared/molecules/VideoPlayer'
import { DistributionSystem, Grant, GrantType, VotingSystem } from '../../../../types'
import { getShortAmountLabel, useMobileMode } from '../../../../utils'
import { useMobileMode } from '../../../../utils'
import { ContributionsWidget } from '../../components/ContributionsWidget'
import {
GRANT_STATUS_COUNTDOWN_TITLES,
GRANT_STATUS_COUNTDOWN_TITLES_NON_VOTE,
GRANT_STATUS_MAP,
GrantHasVoting,
} from '../../constants'
import { GRANT_STATUS_MAP } from '../../constants'

const CUSTOM_VIDEO_URL = 'https://youtu.be/xemVDGbQwHs'

Expand All @@ -41,8 +36,6 @@ export const GrantSummary = ({ grant, grantHasVoting }: { grant: Grant; grantHas
const { t } = useTranslation()
const isMobile = useMobileMode()

const votingEndDate = grant.statuses.find((s) => s.status === grant.status)?.endAt

const renderImageOrVideo = () => {
if (grant.name === 'grant-round-008') {
return <VideoPlayer url={CUSTOM_VIDEO_URL} />
Expand Down Expand Up @@ -138,19 +131,6 @@ export const GrantSummary = ({ grant, grantHasVoting }: { grant: Grant; grantHas
}
}

const contributions = () => {
if (grant?.__typename === 'CommunityVoteGrant' && grant.votingSystem === VotingSystem.OneToOne) {
return getShortAmountLabel(
grant.applicants.reduce((prev, curr) => prev + (curr?.funding.communityFunding || 0), 0) || 0,
true,
)
}

if (grant?.__typename === 'CommunityVoteGrant' && grant.votingSystem === VotingSystem.StepLog_10) {
return getShortAmountLabel(grant.votes?.voteCount || 0, true)
}
}

return (
<CardLayout noborder={isMobile} padding={{ base: 0, lg: 0 }}>
{renderImageOrVideo()}
Expand Down Expand Up @@ -188,22 +168,7 @@ export const GrantSummary = ({ grant, grantHasVoting }: { grant: Grant; grantHas
</Tooltip>
)}
</Box>
<ContributionsWidget
sponsors={grant.sponsors}
endDateSubtitle={
grantHasVoting
? t(GRANT_STATUS_COUNTDOWN_TITLES[grant.status])
: t(GRANT_STATUS_COUNTDOWN_TITLES_NON_VOTE[grant.status])
}
endDateTimestamp={votingEndDate}
balance={getShortAmountLabel(grant.balance || 0, true)}
hasVoting={GrantHasVoting[grant.name]}
contributions={contributions()}
distributionSystem={
grant?.__typename === 'CommunityVoteGrant' ? grant.distributionSystem : DistributionSystem.None
}
votingSystem={grant?.__typename === 'CommunityVoteGrant' ? grant.votingSystem : VotingSystem.OneToOne}
/>
<ContributionsWidget grant={grant} />
</Box>
</Box>
</CardLayout>
Expand Down
Loading
0