Skip to content

Commit

Permalink
fix team navigation (#1659)
Browse files Browse the repository at this point in the history
  • Loading branch information
frzyc committed Mar 12, 2024
1 parent 6ed2db7 commit 53ebea1
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions apps/frontend/src/app/PageTeam/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { SillyContext } from '@genshin-optimizer/gi/ui'
import { Box, CardContent, Skeleton } from '@mui/material'
import { Suspense, useContext, useEffect, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Navigate, useMatch, useNavigate, useParams } from 'react-router-dom'
import { Navigate, useMatch, useParams } from 'react-router-dom'
import type { CharacterContextObj } from '../Context/CharacterContext'
import { CharacterContext } from '../Context/CharacterContext'
import { DataContext, type dataContextObj } from '../Context/DataContext'
Expand Down Expand Up @@ -68,7 +68,6 @@ const fallback = <Skeleton variant="rectangular" width="100%" height={1000} />
const chartDataAll: Record<string, ChartData> = {}
const graphBuildAll: Record<string, GeneratedBuild[]> = {}
function Page({ teamId }: { teamId: string }) {
const navigate = useNavigate()
const { silly } = useContext(SillyContext)
const database = useDatabase()
const { gender } = useDBMeta()
Expand All @@ -88,7 +87,6 @@ function Page({ teamId }: { teamId: string }) {
} = useMatch({ path: '/teams/:teamId/:characterKey/:tab', end: false }) ?? {
params: {},
}

// validate characterKey
const { characterKey, teamCharId } = useMemo(() => {
const teamCharId =
Expand All @@ -112,21 +110,6 @@ function Page({ teamId }: { teamId: string }) {
}
return tabRaw
}, [teamChar, tabRaw])
// Enforce validated routing for tabs and character
useEffect(() => {
if (!characterKey) return
if (characterKeyRaw !== characterKey || tab !== tabRaw)
navigate(`/teams/${teamId}/${characterKey}/${tab}`)
}, [
database,
characterKey,
characterKeyRaw,
navigate,
teamCharIds,
tab,
teamId,
tabRaw,
])

const { t } = useTranslation([
'sillyWisher_charNames',
Expand Down

0 comments on commit 53ebea1

Please sign in to comment.