Merge branch 'develop' into feature/add-boss-data
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useState, useEffect, useMemo } from 'react'
|
||||
import { useRoutePokemon } from '../hooks/useGames'
|
||||
import { useNameSuggestions } from '../hooks/useRuns'
|
||||
import {
|
||||
EncounterMethodBadge,
|
||||
getMethodLabel,
|
||||
@@ -15,6 +16,8 @@ import type {
|
||||
interface EncounterModalProps {
|
||||
route: Route
|
||||
gameId: number
|
||||
runId: number
|
||||
namingScheme?: string | null
|
||||
existing?: EncounterDetail
|
||||
dupedPokemonIds?: Set<number>
|
||||
retiredPokemonIds?: Set<number>
|
||||
@@ -92,6 +95,8 @@ function pickRandomPokemon(
|
||||
export function EncounterModal({
|
||||
route,
|
||||
gameId,
|
||||
runId,
|
||||
namingScheme,
|
||||
existing,
|
||||
dupedPokemonIds,
|
||||
retiredPokemonIds,
|
||||
@@ -120,6 +125,10 @@ export function EncounterModal({
|
||||
|
||||
const isEditing = !!existing
|
||||
|
||||
const showSuggestions = !!namingScheme && status === 'caught' && !isEditing
|
||||
const { data: suggestions, refetch: regenerate, isFetching: loadingSuggestions } =
|
||||
useNameSuggestions(showSuggestions ? runId : null)
|
||||
|
||||
// Pre-select pokemon when editing
|
||||
useEffect(() => {
|
||||
if (existing && routePokemon) {
|
||||
@@ -380,6 +389,39 @@ export function EncounterModal({
|
||||
placeholder="Give it a name..."
|
||||
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"
|
||||
/>
|
||||
{showSuggestions && suggestions && suggestions.length > 0 && (
|
||||
<div className="mt-2">
|
||||
<div className="flex items-center justify-between mb-1.5">
|
||||
<span className="text-xs text-gray-500 dark:text-gray-400">
|
||||
Suggestions ({namingScheme})
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => regenerate()}
|
||||
disabled={loadingSuggestions}
|
||||
className="text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 disabled:opacity-50 transition-colors"
|
||||
>
|
||||
{loadingSuggestions ? 'Loading...' : 'Regenerate'}
|
||||
</button>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{suggestions.map((name) => (
|
||||
<button
|
||||
key={name}
|
||||
type="button"
|
||||
onClick={() => setNickname(name)}
|
||||
className={`px-2.5 py-1 text-xs rounded-full border transition-colors ${
|
||||
nickname === name
|
||||
? 'bg-blue-100 border-blue-300 text-blue-800 dark:bg-blue-900/40 dark:border-blue-600 dark:text-blue-300'
|
||||
: 'border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:border-blue-300 dark:hover:border-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/20'
|
||||
}`}
|
||||
>
|
||||
{name}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user