Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Change account fixes #2238

Merged
merged 2 commits into from
Jan 21, 2022
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
9 changes: 4 additions & 5 deletions src/custom/pages/Claim/CanUserClaimMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ import { ButtonSecondary } from 'components/Button'
import { ExternalLink } from 'theme'
import { IntroDescription } from './styled'
import { ClaimCommonTypes } from './types'
import { useClaimDispatchers, useClaimState, useClaimTimeInfo } from 'state/claim/hooks'
import { useClaimState, useClaimTimeInfo } from 'state/claim/hooks'
import { ClaimStatus } from 'state/claim/actions'

type ClaimIntroductionProps = Pick<ClaimCommonTypes, 'hasClaims'> & {
type ClaimIntroductionProps = Pick<ClaimCommonTypes, 'hasClaims' | 'handleChangeAccount'> & {
isAirdropOnly: boolean
}

export default function CanUserClaimMessage({ hasClaims, isAirdropOnly }: ClaimIntroductionProps) {
export default function CanUserClaimMessage({ hasClaims, isAirdropOnly, handleChangeAccount }: ClaimIntroductionProps) {
const { activeClaimAccount, claimStatus } = useClaimState()
const { setActiveClaimAccount } = useClaimDispatchers()

const { airdropDeadline } = useClaimTimeInfo()

Expand All @@ -39,7 +38,7 @@ export default function CanUserClaimMessage({ hasClaims, isAirdropOnly }: ClaimI
<IntroDescription center>
<Trans>
Unfortunately this account is not eligible for any vCOW claims. <br />
<ButtonSecondary onClick={() => setActiveClaimAccount('')} padding="0">
<ButtonSecondary onClick={handleChangeAccount} padding="0">
Try another account
</ButtonSecondary>{' '}
or <ExternalLink href="https://cow.fi/">read more about vCOW</ExternalLink>
Expand Down
16 changes: 9 additions & 7 deletions src/custom/pages/Claim/ClaimNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@ export default function ClaimNav({ account, handleChangeAccount }: ClaimNavProps
const { setActiveClaimAccount } = useClaimDispatchers()

const isAttempting = useMemo(() => claimStatus === ClaimStatus.ATTEMPTING, [claimStatus])

if (!activeClaimAccount) return null
const hasActiveAccount = activeClaimAccount !== ''

return (
<TopNav>
<ClaimAccount>
<div>
<Identicon account={activeClaimAccount} size={46} />
<p>{activeClaimAccountENS ? activeClaimAccountENS : shortenAddress(activeClaimAccount)}</p>
{hasActiveAccount && (
<>
<Identicon account={activeClaimAccount} size={46} />
<p>{activeClaimAccountENS ? activeClaimAccountENS : shortenAddress(activeClaimAccount)}</p>
</>
)}
</div>

<ClaimAccountButtons>
{!!account && account !== activeClaimAccount && (
{!!account && (account !== activeClaimAccount || activeClaimAccount === '') && (
<ButtonSecondary disabled={isAttempting} onClick={() => setActiveClaimAccount(account)}>
Switch to connected account
</ButtonSecondary>
Expand All @@ -36,7 +38,7 @@ export default function ClaimNav({ account, handleChangeAccount }: ClaimNavProps
* last investment step
* attempted claim in progress
*/}
{(investFlowStep < 2 || !isAttempting) && (
{hasActiveAccount && (investFlowStep < 2 || !isAttempting) && (
<ButtonSecondary disabled={isAttempting} onClick={handleChangeAccount}>
Change account
</ButtonSecondary>
Expand Down
6 changes: 5 additions & 1 deletion src/custom/pages/Claim/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ export default function Claim() {
{/* Get address/ENS (user not connected yet or opted for checking 'another' account) */}
<ClaimAddress account={account} toggleWalletModal={toggleWalletModal} />
{/* Is Airdrop only (simple) - does user have claims? Show messages dependent on claim state */}
<CanUserClaimMessage hasClaims={hasClaims} isAirdropOnly={isAirdropOnly} />
<CanUserClaimMessage
hasClaims={hasClaims}
isAirdropOnly={isAirdropOnly}
handleChangeAccount={handleChangeAccount}
/>

{/* Try claiming or inform succesfull claim */}
<ClaimingStatus />
Expand Down