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

feat: idle opportunities DeFi modal title #3911

Merged
merged 2 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import { CircularProgress } from 'components/CircularProgress/CircularProgress'
import type { DefiStepProps } from 'components/DeFi/components/Steps'
import { Steps } from 'components/DeFi/components/Steps'
import { useBrowserRouter } from 'hooks/useBrowserRouter/useBrowserRouter'
import { selectAssetById, selectMarketDataById } from 'state/slices/selectors'
import type { StakingId } from 'state/slices/opportunitiesSlice/types'
import {
selectAssetById,
selectMarketDataById,
selectStakingOpportunitiesById,
} from 'state/slices/selectors'
import { useAppSelector } from 'state/store'

import { ClaimContext } from './ClaimContext'
Expand Down Expand Up @@ -50,6 +55,12 @@ export const IdleClaim: React.FC<IdleClaimProps> = ({ accountId }) => {

const marketData = useAppSelector(state => selectMarketDataById(state, underlyingAssetId))

const opportunitiesMetadata = useAppSelector(state => selectStakingOpportunitiesById(state))
const opportunityMetadata = useMemo(
() => opportunitiesMetadata[assetId as StakingId],
[assetId, opportunitiesMetadata],
)

// user info
const handleBack = useCallback(() => {
history.push({
Expand Down Expand Up @@ -78,7 +89,7 @@ export const IdleClaim: React.FC<IdleClaimProps> = ({ accountId }) => {
// We only need this to update on symbol change
}, [accountId, translate, underlyingAsset.symbol])

if (!asset || !marketData)
if (!asset || !marketData || !opportunityMetadata)
return (
<Center minW='350px' minH='350px'>
<CircularProgress />
Expand All @@ -90,7 +101,7 @@ export const IdleClaim: React.FC<IdleClaimProps> = ({ accountId }) => {
<DefiModalContent>
<DefiModalHeader
title={translate('modals.claim.claimFrom', {
opportunity: `${underlyingAsset.symbol} Vault`,
opportunity: opportunityMetadata.name,
})}
onBack={handleBack}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const IdleDeposit: React.FC<IdleDepositProps> = ({

const value = useMemo(() => ({ state, dispatch }), [state])

if (loading || !asset || !marketData) {
if (loading || !asset || !marketData || !opportunityData) {
return (
<Center minW='350px' minH='350px'>
<CircularProgress />
Expand All @@ -154,7 +154,7 @@ export const IdleDeposit: React.FC<IdleDepositProps> = ({
<DepositContext.Provider value={value}>
<DefiModalContent>
<DefiModalHeader
title={translate('modals.deposit.depositInto', { opportunity: `${asset.symbol} Vault` })}
title={translate('modals.deposit.depositInto', { opportunity: opportunityData.name })}
onBack={handleBack}
/>
<Steps steps={StepConfig} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const IdleWithdraw: React.FC<WithdrawProps> = ({ accountId }) => {

const value = useMemo(() => ({ state, dispatch }), [state])

if (!asset || !marketData)
if (!asset || !marketData || !opportunityData)
return (
<Center minW='350px' minH='350px'>
<CircularProgress />
Expand All @@ -146,7 +146,7 @@ export const IdleWithdraw: React.FC<WithdrawProps> = ({ accountId }) => {
<DefiModalContent>
<DefiModalHeader
title={translate('modals.withdraw.withdrawFrom', {
opportunity: `${underlyingAsset.symbol} Vault`,
opportunity: opportunityData.name,
})}
onBack={handleBack}
/>
Expand Down