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

Commit

Permalink
Simplify links (#2266)
Browse files Browse the repository at this point in the history
* Simplify links

* Remove unused
  • Loading branch information
anxolin authored Jan 24, 2022
1 parent b7f82f0 commit 71ecc44
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/custom/pages/Claim/ClaimNav.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useMemo } from 'react'
import { ButtonSecondary } from 'components/Button'
import { shortenAddress } from 'utils'
import { TopNav, ClaimAccount, ClaimAccountButtons } from './styled'
Expand All @@ -13,8 +12,10 @@ export default function ClaimNav({ account, handleChangeAccount }: ClaimNavProps
const { activeClaimAccount, activeClaimAccountENS, claimStatus, investFlowStep } = useClaimState()
const { setActiveClaimAccount } = useClaimDispatchers()

const isAttempting = useMemo(() => claimStatus === ClaimStatus.ATTEMPTING, [claimStatus])
const isDefaultStatus = claimStatus === ClaimStatus.DEFAULT
const isConfirmed = claimStatus === ClaimStatus.CONFIRMED
const hasActiveAccount = activeClaimAccount !== ''
const allowToChangeAccount = investFlowStep < 2 && (isDefaultStatus || isConfirmed)

return (
<TopNav>
Expand All @@ -28,20 +29,15 @@ export default function ClaimNav({ account, handleChangeAccount }: ClaimNavProps
)}
</div>
<ClaimAccountButtons>
{!!account && (account !== activeClaimAccount || activeClaimAccount === '') && (
<ButtonSecondary disabled={isAttempting} onClick={() => setActiveClaimAccount(account)}>
Switch to connected account
</ButtonSecondary>
)}

{/* Hide account changing action on:
* last investment step
* attempted claim in progress
*/}
{hasActiveAccount && (investFlowStep < 2 || !isAttempting) && (
<ButtonSecondary disabled={isAttempting} onClick={handleChangeAccount}>
Change account
</ButtonSecondary>
{allowToChangeAccount && hasActiveAccount ? (
<ButtonSecondary onClick={handleChangeAccount}>Change account</ButtonSecondary>
) : (
!!account &&
allowToChangeAccount && (
<ButtonSecondary onClick={() => setActiveClaimAccount(account)}>
Switch to connected account
</ButtonSecondary>
)
)}
</ClaimAccountButtons>
</ClaimAccount>
Expand Down

0 comments on commit 71ecc44

Please sign in to comment.