6f52d325a6
Sitios de voto: los 4 apuntaban a las fichas de UltimoWoW en los rankings con SUS ids (Gtop100 94649, pingUsername 91402, etc.). No era cosmética: cada voto de nuestros jugadores subía a UltimoWoW en el ranking. Se cambian nombre e ids por un 236588 de relleno, así el enlace deja de acreditar a otro servidor. Las fichas reales de NightSpire están por crear; entonces habrá que poner sus ids. Nota legal: decía "Error 404 es la empresa que representa el servicio", heredado de ultimowow. Al renombrar la marca pasaba a afirmar que una empresa ajena representa a NightSpire, lo cual es falso. Se quita la empresa en ES y EN. Prefijo uw- (de UltimoWoW) -> ns-: 100 identificadores en 11 ficheros (clases CSS, ids de formulario, eventos y la cookie de consentimiento, que pasa a ns_cookie_consent; a los usuarios les reaparecerá el aviso una vez). Se comprobó antes que el CSS del tema no define ninguna clase uw-, así que no rompe estilos. btn-ns-form y ns-cookie-btn-customize se usan sin estar definidas, pero ya era así antes del cambio: eran clases muertas. Repo de Gitea renombrado Inna/NovaWoW -> Inna/NightSpire (era la marca vieja más visible de /changelogs, que forma la URL de cada commit). Gitea redirige la URL antigua con 301. Se actualizan el remoto y lib/changelog.ts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
114 lines
4.3 KiB
TypeScript
114 lines
4.3 KiB
TypeScript
'use client'
|
|
|
|
import { useState } from 'react'
|
|
import { useTranslations, useLocale } from 'next-intl'
|
|
import { CharacterSelect, type CharOption } from '@/components/CharacterSelect'
|
|
import { PaymentMethodSelect, pdCostOf, type PayMethod } from '@/components/PaymentMethodSelect'
|
|
|
|
/** Campo con ojo para mostrar/ocultar (contraseña / token). */
|
|
function SecretInput({
|
|
id,
|
|
value,
|
|
onChange,
|
|
placeholder,
|
|
maxLength,
|
|
toggleClass,
|
|
}: {
|
|
id: string
|
|
value: string
|
|
onChange: (v: string) => void
|
|
placeholder: string
|
|
maxLength: number
|
|
toggleClass: string
|
|
}) {
|
|
const [show, setShow] = useState(false)
|
|
return (
|
|
<>
|
|
<input
|
|
type={show ? 'text' : 'password'}
|
|
id={id}
|
|
maxLength={maxLength}
|
|
value={value}
|
|
onChange={(e) => onChange(e.target.value)}
|
|
placeholder={placeholder}
|
|
required
|
|
/>{' '}
|
|
<span
|
|
className={`far ${show ? 'fa-eye-slash' : 'fa-eye'} ${toggleClass}`}
|
|
role="button"
|
|
tabIndex={0}
|
|
onClick={() => setShow((s) => !s)}
|
|
/>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export function TransferForm({ characters, price, pdBalance }: { characters: CharOption[]; price: number; pdBalance: number }) {
|
|
const t = useTranslations('CharService')
|
|
const tpay = useTranslations('Pay')
|
|
const locale = useLocale()
|
|
const [character, setCharacter] = useState('')
|
|
const [destination, setDestination] = useState('')
|
|
const [password, setPassword] = useState('')
|
|
const [token, setToken] = useState('')
|
|
const [method, setMethod] = useState<PayMethod>(pdBalance >= pdCostOf(price) ? 'pd' : 'sumup')
|
|
const [busy, setBusy] = useState(false)
|
|
const [error, setError] = useState<string | null>(null)
|
|
|
|
async function handleSubmit(e: React.FormEvent) {
|
|
e.preventDefault()
|
|
if (busy || !character || !destination.trim() || !password || !token.trim()) return
|
|
if (!window.confirm(t('transfer.confirm', { character, destination: destination.trim(), price }))) return
|
|
setBusy(true)
|
|
setError(null)
|
|
try {
|
|
const res = await fetch('/api/character/transfer/checkout', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
credentials: 'same-origin',
|
|
body: JSON.stringify({
|
|
character,
|
|
destination_account: destination.trim(),
|
|
password,
|
|
security_token: token.trim(),
|
|
provider: method,
|
|
locale,
|
|
}),
|
|
})
|
|
const data: { success?: boolean; url?: string; message?: string; error?: string } = await res.json()
|
|
if (data.success && data.url) window.location.href = data.url
|
|
else {
|
|
setError(data.message || (data.error && tpay.has(`errors.${data.error}`) ? tpay(`errors.${data.error}`) : t('transfer.errorGeneric')))
|
|
setBusy(false)
|
|
}
|
|
} catch {
|
|
setError(t('transfer.errorUnexpected'))
|
|
setBusy(false)
|
|
}
|
|
}
|
|
|
|
if (characters.length === 0) return <p className="second-brown">{t('transfer.noCharacters')}</p>
|
|
|
|
return (
|
|
<div className="centered">
|
|
<form noValidate id="ns-transfer-character-form" onSubmit={handleSubmit} acceptCharset="utf-8">
|
|
<CharacterSelect characters={characters} value={character} onChange={setCharacter} placeholder={t('transfer.selectPlaceholder')} />
|
|
<br />
|
|
<input type="text" maxLength={32} placeholder={t('transfer.destinationPlaceholder')} value={destination} onChange={(e) => setDestination(e.target.value)} required />
|
|
<br />
|
|
<SecretInput id="password" value={password} onChange={setPassword} placeholder={t('transfer.passwordPlaceholder')} maxLength={16} toggleClass="toggle-password" />
|
|
<br />
|
|
<SecretInput id="security-token" value={token} onChange={setToken} placeholder={t('transfer.tokenPlaceholder')} maxLength={6} toggleClass="toggle-token" />
|
|
<PaymentMethodSelect value={method} onChange={setMethod} priceEur={price} pdBalance={pdBalance} />
|
|
<button type="submit" className="transfer-button" disabled={busy || !character || !destination.trim() || !password || !token.trim()}>
|
|
{busy ? t('transfer.submitting') : t('transfer.submit')}
|
|
</button>
|
|
</form>
|
|
<hr />
|
|
<div className="alert-message" id="transfer-character-response" style={{ display: error ? 'block' : 'none' }}>
|
|
{error && <span className="red-form-response">{error}</span>}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|