Skip to content

Commit

Permalink
fixed payeeName bug again
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen-Gordon committed Mar 26, 2024
1 parent 4c59400 commit 0d550c6
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/app/@auth/(.)confirm/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ import { useDispatch } from 'react-redux';
import useFindPayeeName from '@/app/hooks/useFindPayeeName';
import { ArrowDown, SendHorizonal, Send } from 'lucide-react';

// redux
import { useSelector } from 'react-redux';
import { RootState } from '@/GlobalRedux/store';
import { Contact } from '@/app/types/types';

interface ConfirmProps {
showConfirm: boolean;
}
Expand All @@ -54,6 +59,22 @@ export default function Page({ showConfirm }: ConfirmProps) {
useSendUsdc();


const contactsState = useSelector((state: RootState) => state.contacts.value);

const findPayeeName = (payeeAddress: string): string | null => {
if (!contactsState || contactsState.length === 0) {
return truncateEthAddress(payeeAddress);
}

// Ensure to lower case both sides to match
const contact = contactsState.find(
(element: Contact) => element.address?.toLocaleLowerCase() === payeeAddress.toLocaleLowerCase()
);

return contact ? contact.name : truncateEthAddress(payeeAddress);
};



const handleSend = () => {
if (!payee || !amount) return;
Expand Down Expand Up @@ -97,7 +118,7 @@ export default function Page({ showConfirm }: ConfirmProps) {


<div className='text-lg text-center text-muted-foreground font-bold leading-none'>
{payee && useFindPayeeName(payee) }
{payee && findPayeeName(payee) }
</div>
</div>
{ loading == true || transactionStatus == true ? (<>
Expand Down

0 comments on commit 0d550c6

Please sign in to comment.