Skip to content

Commit

Permalink
fixed filtering issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen-Gordon committed Mar 26, 2024
1 parent ff54bc1 commit 9901e42
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/app/hooks/useFindPayeeName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ import { Contact } from '@/app/types/types';
import truncateEthAddress from 'truncate-eth-address';

const useFindPayeeName = (payeeAddress: string) => {

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

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

// make sure theyre lowercase to match them
const contact = contactsState.find(
(contact: Contact) => contact.address === payeeAddress
(element: Contact) => element.address?.toLocaleLowerCase() == payeeAddress.toLocaleLowerCase()
);
console.log("contact ", contact)

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

0 comments on commit 9901e42

Please sign in to comment.