Add naming scheme selection to run configuration
Add a nullable naming_scheme column to NuzlockeRun so users can pick a themed word category for nickname suggestions. Includes Alembic migration, updated Pydantic schemas, a GET /runs/naming-categories endpoint backed by a cached dictionary loader, and frontend dropdowns in both the NewRun creation flow and the RunDashboard for mid-run changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import { useMemo, useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { GameGrid, RulesConfiguration, StepIndicator } from '../components'
|
||||
import { useGames, useGameRoutes } from '../hooks/useGames'
|
||||
import { useCreateRun, useRuns } from '../hooks/useRuns'
|
||||
import { useCreateRun, useRuns, useNamingCategories } from '../hooks/useRuns'
|
||||
import type { Game, NuzlockeRules } from '../types'
|
||||
import { DEFAULT_RULES } from '../types'
|
||||
import { RULE_DEFINITIONS } from '../types/rules'
|
||||
@@ -14,11 +14,13 @@ export function NewRun() {
|
||||
const { data: games, isLoading, error } = useGames()
|
||||
const { data: runs } = useRuns()
|
||||
const createRun = useCreateRun()
|
||||
const { data: namingCategories } = useNamingCategories()
|
||||
|
||||
const [step, setStep] = useState(1)
|
||||
const [selectedGame, setSelectedGame] = useState<Game | null>(null)
|
||||
const [rules, setRules] = useState<NuzlockeRules>(DEFAULT_RULES)
|
||||
const [runName, setRunName] = useState('')
|
||||
const [namingScheme, setNamingScheme] = useState<string | null>(null)
|
||||
const { data: routes } = useGameRoutes(selectedGame?.id ?? null)
|
||||
|
||||
const hiddenRules = useMemo(() => {
|
||||
@@ -44,7 +46,7 @@ export function NewRun() {
|
||||
const handleCreate = () => {
|
||||
if (!selectedGame) return
|
||||
createRun.mutate(
|
||||
{ gameId: selectedGame.id, name: runName, rules },
|
||||
{ gameId: selectedGame.id, name: runName, rules, namingScheme },
|
||||
{ onSuccess: (data) => navigate(`/runs/${data.id}`) },
|
||||
)
|
||||
}
|
||||
@@ -180,6 +182,33 @@ export function NewRun() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{namingCategories && namingCategories.length > 0 && (
|
||||
<div>
|
||||
<label
|
||||
htmlFor="naming-scheme"
|
||||
className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"
|
||||
>
|
||||
Naming Scheme
|
||||
</label>
|
||||
<select
|
||||
id="naming-scheme"
|
||||
value={namingScheme ?? ''}
|
||||
onChange={(e) => setNamingScheme(e.target.value || null)}
|
||||
className="w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
||||
>
|
||||
<option value="">None (manual nicknames)</option>
|
||||
{namingCategories.map((cat) => (
|
||||
<option key={cat} value={cat}>
|
||||
{cat.charAt(0).toUpperCase() + cat.slice(1)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<p className="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
||||
Get nickname suggestions from a themed word list when catching Pokemon.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="border-t border-gray-200 dark:border-gray-700 pt-4">
|
||||
<h3 className="text-sm font-medium text-gray-500 dark:text-gray-400 mb-2">
|
||||
Summary
|
||||
@@ -203,6 +232,14 @@ export function NewRun() {
|
||||
{enabledRuleCount} of {totalRuleCount} enabled
|
||||
</dd>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<dt className="text-gray-600 dark:text-gray-400">Naming Scheme</dt>
|
||||
<dd className="text-gray-900 dark:text-gray-100 font-medium">
|
||||
{namingScheme
|
||||
? namingScheme.charAt(0).toUpperCase() + namingScheme.slice(1)
|
||||
: 'None'}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user