load human language data on tab route activation

Trigger hierarchy fetch whenever the Human Language route is selected so data appears immediately when switching tabs from Content Management.

Made-with: Cursor
This commit is contained in:
Yared Yemane 2026-04-14 09:10:00 -07:00
parent 60a29816fb
commit 967339a400

View File

@ -1,5 +1,5 @@
import { useEffect, useMemo, useState, type ChangeEvent } from "react" import { useEffect, useMemo, useState, type ChangeEvent } from "react"
import { Link, useNavigate } from "react-router-dom" import { Link, useLocation, useNavigate } from "react-router-dom"
import { import {
ChevronDown, ChevronDown,
ChevronRight, ChevronRight,
@ -335,6 +335,7 @@ function nextMissingPositive(values: number[]): number {
export function HumanLanguagePage() { export function HumanLanguagePage() {
const navigate = useNavigate() const navigate = useNavigate()
const location = useLocation()
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
const [categoryId, setCategoryId] = useState<number | null>(null) const [categoryId, setCategoryId] = useState<number | null>(null)
const [subCategories, setSubCategories] = useState<HumanLanguageSubCategoryTree[]>([]) const [subCategories, setSubCategories] = useState<HumanLanguageSubCategoryTree[]>([])
@ -444,6 +445,7 @@ export function HumanLanguagePage() {
} }
useEffect(() => { useEffect(() => {
if (!location.pathname.startsWith("/content/human-language")) return
let cancelled = false let cancelled = false
const run = async () => { const run = async () => {
setLoading(true) setLoading(true)
@ -478,7 +480,7 @@ export function HumanLanguagePage() {
return () => { return () => {
cancelled = true cancelled = true
} }
}, []) }, [location.pathname, location.key])
useEffect(() => { useEffect(() => {
const save = () => sessionStorage.setItem(HUMAN_LANGUAGE_SCROLL_KEY, String(window.scrollY || 0)) const save = () => sessionStorage.setItem(HUMAN_LANGUAGE_SCROLL_KEY, String(window.scrollY || 0))