Integrate name suggestions into encounter registration UI

Add clickable suggestion chips below the nickname input in the encounter
modal. Chips are fetched from GET /runs/{id}/name-suggestions via React
Query, shown only when a naming scheme is set. Clicking a chip fills in
the nickname; a regenerate button fetches a fresh random batch. Completes
the Name Generation epic.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-11 21:48:29 +01:00
parent 2ac6c23577
commit 39d18c241e
6 changed files with 69 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { toast } from 'sonner'
import { getRuns, getRun, createRun, updateRun, deleteRun, getNamingCategories } from '../api/runs'
import { getRuns, getRun, createRun, updateRun, deleteRun, getNamingCategories, getNameSuggestions } from '../api/runs'
import type { CreateRunInput, UpdateRunInput } from '../types/game'
export function useRuns() {
@@ -59,3 +59,11 @@ export function useNamingCategories() {
staleTime: Infinity,
})
}
export function useNameSuggestions(runId: number | null) {
return useQuery({
queryKey: ['name-suggestions', runId],
queryFn: () => getNameSuggestions(runId!),
enabled: runId !== null,
})
}