From d6af0c389e42d90a06e4f9a5e10824e38507716d Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Wed, 6 Jul 2022 13:23:34 -0600 Subject: [PATCH] Remove unnecessary icons --- web/pages/notifications.tsx | 85 +++++++++++++++---------------------- 1 file changed, 34 insertions(+), 51 deletions(-) diff --git a/web/pages/notifications.tsx b/web/pages/notifications.tsx index 1e626f2d..c76218f3 100644 --- a/web/pages/notifications.tsx +++ b/web/pages/notifications.tsx @@ -34,9 +34,10 @@ import toast from 'react-hot-toast' import { formatMoney } from 'common/util/format' import { groupPath } from 'web/lib/firebase/groups' import { UNIQUE_BETTOR_BONUS_AMOUNT } from 'common/numeric-constants' -import { groupBy, uniq } from 'lodash' +import { groupBy, sum, uniq } from 'lodash' export const NOTIFICATIONS_PER_PAGE = 30 +const MULTIPLE_USERS_KEY = 'multipleUsers' export default function Notifications() { const user = useUser() @@ -186,7 +187,6 @@ function IncomeNotificationGroupItem(props: { const { notificationGroup, className } = props const { notifications } = notificationGroup const numSummaryLines = 3 - const [expanded, setExpanded] = useState(false) const [highlighted, setHighlighted] = useState( notifications.some((n) => !n.isSeen) @@ -200,12 +200,12 @@ function IncomeNotificationGroupItem(props: { if (expanded) setHighlighted(false) }, [expanded]) - const totalIncome = notifications.reduce( - (acc, notification) => - acc + (notification.sourceText ? parseInt(notification.sourceText) : 0), - 0 + const totalIncome = sum( + notifications.map((notification) => + notification.sourceText ? parseInt(notification.sourceText) : 0 + ) ) - // loop through the contracts and combine the notification items into one + // Loop through the contracts and combine the notification items into one function combineNotificationsByAddingNumericSourceTexts( notifications: Notification[] ) { @@ -245,7 +245,7 @@ function IncomeNotificationGroupItem(props: { sourceText: sum.toString(), sourceUserUsername: uniqueUsers.length > 1 - ? 'Multiple Users' + ? MULTIPLE_USERS_KEY : notificationsForContractId[0].sourceType, } newNotifications.push(newNotification) @@ -362,10 +362,10 @@ function IncomeNotificationItem(props: { let reasonText = '' if (sourceType === 'bonus' && sourceText) { reasonText = !simple - ? `for ${ + ? `bonus for ${ parseInt(sourceText) / UNIQUE_BETTOR_BONUS_AMOUNT } unique bettors` - : ' for unique bettors on' + : ' bonus for unique bettors on' } else if (sourceType === 'tip') { reasonText = !simple ? `tipped you` : `in tips on` } @@ -407,48 +407,31 @@ function IncomeNotificationItem(props: { > - {sourceType != 'bonus' ? ( - sourceUserUsername === 'Multiple Users' ? ( -
- -
- ) : ( - - ) - ) : ( - - )} -
-
- {sourceType && reason && ( -
- - + {sourceType && reason && ( +
+ + + + + {sourceType != 'bonus' && + (sourceUserUsername === MULTIPLE_USERS_KEY ? ( + Multiple users + ) : ( + - - {sourceType != 'bonus' && - (sourceUserUsername === 'Multiple Users' ? ( - Users - ) : ( - - ))} - {getReasonForShowingIncomeNotification(false)} -
- )} -
+ ))} +
+ )} + {getReasonForShowingIncomeNotification(false)}