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

Commit

Permalink
Remove Loading Component added on 1753
Browse files Browse the repository at this point in the history
  • Loading branch information
henrypalacios committed Nov 5, 2021
1 parent 1ba6f4c commit 37f8dea
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
5 changes: 3 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 All @@ -22,6 +22,7 @@ export default function useFetchProfile(): FetchProfileState {
const [profile, setProfile] = useState<FetchProfileState>(emptyState)

useEffect(() => {
setProfile({ ...emptyState, isLoading: true })
async function fetchAndSetProfileData() {
try {
if (chainId && account) {
Expand Down
25 changes: 19 additions & 6 deletions src/custom/pages/Profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,26 @@ 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 = () => {
return (
<>
{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 +74,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 37f8dea

Please sign in to comment.