From f43255bde135d4ce39bc38fa7d545fd874e2b1a4 Mon Sep 17 00:00:00 2001 From: Mateo Daza Date: Tue, 3 May 2022 19:25:58 -0500 Subject: [PATCH 1/6] displays archived pools on toggle --- src/components/cards/BaseStakingCard.tsx | 29 +++++++++++--------- src/components/homeTabs/GIVfarm.sc.tsx | 6 ++++- src/components/homeTabs/GIVfarm.tsx | 31 +++++++++++++--------- src/components/views/donate/RadioTitle.tsx | 19 ++++++++++--- 4 files changed, 54 insertions(+), 31 deletions(-) diff --git a/src/components/cards/BaseStakingCard.tsx b/src/components/cards/BaseStakingCard.tsx index f46b3612e5..f83399012f 100644 --- a/src/components/cards/BaseStakingCard.tsx +++ b/src/components/cards/BaseStakingCard.tsx @@ -129,9 +129,10 @@ const BaseStakingCard: FC = ({ BUY_LINK, unit, farmStartTimeMS, + active, } = poolStakingConfig; - const isV3Staking = type === StakingType.UNISWAPV3; + const isInactive = !active || type === StakingType.UNISWAPV3; const { apr, earned, stakedLpAmount, userNotStakedAmount } = stakeInfo; @@ -165,10 +166,12 @@ const BaseStakingCard: FC = ({ setStarted(farmStartTimeMS ? getNowUnixMS() > farmStartTimeMS : true); }, [farmStartTimeMS]); + // if(isInactive) return null + return ( <> - {isV3Staking && disableModal && ( + {isInactive && disableModal && ( @@ -253,7 +256,7 @@ const BaseStakingCard: FC = ({ APR - {isV3Staking ? ( + {isInactive ? (
N/A %
) : ( <> @@ -288,7 +291,7 @@ const BaseStakingCard: FC = ({ Claimable - {isV3Staking ? ( + {isInactive ? (
N/A
) : ( `${formatWeiHelper( @@ -312,7 +315,7 @@ const BaseStakingCard: FC = ({
- {isV3Staking ? ( + {isInactive ? (
N/A
) : ( formatWeiHelper( @@ -333,7 +336,7 @@ const BaseStakingCard: FC = ({ /> )} setShowHarvestModal(true)} label='HARVEST REWARDS' buttonType='primary' @@ -345,12 +348,12 @@ const BaseStakingCard: FC = ({ size='small' disabled={ userNotStakedAmount.isZero() || - isV3Staking + isInactive } onClick={() => setShowStakeModal(true)} /> - {isV3Staking + {isInactive ? `${userNotStakedAmount.toNumber()} ${unit}` : `${formatWeiHelper( userNotStakedAmount, @@ -367,7 +370,7 @@ const BaseStakingCard: FC = ({ } /> - {isV3Staking + {isInactive ? `${stakedLpAmount.toNumber()} ${unit}` : `${formatWeiHelper( stakedLpAmount, @@ -375,7 +378,7 @@ const BaseStakingCard: FC = ({ - {!isV3Staking && ( + {!isInactive && ( = ({ : 'PROVIDE LIQUIDITY' } onClick={() => { - if (isV3Staking) { + if (isInactive) { setShowUniV3APRModal(true); } else { window.open( @@ -428,7 +431,7 @@ const BaseStakingCard: FC = ({ /> )} {showStakeModal && - (isV3Staking ? ( + (isInactive ? ( = ({ /> ))} {showUnStakeModal && - (isV3Staking ? ( + (isInactive ? ( - pools - .filter(p => p.active === active) + showArchivedPools?: boolean, +) => { + return pools + .filter(p => (showArchivedPools ? p : p.active === active)) .map((poolStakingConfig, index) => { return ( ); }); +}; export const TabGIVfarmTop = () => { const [rewardLiquidPart, setRewardLiquidPart] = useState(constants.Zero); @@ -117,6 +121,7 @@ export const TabGIVfarmTop = () => { export const TabGIVfarmBottom = () => { const { chainId } = useWeb3React(); + const [showArchivedPools, setArchivedPools] = useState(false); return ( @@ -175,6 +180,14 @@ export const TabGIVfarmBottom = () => {
+ + setArchivedPools(!showArchivedPools)} + isSelected={showArchivedPools} + /> + + {chainId === config.XDAI_NETWORK_NUMBER && ( <> @@ -182,6 +195,7 @@ export const TabGIVfarmBottom = () => { config.XDAI_CONFIG.pools, config.XDAI_NETWORK_NUMBER, true, + showArchivedPools, )} { )} /> - {renderPools( - config.XDAI_CONFIG.pools, - config.XDAI_NETWORK_NUMBER, - false, - )} { config.MAINNET_CONFIG.pools, config.MAINNET_NETWORK_NUMBER, true, + showArchivedPools, )} { )} /> - {renderPools( - config.MAINNET_CONFIG.pools, - config.MAINNET_NETWORK_NUMBER, - false, - )} void; }) => { const { title, subtitle, isSelected, toggleRadio } = props; + const { theme } = useGeneral(); return ( @@ -26,7 +28,12 @@ const RadioTitle = (props: { alt='radio icon' />
- {title} + + {title} + {subtitle} @@ -46,8 +53,12 @@ const RadioTitleBox = styled.div` `; const RadioTitleText = styled(Lead)` - color: ${(props: { isSelected: boolean }) => - props.isSelected ? brandColors.deep[900] : neutralColors.gray[600]}; + color: ${(props: { isSelected: boolean; isDark: boolean }) => + props.isSelected + ? props.isDark + ? 'white' + : brandColors.deep[900] + : neutralColors.gray[600]}; `; const RadioSubtitleText = styled(Subline)` From 357489bca656047cbcbb34aff1ee4c1eb080ec09 Mon Sep 17 00:00:00 2001 From: Mateo Daza Date: Wed, 4 May 2022 07:43:19 -0500 Subject: [PATCH 2/6] Update GIVfarm.sc.tsx --- src/components/homeTabs/GIVfarm.sc.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/homeTabs/GIVfarm.sc.tsx b/src/components/homeTabs/GIVfarm.sc.tsx index 844d5ec462..daffbda79b 100644 --- a/src/components/homeTabs/GIVfarm.sc.tsx +++ b/src/components/homeTabs/GIVfarm.sc.tsx @@ -1,6 +1,6 @@ import styled from 'styled-components'; -import { D1, QuoteText, Caption, brandColors } from '@giveth/ui-design-system'; +import { D1, QuoteText, brandColors } from '@giveth/ui-design-system'; import { BottomContainer, EnhancedRewardCard, TopContainer } from './commons'; import { Flex } from '../styled-components/Flex'; import { Row } from '../Grid'; From f4739241d6bdbd7c987cc8af3d567a2fe1e2d742 Mon Sep 17 00:00:00 2001 From: Mateo Daza Date: Wed, 4 May 2022 08:01:45 -0500 Subject: [PATCH 3/6] unescapes html text on card --- src/lib/helpers.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/helpers.ts b/src/lib/helpers.ts index bf5d741eb1..87f0a32505 100644 --- a/src/lib/helpers.ts +++ b/src/lib/helpers.ts @@ -18,6 +18,8 @@ import { gToast, ToastType } from '@/components/toasts'; import StorageLabel from '@/lib/localStorage'; import { networksParams } from '@/helpers/blockchain'; +import { unescape } from 'lodash'; + declare let window: any; export const formatBalance = (balance?: string | number) => { @@ -127,12 +129,13 @@ export const isUserRegistered = (user?: IUser) => { export const htmlToText = (text?: string) => { if (!text) return; - return text + const formattedText = text + .replace(/<[^>]+>/g, '') .replace(/<\/(?:.|\n)*?>/gm, ' ') // replace closing tags w/ a space .replace(/<(?:.|\n)*?>/gm, '') // strip opening tags .trim(); + return unescape(formattedText); }; - export const capitalizeFirstLetter = (string: string) => { return string.charAt(0).toUpperCase() + string.slice(1); }; From 8b35a965de711e4e74eca88cd65065386262b595 Mon Sep 17 00:00:00 2001 From: Mateo Daza Date: Wed, 4 May 2022 08:05:16 -0500 Subject: [PATCH 4/6] fixes build --- src/lib/helpers.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/helpers.ts b/src/lib/helpers.ts index 87f0a32505..5e86c7b9dc 100644 --- a/src/lib/helpers.ts +++ b/src/lib/helpers.ts @@ -1,4 +1,5 @@ import { promisify } from 'util'; +import { unescape } from 'lodash'; import { parseUnits, parseEther } from '@ethersproject/units'; import { keccak256 } from '@ethersproject/keccak256'; import { Contract } from '@ethersproject/contracts'; @@ -18,8 +19,6 @@ import { gToast, ToastType } from '@/components/toasts'; import StorageLabel from '@/lib/localStorage'; import { networksParams } from '@/helpers/blockchain'; -import { unescape } from 'lodash'; - declare let window: any; export const formatBalance = (balance?: string | number) => { From 3357acc64ca5fe33b35cf2ebba8d1f25f319a2a4 Mon Sep 17 00:00:00 2001 From: Mateo Daza Date: Mon, 9 May 2022 08:17:22 -0500 Subject: [PATCH 5/6] sorts active first on archived pools --- package.json | 2 +- src/components/homeTabs/GIVfarm.tsx | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 846691624f..a4b12afd78 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "givethdapp", - "version": "2.2.1", + "version": "2.0.6", "private": true, "scripts": { "build": "next build", diff --git a/src/components/homeTabs/GIVfarm.tsx b/src/components/homeTabs/GIVfarm.tsx index b1b6276b43..0ccf95c7f0 100644 --- a/src/components/homeTabs/GIVfarm.tsx +++ b/src/components/homeTabs/GIVfarm.tsx @@ -50,6 +50,7 @@ const renderPools = ( ) => { return pools .filter(p => (showArchivedPools ? p : p.active === active)) + .sort(p => (p.active ? -1 : 1)) .map((poolStakingConfig, index) => { return ( { {chainId === config.XDAI_NETWORK_NUMBER && ( <> - {renderPools( - config.XDAI_CONFIG.pools, - config.XDAI_NETWORK_NUMBER, - true, - showArchivedPools, - )} { )} /> + {renderPools( + config.XDAI_CONFIG.pools, + config.XDAI_NETWORK_NUMBER, + true, + showArchivedPools, + )} { !givEconomySupportedNetworks.includes(chainId) } > - {renderPools( - config.MAINNET_CONFIG.pools, - config.MAINNET_NETWORK_NUMBER, - true, - showArchivedPools, - )} { )} /> + {renderPools( + config.MAINNET_CONFIG.pools, + config.MAINNET_NETWORK_NUMBER, + true, + showArchivedPools, + )} Date: Mon, 9 May 2022 10:26:40 -0500 Subject: [PATCH 6/6] Update GIVfarm.tsx --- src/components/homeTabs/GIVfarm.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/homeTabs/GIVfarm.tsx b/src/components/homeTabs/GIVfarm.tsx index 0ccf95c7f0..6ea2f0459e 100644 --- a/src/components/homeTabs/GIVfarm.tsx +++ b/src/components/homeTabs/GIVfarm.tsx @@ -45,11 +45,10 @@ import { const renderPools = ( pools: BasicNetworkConfig['pools'], network: number, - active: boolean, showArchivedPools?: boolean, ) => { return pools - .filter(p => (showArchivedPools ? p : p.active === active)) + .filter(p => (showArchivedPools ? true : !!p.active)) .sort(p => (p.active ? -1 : 1)) .map((poolStakingConfig, index) => { return ( @@ -203,7 +202,6 @@ export const TabGIVfarmBottom = () => { {renderPools( config.XDAI_CONFIG.pools, config.XDAI_NETWORK_NUMBER, - true, showArchivedPools, )} @@ -234,7 +232,6 @@ export const TabGIVfarmBottom = () => { {renderPools( config.MAINNET_CONFIG.pools, config.MAINNET_NETWORK_NUMBER, - true, showArchivedPools, )}