From 8943a3587a184921ee6954071143f458f02af743 Mon Sep 17 00:00:00 2001 From: nicktytarenko Date: Sat, 12 Sep 2026 22:51:08 +0300 Subject: [PATCH] Show RFP funding amount on activity feed cards --- .../Activity/lib/activityDisplay.utils.ts | 3 ++- components/Activity/lib/activityWork.utils.ts | 23 +++++++++++++------ components/Feed/items/FeedItemGrant.tsx | 6 ++--- types/feed.ts | 2 ++ types/work.ts | 3 ++- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/components/Activity/lib/activityDisplay.utils.ts b/components/Activity/lib/activityDisplay.utils.ts index 6f53ea2cc..ef1a92c02 100644 --- a/components/Activity/lib/activityDisplay.utils.ts +++ b/components/Activity/lib/activityDisplay.utils.ts @@ -1,5 +1,6 @@ import { buildWorkUrl } from '@/utils/url'; import { isFoundationUser } from '@/components/Bounty/lib/bountyUtil'; +import { getGrantBadgeAmount } from '@/types/grant'; import type { CurrencyAmount } from '@/utils/currency'; import type { FeedCommentContent, @@ -367,7 +368,7 @@ export function getGrantAmount(entry: FeedEntry): ActivityGrantAmount | undefine if (entry.contentType !== 'GRANT') return undefined; const grant = (entry.content as FeedGrantContent).grant; if (!grant?.amount) return undefined; - return { usd: grant.amount.usd, rsc: grant.amount.rsc }; + return getGrantBadgeAmount(grant); } export interface ActivityCommentPreview { diff --git a/components/Activity/lib/activityWork.utils.ts b/components/Activity/lib/activityWork.utils.ts index c82e3fa80..e50641864 100644 --- a/components/Activity/lib/activityWork.utils.ts +++ b/components/Activity/lib/activityWork.utils.ts @@ -7,6 +7,7 @@ import { } from './activityDisplay.utils'; import { formatCurrency } from '@/utils/currency'; import { toOptionalNumber } from '@/utils/number'; +import { getGrantBadgeAmount } from '@/types/grant'; import type { ActivityAction, FeedBountyContent, @@ -104,7 +105,7 @@ function resolveWorkTab(entry: FeedEntry, workContentType?: ContentType): Activi function resolveActivityBodySlot( activityAction?: ActivityAction, - work?: Pick, + work?: Pick, options?: { isReview?: boolean } ): ActivityBodySlot { if (activityAction === 'bounty_opened' || activityAction === 'bounty_contributed') { @@ -113,6 +114,9 @@ function resolveActivityBodySlot( if (activityAction === 'grant_opened') { return work?.grant ? 'grant' : 'default'; } + if (work?.grant && work.documentType === 'funding_request') { + return 'grant'; + } if ( activityAction === 'tip_review' || activityAction === 'bounty_payout' || @@ -230,17 +234,21 @@ function presentGrant( exchangeRate: number ): WorkCardPresentation { const stats: WorkCardStat[] = []; + const badge = getGrantBadgeAmount({ + amount: { usd: grant.amount.usd, rsc: grant.amount.rsc ?? 0 }, + fundingPool: grant.fundingPool, + }); let budgetAmount: number | null = null; let skipConversion = showUSD; if (showUSD) { - if (grant.amount.usd > 0) { - budgetAmount = grant.amount.usd; + if (badge.usd > 0) { + budgetAmount = badge.usd; } - } else if (grant.amount.rsc != null && grant.amount.rsc > 0) { - budgetAmount = grant.amount.rsc; - } else if (grant.amount.usd > 0 && exchangeRate > 0) { - budgetAmount = grant.amount.usd / exchangeRate; + } else if (badge.rsc > 0) { + budgetAmount = badge.rsc; + } else if (badge.usd > 0 && exchangeRate > 0) { + budgetAmount = badge.usd / exchangeRate; skipConversion = true; } @@ -312,6 +320,7 @@ function grantSummaryFromFeedGrant(content: FeedGrantContent): WorkGrantSummary status: grant.status, organization: grant.organization, amount: { usd: grant.amount.usd, rsc: grant.amount.rsc ?? null }, + fundingPool: grant.fundingPool ?? null, numApplicants: grant.applicants?.length ?? 0, endDate: grant.endDate, }; diff --git a/components/Feed/items/FeedItemGrant.tsx b/components/Feed/items/FeedItemGrant.tsx index 052986bc1..58810ebe8 100644 --- a/components/Feed/items/FeedItemGrant.tsx +++ b/components/Feed/items/FeedItemGrant.tsx @@ -18,6 +18,7 @@ import { useCurrencyPreference } from '@/contexts/CurrencyPreferenceContext'; import { useExchangeRate } from '@/contexts/ExchangeRateContext'; import { formatCurrency } from '@/utils/currency'; import { isDeadlineInFuture } from '@/utils/date'; +import { getGrantBadgeAmount } from '@/types/grant'; interface FeedItemGrantProps { entry: FeedEntry; @@ -74,9 +75,8 @@ export const FeedItemGrant: FC = ({ authorId: profile.id || undefined, })) || []; - const budgetAmount = showUSD - ? Math.round(grant.grant?.amount?.usd || 0) - : Math.round(grant.grant?.amount?.rsc || 0); + const badgeAmount = grant.grant ? getGrantBadgeAmount(grant.grant) : { usd: 0, rsc: 0 }; + const budgetAmount = showUSD ? Math.round(badgeAmount.usd) : Math.round(badgeAmount.rsc); return (