-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #438 from lidofinance/feature/si-1557-rewards-hist…
…ory-with-address-input-back feat: rewards history with address input back
- Loading branch information
Showing
24 changed files
with
409 additions
and
282 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions
50
features/rewards/components/address-input/address-input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { FC, useMemo } from 'react'; | ||
import { Input, Loader, Identicon } from '@lidofinance/lido-ui'; | ||
import CopyAddressUrl from 'features/rewards/components/CopyAddressUrl'; | ||
import { isValidAnyAddress } from 'features/rewards/utils'; | ||
import { ReactComponent as ErrorTriangle } from 'assets/icons/error-triangle.svg'; | ||
|
||
import { AddressInputProps } from './types'; | ||
|
||
export const AddressInput: FC<AddressInputProps> = (props) => { | ||
const { | ||
inputValue, | ||
isAddressResolving, | ||
handleInputChange, | ||
address, | ||
addressError: invalidENSAddress, | ||
loading, | ||
} = props; | ||
|
||
const invalidEthereumAddress = useMemo( | ||
() => inputValue.length > 0 && !isValidAnyAddress(inputValue), | ||
[inputValue], | ||
); | ||
|
||
return ( | ||
<Input | ||
fullwidth | ||
value={inputValue} | ||
onChange={(e) => handleInputChange(e.target.value)} | ||
placeholder="Ethereum address" | ||
leftDecorator={ | ||
loading || isAddressResolving ? ( | ||
<Loader size="small" /> | ||
) : invalidEthereumAddress || invalidENSAddress ? ( | ||
<ErrorTriangle /> | ||
) : address ? ( | ||
<Identicon data-testid="addressIcon" address={address} /> | ||
) : null | ||
} | ||
rightDecorator={address ? <CopyAddressUrl address={inputValue} /> : null} | ||
spellCheck="false" | ||
error={ | ||
invalidEthereumAddress | ||
? 'Invalid ethereum address' | ||
: invalidENSAddress | ||
? invalidENSAddress | ||
: null | ||
} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './address-input'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export type AddressInputProps = { | ||
inputValue: string; | ||
isAddressResolving: boolean; | ||
handleInputChange: (value: string) => void; | ||
address: string; | ||
addressError: string; | ||
loading: boolean; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { FC } from 'react'; | ||
import { Box, Question, Tooltip } from '@lidofinance/lido-ui'; | ||
|
||
import NumberFormat from 'features/rewards/components/NumberFormat'; | ||
import { useRewardsHistory } from 'features/rewards/hooks'; | ||
|
||
import { Item } from './components/item'; | ||
import { FlexCenter } from './components/styles'; | ||
|
||
export const AverageAprBlock: FC = () => { | ||
const { data, initialLoading: loading } = useRewardsHistory(); | ||
|
||
return ( | ||
<Item | ||
loading={loading} | ||
dataTestId="averageAprBlock" | ||
title={ | ||
<> | ||
<FlexCenter> | ||
Average APR | ||
<Tooltip title={'APR on stETH over your staking period'}> | ||
<Question /> | ||
</Tooltip> | ||
</FlexCenter> | ||
</> | ||
} | ||
value={ | ||
<> | ||
{parseFloat(data?.averageApr || '0') ? ( | ||
<> | ||
<NumberFormat number={data?.averageApr} percent /> | ||
<Box display="inline-block" pl="3px"> | ||
% | ||
</Box> | ||
</> | ||
) : ( | ||
'—' | ||
)} | ||
</> | ||
} | ||
valueDataTestId="averageApr" | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { FC, ReactNode } from 'react'; | ||
|
||
import { Block, Title, Value, UnderValue, InlineLoader } from './styles'; | ||
|
||
type ItemProps = { | ||
dataTestId: string; | ||
title: ReactNode | ReactNode[]; | ||
|
||
value: ReactNode | ReactNode[]; | ||
valueDataTestId: string; | ||
|
||
underValue?: ReactNode | ReactNode[] | undefined; | ||
underValueDataTestId?: string | undefined; | ||
|
||
loading: boolean; | ||
}; | ||
|
||
export const Item: FC<ItemProps> = (props) => { | ||
const { | ||
dataTestId, | ||
title, | ||
value, | ||
valueDataTestId, | ||
underValue, | ||
underValueDataTestId, | ||
loading, | ||
} = props; | ||
|
||
return ( | ||
<Block data-testid={dataTestId}> | ||
<Title>{title}</Title> | ||
<Value data-testid={valueDataTestId}> | ||
{!loading ? value : <InlineLoader />} | ||
</Value> | ||
<UnderValue data-testid={underValueDataTestId}> | ||
{!loading ? underValue : <InlineLoader />} | ||
</UnderValue> | ||
</Block> | ||
); | ||
}; |
Oops, something went wrong.