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

fix team navigation #1659

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading