Skip to content

Commit

Permalink
update recipient fields
Browse files Browse the repository at this point in the history
  • Loading branch information
cuteolaf committed May 9, 2024
1 parent 5857ce6 commit 6001d1c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 62 deletions.
47 changes: 47 additions & 0 deletions src/components/Elements/RecipientInput/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Box, Button, Input, InputAdornment, Typography } from '@mui/material';

import { isValidAddress } from '@/utils/functions';

import { useAccounts } from '@/contexts/account';

export interface RecipientInputProps {
setRecipient: (_: string) => void;
recipient: string;
}

export const RecipientInput = ({
setRecipient,
recipient,
}: RecipientInputProps) => {
const {
state: { activeAccount },
} = useAccounts();

return (
<Box>
<Typography>Recipient</Typography>
<Input
value={recipient}
onChange={(e) => setRecipient(e.target.value)}
fullWidth
type='text'
placeholder='Address of the recipient'
endAdornment={
<InputAdornment position='end'>
<Button
variant='text'
color='info'
onClick={() =>
activeAccount && setRecipient(activeAccount.address)
}
>
Me
</Button>
</InputAdornment>
}
sx={{ height: '3rem' }}
error={recipient.length > 0 && !isValidAddress(recipient)}
/>
</Box>
);
};
56 changes: 0 additions & 56 deletions src/components/Elements/Selectors/RecipientSelector/index.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/Elements/Selectors/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './AssetSelector';
export * from './ChainSelector';
export * from './FinalitySelector';
export * from './RecipientSelector';
export * from './RegionSelector';
1 change: 1 addition & 0 deletions src/components/Elements/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export * from './FeatureCard';
export * from './Label';
export * from './ListingCard';
export * from './MarketFilters';
export * from './RecipientInput';
export * from './RegionCard';
export * from './SaleInfoPanel';
export * from './SalePhaseInfoPanel';
Expand Down
5 changes: 2 additions & 3 deletions src/components/Modals/Sell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import {
import { Region } from 'coretime-utils';
import { useEffect, useState } from 'react';

import { AmountInput, RegionCard } from '@/components/Elements';
import { RecipientSelector } from '@/components/Elements/Selectors/RecipientSelector';
import { AmountInput, RecipientInput, RegionCard } from '@/components/Elements';

import { useAccounts } from '@/contexts/account';
import { useCoretimeApi } from '@/contexts/apis';
Expand Down Expand Up @@ -123,7 +122,7 @@ export const SellModal = ({
/>
</Stack>
<Stack direction='column' gap={2}>
<RecipientSelector
<RecipientInput
setRecipient={setSaleRecipient}
recipient={saleRecipient}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
AmountInput,
ChainSelector,
ProgressButton,
RecipientSelector,
RecipientInput,
RegionCard,
RegionSelector,
} from '@/components';
Expand Down Expand Up @@ -297,7 +297,7 @@ const TransferPage = () => {
>
Transfer to:
</Typography>
<RecipientSelector recipient={newOwner} setRecipient={setNewOwner} />
<RecipientInput recipient={newOwner} setRecipient={setNewOwner} />
</Stack>
{asset === AssetType.TOKEN &&
originChain !== ChainType.NONE &&
Expand Down

0 comments on commit 6001d1c

Please sign in to comment.