From f7bf65c845597b8ea205fa80a2de75cb37758601 Mon Sep 17 00:00:00 2001 From: daniyal Date: Wed, 25 Sep 2024 21:12:42 +0500 Subject: [PATCH] fix: in mod detail page fixed navigation for game route and edit mod --- src/components/GameCard.tsx | 13 +++++-------- src/pages/mod/index.tsx | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/components/GameCard.tsx b/src/components/GameCard.tsx index 1b34432..0d76af9 100644 --- a/src/components/GameCard.tsx +++ b/src/components/GameCard.tsx @@ -1,7 +1,7 @@ -import { useNavigate } from 'react-router-dom' +import { Link } from 'react-router-dom' +import { getGamePageRoute } from 'routes' import '../styles/cardGames.css' import { handleGameImageError } from '../utils' -import { getGamePageRoute } from 'routes' type GameCardProps = { title: string @@ -9,13 +9,10 @@ type GameCardProps = { } export const GameCard = ({ title, imageUrl }: GameCardProps) => { - const navigate = useNavigate() + const route = getGamePageRoute(title) return ( -
navigate(getGamePageRoute(title))} - > +
{

{title}

-
+ ) } diff --git a/src/pages/mod/index.tsx b/src/pages/mod/index.tsx index bcce8bd..ac1636f 100644 --- a/src/pages/mod/index.tsx +++ b/src/pages/mod/index.tsx @@ -5,7 +5,7 @@ import { formatDate } from 'date-fns' import FsLightbox from 'fslightbox-react' import { Filter, kinds, nip19, UnsignedEvent } from 'nostr-tools' import { useEffect, useRef, useState } from 'react' -import { useNavigate, useParams } from 'react-router-dom' +import { Link as ReactRouterLink, useParams } from 'react-router-dom' import { toast } from 'react-toastify' import { BlogCard } from '../../components/BlogCard' import { LoadingSpinner } from '../../components/LoadingSpinner' @@ -16,7 +16,7 @@ import { UserRelaysType } from '../../controllers' import { useAppSelector, useDidMount } from '../../hooks' -import { getModsEditPageRoute } from '../../routes' +import { getGamePageRoute, getModsEditPageRoute } from '../../routes' import '../../styles/comments.css' import '../../styles/downloads.css' import '../../styles/innerPage.css' @@ -41,9 +41,9 @@ import { sendDMUsingRandomKey, signAndPublish } from '../../utils' +import { Comments } from './internal/comment' import { Reactions } from './internal/reactions' import { Zap } from './internal/zap' -import { Comments } from './internal/comment' export const ModPage = () => { const { naddr } = useParams() @@ -214,7 +214,6 @@ type GameProps = { } const Game = ({ naddr, game, author, aTag }: GameProps) => { - const navigate = useNavigate() const userState = useAppSelector((state) => state.user) const [isLoading, setIsLoading] = useState(false) const [loadingSpinnerDesc, setLoadingSpinnerDesc] = useState('') @@ -510,15 +509,18 @@ const Game = ({ naddr, game, author, aTag }: GameProps) => { userState.user?.npub && userState.user.npub === import.meta.env.VITE_REPORTING_NPUB + const gameRoute = getGamePageRoute(game) + const editRoute = getModsEditPageRoute(naddr) + return ( <> {isLoading && }

Mod for:  - + {game} - +

{userState.auth && userState.user?.pubkey === author && ( - navigate(getModsEditPageRoute(naddr))} + to={editRoute} > { Edit - + )}