-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: React query 5-3, Authentication wrapper component (#1861)
Co-authored-by: Nikita Boakrev <right2maresko@gmail.com>
- Loading branch information
1 parent
f27b337
commit ccbd630
Showing
33 changed files
with
266 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Box, CircularProgress } from '@mui/material'; | ||
import React, { ReactNode } from 'react'; | ||
import { | ||
ExtendedFormattedUser, | ||
useAppDataContext, | ||
} from 'src/hooks/app-data-provider/useAppDataProvider'; | ||
import invariant from 'tiny-invariant'; | ||
|
||
interface UserAuthenticatedProps { | ||
children: (user: ExtendedFormattedUser) => ReactNode; | ||
} | ||
|
||
export const UserAuthenticated = ({ children }: UserAuthenticatedProps) => { | ||
const { user, loading } = useAppDataContext(); | ||
if (loading) { | ||
return ( | ||
<Box sx={{ width: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' }}> | ||
<CircularProgress /> | ||
</Box> | ||
); | ||
} | ||
invariant(user, 'User data loaded but no user found'); | ||
return <>{children(user)}</>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
src/components/transactions/ClaimRewards/ClaimRewardsModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
import React from 'react'; | ||
import { UserAuthenticated } from 'src/components/UserAuthenticated'; | ||
import { useAppDataContext } from 'src/hooks/app-data-provider/useAppDataProvider'; | ||
import { ModalType, useModalContext } from 'src/hooks/useModal'; | ||
|
||
import { BasicModal } from '../../primitives/BasicModal'; | ||
import { ClaimRewardsModalContent } from './ClaimRewardsModalContent'; | ||
|
||
export const ClaimRewardsModal = () => { | ||
const { type, close } = useModalContext(); | ||
const { reserves } = useAppDataContext(); | ||
return ( | ||
<BasicModal open={type === ModalType.ClaimRewards} setOpen={close}> | ||
<ClaimRewardsModalContent /> | ||
<UserAuthenticated> | ||
{(user) => <ClaimRewardsModalContent user={user} reserves={reserves} />} | ||
</UserAuthenticated> | ||
</BasicModal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
ccbd630
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit was deployed on ipfs