2026-02-08 21:47:35 +01:00
|
|
|
import { useState, useMemo } from 'react'
|
2026-02-16 20:39:41 +01:00
|
|
|
import type { EncounterDetail, UpdateEncounterInput, CreateEncounterInput } from '../types'
|
2026-02-08 12:55:11 +01:00
|
|
|
import { useEvolutions, useForms } from '../hooks/useEncounters'
|
2026-02-07 21:12:45 +01:00
|
|
|
import { TypeBadge } from './TypeBadge'
|
2026-02-08 14:03:43 +01:00
|
|
|
import { formatEvolutionMethod } from '../utils/formatEvolution'
|
2026-02-05 18:36:08 +01:00
|
|
|
|
|
|
|
|
interface StatusChangeModalProps {
|
|
|
|
|
encounter: EncounterDetail
|
2026-02-14 16:41:24 +01:00
|
|
|
onUpdate: (data: { id: number; data: UpdateEncounterInput }) => void
|
2026-02-05 18:36:08 +01:00
|
|
|
onClose: () => void
|
|
|
|
|
isPending: boolean
|
2026-02-07 20:05:07 +01:00
|
|
|
region?: string
|
2026-02-08 21:47:35 +01:00
|
|
|
onCreateEncounter?: (data: CreateEncounterInput) => void
|
2026-02-05 18:36:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function StatusChangeModal({
|
|
|
|
|
encounter,
|
|
|
|
|
onUpdate,
|
|
|
|
|
onClose,
|
|
|
|
|
isPending,
|
2026-02-07 20:05:07 +01:00
|
|
|
region,
|
2026-02-08 21:47:35 +01:00
|
|
|
onCreateEncounter,
|
2026-02-05 18:36:08 +01:00
|
|
|
}: StatusChangeModalProps) {
|
2026-02-16 20:39:41 +01:00
|
|
|
const { pokemon, currentPokemon, route, nickname, catchLevel, faintLevel, deathCause } = encounter
|
2026-02-05 18:36:08 +01:00
|
|
|
const isDead = faintLevel !== null
|
2026-02-05 19:26:49 +01:00
|
|
|
const displayPokemon = currentPokemon ?? pokemon
|
2026-02-05 18:36:08 +01:00
|
|
|
const [showConfirm, setShowConfirm] = useState(false)
|
2026-02-05 19:26:49 +01:00
|
|
|
const [showEvolve, setShowEvolve] = useState(false)
|
2026-02-08 12:55:11 +01:00
|
|
|
const [showFormChange, setShowFormChange] = useState(false)
|
2026-02-08 21:47:35 +01:00
|
|
|
const [showShedConfirm, setShowShedConfirm] = useState(false)
|
2026-02-16 20:39:41 +01:00
|
|
|
const [pendingEvolutionId, setPendingEvolutionId] = useState<number | null>(null)
|
2026-02-08 21:47:35 +01:00
|
|
|
const [shedNickname, setShedNickname] = useState('')
|
2026-02-05 18:36:08 +01:00
|
|
|
const [deathLevel, setDeathLevel] = useState('')
|
|
|
|
|
const [cause, setCause] = useState('')
|
|
|
|
|
|
2026-02-05 19:26:49 +01:00
|
|
|
const activePokemonId = currentPokemon?.id ?? pokemon.id
|
|
|
|
|
const { data: evolutions, isLoading: evolutionsLoading } = useEvolutions(
|
2026-02-08 21:47:35 +01:00
|
|
|
showEvolve || showShedConfirm ? activePokemonId : null,
|
2026-02-14 16:41:24 +01:00
|
|
|
region
|
2026-02-05 19:26:49 +01:00
|
|
|
)
|
2026-02-08 12:55:11 +01:00
|
|
|
const { data: forms } = useForms(isDead ? null : activePokemonId)
|
2026-02-05 19:26:49 +01:00
|
|
|
|
2026-02-08 21:47:35 +01:00
|
|
|
const { normalEvolutions, shedCompanion } = useMemo(() => {
|
|
|
|
|
if (!evolutions) return { normalEvolutions: [], shedCompanion: null }
|
|
|
|
|
return {
|
2026-02-14 16:41:24 +01:00
|
|
|
normalEvolutions: evolutions.filter((e) => e.trigger !== 'shed'),
|
|
|
|
|
shedCompanion: evolutions.find((e) => e.trigger === 'shed') ?? null,
|
2026-02-08 21:47:35 +01:00
|
|
|
}
|
|
|
|
|
}, [evolutions])
|
|
|
|
|
|
2026-02-05 18:36:08 +01:00
|
|
|
const handleConfirmDeath = () => {
|
|
|
|
|
onUpdate({
|
|
|
|
|
id: encounter.id,
|
|
|
|
|
data: {
|
|
|
|
|
faintLevel: deathLevel ? Number(deathLevel) : undefined,
|
|
|
|
|
deathCause: cause || undefined,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-05 19:26:49 +01:00
|
|
|
const handleEvolve = (toPokemonId: number) => {
|
2026-02-08 21:47:35 +01:00
|
|
|
if (shedCompanion && onCreateEncounter) {
|
|
|
|
|
setPendingEvolutionId(toPokemonId)
|
|
|
|
|
setShowEvolve(false)
|
|
|
|
|
setShowShedConfirm(true)
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-02-05 19:26:49 +01:00
|
|
|
onUpdate({
|
|
|
|
|
id: encounter.id,
|
|
|
|
|
data: { currentPokemonId: toPokemonId },
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-08 21:47:35 +01:00
|
|
|
const applyEvolution = (includeShed: boolean) => {
|
|
|
|
|
if (pendingEvolutionId === null) return
|
|
|
|
|
onUpdate({
|
|
|
|
|
id: encounter.id,
|
|
|
|
|
data: { currentPokemonId: pendingEvolutionId },
|
|
|
|
|
})
|
|
|
|
|
if (includeShed && shedCompanion && onCreateEncounter) {
|
|
|
|
|
onCreateEncounter({
|
|
|
|
|
routeId: encounter.routeId,
|
|
|
|
|
pokemonId: shedCompanion.toPokemon.id,
|
|
|
|
|
nickname: shedNickname || undefined,
|
|
|
|
|
status: 'caught',
|
|
|
|
|
origin: 'shed_evolution',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-05 18:36:08 +01:00
|
|
|
return (
|
|
|
|
|
<div className="fixed inset-0 z-50 flex items-center justify-center p-4">
|
|
|
|
|
<div className="fixed inset-0 bg-black/50" onClick={onClose} />
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="relative bg-surface-1 rounded-xl shadow-xl max-w-sm w-full">
|
2026-02-05 18:36:08 +01:00
|
|
|
{/* Header */}
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="flex items-center justify-between px-6 py-4 border-b border-border-default">
|
|
|
|
|
<h2 className="text-lg font-semibold text-text-primary">
|
2026-02-05 18:36:08 +01:00
|
|
|
{isDead ? 'Death Details' : 'Pokemon Status'}
|
|
|
|
|
</h2>
|
2026-02-17 21:08:53 +01:00
|
|
|
<button onClick={onClose} className="text-text-tertiary hover:text-text-primary">
|
2026-02-16 20:39:41 +01:00
|
|
|
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
2026-02-05 18:36:08 +01:00
|
|
|
<path
|
|
|
|
|
strokeLinecap="round"
|
|
|
|
|
strokeLinejoin="round"
|
|
|
|
|
strokeWidth={2}
|
|
|
|
|
d="M6 18L18 6M6 6l12 12"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="px-6 py-4">
|
|
|
|
|
{/* Pokemon info */}
|
|
|
|
|
<div className="flex items-center gap-4 mb-4">
|
2026-02-05 19:26:49 +01:00
|
|
|
{displayPokemon.spriteUrl ? (
|
2026-02-05 18:36:08 +01:00
|
|
|
<img
|
2026-02-05 19:26:49 +01:00
|
|
|
src={displayPokemon.spriteUrl}
|
|
|
|
|
alt={displayPokemon.name}
|
2026-02-05 18:36:08 +01:00
|
|
|
className={`w-16 h-16 ${isDead ? 'grayscale opacity-60' : ''}`}
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="w-16 h-16 rounded-full bg-surface-3 flex items-center justify-center text-xl font-bold text-text-secondary">
|
2026-02-16 20:39:41 +01:00
|
|
|
{displayPokemon.name[0]?.toUpperCase()}
|
2026-02-05 18:36:08 +01:00
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
<div>
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="font-semibold text-text-primary">
|
2026-02-05 19:26:49 +01:00
|
|
|
{nickname || displayPokemon.name}
|
2026-02-05 18:36:08 +01:00
|
|
|
</div>
|
|
|
|
|
{nickname && (
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="text-xs text-text-tertiary capitalize">{displayPokemon.name}</div>
|
2026-02-05 18:36:08 +01:00
|
|
|
)}
|
2026-02-08 12:56:42 +01:00
|
|
|
<div className="flex flex-col items-start gap-0.5 mt-1">
|
2026-02-05 19:26:49 +01:00
|
|
|
{displayPokemon.types.map((type) => (
|
2026-02-07 21:12:45 +01:00
|
|
|
<TypeBadge key={type} type={type} />
|
2026-02-05 18:36:08 +01:00
|
|
|
))}
|
|
|
|
|
</div>
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="text-xs text-text-tertiary mt-1">
|
2026-02-05 18:36:08 +01:00
|
|
|
Lv. {catchLevel ?? '?'} · {route.name}
|
|
|
|
|
</div>
|
2026-02-05 19:26:49 +01:00
|
|
|
{currentPokemon && (
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="text-[10px] text-text-muted mt-0.5">Originally: {pokemon.name}</div>
|
2026-02-05 19:26:49 +01:00
|
|
|
)}
|
2026-02-05 18:36:08 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Dead pokemon: view-only details */}
|
|
|
|
|
{isDead && (
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="bg-status-failed-bg rounded-lg p-4 space-y-2">
|
|
|
|
|
<div className="flex items-center gap-2 text-status-failed font-medium text-sm">
|
2026-02-05 18:36:08 +01:00
|
|
|
<span className="w-2 h-2 rounded-full bg-red-500" />
|
|
|
|
|
Deceased
|
|
|
|
|
</div>
|
|
|
|
|
{faintLevel !== null && (
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="text-sm text-text-secondary">
|
|
|
|
|
<span className="text-text-tertiary">Level at death:</span> {faintLevel}
|
2026-02-05 18:36:08 +01:00
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
{deathCause && (
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="text-sm text-text-secondary">
|
|
|
|
|
<span className="text-text-tertiary">Cause:</span> {deathCause}
|
2026-02-05 18:36:08 +01:00
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-02-05 19:26:49 +01:00
|
|
|
{/* Alive pokemon: actions */}
|
2026-02-16 20:39:41 +01:00
|
|
|
{!isDead && !showConfirm && !showEvolve && !showFormChange && !showShedConfirm && (
|
|
|
|
|
<div className="flex gap-3">
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => setShowEvolve(true)}
|
2026-02-17 21:08:53 +01:00
|
|
|
className="flex-1 px-4 py-2 bg-accent-600 text-white rounded-lg font-medium hover:bg-accent-500 transition-colors"
|
2026-02-16 20:39:41 +01:00
|
|
|
>
|
|
|
|
|
Evolve
|
|
|
|
|
</button>
|
|
|
|
|
{forms && forms.length > 0 && (
|
2026-02-14 16:41:24 +01:00
|
|
|
<button
|
|
|
|
|
type="button"
|
2026-02-16 20:39:41 +01:00
|
|
|
onClick={() => setShowFormChange(true)}
|
|
|
|
|
className="flex-1 px-4 py-2 bg-purple-600 text-white rounded-lg font-medium hover:bg-purple-700 transition-colors"
|
2026-02-14 16:41:24 +01:00
|
|
|
>
|
2026-02-16 20:39:41 +01:00
|
|
|
Change Form
|
2026-02-14 16:41:24 +01:00
|
|
|
</button>
|
2026-02-16 20:39:41 +01:00
|
|
|
)}
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => setShowConfirm(true)}
|
|
|
|
|
className="flex-1 px-4 py-2 bg-red-600 text-white rounded-lg font-medium hover:bg-red-700 transition-colors"
|
|
|
|
|
>
|
|
|
|
|
Mark as Dead
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2026-02-05 19:26:49 +01:00
|
|
|
|
|
|
|
|
{/* Evolution selection */}
|
|
|
|
|
{!isDead && showEvolve && (
|
|
|
|
|
<div className="space-y-3">
|
|
|
|
|
<div className="flex items-center justify-between">
|
2026-02-17 20:48:42 +01:00
|
|
|
<h3 className="text-sm font-medium text-text-secondary">Evolve into:</h3>
|
2026-02-05 19:26:49 +01:00
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => setShowEvolve(false)}
|
2026-02-17 21:08:53 +01:00
|
|
|
className="text-xs text-text-tertiary hover:text-text-secondary"
|
2026-02-05 19:26:49 +01:00
|
|
|
>
|
|
|
|
|
Back
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
{evolutionsLoading && (
|
2026-02-17 20:48:42 +01:00
|
|
|
<p className="text-sm text-text-tertiary">Loading evolutions...</p>
|
2026-02-05 19:26:49 +01:00
|
|
|
)}
|
2026-02-08 21:47:35 +01:00
|
|
|
{!evolutionsLoading && normalEvolutions.length === 0 && (
|
2026-02-17 20:48:42 +01:00
|
|
|
<p className="text-sm text-text-tertiary">No evolutions available</p>
|
2026-02-05 19:26:49 +01:00
|
|
|
)}
|
2026-02-08 21:47:35 +01:00
|
|
|
{!evolutionsLoading && normalEvolutions.length > 0 && (
|
2026-02-05 19:26:49 +01:00
|
|
|
<div className="space-y-2">
|
2026-02-08 21:47:35 +01:00
|
|
|
{normalEvolutions.map((evo) => (
|
2026-02-05 19:26:49 +01:00
|
|
|
<button
|
|
|
|
|
key={evo.id}
|
|
|
|
|
type="button"
|
|
|
|
|
disabled={isPending}
|
|
|
|
|
onClick={() => handleEvolve(evo.toPokemon.id)}
|
2026-02-17 21:08:53 +01:00
|
|
|
className="w-full flex items-center gap-3 p-3 rounded-lg border border-border-default hover:bg-accent-900/20 hover:border-accent-600 transition-colors disabled:opacity-50"
|
2026-02-05 19:26:49 +01:00
|
|
|
>
|
|
|
|
|
{evo.toPokemon.spriteUrl ? (
|
2026-02-14 16:41:24 +01:00
|
|
|
<img
|
|
|
|
|
src={evo.toPokemon.spriteUrl}
|
|
|
|
|
alt={evo.toPokemon.name}
|
|
|
|
|
className="w-10 h-10"
|
|
|
|
|
/>
|
2026-02-05 19:26:49 +01:00
|
|
|
) : (
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="w-10 h-10 rounded-full bg-surface-3 flex items-center justify-center text-sm font-bold text-text-secondary">
|
2026-02-16 20:39:41 +01:00
|
|
|
{evo.toPokemon.name[0]?.toUpperCase()}
|
2026-02-05 19:26:49 +01:00
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
<div className="text-left">
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="font-medium text-text-primary text-sm">
|
2026-02-05 19:26:49 +01:00
|
|
|
{evo.toPokemon.name}
|
|
|
|
|
</div>
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="text-xs text-text-tertiary">
|
2026-02-05 19:26:49 +01:00
|
|
|
{formatEvolutionMethod(evo)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2026-02-05 18:36:08 +01:00
|
|
|
)}
|
|
|
|
|
|
2026-02-08 21:47:35 +01:00
|
|
|
{/* Shed evolution confirmation (Nincada → Ninjask + Shedinja) */}
|
|
|
|
|
{!isDead && showShedConfirm && shedCompanion && (
|
|
|
|
|
<div className="space-y-3">
|
|
|
|
|
<div className="flex items-center justify-between">
|
2026-02-17 20:48:42 +01:00
|
|
|
<h3 className="text-sm font-medium text-text-secondary">Shed Evolution</h3>
|
2026-02-08 21:47:35 +01:00
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setShowShedConfirm(false)
|
|
|
|
|
setPendingEvolutionId(null)
|
|
|
|
|
setShedNickname('')
|
|
|
|
|
setShowEvolve(true)
|
|
|
|
|
}}
|
2026-02-17 21:08:53 +01:00
|
|
|
className="text-xs text-text-tertiary hover:text-text-secondary"
|
2026-02-08 21:47:35 +01:00
|
|
|
>
|
|
|
|
|
Back
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2026-02-17 21:08:53 +01:00
|
|
|
<div className="bg-amber-900/20 border border-amber-700 rounded-lg p-3">
|
2026-02-08 21:47:35 +01:00
|
|
|
<div className="flex items-center gap-3">
|
|
|
|
|
{shedCompanion.toPokemon.spriteUrl ? (
|
|
|
|
|
<img
|
|
|
|
|
src={shedCompanion.toPokemon.spriteUrl}
|
|
|
|
|
alt={shedCompanion.toPokemon.name}
|
|
|
|
|
className="w-12 h-12"
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="w-12 h-12 rounded-full bg-surface-3 flex items-center justify-center text-sm font-bold text-text-secondary">
|
2026-02-16 20:39:41 +01:00
|
|
|
{shedCompanion.toPokemon.name[0]?.toUpperCase()}
|
2026-02-08 21:47:35 +01:00
|
|
|
</div>
|
|
|
|
|
)}
|
2026-02-17 21:08:53 +01:00
|
|
|
<p className="text-sm text-amber-300">
|
2026-02-16 20:39:41 +01:00
|
|
|
{displayPokemon.name} shed its shell! Would you also like to add{' '}
|
|
|
|
|
<span className="font-semibold">{shedCompanion.toPokemon.name}</span>?
|
2026-02-08 21:47:35 +01:00
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<label
|
|
|
|
|
htmlFor="shed-nickname"
|
2026-02-17 20:48:42 +01:00
|
|
|
className="block text-sm font-medium text-text-secondary mb-1"
|
2026-02-08 21:47:35 +01:00
|
|
|
>
|
2026-02-17 21:08:53 +01:00
|
|
|
Nickname <span className="font-normal text-text-tertiary">(optional)</span>
|
2026-02-08 21:47:35 +01:00
|
|
|
</label>
|
|
|
|
|
<input
|
|
|
|
|
id="shed-nickname"
|
|
|
|
|
type="text"
|
|
|
|
|
maxLength={30}
|
|
|
|
|
value={shedNickname}
|
|
|
|
|
onChange={(e) => setShedNickname(e.target.value)}
|
|
|
|
|
placeholder={shedCompanion.toPokemon.name}
|
2026-02-17 20:48:42 +01:00
|
|
|
className="w-full px-3 py-2 rounded-lg border border-border-default bg-surface-2 text-text-primary focus:outline-none focus:ring-2 focus:ring-amber-500"
|
2026-02-08 21:47:35 +01:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex gap-3 pt-1">
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
disabled={isPending}
|
|
|
|
|
onClick={() => applyEvolution(false)}
|
2026-02-17 20:48:42 +01:00
|
|
|
className="flex-1 px-4 py-2 bg-surface-2 text-text-secondary rounded-lg font-medium hover:bg-surface-3 disabled:opacity-50 transition-colors"
|
2026-02-08 21:47:35 +01:00
|
|
|
>
|
|
|
|
|
Skip
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
disabled={isPending}
|
|
|
|
|
onClick={() => applyEvolution(true)}
|
|
|
|
|
className="flex-1 px-4 py-2 bg-amber-600 text-white rounded-lg font-medium hover:bg-amber-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
|
|
|
|
>
|
2026-02-16 20:39:41 +01:00
|
|
|
{isPending ? 'Saving...' : `Add ${shedCompanion.toPokemon.name}`}
|
2026-02-08 21:47:35 +01:00
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-02-08 12:55:11 +01:00
|
|
|
{/* Form change selection */}
|
|
|
|
|
{!isDead && showFormChange && (
|
|
|
|
|
<div className="space-y-3">
|
|
|
|
|
<div className="flex items-center justify-between">
|
2026-02-17 20:48:42 +01:00
|
|
|
<h3 className="text-sm font-medium text-text-secondary">Change form to:</h3>
|
2026-02-08 12:55:11 +01:00
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => setShowFormChange(false)}
|
2026-02-17 21:08:53 +01:00
|
|
|
className="text-xs text-text-tertiary hover:text-text-secondary"
|
2026-02-08 12:55:11 +01:00
|
|
|
>
|
|
|
|
|
Back
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
{forms && forms.length > 0 && (
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
{forms.map((form) => (
|
|
|
|
|
<button
|
|
|
|
|
key={form.id}
|
|
|
|
|
type="button"
|
|
|
|
|
disabled={isPending}
|
|
|
|
|
onClick={() => handleEvolve(form.id)}
|
2026-02-17 21:08:53 +01:00
|
|
|
className="w-full flex items-center gap-3 p-3 rounded-lg border border-border-default hover:bg-purple-900/20 hover:border-purple-600 transition-colors disabled:opacity-50"
|
2026-02-08 12:55:11 +01:00
|
|
|
>
|
|
|
|
|
{form.spriteUrl ? (
|
2026-02-16 20:39:41 +01:00
|
|
|
<img src={form.spriteUrl} alt={form.name} className="w-10 h-10" />
|
2026-02-08 12:55:11 +01:00
|
|
|
) : (
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="w-10 h-10 rounded-full bg-surface-3 flex items-center justify-center text-sm font-bold text-text-secondary">
|
2026-02-16 20:39:41 +01:00
|
|
|
{form.name[0]?.toUpperCase()}
|
2026-02-08 12:55:11 +01:00
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
<div className="text-left">
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="font-medium text-text-primary text-sm">{form.name}</div>
|
2026-02-08 12:55:11 +01:00
|
|
|
<div className="flex gap-1">
|
|
|
|
|
{form.types.map((type) => (
|
|
|
|
|
<TypeBadge key={type} type={type} />
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-02-05 18:36:08 +01:00
|
|
|
{/* Confirmation form */}
|
|
|
|
|
{!isDead && showConfirm && (
|
|
|
|
|
<div className="space-y-3">
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="bg-status-failed-bg rounded-lg p-3">
|
|
|
|
|
<p className="text-sm text-status-failed font-medium">
|
2026-02-05 18:36:08 +01:00
|
|
|
This cannot be undone (Nuzlocke rules).
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<label
|
|
|
|
|
htmlFor="death-level"
|
2026-02-17 20:48:42 +01:00
|
|
|
className="block text-sm font-medium text-text-secondary mb-1"
|
2026-02-05 18:36:08 +01:00
|
|
|
>
|
2026-02-17 21:08:53 +01:00
|
|
|
Level at Death <span className="font-normal text-text-tertiary">(optional)</span>
|
2026-02-05 18:36:08 +01:00
|
|
|
</label>
|
|
|
|
|
<input
|
|
|
|
|
id="death-level"
|
|
|
|
|
type="number"
|
|
|
|
|
min={1}
|
|
|
|
|
max={100}
|
|
|
|
|
value={deathLevel}
|
|
|
|
|
onChange={(e) => setDeathLevel(e.target.value)}
|
|
|
|
|
placeholder="Level"
|
2026-02-17 20:48:42 +01:00
|
|
|
className="w-24 px-3 py-2 rounded-lg border border-border-default bg-surface-2 text-text-primary focus:outline-none focus:ring-2 focus:ring-red-500"
|
2026-02-05 18:36:08 +01:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<label
|
|
|
|
|
htmlFor="death-cause"
|
2026-02-17 20:48:42 +01:00
|
|
|
className="block text-sm font-medium text-text-secondary mb-1"
|
2026-02-05 18:36:08 +01:00
|
|
|
>
|
2026-02-17 21:08:53 +01:00
|
|
|
Cause of Death <span className="font-normal text-text-tertiary">(optional)</span>
|
2026-02-05 18:36:08 +01:00
|
|
|
</label>
|
|
|
|
|
<input
|
|
|
|
|
id="death-cause"
|
|
|
|
|
type="text"
|
|
|
|
|
maxLength={100}
|
|
|
|
|
value={cause}
|
|
|
|
|
onChange={(e) => setCause(e.target.value)}
|
|
|
|
|
placeholder="e.g. Crit from rival's Charizard"
|
2026-02-17 20:48:42 +01:00
|
|
|
className="w-full px-3 py-2 rounded-lg border border-border-default bg-surface-2 text-text-primary focus:outline-none focus:ring-2 focus:ring-red-500"
|
2026-02-05 18:36:08 +01:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="flex gap-3 pt-1">
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => setShowConfirm(false)}
|
2026-02-17 20:48:42 +01:00
|
|
|
className="flex-1 px-4 py-2 bg-surface-2 text-text-secondary rounded-lg font-medium hover:bg-surface-3 transition-colors"
|
2026-02-05 18:36:08 +01:00
|
|
|
>
|
|
|
|
|
Cancel
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
disabled={isPending}
|
|
|
|
|
onClick={handleConfirmDeath}
|
|
|
|
|
className="flex-1 px-4 py-2 bg-red-600 text-white rounded-lg font-medium hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
|
|
|
|
>
|
|
|
|
|
{isPending ? 'Saving...' : 'Confirm Death'}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-02-05 19:26:49 +01:00
|
|
|
{/* Footer for dead/no-confirm/no-evolve views */}
|
2026-02-14 16:41:24 +01:00
|
|
|
{(isDead ||
|
2026-02-16 20:39:41 +01:00
|
|
|
(!isDead && !showConfirm && !showEvolve && !showFormChange && !showShedConfirm)) && (
|
2026-02-17 20:48:42 +01:00
|
|
|
<div className="px-6 py-4 border-t border-border-default flex justify-end">
|
2026-02-05 18:36:08 +01:00
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={onClose}
|
2026-02-17 20:48:42 +01:00
|
|
|
className="px-4 py-2 bg-surface-2 text-text-secondary rounded-lg font-medium hover:bg-surface-3 transition-colors"
|
2026-02-05 18:36:08 +01:00
|
|
|
>
|
|
|
|
|
Close
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|