fix: resolve all 15 frontend ESLint errors for green CI
- Replace setState-in-effect with state-based tracking (AdminLayout, EditCategoryModal) - Convert inline SortIcon component to getSortIcon function (TreeTableView) - Remove unused catch parameters (CreateCategoryModal, EditCategoryModal) - Replace `any` types with proper types (SessionFilters, AdminCategoriesPage, SessionHistoryPage) - Fix unused destructuring variable (StepRatingModal) - Fix constant binary expression in test (utils.test.ts) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,12 +5,16 @@ import { AdminSidebar } from './AdminSidebar'
|
||||
|
||||
export function AdminLayout() {
|
||||
const [mobileOpen, setMobileOpen] = useState(false)
|
||||
const [prevPathname, setPrevPathname] = useState('')
|
||||
const location = useLocation()
|
||||
|
||||
// Close on route change
|
||||
useEffect(() => {
|
||||
setMobileOpen(false)
|
||||
}, [location.pathname])
|
||||
// Close on route change (state-based tracking, no effect needed)
|
||||
if (prevPathname !== location.pathname) {
|
||||
setPrevPathname(location.pathname)
|
||||
if (mobileOpen) {
|
||||
setMobileOpen(false)
|
||||
}
|
||||
}
|
||||
|
||||
const handleKeyDown = useCallback((e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape') setMobileOpen(false)
|
||||
|
||||
@@ -43,7 +43,7 @@ export function CreateCategoryModal({
|
||||
// Reset form on success
|
||||
setName('')
|
||||
setDescription('')
|
||||
} catch (err) {
|
||||
} catch {
|
||||
setError('Failed to create category')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useState } from 'react'
|
||||
import { X } from 'lucide-react'
|
||||
import { cn } from '@/lib/utils'
|
||||
import type { StepCategoryListItem } from '@/types'
|
||||
@@ -21,14 +21,17 @@ export function EditCategoryModal({
|
||||
const [name, setName] = useState('')
|
||||
const [description, setDescription] = useState('')
|
||||
const [error, setError] = useState('')
|
||||
const [prevCategoryId, setPrevCategoryId] = useState<string | null>(null)
|
||||
|
||||
// Pre-populate form when category changes
|
||||
useEffect(() => {
|
||||
if (category) {
|
||||
setName(category.name)
|
||||
setDescription(category.description || '')
|
||||
}
|
||||
}, [category])
|
||||
// Pre-populate form when category changes (state-based tracking)
|
||||
if (category && category.id !== prevCategoryId) {
|
||||
setPrevCategoryId(category.id)
|
||||
setName(category.name)
|
||||
setDescription(category.description || '')
|
||||
}
|
||||
if (!category && prevCategoryId !== null) {
|
||||
setPrevCategoryId(null)
|
||||
}
|
||||
|
||||
if (!isOpen || !category) return null
|
||||
|
||||
@@ -51,7 +54,7 @@ export function EditCategoryModal({
|
||||
name: name.trim(),
|
||||
description: description.trim()
|
||||
})
|
||||
} catch (err) {
|
||||
} catch {
|
||||
setError('Failed to update category')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user