fix(report): available only to logged in users

Closes #179
This commit is contained in:
enes 2025-01-15 19:32:06 +01:00
parent a97159119d
commit 4832c46548
3 changed files with 59 additions and 50 deletions

View File

@ -35,6 +35,7 @@ export const BlogPage = () => {
const isAdmin = const isAdmin =
userState.user?.npub && userState.user?.npub &&
userState.user.npub === import.meta.env.VITE_REPORTING_NPUB userState.user.npub === import.meta.env.VITE_REPORTING_NPUB
const isLoggedIn = userState.auth && userState.user?.pubkey !== 'undefined'
const navigation = useNavigation() const navigation = useNavigation()
const [commentCount, setCommentCount] = useState(0) const [commentCount, setCommentCount] = useState(0)
@ -172,23 +173,25 @@ export const BlogPage = () => {
Share Share
</a> </a>
<a {isLoggedIn && (
className='dropdown-item dropdownMainMenuItem' <a
id='reportPost' className='dropdown-item dropdownMainMenuItem'
onClick={() => setShowReportPopUp(Date.now())} id='reportPost'
> onClick={() => setShowReportPopUp(Date.now())}
<svg
xmlns='http://www.w3.org/2000/svg'
viewBox='0 0 512 512'
width='1em'
height='1em'
fill='currentColor'
className='IBMSMSMSSS_Author_Top_Icon'
> >
<path d='M506.3 417l-213.3-364c-16.33-28-57.54-28-73.98 0l-213.2 364C-10.59 444.9 9.849 480 42.74 480h426.6C502.1 480 522.6 445 506.3 417zM232 168c0-13.25 10.75-24 24-24S280 154.8 280 168v128c0 13.25-10.75 24-23.1 24S232 309.3 232 296V168zM256 416c-17.36 0-31.44-14.08-31.44-31.44c0-17.36 14.07-31.44 31.44-31.44s31.44 14.08 31.44 31.44C287.4 401.9 273.4 416 256 416z'></path> <svg
</svg> xmlns='http://www.w3.org/2000/svg'
Report viewBox='0 0 512 512'
</a> width='1em'
height='1em'
fill='currentColor'
className='IBMSMSMSSS_Author_Top_Icon'
>
<path d='M506.3 417l-213.3-364c-16.33-28-57.54-28-73.98 0l-213.2 364C-10.59 444.9 9.849 480 42.74 480h426.6C502.1 480 522.6 445 506.3 417zM232 168c0-13.25 10.75-24 24-24S280 154.8 280 168v128c0 13.25-10.75 24-23.1 24S232 309.3 232 296V168zM256 416c-17.36 0-31.44-14.08-31.44-31.44c0-17.36 14.07-31.44 31.44-31.44s31.44 14.08 31.44 31.44C287.4 401.9 273.4 416 256 416z'></path>
</svg>
Report
</a>
)}
<a <a
className='dropdown-item dropdownMainMenuItem' className='dropdown-item dropdownMainMenuItem'

View File

@ -194,6 +194,7 @@ const Game = () => {
const { mod, isAddedToNSFW, isBlocked, isRepost } = const { mod, isAddedToNSFW, isBlocked, isRepost } =
useLoaderData() as ModPageLoaderResult useLoaderData() as ModPageLoaderResult
const userState = useAppSelector((state) => state.user) const userState = useAppSelector((state) => state.user)
const isLoggedIn = userState.auth && userState.user?.pubkey !== 'undefined'
const [showReportPopUp, setShowReportPopUp] = useState<number | undefined>() const [showReportPopUp, setShowReportPopUp] = useState<number | undefined>()
useBodyScrollDisable(!!showReportPopUp) useBodyScrollDisable(!!showReportPopUp)
@ -336,25 +337,27 @@ const Game = () => {
</svg> </svg>
Share Share
</a> </a>
<a {isLoggedIn && (
className='dropdown-item dropdownMainMenuItem' <a
id='reportPost' className='dropdown-item dropdownMainMenuItem'
onClick={() => { id='reportPost'
setShowReportPopUp(Date.now()) onClick={() => {
}} setShowReportPopUp(Date.now())
> }}
<svg
xmlns='http://www.w3.org/2000/svg'
viewBox='0 0 512 512'
width='1em'
height='1em'
fill='currentColor'
className='IBMSMSMSSS_Author_Top_Icon'
> >
<path d='M506.3 417l-213.3-364c-16.33-28-57.54-28-73.98 0l-213.2 364C-10.59 444.9 9.849 480 42.74 480h426.6C502.1 480 522.6 445 506.3 417zM232 168c0-13.25 10.75-24 24-24S280 154.8 280 168v128c0 13.25-10.75 24-23.1 24S232 309.3 232 296V168zM256 416c-17.36 0-31.44-14.08-31.44-31.44c0-17.36 14.07-31.44 31.44-31.44s31.44 14.08 31.44 31.44C287.4 401.9 273.4 416 256 416z'></path> <svg
</svg> xmlns='http://www.w3.org/2000/svg'
Report viewBox='0 0 512 512'
</a> width='1em'
height='1em'
fill='currentColor'
className='IBMSMSMSSS_Author_Top_Icon'
>
<path d='M506.3 417l-213.3-364c-16.33-28-57.54-28-73.98 0l-213.2 364C-10.59 444.9 9.849 480 42.74 480h426.6C502.1 480 522.6 445 506.3 417zM232 168c0-13.25 10.75-24 24-24S280 154.8 280 168v128c0 13.25-10.75 24-23.1 24S232 309.3 232 296V168zM256 416c-17.36 0-31.44-14.08-31.44-31.44c0-17.36 14.07-31.44 31.44-31.44s31.44 14.08 31.44 31.44C287.4 401.9 273.4 416 256 416z'></path>
</svg>
Report
</a>
)}
<a <a
className='dropdown-item dropdownMainMenuItem' className='dropdown-item dropdownMainMenuItem'
onClick={handleBlock} onClick={handleBlock}

View File

@ -59,6 +59,7 @@ export const ProfilePage = () => {
const displayName = const displayName =
profile?.displayName || profile?.name || '[name not set up]' profile?.displayName || profile?.name || '[name not set up]'
const [showReportPopUp, setShowReportPopUp] = useState(false) const [showReportPopUp, setShowReportPopUp] = useState(false)
const isLoggedIn = userState.auth && userState.user?.pubkey !== 'undefined'
const isOwnProfile = const isOwnProfile =
userState.auth && userState.auth &&
userState.user?.pubkey && userState.user?.pubkey &&
@ -376,23 +377,25 @@ export const ProfilePage = () => {
</a> </a>
{!isOwnProfile && ( {!isOwnProfile && (
<> <>
<a {isLoggedIn && (
className='dropdown-item dropdownMainMenuItem' <a
id='reportUser' className='dropdown-item dropdownMainMenuItem'
onClick={() => setShowReportPopUp(true)} id='reportUser'
> onClick={() => setShowReportPopUp(true)}
<svg
xmlns='http://www.w3.org/2000/svg'
viewBox='0 0 512 512'
width='1em'
height='1em'
fill='currentColor'
className='IBMSMSMSSS_Author_Top_Icon'
> >
<path d='M506.3 417l-213.3-364c-16.33-28-57.54-28-73.98 0l-213.2 364C-10.59 444.9 9.849 480 42.74 480h426.6C502.1 480 522.6 445 506.3 417zM232 168c0-13.25 10.75-24 24-24S280 154.8 280 168v128c0 13.25-10.75 24-23.1 24S232 309.3 232 296V168zM256 416c-17.36 0-31.44-14.08-31.44-31.44c0-17.36 14.07-31.44 31.44-31.44s31.44 14.08 31.44 31.44C287.4 401.9 273.4 416 256 416z'></path> <svg
</svg> xmlns='http://www.w3.org/2000/svg'
Report viewBox='0 0 512 512'
</a> width='1em'
height='1em'
fill='currentColor'
className='IBMSMSMSSS_Author_Top_Icon'
>
<path d='M506.3 417l-213.3-364c-16.33-28-57.54-28-73.98 0l-213.2 364C-10.59 444.9 9.849 480 42.74 480h426.6C502.1 480 522.6 445 506.3 417zM232 168c0-13.25 10.75-24 24-24S280 154.8 280 168v128c0 13.25-10.75 24-23.1 24S232 309.3 232 296V168zM256 416c-17.36 0-31.44-14.08-31.44-31.44c0-17.36 14.07-31.44 31.44-31.44s31.44 14.08 31.44 31.44C287.4 401.9 273.4 416 256 416z'></path>
</svg>
Report
</a>
)}
<a <a
className='dropdown-item dropdownMainMenuItem' className='dropdown-item dropdownMainMenuItem'
onClick={isBlocked ? handleUnblock : handleBlock} onClick={isBlocked ? handleUnblock : handleBlock}