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

Prompting Unauthenticated Users to sign in first to upvote a story #163

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
5 changes: 4 additions & 1 deletion src/components/AuthWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import LanguageDropdown from './LanguageDropdown'
import eosIcon from '../assets/images/user-story-logo.svg'
import SocialMediaLinks from '../components/SocialMediaLinks'
import { EOS_COPYRIGHT } from 'eos-icons-react'
import { Link } from '@reach/router'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this issue seems to already have been addressed in #162

Please remove these changes from this PR so that the other one can be merged

export const AuthWrapper = ({ children }) => {
return (
<div className='authentication-wrapper'>
Expand Down Expand Up @@ -43,7 +44,9 @@ export const AuthRightContainer = ({ children, logo }) => {
<div className='container-right'>
<div className='flex flex-row flex-space-between'>
<div className='image image-logo eos-logo-resize'>
<img src={logo ?? eosIcon} alt='EOS Logo' />
<Link className='link' data-cy='nav-eos-logo' to='/'>
<img className='logo' src={eosIcon} alt='EOS Logo' />
</Link>
</div>
<LanguageDropdown translator={i18n} />
</div>
Expand Down
38 changes: 34 additions & 4 deletions src/components/StoryPageTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const StoryPageTimeline = (props) => {

const [isOpen, setIsOpen] = useState(false)

const [showLog, setShowLog] = useState(false)

const [previousStatuses, setPreviousStatuses] = useState([])

const togglePopup = () => {
Expand Down Expand Up @@ -88,11 +90,15 @@ const StoryPageTimeline = (props) => {
>
<div
data-cy='story-vote-btn'
className={`story-vote-button ${
userId ? 'story-vote-button-clickable' : ''
}`}
className={`story-vote-button story-vote-button-clickable`}
onClick={() => {
if (userId && !voteClicked) updateVote(story)
if (userId && !voteClicked) {
updateVote(story)
console.log('even after being logged')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid leaving console logs in production. They don't add value to users

} else if (!userId) {
console.log('Not loged In')
setShowLog(!showLog)
}
}}
>
<EOS_THUMB_UP className='eos-icons' color='white' size='l' />
Expand All @@ -104,6 +110,30 @@ const StoryPageTimeline = (props) => {
>
{votes} Votes
</div>
{showLog && (
<>
<Modal
content={
<>
<div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try not to use too many empty divs that don't even have classes. Titles are display block elements, they don't need to be encapsulated in divs

<h1>Oops! You're not signed In</h1>
<div>
<h2>
<Link className='btn' data-cy='btn-signin' to='/login'>
Sign-In to UpVote :)
</Link>
</h2>
</div>
</div>
</>
}
handleClose={() => {
setShowLog(!showLog)
}}
active={showLog}
/>
</>
)}
{isOpen && (
<Modal
content={
Expand Down
8 changes: 6 additions & 2 deletions src/components/Vote.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ const Vote = (props) => {
{votes}
</div>
<div
className={`vote-button ${userId ? 'vote-button-clickable' : ''}`}
className={`vote-button`}
onClick={() => {
if (userId && !voteClicked) updateVote(story)
if (userId && !voteClicked) {
updateVote(story)
} else if (!userId) {
console.log('Not loged In')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid leaving console logs in production. They don't add value to users

}
}}
>
<EOS_THUMB_UP className='eos-icons' color='white' />
Expand Down