-
Notifications
You must be signed in to change notification settings - Fork 13
Chore/gtag #887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chore/gtag #887
Changes from all commits
1bc397a
e7f6e12
9e6c97a
abb5199
a5bbe2b
67cccdd
3707527
97bc204
a826c75
5f78ac1
7c464e2
8a92912
552f0a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import AvatarWithBadge, { AvatarSize } from '@/components/Profile/AvatarWithBadg | |
import { PEANUT_WALLET_TOKEN_SYMBOL } from '@/constants' | ||
import { RecipientType } from '@/lib/url-parser/types/payment' | ||
import { printableAddress } from '@/utils' | ||
import { getColorForUsername } from '@/utils/color.utils' | ||
import { AVATAR_TEXT_DARK, getColorForUsername } from '@/utils/color.utils' | ||
import { useCallback } from 'react' | ||
import { twMerge } from 'tailwind-merge' | ||
import Attachment from '../Attachment' | ||
|
@@ -85,9 +85,19 @@ export default function PeanutActionDetailsCard({ | |
backgroundColor: | ||
viewType === 'SUCCESS' | ||
? '#29CC6A' | ||
: transactionType === 'ADD_MONEY' || recipientType === 'ADDRESS' | ||
: transactionType === 'ADD_MONEY' || | ||
recipientType === 'ADDRESS' || | ||
recipientType === 'ENS' | ||
? '#FFC900' | ||
: getColorForUsername(recipientName).backgroundColor, | ||
: getColorForUsername(recipientName).darkShade, | ||
Comment on lines
+88
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix potential contrast issue with background color. The logic uses Apply this fix: - : getColorForUsername(recipientName).darkShade,
+ : getColorForUsername(recipientName).lightShade, 🤖 Prompt for AI Agents
|
||
color: | ||
viewType === 'SUCCESS' | ||
? AVATAR_TEXT_DARK | ||
: transactionType === 'ADD_MONEY' || | ||
recipientType === 'ADDRESS' || | ||
recipientType === 'ENS' | ||
? AVATAR_TEXT_DARK | ||
: getColorForUsername(recipientName).darkShade, | ||
}} | ||
/> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -13,6 +13,9 @@ import ProfileHeader from './ProfileHeader' | |||||||||
import { useState, useEffect } from 'react' | ||||||||||
import { usersApi } from '@/services/users' | ||||||||||
import { useRouter } from 'next/navigation' | ||||||||||
import { formatExtendedNumber } from '@/utils' | ||||||||||
import Card from '@/components/Global/Card' | ||||||||||
import { useAuth } from '@/context/authContext' | ||||||||||
|
||||||||||
interface PublicProfileProps { | ||||||||||
username: string | ||||||||||
|
@@ -29,6 +32,9 @@ const PublicProfile: React.FC<PublicProfileProps> = ({ | |||||||||
}) => { | ||||||||||
const dispatch = useAppDispatch() | ||||||||||
const [fullName, setFullName] = useState<string>(username) | ||||||||||
const [totalSent, setTotalSent] = useState<string>('0.00') | ||||||||||
const [totalReceived, setTotalReceived] = useState<string>('0.00') | ||||||||||
const { user } = useAuth() | ||||||||||
const router = useRouter() | ||||||||||
|
||||||||||
// Handle send button click | ||||||||||
|
@@ -43,6 +49,8 @@ const PublicProfile: React.FC<PublicProfileProps> = ({ | |||||||||
useEffect(() => { | ||||||||||
usersApi.getByUsername(username).then((user) => { | ||||||||||
if (user?.fullName) setFullName(user.fullName) | ||||||||||
setTotalSent(user.totalUsdSent) | ||||||||||
setTotalReceived(user.totalUsdReceived) | ||||||||||
Comment on lines
+52
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add null/undefined checks for API response fields. The code directly assigns Apply this diff to add proper null checking: -setTotalSent(user.totalUsdSent)
-setTotalReceived(user.totalUsdReceived)
+setTotalSent(user.totalUsdSent ?? '0.00')
+setTotalReceived(user.totalUsdReceived ?? '0.00') 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||
}) | ||||||||||
}, [username]) | ||||||||||
|
||||||||||
|
@@ -92,31 +100,26 @@ const PublicProfile: React.FC<PublicProfileProps> = ({ | |||||||||
</Link> | ||||||||||
</div> | ||||||||||
|
||||||||||
{/* | ||||||||||
<div className="space-y-6"> | ||||||||||
{!!hasTransactions && ( | ||||||||||
{totalSent !== '0.00' && totalReceived !== '0.00' && ( | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider showing stats when either value is non-zero. The current condition requires both Consider changing the logic to show stats when at least one value is non-zero: -{totalSent !== '0.00' && totalReceived !== '0.00' && (
+{(totalSent !== '0.00' || totalReceived !== '0.00') && ( 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||
<div className="space-y-6"> | ||||||||||
<div> | ||||||||||
<Card position="first"> | ||||||||||
<div className="flex items-center justify-between py-2"> | ||||||||||
<span className="font-medium">Total sent to</span> | ||||||||||
<span className="font-medium"> | ||||||||||
${formatExtendedNumber(transactions?.sent || 0)} | ||||||||||
</span> | ||||||||||
<span className="font-medium">${formatExtendedNumber(totalSent)}</span> | ||||||||||
</div> | ||||||||||
</Card> | ||||||||||
<Card position="last"> | ||||||||||
<div className="flex items-center justify-between py-2"> | ||||||||||
<span className="font-medium">Total received from</span> | ||||||||||
<span className="font-medium"> | ||||||||||
${formatExtendedNumber(transactions?.received || 0)} | ||||||||||
</span> | ||||||||||
<span className="font-medium">${formatExtendedNumber(totalReceived)}</span> | ||||||||||
</div> | ||||||||||
</Card> | ||||||||||
</div> | ||||||||||
)} | ||||||||||
|
||||||||||
</div> | ||||||||||
</div> | ||||||||||
)} | ||||||||||
|
||||||||||
{/* | ||||||||||
{!hasTransactions && ( | ||||||||||
<div className="relative flex flex-col items-center"> | ||||||||||
<Card position="single" className="z-10 mt-28 space-y-2 p-4 text-center"> | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix redundant conditional and align with color scheme pattern.
The conditional logic on line 65 is redundant since both branches return
'black'
. Based on the new color utility pattern used in other components, non-bank icons should usedarkShade
for better contrast and consistency.Apply this diff to fix the redundant conditional:
📝 Committable suggestion
🤖 Prompt for AI Agents