Fase 2 (isla): selector de cuenta de juego en React/TSX, sin POST

El selector de cuenta de juego (bnet con varias) pasa a isla React y la selección
se hace vía GET (a petición), no POST:

- Nuevo endpoint GET /api/account/select/?account_id=<id> (account_select_api):
  idempotente y solo permite elegir cuentas ligadas a la bnet en sesión; fija la
  cuenta en sesión y devuelve {success, redirect}. 401 si no hay sesión bnet.
- select_account_view: se elimina el manejo de POST (queda solo la lógica GET:
  redirect si no hay bnet, autoseleccionar si hay una, render si hay varias).
- SelectAccount.tsx lee las cuentas embebidas con json_script y, al pulsar, hace
  fetch GET y redirige. Nueva entry 'select_account'.
- select_account.html: el <form> POST se sustituye por la isla + json_script.

Verificado: check OK, endpoint 401 sin sesión, /select-account/ redirige a login.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-12 20:50:37 +00:00
parent 8156befe4f
commit 45f48c2799
7 changed files with 117 additions and 24 deletions
+18
View File
@@ -0,0 +1,18 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { SelectAccount, type GameAccount } from '../components/SelectAccount'
const dataEl = document.getElementById('select-account-data')
const accounts: GameAccount[] = dataEl ? JSON.parse(dataEl.textContent || '[]') : []
const el = document.getElementById('select-account-app')
if (el) {
createRoot(el).render(
<StrictMode>
<SelectAccount
accounts={accounts}
selectUrl={el.dataset.selectUrl || '/api/account/select/'}
/>
</StrictMode>,
)
}