Skip to content
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

Add reject modal icon && Test Creation flow #1711

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/components/chat/unlockProfile/UnlockProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ const UnlockProfile = ({ InnerComponentProps, onClose }: UnlockProfileModalProps
<HoverableSVG
icon={
<CrossFilled
size={24}
color="pink-700"
size={30}
color="gray-400"
onClick={onClose}
/>
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/chat/unlockProfile/UnlockProfileWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface IntroContainerProps {
type?: UNLOCK_PROFILE_TYPE;
showConnectModal?: boolean;
description?: string;
onClose?: () => void;
handleClose?: () => void;
corlard3y marked this conversation as resolved.
Show resolved Hide resolved
closeIcon?: boolean;
corlard3y marked this conversation as resolved.
Show resolved Hide resolved
}

Expand All @@ -25,7 +25,7 @@ const UnlockProfileWrapper = ({
type = DEFAULT_PROPS.type,
showConnectModal,
description,
onClose,
handleClose,
closeIcon,
}: IntroContainerProps) => {
const {
Expand All @@ -38,7 +38,7 @@ const UnlockProfileWrapper = ({
if (type === UNLOCK_PROFILE_TYPE.MODAL && showConnectModal) {
showProfileModal();
}
}, [type]);
}, [type, showConnectModal]);

if (type === UNLOCK_PROFILE_TYPE.MODAL) {
return (
Expand Down
4 changes: 3 additions & 1 deletion src/modules/rewards/Rewards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Rewards: FC<RewardsProps> = () => {

const { activeTab, handleSetActiveTab } = useRewardsTabs();

const { showConnectModal, setShowConnectModal, status, connectUserWallet } = useRewardsAuth();
const { showConnectModal, setShowConnectModal, status, connectUserWallet, toggleModalOff } = useRewardsAuth();

useCreateRewardsUser();

Expand Down Expand Up @@ -115,6 +115,8 @@ const Rewards: FC<RewardsProps> = () => {
<UnlockProfileWrapper
type={UNLOCK_PROFILE_TYPE.MODAL}
showConnectModal={showConnectModal}
handleClose={() => toggleModalOff()}
closeIcon={true}
corlard3y marked this conversation as resolved.
Show resolved Hide resolved
description="Unlock your profile to proceed."
/>
</Box>
Expand Down
63 changes: 26 additions & 37 deletions src/modules/rewards/components/ActivityVerificationButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { UserStoreType } from 'types';
// components
import { Box, Button } from 'blocks';
import UnlockProfileWrapper, { UNLOCK_PROFILE_TYPE } from 'components/chat/unlockProfile/UnlockProfileWrapper';
import { useRewardsAuth } from '../hooks/useRewardsAuth';

type ActivityVerificationButtonProps = {
userId: string;
Expand All @@ -38,8 +37,6 @@ export const ActivityVerificationButton = ({
const { isWalletConnected } = useAccount();
const { userPushSDKInstance } = useSelector((state: UserStoreType) => state.user);

// const { setShowConnectModal } = useRewardsAuth();

const { handleTwitterVerification } = useVerifyTwitter({
activityTypeId,
refetchActivity,
Expand Down Expand Up @@ -70,42 +67,10 @@ export const ActivityVerificationButton = ({
}
}, [activityType, userPushSDKInstance]);

const { isAuthenticated, authButton, showConnectModal, setShowConnectModal } = useAuthWithButton({
const { isAuthenticated, authButton, showConnectModal, toggleModalOff } = useAuthWithButton({
corlard3y marked this conversation as resolved.
Show resolved Hide resolved
onSuccess: (userDetails) => activityData?.action(userDetails?.userId),
});

const handleCloseModal = () => {
setShowConnectModal(false);
};

console.log('Modal closed');
console.log('isAuthenticated:', isAuthenticated);
console.log('isWalletConnected:', isWalletConnected);
console.log('showConnectModal:', showConnectModal);

if (userPushSDKInstance && userPushSDKInstance?.readmode() && showConnectModal) {
return (
<Box
display="flex"
justifyContent="center"
width="-webkit-fill-available"
height="-webkit-fill-available"
alignItems="center"
css={css`
z-index: 99999;
`}
>
<UnlockProfileWrapper
type={UNLOCK_PROFILE_TYPE.MODAL}
showConnectModal={showConnectModal}
// onClose={handleCloseModal}
// closeIcon={true}
description="Unlock your profile to proceed."
/>
</Box>
);
}

if (isAuthenticated && isWalletConnected && !userPushSDKInstance?.readmode()) {
return (
<Button
Expand All @@ -118,5 +83,29 @@ export const ActivityVerificationButton = ({
);
}

return authButton;
return (
<Box>
{userPushSDKInstance && userPushSDKInstance?.readmode() && showConnectModal && (
<Box
display="flex"
justifyContent="center"
width="-webkit-fill-available"
height="-webkit-fill-available"
alignItems="center"
css={css`
z-index: 99999;
`}
>
<UnlockProfileWrapper
type={UNLOCK_PROFILE_TYPE.MODAL}
showConnectModal={showConnectModal}
handleClose={() => toggleModalOff()}
closeIcon={true}
corlard3y marked this conversation as resolved.
Show resolved Hide resolved
description="Unlock your profile to proceed."
/>
</Box>
)}
{authButton}
</Box>
);
};
1 change: 1 addition & 0 deletions src/modules/rewards/components/RewardsActivitiesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const RewardsActivitiesList: FC<RewardActivitiesProps> = () => {
>
{activityList.map((activity: Activity) => (
<RewardsActivitiesListItem
key={activity.activityType}
userId={userDetails?.userId || ''}
activity={activity}
isLoadingItem={isLoading}
Expand Down
12 changes: 12 additions & 0 deletions src/modules/rewards/hooks/useRewardsAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const useRewardsAuth = () => {
const connectWallet = () => {
setHandleVerify(false);
setIsVerifyClicked(true);
setShowConnectModal(false);

if (!isWalletConnected) {
connect();
Expand All @@ -52,9 +53,18 @@ const useRewardsAuth = () => {

// dashboard referral section unlock profile
const connectUserWallet = () => {
setShowConnectModal(false);
setIsDashClicked(true);
};

const toggleModalOn = () => {
setShowConnectModal(true);
};

const toggleModalOff = () => {
setShowConnectModal(false);
};
corlard3y marked this conversation as resolved.
Show resolved Hide resolved

// unlock profile function
const unlockProfile = async () => {
// get ref, send with user wallet. if ref is null, send only user wallet
Expand Down Expand Up @@ -125,6 +135,8 @@ const useRewardsAuth = () => {
isVerifyClicked,
connectUserWallet,
isDashClicked,
toggleModalOff,
toggleModalOn,
corlard3y marked this conversation as resolved.
Show resolved Hide resolved
};
};

Expand Down
12 changes: 11 additions & 1 deletion src/modules/rewards/hooks/useWithAuthButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ export const useAuthWithButton = ({ onSuccess }: { onSuccess: (userDetails: User
const { isWalletConnected } = useAccount();
const { userPushSDKInstance } = useSelector((state: UserStoreType) => state.user);

const { showConnectModal, setShowConnectModal, connectWallet, handleVerify, userDetails } = useRewardsAuth();
const {
showConnectModal,
setShowConnectModal,
connectWallet,
handleVerify,
userDetails,
toggleModalOff,
toggleModalOn,
corlard3y marked this conversation as resolved.
Show resolved Hide resolved
} = useRewardsAuth();
const { isSuccess, isUserProfileUnlocked } = useCreateRewardsUser();

const showAuthModal = async () => {
Expand Down Expand Up @@ -76,5 +84,7 @@ export const useAuthWithButton = ({ onSuccess }: { onSuccess: (userDetails: User
isAuthenticated: isWalletConnectedAndProfileUnlocked,
showConnectModal: showConnectModal,
setShowConnectModal: setShowConnectModal,
toggleModalOff: toggleModalOff,
toggleModalOn: toggleModalOn,
corlard3y marked this conversation as resolved.
Show resolved Hide resolved
};
};
Loading