Skip to content
Merged
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
27 changes: 26 additions & 1 deletion components/Notification/lib/formatNotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@
useAvatar: false,
title: 'Funding payout',
},
FUNDRAISE_CONTRIBUTION: {
icon: 'fund',
useAvatar: true,
title: 'New contribution',
},
RSC_SUPPORT_ON_DIS: {
icon: 'fund',
useAvatar: true,
Expand Down Expand Up @@ -262,7 +267,11 @@
}

export function getRSCAmountForBadge(notification: Notification, message: string): number | null {
if (notification.type === 'FUNDING_CREDITS_REMINDER') {
// Contribution copy already includes its amount in the original currency (USD or RSC).
if (
notification.type === 'FUNDING_CREDITS_REMINDER' ||
notification.type === 'FUNDRAISE_CONTRIBUTION'
) {
return null;
}

Expand Down Expand Up @@ -406,7 +415,7 @@
const userName = actionUser ? actionUser.fullName : 'A user';
const truncatedTitle = truncateText(stripHtml(work?.title || 'an item'), 60);

switch (type) {

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

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Reduce the number of non-empty switch cases from 31 to at most 30.

See more on https://sonarcloud.io/project/issues?id=ResearchHub_web&issues=AaDZPyM4iAbtN7wD1_5z&open=AaDZPyM4iAbtN7wD1_5z&pullRequest=1130
// Financial notifications
case 'RSC_WITHDRAWAL_COMPLETE':
return 'Your RSC withdrawal has been completed';
Expand Down Expand Up @@ -475,6 +484,22 @@
return `${userName} supported your work "${truncatedTitle}" with RSC`;

// Fundraising notifications
case 'FUNDRAISE_CONTRIBUTION':
// Stored notifications may contain only the contributor's first name.
return (
stripHtml(
notification.body
.map((segment, index) =>
index === 0 &&
segment.type === 'link' &&
(actionUser?.firstName || actionUser?.lastName)
? actionUser.fullName
: segment.value
)
.join('')
) || `${userName} submitted a contribution to your proposal "${truncatedTitle}"`
);

case 'FUNDRAISE_PAYOUT':
return 'Your fundraising payout has been processed';

Expand Down
Loading