import { useEffect, useState } from "react"; import { api, asUiError, type RealmProfiles } from "@/lib/api"; import { Card } from "@/components/ui/card"; import { useT } from "@/i18n"; export function RealmStartupSettings({ serverId }: { serverId: string }) { const t = useT(); const [view, setView] = useState(null); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); useEffect(() => { let alive = true; void api.realmProfiles(serverId).then(v => { if (alive) setView(v); }).catch(e => { if (alive) setError(asUiError(e).technical); }); return () => { alive = false; }; }, [serverId]); async function change(realm: "wildcard" | "reborn", enabled: boolean) { setBusy(true); setError(null); try { setView(await (realm === "wildcard" ? api.realmSimultaneous : api.realmWithReborn)(serverId, enabled)); } catch (e) { setError(asUiError(e).technical); } finally { setBusy(false); } } return

{t("realm.startupTitle")}

{view?.simultaneous &&

{t("realm.secondPort", { port: view.secondary_world_port ?? "—" })}

} {view?.with_reborn &&

{t("realm.rebornPort", { port: view.reborn_world_port ?? "—" })}

} {view && view.active !== "coa" && !view.with_reborn &&

{t("realm.rebornNeedsCoa")}

} {view?.simultaneous && view.with_reborn &&

{t("realm.allThree")}

}
{t("settings.startupHelp")}

{t("realm.simultaneousHint")}

{busy &&

{t("realm.preparing")}

} {error &&

{error}

}
; }