From 38fc43a8c6167e23120aaed343606f030d817bf6 Mon Sep 17 00:00:00 2001 From: teodorus-nathaniel Date: Wed, 6 Mar 2024 20:00:30 +0700 Subject: [PATCH] Change open sign in to redirect to login page --- src/components/posts/share/SharePostLink.tsx | 4 ++-- src/components/voting/SuperLike.tsx | 8 +++----- src/utils/url.ts | 5 +++++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/posts/share/SharePostLink.tsx b/src/components/posts/share/SharePostLink.tsx index 76c28d41c..d39838209 100644 --- a/src/components/posts/share/SharePostLink.tsx +++ b/src/components/posts/share/SharePostLink.tsx @@ -1,6 +1,7 @@ import { EditOutlined } from '@ant-design/icons' import React, { useState } from 'react' import { PostWithSomeDetails } from 'src/types' +import { redirectToLogin } from 'src/utils/url' import { useAuth } from '../../auth/AuthContext' import { IconWithLabel } from '../../utils' import { SharePostModal } from './ShareModal' @@ -22,7 +23,6 @@ export const SharePostLink = ({ }, }: Props) => { const { - openSignInModal, state: { completedSteps: { isSignedIn }, }, @@ -35,7 +35,7 @@ export const SharePostLink = ({ <> (isSignedIn ? setOpen(true) : openSignInModal())} + onClick={() => (isSignedIn ? setOpen(true) : redirectToLogin())} title={title} > diff --git a/src/components/voting/SuperLike.tsx b/src/components/voting/SuperLike.tsx index 007b6e7c3..682125f76 100644 --- a/src/components/voting/SuperLike.tsx +++ b/src/components/voting/SuperLike.tsx @@ -31,7 +31,7 @@ import { useFetchTotalStake } from 'src/rtk/features/creators/totalStakeHooks' import { useMyAccount } from 'src/stores/my-account' import { getAmountRange } from 'src/utils/analytics' import { getSubIdCreatorsLink } from 'src/utils/links' -import { useAuth } from '../auth/AuthContext' +import { redirectToLogin } from 'src/utils/url' import { useMyAddress } from '../auth/MyAccountsContext' import { IconWithLabel } from '../utils' import CustomModal from '../utils/CustomModal' @@ -77,13 +77,11 @@ export default function SuperLike({ post, iconClassName, isComment, ...props }: const canBeSuperliked = clientCanPostSuperLiked && canPostSuperLiked const isDisabled = !canBeSuperliked || isMyPost || loadingTotalStake || !superLikeMessage.message - const { openSignInModal } = useAuth() - const onClick = async () => { if (isActive || isDisabled) return - if (!myGrillAddress) { - openSignInModal() + if (!myAddress || !myGrillAddress) { + redirectToLogin() return } if (!totalStake?.hasStakedEnough) { diff --git a/src/utils/url.ts b/src/utils/url.ts index a93b61151..ee15dc85d 100644 --- a/src/utils/url.ts +++ b/src/utils/url.ts @@ -35,3 +35,8 @@ export function getUrlQuery(queryName: string) { const searchParams = new URLSearchParams(query) return searchParams.get(queryName) ?? '' } + +export function redirectToLogin() { + if (isServerSide()) return + window.location.href = '/c/widget/login' +}