web-next: selector de personaje coloreado + rediseño unstuck + fixes vote/account-info
- CharacterSelect: componente reutilizable que colorea las opciones por clase (class="priest big-font"…) y el <select> con la clase seleccionada. Usado en unstuck, revive, gold, transfer, trade-points, servicios de pago y recruit. getGameCharacters ahora devuelve classCss. - /unstuck (+revive): diseño del original (info + NOTA, prompt, opciones coloreadas, botón "Desbloqueado"/"Revivido" con refresh). - /vote-points: seed de los 4 sitios con logos y URLs (sql/seed_votesites.sql); botón voted-button para sitios en cooldown; etiqueta "Nota:" separada. - account-info.png (imagen nueva) y CSS de los paneles de cuenta: se añade background-blend-mode: saturation y background-size en #account-settings y .account-fieldset para que la imagen salga como el original. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,26 +2,41 @@
|
||||
|
||||
import { useState } from 'react'
|
||||
import { useTranslations } from 'next-intl'
|
||||
import { useRouter } from '@/i18n/navigation'
|
||||
import { CharacterSelect, type CharOption } from '@/components/CharacterSelect'
|
||||
|
||||
const ERROR_KEYS = ['noCharacter', 'notOfflineOrOwned', 'cooldown', 'soapError'] as const
|
||||
|
||||
interface Props {
|
||||
characters: string[]
|
||||
characters: CharOption[]
|
||||
endpoint: string
|
||||
actionLabel: string
|
||||
buttonClass?: string
|
||||
processingLabel?: string // texto mientras procesa (por defecto t('processing'))
|
||||
doneLabel?: string // si se pasa, muestra el estado "hecho" (dorado) y refresca a los 5s
|
||||
promptText?: string // texto encima del selector (por defecto t('choose'))
|
||||
}
|
||||
|
||||
/** Formulario reutilizable para acciones de personaje por SOAP (revive, unstuck...). */
|
||||
export function CharacterActionForm({ characters, endpoint, actionLabel, buttonClass = '' }: Props) {
|
||||
export function CharacterActionForm({
|
||||
characters,
|
||||
endpoint,
|
||||
actionLabel,
|
||||
buttonClass = '',
|
||||
processingLabel,
|
||||
doneLabel,
|
||||
promptText,
|
||||
}: Props) {
|
||||
const t = useTranslations('Services')
|
||||
const router = useRouter()
|
||||
const [character, setCharacter] = useState('')
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [done, setDone] = useState(false)
|
||||
const [message, setMessage] = useState<{ ok: boolean; text: string } | null>(null)
|
||||
|
||||
async function handleSubmit(e: React.FormEvent) {
|
||||
e.preventDefault()
|
||||
if (busy || !character) return
|
||||
if (busy || done || !character) return
|
||||
setBusy(true)
|
||||
setMessage(null)
|
||||
try {
|
||||
@@ -32,10 +47,22 @@ export function CharacterActionForm({ characters, endpoint, actionLabel, buttonC
|
||||
body: JSON.stringify({ character }),
|
||||
})
|
||||
const data: { success?: boolean; error?: string } = await res.json()
|
||||
if (data.success) setMessage({ ok: true, text: t('success') })
|
||||
else {
|
||||
if (data.success) {
|
||||
setMessage({ ok: true, text: t('success') })
|
||||
if (doneLabel) {
|
||||
// Como el original: tras 5 s se limpia el formulario y se refresca.
|
||||
setDone(true)
|
||||
setTimeout(() => {
|
||||
setDone(false)
|
||||
setCharacter('')
|
||||
setMessage(null)
|
||||
router.refresh()
|
||||
}, 5000)
|
||||
}
|
||||
} else {
|
||||
const key = (ERROR_KEYS as readonly string[]).includes(data.error ?? '') ? data.error! : 'genericError'
|
||||
setMessage({ ok: false, text: t(key) })
|
||||
setTimeout(() => setMessage(null), 5000)
|
||||
}
|
||||
} catch {
|
||||
setMessage({ ok: false, text: t('genericError') })
|
||||
@@ -50,29 +77,25 @@ export function CharacterActionForm({ characters, endpoint, actionLabel, buttonC
|
||||
|
||||
return (
|
||||
<div className="centered">
|
||||
<p>{t('choose')}</p>
|
||||
<br />
|
||||
<br />
|
||||
<p>{promptText ?? t('choose')}</p>
|
||||
<br />
|
||||
<form onSubmit={handleSubmit} acceptCharset="utf-8">
|
||||
<select value={character} onChange={(e) => setCharacter(e.target.value)} required>
|
||||
<option value="" disabled>
|
||||
{t('selectCharacter')}
|
||||
</option>
|
||||
{characters.map((c) => (
|
||||
<option key={c} value={c}>
|
||||
{c}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<CharacterSelect characters={characters} value={character} onChange={setCharacter} placeholder={t('selectCharacter')} />
|
||||
<br />
|
||||
<button type="submit" className={buttonClass} disabled={busy || !character}>
|
||||
{busy ? t('processing') : actionLabel}
|
||||
<button
|
||||
type="submit"
|
||||
className={buttonClass}
|
||||
disabled={busy || done || !character}
|
||||
style={done ? { color: '#d79602' } : undefined}
|
||||
>
|
||||
{done && doneLabel ? doneLabel : busy ? processingLabel ?? t('processing') : actionLabel}
|
||||
</button>
|
||||
</form>
|
||||
<hr />
|
||||
<div className="alert-message" style={{ display: message ? 'block' : 'none' }}>
|
||||
{message && (
|
||||
<span className={message.ok ? 'ok-form-response' : 'red-form-response'}>{message.text}</span>
|
||||
)}
|
||||
{message && <span className={message.ok ? 'ok-form-response' : 'red-form-response'}>{message.text}</span>}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user