direct user to login on certain actions
This commit is contained in:
parent
a68da87382
commit
d8ae6ecb04
|
@ -47,9 +47,13 @@ export default function Header () {
|
||||||
<Link href='/recent' passHref>
|
<Link href='/recent' passHref>
|
||||||
<NavDropdown.Item>recent</NavDropdown.Item>
|
<NavDropdown.Item>recent</NavDropdown.Item>
|
||||||
</Link>
|
</Link>
|
||||||
|
{session
|
||||||
|
? (
|
||||||
<Link href='/post' passHref>
|
<Link href='/post' passHref>
|
||||||
<NavDropdown.Item>post</NavDropdown.Item>
|
<NavDropdown.Item>post</NavDropdown.Item>
|
||||||
</Link>
|
</Link>
|
||||||
|
)
|
||||||
|
: <NavDropdown.Item onClick={signIn}>post</NavDropdown.Item>}
|
||||||
<NavDropdown.Item href='https://bitcoinerjobs.co' target='_blank'>jobs</NavDropdown.Item>
|
<NavDropdown.Item href='https://bitcoinerjobs.co' target='_blank'>jobs</NavDropdown.Item>
|
||||||
</div>
|
</div>
|
||||||
<NavDropdown.Divider />
|
<NavDropdown.Divider />
|
||||||
|
@ -84,9 +88,13 @@ export default function Header () {
|
||||||
</Link>
|
</Link>
|
||||||
</Nav.Item>
|
</Nav.Item>
|
||||||
<Nav.Item className='d-md-flex d-none'>
|
<Nav.Item className='d-md-flex d-none'>
|
||||||
|
{session
|
||||||
|
? (
|
||||||
<Link href='/post' passHref>
|
<Link href='/post' passHref>
|
||||||
<Nav.Link className={styles.navLink}>post</Nav.Link>
|
<Nav.Link className={styles.navLink}>post</Nav.Link>
|
||||||
</Link>
|
</Link>
|
||||||
|
)
|
||||||
|
: <Nav.Link className={styles.navLink} onClick={signIn}>post</Nav.Link>}
|
||||||
</Nav.Item>
|
</Nav.Item>
|
||||||
<Nav.Item className='d-md-flex d-none'>
|
<Nav.Item className='d-md-flex d-none'>
|
||||||
<Nav.Link href='https://bitcoinerjobs.co' target='_blank' className={styles.navLink}>jobs</Nav.Link>
|
<Nav.Link href='https://bitcoinerjobs.co' target='_blank' className={styles.navLink}>jobs</Nav.Link>
|
||||||
|
|
|
@ -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>
|
<a className={`${styles.title} text-reset flex-md-shrink-0 mr-2`}>{item.title}</a>
|
||||||
</Link>
|
</Link>
|
||||||
{item.url &&
|
{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?:|^)\/\//, '')}
|
{item.url.replace(/(^https?:|^)\/\//, '')}
|
||||||
</a>}
|
</a>}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,8 +2,10 @@ import { LightningConsumer } from './lightning'
|
||||||
import UpArrow from '../svgs/lightning-arrow.svg'
|
import UpArrow from '../svgs/lightning-arrow.svg'
|
||||||
import styles from './upvote.module.css'
|
import styles from './upvote.module.css'
|
||||||
import { gql, useMutation } from '@apollo/client'
|
import { gql, useMutation } from '@apollo/client'
|
||||||
|
import { signIn, useSession } from 'next-auth/client'
|
||||||
|
|
||||||
export default function UpVote ({ itemId, meSats, className }) {
|
export default function UpVote ({ itemId, meSats, className }) {
|
||||||
|
const [session] = useSession()
|
||||||
const [vote] = useMutation(
|
const [vote] = useMutation(
|
||||||
gql`
|
gql`
|
||||||
mutation vote($id: ID!, $sats: Int!) {
|
mutation vote($id: ID!, $sats: Int!) {
|
||||||
|
@ -39,7 +41,9 @@ export default function UpVote ({ itemId, meSats, className }) {
|
||||||
${className || ''}
|
${className || ''}
|
||||||
${meSats ? (meSats > 1 ? styles.stimi : styles.voted) : ''}`
|
${meSats ? (meSats > 1 ? styles.stimi : styles.voted) : ''}`
|
||||||
}
|
}
|
||||||
onClick={async () => {
|
onClick={
|
||||||
|
session
|
||||||
|
? async () => {
|
||||||
if (!itemId) return
|
if (!itemId) return
|
||||||
const { error } = await vote({ variables: { id: itemId, sats: 1 } })
|
const { error } = await vote({ variables: { id: itemId, sats: 1 } })
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -47,7 +51,9 @@ export default function UpVote ({ itemId, meSats, className }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
strike()
|
strike()
|
||||||
}}
|
}
|
||||||
|
: signIn
|
||||||
|
}
|
||||||
/>}
|
/>}
|
||||||
</LightningConsumer>
|
</LightningConsumer>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue