diff --git a/functions/src/create-notification.ts b/functions/src/create-notification.ts index 979e1305..53e7dd16 100644 --- a/functions/src/create-notification.ts +++ b/functions/src/create-notification.ts @@ -486,7 +486,14 @@ export const createLoanIncomeNotification = async ( reason: 'loan_income', createdTime: Date.now(), isSeen: false, - sourceText: formatMoney(income), + sourceId: idempotencyKey, + sourceType: 'loan', + sourceUpdateType: 'updated', + sourceUserName: toUser.name, + sourceUserUsername: toUser.username, + sourceUserAvatarUrl: toUser.avatarUrl, + sourceText: income.toString(), + sourceTitle: 'Loan', } await notificationRef.set(removeUndefinedProps(notification)) } diff --git a/web/pages/notifications.tsx b/web/pages/notifications.tsx index f079407f..346681cd 100644 --- a/web/pages/notifications.tsx +++ b/web/pages/notifications.tsx @@ -385,6 +385,8 @@ function IncomeNotificationItem(props: { : 'bonus on' } else if (sourceType === 'tip') { reasonText = !simple ? `tipped you on` : `in tips on` + } else if (sourceType === 'loan' && sourceText) { + reasonText = `of your invested bets returned as` } else if (sourceType === 'betting_streak_bonus' && sourceText) { reasonText = `for your ${ parseInt(sourceText) / BETTING_STREAK_BONUS_AMOUNT @@ -393,7 +395,15 @@ function IncomeNotificationItem(props: { return ( <> {reasonText} - {sourceType === 'betting_streak_bonus' ? ( + {sourceType === 'loan' ? ( + simple ? ( + Loan + ) : ( + + Loan + + ) + ) : sourceType === 'betting_streak_bonus' ? ( simple ? ( Betting Streak ) : ( @@ -437,6 +447,7 @@ function IncomeNotificationItem(props: { if (sourceType === 'challenge') return `${sourceSlug}` if (sourceType === 'betting_streak_bonus') return `/${sourceUserUsername}/?show=betting-streak` + if (sourceType === 'loan') return `/${sourceUserUsername}/?show=loan` if (sourceContractCreatorUsername && sourceContractSlug) return `/${sourceContractCreatorUsername}/${sourceContractSlug}#${getSourceIdForLinkComponent( sourceId ?? '', @@ -1003,8 +1014,6 @@ function getReasonForShowingNotification( case 'challenge': reasonText = 'accepted your challenge' break - case 'loan': - reasonText = 'got a portion of your bet back' default: reasonText = '' }