import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { TransferForm } from '../components/TransferForm'

const el = document.getElementById('transfer-app')
if (el) {
  const cEl = document.getElementById('transfer-characters-data')
  const characters: string[] = cEl ? JSON.parse(cEl.textContent || '[]') : []
  createRoot(el).render(
    <StrictMode>
      <TransferForm
        url={el.dataset.url || ''}
        csrfToken={el.dataset.csrf || ''}
        characters={characters}
        price={el.dataset.price || ''}
      />
    </StrictMode>,
  )
}
