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

Commit

Permalink
Adding errorState in useFetchProfile (#1745)
Browse files Browse the repository at this point in the history
* Adding errorState in useFetchProfile
  • Loading branch information
henrypalacios authored Nov 8, 2021
1 parent 2c121be commit 7e08a83
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/custom/hooks/useFetchProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { ProfileData } from 'api/gnosisProtocol/api'

type FetchProfileState = {
profileData: ProfileData | null
//error: string
error: string
isLoading: boolean
}

const emptyState: FetchProfileState = {
profileData: null,
//error: '',
error: '',
isLoading: false,
}

Expand Down
23 changes: 17 additions & 6 deletions src/custom/pages/Profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,24 @@ import { SupportedChainId as ChainId } from 'constants/chains'
export default function Profile() {
const referralLink = useReferralLink()
const { account, chainId } = useActiveWeb3React()
const { profileData, isLoading } = useFetchProfile()
const { profileData, isLoading, error } = useFetchProfile()
const lastUpdated = useTimeAgo(profileData?.lastUpdated)

const renderNotificationMessages = (
<>
{error && (
<StyledNotificationBanner isVisible level="error" canClose={false}>
There was an error loading your profile data. Please try again later.
</StyledNotificationBanner>
)}
{chainId && chainId !== ChainId.MAINNET && (
<StyledNotificationBanner isVisible level="info" canClose={false}>
Profile data is only available for mainnet. Please change the network to see it.
</StyledNotificationBanner>
)}
</>
)

return (
<Wrapper>
<GridWrap>
Expand Down Expand Up @@ -57,11 +72,7 @@ export default function Profile() {
</Loader>
)}
</CardHead>
{chainId && chainId !== ChainId.MAINNET && (
<StyledNotificationBanner isVisible level="info" canClose={false}>
Profile data is only available for mainnet. Please change the network to see it.
</StyledNotificationBanner>
)}
{renderNotificationMessages}
<ChildWrapper>
<Txt fs={16}>
<strong>Your referral url</strong>
Expand Down

0 comments on commit 7e08a83

Please sign in to comment.