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

const el = document.getElementById('rename-guild-app')
if (el) {
  const dEl = document.getElementById('rename-guild-data')
  const guilds: string[] = dEl ? JSON.parse(dEl.textContent || '[]') : []
  createRoot(el).render(
    <StrictMode>
      <GuildRenameForm url={el.dataset.url || ''} csrfToken={el.dataset.csrf || ''} guilds={guilds} />
    </StrictMode>,
  )
}
