direct user to login on certain actions

This commit is contained in:
keyan 2021-05-20 14:41:21 -05:00
parent a68da87382
commit d8ae6ecb04
3 changed files with 29 additions and 15 deletions

View File

@ -47,9 +47,13 @@ export default function Header () {
<Link href='/recent' passHref>
<NavDropdown.Item>recent</NavDropdown.Item>
</Link>
<Link href='/post' passHref>
<NavDropdown.Item>post</NavDropdown.Item>
</Link>
{session
? (
<Link href='/post' passHref>
<NavDropdown.Item>post</NavDropdown.Item>
</Link>
)
: <NavDropdown.Item onClick={signIn}>post</NavDropdown.Item>}
<NavDropdown.Item href='https://bitcoinerjobs.co' target='_blank'>jobs</NavDropdown.Item>
</div>
<NavDropdown.Divider />
@ -84,9 +88,13 @@ export default function Header () {
</Link>
</Nav.Item>
<Nav.Item className='d-md-flex d-none'>
<Link href='/post' passHref>
<Nav.Link className={styles.navLink}>post</Nav.Link>
</Link>
{session
? (
<Link href='/post' passHref>
<Nav.Link className={styles.navLink}>post</Nav.Link>
</Link>
)
: <Nav.Link className={styles.navLink} onClick={signIn}>post</Nav.Link>}
</Nav.Item>
<Nav.Item className='d-md-flex d-none'>
<Nav.Link href='https://bitcoinerjobs.co' target='_blank' className={styles.navLink}>jobs</Nav.Link>

View File

@ -20,7 +20,7 @@ export default function Item ({ item, rank, children }) {
<a className={`${styles.title} text-reset flex-md-shrink-0 mr-2`}>{item.title}</a>
</Link>
{item.url &&
<a className={styles.link} href={item.url} rel={item.sats > 5 ? null : 'nofollow'}>
<a className={styles.link} href={item.url} rel={item.sats + item.boost >= 10 ? null : 'nofollow'}>
{item.url.replace(/(^https?:|^)\/\//, '')}
</a>}
</div>

View File

@ -2,8 +2,10 @@ import { LightningConsumer } from './lightning'
import UpArrow from '../svgs/lightning-arrow.svg'
import styles from './upvote.module.css'
import { gql, useMutation } from '@apollo/client'
import { signIn, useSession } from 'next-auth/client'
export default function UpVote ({ itemId, meSats, className }) {
const [session] = useSession()
const [vote] = useMutation(
gql`
mutation vote($id: ID!, $sats: Int!) {
@ -39,15 +41,19 @@ export default function UpVote ({ itemId, meSats, className }) {
${className || ''}
${meSats ? (meSats > 1 ? styles.stimi : styles.voted) : ''}`
}
onClick={async () => {
if (!itemId) return
const { error } = await vote({ variables: { id: itemId, sats: 1 } })
if (error) {
throw new Error({ message: error.toString() })
}
onClick={
session
? async () => {
if (!itemId) return
const { error } = await vote({ variables: { id: itemId, sats: 1 } })
if (error) {
throw new Error({ message: error.toString() })
}
strike()
}}
strike()
}
: signIn
}
/>}
</LightningConsumer>
)