Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
8 changes: 6 additions & 2 deletions components/Notification/NotificationItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
formatNotificationMessage,
getHubDetailsFromNotification,
formatNavigationUrl,
getBountyForYouUsdOverride,
getRSCAmountFromNotification,
} from './lib/formatNotification';
import { Avatar } from '@/components/ui/Avatar';
Expand Down Expand Up @@ -32,6 +33,7 @@
const formattedNavigationUrl = formatNavigationUrl(notification);
const hasNavigationUrl = !!formattedNavigationUrl && formattedNavigationUrl.trim() !== '';
const rscAmount = getRSCAmountFromNotification(notification);
const bountyUsdOverride = getBountyForYouUsdOverride(notification);

const hubDetails = getHubDetailsFromNotification(notification);

Expand Down Expand Up @@ -83,10 +85,12 @@
<TopicAndJournalBadge name={hubDetails.name} slug={hubDetails.slug} size="sm" />
</div>
)}
{rscAmount && (
{(rscAmount || bountyUsdOverride !== null) && (
<div className="inline-block">
<CurrencyBadge
amount={rscAmount}
amount={bountyUsdOverride ?? rscAmount ?? 0}
currency={bountyUsdOverride !== null ? 'USD' : 'RSC'}

Check warning on line 92 in components/Notification/NotificationItem.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unexpected negated condition.

See more on https://sonarcloud.io/project/issues?id=ResearchHub_web&issues=AZ1my3l-Kxecox-xnU2R&open=AZ1my3l-Kxecox-xnU2R&pullRequest=749
skipConversion={bountyUsdOverride !== null}
size="xs"
variant={isReceivedRSC ? 'received' : 'badge'}
showText
Expand Down
20 changes: 19 additions & 1 deletion components/Notification/lib/formatNotification.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type IconName } from '@/components/ui/icons/Icon';
import { FOUNDATION_BOUNTY_FLAT_USD } from '@/config/constants';
import { Notification } from '@/types/notification';
import { formatUsdValue, formatRSC } from '@/utils/number';

Expand Down Expand Up @@ -189,6 +190,21 @@
return null;
}

const isPeerReviewBountyNotification = (notification: Notification): boolean => {
return (
notification.type === 'BOUNTY_FOR_YOU' &&
notification.extra?.bounty_type?.toUpperCase() === 'REVIEW'
);
};
Comment thread
jeevan6996 marked this conversation as resolved.

export function getBountyForYouUsdOverride(notification: Notification): number | null {
if (isPeerReviewBountyNotification(notification)) {
return FOUNDATION_BOUNTY_FLAT_USD;
}

return null;
}

/**
* Transform ResearchHub URLs to relative paths and convert #comments to /conversation
* Examples:
Expand Down Expand Up @@ -303,7 +319,9 @@
const amount = notification.extra?.amount || '0';
const bountyType = notification.extra?.bounty_type || '';
const bountyTypeAction = getBountyTypeAction(bountyType);
const usdValue = formatUsdValue(amount, exchangeRate);
const usdAmount = getBountyForYouUsdOverride(notification);
const usdValue =
usdAmount !== null ? `$${usdAmount.toLocaleString()} USD` : formatUsdValue(amount, exchangeRate);

Check warning on line 324 in components/Notification/lib/formatNotification.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unexpected negated condition.

See more on https://sonarcloud.io/project/issues?id=ResearchHub_web&issues=AZ1my3gWKxecox-xnU2Q&open=AZ1my3gWKxecox-xnU2Q&pullRequest=749
return `Your expertise is needed! Earn ${usdValue} for ${bountyTypeAction} "${truncatedTitle}"`;
}

Expand Down