-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Rewards Dashboard flow #1699
Changes from 4 commits
bdb8c08
4d35a54
1ad5156
ab62390
7ca1089
2a8d041
3b13c1d
7801343
df203a9
a070b1e
2f51792
d800efb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -11,14 +11,15 @@ export enum UNLOCK_PROFILE_TYPE { | |||||
|
||||||
interface IntroContainerProps { | ||||||
type?: UNLOCK_PROFILE_TYPE; | ||||||
showConnectModal?: boolean | ||||||
showConnectModal?: boolean; | ||||||
label?: string; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
const DEFAULT_PROPS = { | ||||||
type: UNLOCK_PROFILE_TYPE.MODAL, | ||||||
}; | ||||||
|
||||||
const UnlockProfileWrapper = ({ type = DEFAULT_PROPS.type, showConnectModal }: IntroContainerProps) => { | ||||||
const UnlockProfileWrapper = ({ type = DEFAULT_PROPS.type, showConnectModal, label }: IntroContainerProps) => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const { | ||||||
isModalOpen: isProfileModalOpen, | ||||||
showModal: showProfileModal, | ||||||
|
@@ -31,12 +32,15 @@ const UnlockProfileWrapper = ({ type = DEFAULT_PROPS.type, showConnectModal }: I | |||||
} | ||||||
}, [type]); | ||||||
|
||||||
console.log(label, 'label'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
if (type === UNLOCK_PROFILE_TYPE.MODAL) { | ||||||
return ( | ||||||
<ProfileModalComponent | ||||||
InnerComponent={UnlockProfile} | ||||||
InnerComponentProps={{ | ||||||
type, | ||||||
label, | ||||||
}} | ||||||
modalRadius="24px" | ||||||
modalBorder={false} | ||||||
|
@@ -46,7 +50,7 @@ const UnlockProfileWrapper = ({ type = DEFAULT_PROPS.type, showConnectModal }: I | |||||
} else { | ||||||
return ( | ||||||
<Container className={type}> | ||||||
<UnlockProfile InnerComponentProps={{ type }} /> | ||||||
<UnlockProfile InnerComponentProps={{ type, label }} /> | ||||||
</Container> | ||||||
); | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,35 +1,37 @@ | ||||||
// React and other libraries | ||||||
import { FC, useEffect } from 'react'; | ||||||
import { FC, useEffect, useContext } from 'react'; | ||||||
|
||||||
// third party libraries | ||||||
import { css } from 'styled-components'; | ||||||
import { useSelector } from 'react-redux'; | ||||||
import { css } from 'styled-components'; | ||||||
|
||||||
//Hooks | ||||||
import { useAccount } from 'hooks'; | ||||||
import { useRewardsTabs } from './hooks/useRewardsTabs'; | ||||||
import { useGenerateUserId } from './hooks/useGenerateUserId'; | ||||||
import { useDiscordSession } from './hooks/useDiscordSession'; | ||||||
import { useGenerateUserId } from './hooks/useGenerateUserId'; | ||||||
|
||||||
//Types | ||||||
import { UserStoreType } from 'types'; | ||||||
import { UNLOCK_PROFILE_TYPE } from 'components/chat/unlockProfile/UnlockProfile'; | ||||||
|
||||||
//helpers | ||||||
import { walletToCAIP10 } from 'helpers/w2w'; | ||||||
import { AppContext } from 'contexts/AppContext'; | ||||||
|
||||||
//Components | ||||||
import { Box, Text } from 'blocks'; | ||||||
import { ReferralSection } from './components/ReferralSection'; | ||||||
import { RewardsTabsContainer } from './components/RewardsTabsContainer'; | ||||||
import UnlockProfileWrapper from 'components/chat/unlockProfile/UnlockProfileWrapper'; | ||||||
import UnlockProfileWrapper, { UNLOCK_PROFILE_TYPE } from 'components/chat/unlockProfile/UnlockProfileWrapper'; | ||||||
import { AppContextType } from 'types/context'; | ||||||
|
||||||
export type RewardsProps = {}; | ||||||
|
||||||
const Rewards: FC<RewardsProps> = () => { | ||||||
const { userPushSDKInstance } = useSelector((state: UserStoreType) => state.user); | ||||||
|
||||||
const { account } = useAccount(); | ||||||
const { account, isWalletConnected } = useAccount(); | ||||||
const { isUserProfileUnlocked } = useContext<AppContextType>(AppContext); | ||||||
|
||||||
const caip10WalletAddress = walletToCAIP10({ account }); | ||||||
|
||||||
|
@@ -38,20 +40,35 @@ const Rewards: FC<RewardsProps> = () => { | |||||
|
||||||
const { activeTab, handleSetActiveTab } = useRewardsTabs(); | ||||||
|
||||||
const { showConnectModal, setConnectModalVisibility } = useGenerateUserId(caip10WalletAddress); | ||||||
const { showConnectModal, setConnectModalVisibility, unlockUser, handleCreateUser, isPending, status } = | ||||||
useGenerateUserId(caip10WalletAddress); | ||||||
|
||||||
useEffect(() => { | ||||||
if (activeTab !== 'activity') { | ||||||
setConnectModalVisibility(false); | ||||||
} | ||||||
|
||||||
if (activeTab === 'activity' && userPushSDKInstance && userPushSDKInstance.readmode()) { | ||||||
if (status == 'success' && activeTab === 'activity' && userPushSDKInstance && userPushSDKInstance.readmode()) { | ||||||
setConnectModalVisibility(true); | ||||||
} | ||||||
}, [activeTab, account, userPushSDKInstance]); | ||||||
}, [account, userPushSDKInstance, activeTab]); | ||||||
|
||||||
useEffect(() => { | ||||||
if (isUserProfileUnlocked && userPushSDKInstance) { | ||||||
handleCreateUser(); | ||||||
} | ||||||
}, [userPushSDKInstance, isUserProfileUnlocked]); | ||||||
|
||||||
const heading = activeTab === 'leaderboard' ? 'Push Reward Points' : 'Introducing Push Reward Points Program'; | ||||||
|
||||||
const handleUser = () => { | ||||||
if (isUserProfileUnlocked) { | ||||||
handleCreateUser(); | ||||||
} else { | ||||||
unlockUser(); | ||||||
} | ||||||
}; | ||||||
|
||||||
return ( | ||||||
<Box | ||||||
height="100%" | ||||||
|
@@ -83,10 +100,15 @@ const Rewards: FC<RewardsProps> = () => { | |||||
handleSetActiveTab={handleSetActiveTab} | ||||||
/> | ||||||
|
||||||
{activeTab === 'dashboard' && <ReferralSection />} | ||||||
{activeTab === 'dashboard' && ( | ||||||
<ReferralSection | ||||||
generateUser={handleUser} | ||||||
isPending={isPending} | ||||||
/> | ||||||
)} | ||||||
</Box> | ||||||
|
||||||
{userPushSDKInstance && userPushSDKInstance?.readmode() && showConnectModal && ( | ||||||
{isWalletConnected && userPushSDKInstance && userPushSDKInstance?.readmode() && showConnectModal && ( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
<Box | ||||||
display="flex" | ||||||
justifyContent="center" | ||||||
|
@@ -99,6 +121,7 @@ const Rewards: FC<RewardsProps> = () => { | |||||
<UnlockProfileWrapper | ||||||
type={UNLOCK_PROFILE_TYPE.MODAL} | ||||||
showConnectModal={showConnectModal} | ||||||
label="Unlock your profile to proceed." | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
/> | ||||||
</Box> | ||||||
)} | ||||||
|
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.