Skip to content

Commit

Permalink
Change open sign in to redirect to login page
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Mar 6, 2024
1 parent db60bd6 commit 38fc43a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/posts/share/SharePostLink.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -22,7 +23,6 @@ export const SharePostLink = ({
},
}: Props) => {
const {
openSignInModal,
state: {
completedSteps: { isSignedIn },
},
Expand All @@ -35,7 +35,7 @@ export const SharePostLink = ({
<>
<a
className='DfBlackLink'
onClick={() => (isSignedIn ? setOpen(true) : openSignInModal())}
onClick={() => (isSignedIn ? setOpen(true) : redirectToLogin())}
title={title}
>
<IconWithLabel icon={EditIcon} label={title} />
Expand Down
8 changes: 3 additions & 5 deletions src/components/voting/SuperLike.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions src/utils/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

0 comments on commit 38fc43a

Please sign in to comment.