Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove input form from reward page #407

Merged
merged 42 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2ecbfda
refactor(reward): top card for connected wallet
solidovic Jul 19, 2024
624e61b
refactor: text color and margin
solidovic Jul 19, 2024
6fb02ae
Merge branch 'develop' into feature/si-1497-reward-esw-remove-input-form
solidovic Jul 29, 2024
ba4025f
Merge branch 'develop' into feature/si-1497-reward-esw-remove-input-form
solidovic Jul 30, 2024
addae41
refactor(rewards page): move to stETH balance
solidovic Jul 31, 2024
703f447
feat(rewards): remove AddressInput
solidovic Jul 31, 2024
c053004
feat(rewards): add connect button instead of rewards table
solidovic Jul 31, 2024
7b3ca13
fix(rewards): wallet text color
solidovic Jul 31, 2024
d034f3f
refactor: wallet block
solidovic Aug 2, 2024
34e3906
refactor: stats block
solidovic Aug 2, 2024
c7ac760
refactor(rewards): hide left filters
solidovic Aug 5, 2024
c2d645b
refactor(rewards): filters layout
solidovic Aug 5, 2024
5256147
refactor(rewards): connect button
solidovic Aug 5, 2024
6fd46fa
refactor(rewards): inline loader
solidovic Aug 5, 2024
2e80a5a
refactor(rewards): inline loader
solidovic Aug 5, 2024
e5f61d6
fix(rewards): hide filter after disconnect
solidovic Aug 5, 2024
b573693
fix(rewards): remove 'Only Show Rewards' checkbox, add 'Include trans…
solidovic Aug 5, 2024
a6e204a
Merge branch 'develop' into feature/si-1497-reward-esw-remove-input-form
solidovic Aug 5, 2024
5dce3fc
fix(rewards): remove InputWrapper component
solidovic Aug 5, 2024
8648ee4
refactor(rewards): paddings
solidovic Aug 5, 2024
65cd552
Merge remote-tracking branch 'origin/feature/si-1497-reward-esw-remov…
solidovic Aug 5, 2024
d93d073
refactor(rewards): stake now wrapper width
solidovic Aug 5, 2024
feea85f
fix: tests
solidovic Aug 5, 2024
a62c78e
Merge branch 'develop' into feature/si-1497-reward-esw-remove-input-form
solidovic Aug 5, 2024
b0fb629
feat(rewards): reset stats after disconnect
solidovic Aug 6, 2024
d48de96
Merge branch 'develop' into feature/si-1497-reward-esw-remove-input-form
solidovic Aug 6, 2024
368dc6c
revert: tests
solidovic Aug 6, 2024
9c3484d
feat: add `mock-qa-rewards-address` for rewards table
solidovic Aug 6, 2024
0f515cb
refactor(useStethEthRate): return const rate for chain != {mainnet, s…
solidovic Aug 6, 2024
a6b4f2a
Merge branch 'develop' into feature/si-1497-reward-esw-remove-input-form
solidovic Aug 6, 2024
d501173
fix: using useStethEthRate
solidovic Aug 6, 2024
49aee98
fix(rewards): wording
solidovic Aug 6, 2024
a11d129
Merge branch 'develop' into feature/si-1497-reward-esw-remove-input-form
solidovic Aug 6, 2024
d5b87a0
fix(rewards): open wallet by click on AddressBadge
solidovic Aug 7, 2024
b8de7f2
fix(layout): remove Y micro scroll
solidovic Aug 7, 2024
1714f3e
fix(rewards): text
solidovic Aug 7, 2024
dbccfff
fix(rewards): flash
solidovic Aug 7, 2024
543e02a
fix(rewards stats): add percent for empty stats
solidovic Aug 7, 2024
85602c9
fix(rewards): hide connecr btn to unsupported chain
solidovic Aug 7, 2024
89adb56
fix(rewards): addressBadge for mobile
solidovic Aug 7, 2024
f81f892
fix(rewards table): loader vertical align
solidovic Aug 7, 2024
12f90c4
fix(rewards): texts
solidovic Aug 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions features/rewards/components/CurrencySelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const StyledSelect = styled(Select)`
height: 32px;
width: 72px;

${({ theme }) => theme.mediaQueries.lg} {
width: 100%;
}

border-radius: 6px;

& > span {
Expand Down
6 changes: 5 additions & 1 deletion features/rewards/components/NumberFormat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ type Props = Partial<FormatArgs> & {

const NumberFormat = (props: Props) => {
if (props.pending)
return <InlineLoader style={{ flexBasis: '60%', minWidth: '60px' }} />;
return (
<InlineLoader
style={{ flexBasis: '60%', minWidth: '60px', maxWidth: '120px' }}
/>
);

return props.number ? (
<Tooltip
Expand Down
38 changes: 0 additions & 38 deletions features/rewards/components/addressInput/AddressInput.tsx

This file was deleted.

1 change: 0 additions & 1 deletion features/rewards/components/addressInput/index.ts

This file was deleted.

7 changes: 0 additions & 7 deletions features/rewards/components/addressInput/types.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export const ErrorBlockNoSteth = ({ hasSteth }: ErrorBlockNoStethProps) => {
</Box>
<LocalLink href={HOME_PATH}>
{!hasSteth && (
<Box width="150px">
<Button>Stake now</Button>
<Box>
<Button size={'xs'}>Stake now</Button>
</Box>
)}
</LocalLink>
Expand Down
5 changes: 5 additions & 0 deletions features/rewards/components/export/Exportstyled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ export const ButtonStyle = styled(Button)`
min-width: unset;
padding: 0 15px;
font-size: 12px;
color: var(--lido-color-text);

&::before {
border-color: var(--lido-color-border);
}
`;

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion features/rewards/components/inputDescription/index.ts

This file was deleted.

11 changes: 0 additions & 11 deletions features/rewards/components/inputWrapper/InputWrapper.tsx

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion features/rewards/components/inputWrapper/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { FC } from 'react';
import { Loader, Divider } from '@lidofinance/lido-ui';
import { useSTETHBalance } from '@lido-sdk/react';
import { Zero } from '@ethersproject/constants';

import { STRATEGY_LAZY } from 'consts/swr-strategies';
import { useRewardsHistory } from 'features/rewards/hooks';
import { ErrorBlockNoSteth } from 'features/rewards/components/errorBlocks/ErrorBlockNoSteth';
import { RewardsTable } from 'features/rewards/components/rewardsTable';
import { useDappStatus } from 'shared/hooks/use-dapp-status';

import { RewardsListsEmpty } from './RewardsListsEmpty';
import { RewardsListErrorMessage } from './RewardsListErrorMessage';
Expand All @@ -10,12 +16,9 @@ import {
TableWrapperStyle,
ErrorWrapper,
} from './RewardsListContentStyles';
import { RewardsTable } from 'features/rewards/components/rewardsTable';
import { useSTETHBalance } from '@lido-sdk/react';
import { STRATEGY_LAZY } from 'consts/swr-strategies';
import { Zero } from '@ethersproject/constants';

export const RewardsListContent: FC = () => {
const { isDappActive } = useDappStatus();
const {
error,
initialLoading,
Expand All @@ -29,7 +32,8 @@ export const RewardsListContent: FC = () => {
useSTETHBalance(STRATEGY_LAZY);
const hasSteth = stethBalance?.gt(Zero);

if (!data && !initialLoading && !error) return <RewardsListsEmpty />;
if (!isDappActive || (!data && !initialLoading && !error))
return <RewardsListsEmpty />;
// showing loading when canceling requests and empty response
if (
(!data && !error) ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,47 @@
import { FC } from 'react';
import { FC, useCallback } from 'react';
import { useConnect } from 'reef-knot/core-react';
import { wrapWithEventTrack } from '@lidofinance/analytics-matomo';
import { Button, Divider } from '@lidofinance/lido-ui';

import { Divider } from '@lidofinance/lido-ui';

import { RewardsListEmptyWrapper } from './RewardsListsEmptyStyles';
import { useUserConfig } from 'config/user-config';
import { MATOMO_CLICK_EVENTS } from 'consts/matomo-click-events';
import { useDappStatus } from 'shared/hooks/use-dapp-status';
import {
RewardsListEmptyButtonWrapper,
RewardsListEmptyWrapper,
} from './RewardsListsEmptyStyles';

export const RewardsListsEmpty: FC = () => {
const { isWalletConnectionAllowed } = useUserConfig();
const { isWalletConnected } = useDappStatus();

const { connect } = useConnect();

const handleClick = wrapWithEventTrack(
MATOMO_CLICK_EVENTS.connectWallet,
useCallback(() => {
if (!isWalletConnectionAllowed) return;
void connect();
}, [isWalletConnectionAllowed, connect]),
);

return (
<>
<Divider indents="lg" />
<RewardsListEmptyWrapper>
Connect your wallet or enter your Ethereum address to see the stats.
<p>Connect your wallet to view your staking rewards</p>
{isWalletConnected ? null : (
<RewardsListEmptyButtonWrapper>
<Button
size={'xs'}
disabled={!isWalletConnectionAllowed}
onClick={handleClick}
data-testid="connectBtn"
>
Connect wallet
</Button>
</RewardsListEmptyButtonWrapper>
)}
</RewardsListEmptyWrapper>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ import styled from 'styled-components';
export const RewardsListEmptyWrapper = styled.div`
text-align: center;
`;

export const RewardsListEmptyButtonWrapper = styled.div`
margin-top: ${({ theme }) => theme.spaceMap.md}px;
`;
28 changes: 14 additions & 14 deletions features/rewards/components/rewardsListHeader/LeftOptions.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
import { FC } from 'react';
import { Tooltip, Checkbox } from '@lidofinance/lido-ui';

import { LeftOptionsWrapper } from './styles';
import { useRewardsHistory } from 'features/rewards/hooks/useRewardsHistory';
import { LeftOptionsWrapper } from './styles';

export const LeftOptions: FC = () => {
const {
isUseArchiveExchangeRate,
isOnlyRewards,
isIncludeTransfers,
setIsUseArchiveExchangeRate,
setIsOnlyRewards,
setIsIncludeTransfers,
} = useRewardsHistory();

return (
<LeftOptionsWrapper>
<Tooltip
placement="bottom"
title="Display only rewards in the table. Other events will be hidden."
>
<Checkbox
checked={isIncludeTransfers}
onChange={() => setIsIncludeTransfers(!isIncludeTransfers)}
data-testid="includeTransfersCheckbox"
label="Include transfers"
/>
</Tooltip>
<Tooltip
placement="bottom"
title="Calculate USD values using an exchange rate at the time of the
Expand All @@ -29,17 +40,6 @@ export const LeftOptions: FC = () => {
label="Historical stETH price"
/>
</Tooltip>
<Tooltip
placement="bottom"
title="Display only transfers in the table. Other events will be hidden."
>
<Checkbox
checked={isOnlyRewards}
onChange={() => setIsOnlyRewards(!isOnlyRewards)}
data-testid="onlyRewardsCheckbox"
label="Only Show Rewards"
/>
</Tooltip>
</LeftOptionsWrapper>
);
};
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import { FC } from 'react';
import { useRewardsHistory } from 'features/rewards/hooks';
import { useDappStatus } from 'shared/hooks/use-dapp-status';

import { LeftOptions } from './LeftOptions';
import { RightOptions } from './RightOptions';
import { RewardsListHeaderStyle } from './styles';
import { TitleStyle } from './styles';

export const RewardsListHeader: FC = () => {
const { isDappActive } = useDappStatus();
const { error, data } = useRewardsHistory();
return (
<RewardsListHeaderStyle data-testid="rewardsHeader">
<TitleStyle>Reward history</TitleStyle>
<LeftOptions />
{!error && data && data?.events.length > 0 && <RightOptions />}
{isDappActive && !error && data && data?.events.length > 0 && (
<>
<LeftOptions />
<RightOptions />
</>
)}
</RewardsListHeaderStyle>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const RightOptions: FC = () => {
currencyObject,
setCurrency,
isUseArchiveExchangeRate,
isOnlyRewards,
isIncludeTransfers,
} = useRewardsHistory();
return (
<RightOptionsWrapper>
Expand All @@ -20,7 +20,7 @@ export const RightOptions: FC = () => {
currency={currencyObject}
address={address}
archiveRate={isUseArchiveExchangeRate}
onlyRewards={isOnlyRewards}
onlyRewards={!isIncludeTransfers}
/>
</RightOptionsWrapper>
);
Expand Down
4 changes: 2 additions & 2 deletions features/rewards/components/rewardsListHeader/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const RewardsListHeaderStyle = styled.div`
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 20px 32px;
gap: 20px 28px;
height: 32px;
align-items: center;

Expand Down Expand Up @@ -39,7 +39,7 @@ export const LeftOptionsWrapper = styled.div`
}

${({ theme }) => theme.mediaQueries.md} {
flex-direction: column;
flex-direction: row;
}
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const ContentStyle = styled.div`
display: flex;
height: 100%;
justify-content: center;
align-items: center;
`;

export const LoaderStyle = styled(Loader)`
Expand Down
1 change: 1 addition & 0 deletions features/rewards/components/stats/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const Item = ({ children, ...rest }: BoxProps) => (
width={['100%', '100%', 'initial']}
display={['flex', 'flex', 'initial']}
justifyContent={['space-between', 'space-between', null]}
marginBottom={['6px']}
{...rest}
>
{children}
Expand Down
4 changes: 2 additions & 2 deletions features/rewards/components/stats/Stat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export const Stat = ({ children, ...rest }: BoxProps) => (
<Box
fontStyle="normal"
fontWeight={[null, null, 600]}
fontSize={['14px', '14px', '20px']}
fontSize={['12px', '12px', '16px']}
lineHeight="20px"
color="text"
height="20px"
mb="6px"
mb="2px"
display={'flex'}
{...rest}
>
Expand Down
Loading
Loading