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

Simplify links #2266

Merged
merged 2 commits into from
Jan 24, 2022
Merged
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
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 &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might as well make this it's on state const to or is this for TS complaining about account?

allowToChangeAccount && (
<ButtonSecondary onClick={() => setActiveClaimAccount(account)}>
Switch to connected account
</ButtonSecondary>
)
)}
</ClaimAccountButtons>
</ClaimAccount>
Expand Down