Add pre-commit hooks for linting and formatting
Set up pre-commit framework with ruff (backend) and ESLint/Prettier/tsc (frontend) hooks to catch issues locally before CI. Auto-format all frontend files with Prettier to comply with the new check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,11 @@ import {
|
||||
} from '../../hooks/useAdmin'
|
||||
import { exportEvolutions } from '../../api/admin'
|
||||
import { downloadJson } from '../../utils/download'
|
||||
import type { EvolutionAdmin, CreateEvolutionInput, UpdateEvolutionInput } from '../../types'
|
||||
import type {
|
||||
EvolutionAdmin,
|
||||
CreateEvolutionInput,
|
||||
UpdateEvolutionInput,
|
||||
} from '../../types'
|
||||
|
||||
const PAGE_SIZE = 50
|
||||
|
||||
@@ -28,7 +32,12 @@ export function AdminEvolutions() {
|
||||
const [triggerFilter, setTriggerFilter] = useState('')
|
||||
const [page, setPage] = useState(0)
|
||||
const offset = page * PAGE_SIZE
|
||||
const { data, isLoading } = useEvolutionList(search || undefined, PAGE_SIZE, offset, triggerFilter || undefined)
|
||||
const { data, isLoading } = useEvolutionList(
|
||||
search || undefined,
|
||||
PAGE_SIZE,
|
||||
offset,
|
||||
triggerFilter || undefined
|
||||
)
|
||||
const evolutions = data?.items ?? []
|
||||
const total = data?.total ?? 0
|
||||
const totalPages = Math.ceil(total / PAGE_SIZE)
|
||||
@@ -120,12 +129,18 @@ export function AdminEvolutions() {
|
||||
>
|
||||
<option value="">All triggers</option>
|
||||
{EVOLUTION_TRIGGERS.map((t) => (
|
||||
<option key={t.value} value={t.value}>{t.label}</option>
|
||||
<option key={t.value} value={t.value}>
|
||||
{t.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{(search || triggerFilter) && (
|
||||
<button
|
||||
onClick={() => { setSearch(''); setTriggerFilter(''); setPage(0) }}
|
||||
onClick={() => {
|
||||
setSearch('')
|
||||
setTriggerFilter('')
|
||||
setPage(0)
|
||||
}}
|
||||
className="text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"
|
||||
>
|
||||
Clear filters
|
||||
@@ -148,7 +163,8 @@ export function AdminEvolutions() {
|
||||
{totalPages > 1 && (
|
||||
<div className="mt-4 flex items-center justify-between">
|
||||
<div className="text-sm text-gray-500 dark:text-gray-400">
|
||||
Showing {offset + 1}-{Math.min(offset + PAGE_SIZE, total)} of {total}
|
||||
Showing {offset + 1}-{Math.min(offset + PAGE_SIZE, total)} of{' '}
|
||||
{total}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<button
|
||||
@@ -213,7 +229,7 @@ export function AdminEvolutions() {
|
||||
onSubmit={(data) =>
|
||||
updateEvolution.mutate(
|
||||
{ id: editing.id, data: data as UpdateEvolutionInput },
|
||||
{ onSuccess: () => setEditing(null) },
|
||||
{ onSuccess: () => setEditing(null) }
|
||||
)
|
||||
}
|
||||
onClose={() => setEditing(null)}
|
||||
|
||||
Reference in New Issue
Block a user