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

Adding errorState in useFetchProfile #1745

Merged
merged 2 commits into from
Nov 8, 2021
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
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