Skip to content

Commit

Permalink
anon user bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasbindar Singh authored and Jasbindar Singh committed Jun 13, 2020
1 parent f65b574 commit 39b8322
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/ShareScreen/ShareScreen.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import React, { useEffect, useState } from 'react'
import React, { useEffect, useState, useContext } from 'react'
import { useParams } from 'react-router-dom';
import { firestore } from '../configs/firebase';
import MainLoader from '../Loader/MainLoader';
import { Icon } from '@iconify/react';
import bxBookmarkPlus from '@iconify/icons-bx/bx-bookmark-plus';
import bxError from '@iconify/icons-bx/bx-error';
import ModalSave from '../Modal/ModalSave';
import { AuthContext } from '../App';

function ShareScreen() {

let { userId, noteId } = useParams()
let { currentUser } = useContext(AuthContext)

const [note, setNote] = useState({});
const [error, setError] = useState(false);
Expand Down Expand Up @@ -37,6 +39,8 @@ function ShareScreen() {
})
}, [userId, noteId])

const isAnonymous = !!currentUser ? currentUser.isAnonymous : false;

return (
<>
{
Expand All @@ -58,10 +62,18 @@ function ShareScreen() {
<span className="text-sm lg:text-lg">{note.title}</span>
<span className="text-xs">By&nbsp;{note.author}</span>
</div>
<ul className={`flex justify-between text-base items-center`}>
<li className="px-4 cursor-pointer"><Icon icon={bxBookmarkPlus} style={{color: '#fff', fontSize: '25px'}} onClick={toggleSave}/></li>
</ul>
<ModalSave isModalOpen={isSaveModalOpen} toggle={toggleSave} noteData={note}/>
{
isAnonymous ? (
null
) : (
<>
<ul className={`flex justify-between text-base items-center`}>
<li className="px-4 cursor-pointer"><Icon icon={bxBookmarkPlus} style={{color: '#fff', fontSize: '25px'}} onClick={toggleSave}/></li>
</ul>
<ModalSave isModalOpen={isSaveModalOpen} toggle={toggleSave} noteData={note}/>
</>
)
}
</>
)
}
Expand Down

0 comments on commit 39b8322

Please sign in to comment.