Add bulk import for evolutions, routes, and bosses
Add three new bulk import endpoints that accept the same JSON format as
their corresponding export endpoints, enabling round-trip compatibility:
- POST /evolutions/bulk-import (upsert by from/to pokemon pair)
- POST /games/{id}/routes/bulk-import (reuses seed loader for hierarchy)
- POST /games/{id}/bosses/bulk-import (reuses seed loader with team data)
Generalize BulkImportModal to support all entity types with configurable
title, example, and result labels. Wire up Bulk Import buttons on
AdminEvolutions, and AdminGameDetail routes/bosses tabs.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import { useState } from 'react'
|
||||
import { AdminTable, type Column } from '../../components/admin/AdminTable'
|
||||
import { BulkImportModal } from '../../components/admin/BulkImportModal'
|
||||
import { EvolutionFormModal } from '../../components/admin/EvolutionFormModal'
|
||||
import {
|
||||
useEvolutionList,
|
||||
useCreateEvolution,
|
||||
useUpdateEvolution,
|
||||
useDeleteEvolution,
|
||||
useBulkImportEvolutions,
|
||||
} from '../../hooks/useAdmin'
|
||||
import { exportEvolutions } from '../../api/admin'
|
||||
import { downloadJson } from '../../utils/download'
|
||||
@@ -25,8 +27,10 @@ export function AdminEvolutions() {
|
||||
const createEvolution = useCreateEvolution()
|
||||
const updateEvolution = useUpdateEvolution()
|
||||
const deleteEvolution = useDeleteEvolution()
|
||||
const bulkImport = useBulkImportEvolutions()
|
||||
|
||||
const [showCreate, setShowCreate] = useState(false)
|
||||
const [showBulkImport, setShowBulkImport] = useState(false)
|
||||
const [editing, setEditing] = useState<EvolutionAdmin | null>(null)
|
||||
|
||||
const columns: Column<EvolutionAdmin>[] = [
|
||||
@@ -71,6 +75,12 @@ export function AdminEvolutions() {
|
||||
>
|
||||
Export
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setShowBulkImport(true)}
|
||||
className="px-4 py-2 text-sm font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800"
|
||||
>
|
||||
Bulk Import
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setShowCreate(true)}
|
||||
className="px-4 py-2 text-sm font-medium rounded-md bg-blue-600 text-white hover:bg-blue-700"
|
||||
@@ -146,6 +156,15 @@ export function AdminEvolutions() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{showBulkImport && (
|
||||
<BulkImportModal
|
||||
title="Bulk Import Evolutions"
|
||||
example={`[\n { "from_pokeapi_id": 1, "to_pokeapi_id": 2, "trigger": "level-up", "min_level": 16 }\n]`}
|
||||
onSubmit={(items) => bulkImport.mutateAsync(items)}
|
||||
onClose={() => setShowBulkImport(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{showCreate && (
|
||||
<EvolutionFormModal
|
||||
onSubmit={(data) =>
|
||||
|
||||
Reference in New Issue
Block a user