From 15ba4eb48cdc83e124003c57a2cc8999b096dfd5 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Fri, 19 Aug 2022 14:20:25 -0500 Subject: [PATCH] Working loan notification --- functions/src/create-notification.ts | 9 ++++++++- web/pages/notifications.tsx | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) 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 = '' }