Skip to content

Commit

Permalink
fix: search and select profile on transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
Jadapema committed Feb 2, 2025
1 parent df1aa7c commit 37abe06
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const FinanceDisplayProfileInfo: FC<FinanceDisplayNameProps> = ({initialList, ca
{
mode === 'profile' ?
(<Box component="span" sx={{ flexGrow: 1, typography: 'subtitle1' }}>
{selectedProfile?.metadata?.displayName ?? 'No profile selected'}
{selectedProfile?.metadata?.displayName ?? selectedProfile?.handle?.localName ?? 'No profile selected'}
</Box>) : null
}
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function FinanceQuickTransferModal({

notifySuccess(SUCCESS.TRANSFER_CREATED_SUCCESSFULLY, {
destination: isSame
? contactInfo?.metadata?.displayName
? contactInfo?.metadata?.displayName ?? contactInfo?.handle?.localName
: truncateAddress(address ?? ''),
});
} catch (err: any) {
Expand Down
11 changes: 4 additions & 7 deletions src/sections/finance/components/finance-quick-transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export default function FinanceQuickTransfer({

// 3) Move the carousel right now
carousel.setCurrentIndex(finalIndex);
setCurrentIndex(finalIndex);

// 4) Update the wallet address & Redux
setWalletAddress(profile.ownedBy?.address ?? '');
Expand Down Expand Up @@ -254,9 +255,6 @@ export default function FinanceQuickTransfer({
}
}, [showRainbow, currentIndex, carousel]);

// We pick the contactInfo to pass to the modal. If currentIndex is -1, there's no matched profile
const contactInfoToPass = currentIndex === -1 ? undefined : getContactInfo;

// Render the carousel of profiles
const renderCarousel = (
<Box sx={{ position: 'relative', mb: 3 }}>
Expand Down Expand Up @@ -374,7 +372,6 @@ export default function FinanceQuickTransfer({

const Wrapper = showRainbow ? NeonPaper : Box;

console.log(list);
return (
<>
<Wrapper
Expand All @@ -400,9 +397,9 @@ export default function FinanceQuickTransfer({

{/* Content */}
<Stack sx={{ p: 3 }}>
<FinanceDisplayProfileInfo mode={'profile'} initialList={initialList} carousel={carousel} />
<FinanceDisplayProfileInfo mode={'profile'} initialList={list} carousel={carousel} />
{list?.length > 0 ? renderCarousel : <FinanceNoFollowingsQuickTransfer />}
<FinanceDisplayProfileInfo mode={'wallet'} initialList={initialList} carousel={carousel} />
<FinanceDisplayProfileInfo mode={'wallet'} initialList={list} carousel={carousel} />
{renderInput}
</Stack>
</Stack>
Expand All @@ -417,7 +414,7 @@ export default function FinanceQuickTransfer({
address={walletAddress}
onClose={confirm.onFalse}
onFinish={handleTransferFinish}
contactInfo={contactInfoToPass} // If currentIndex is -1, this is undefined
contactInfo={getContactInfo}
onChange={handleChangeInput}
/>
</>
Expand Down
2 changes: 2 additions & 0 deletions src/utils/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// ----------------------------------------------------------------------

export const truncateAddress = (text: string, startChars: number = 6, endChars: number = 6) => {
if (!text) return '';

if (text.length <= startChars + endChars) {
return text;
}
Expand Down

0 comments on commit 37abe06

Please sign in to comment.