import type { FormEvent } from 'react' import { useState } from 'react' import { saveAndVerifyH5Connection } from '../../lib/desktopRuntime' import { Button } from '../shared/Button' import { Input } from '../shared/Input' type H5ConnectionViewProps = { initialServerUrl?: string | null error?: string | null onConnected: () => void } export function H5ConnectionView({ initialServerUrl, error: initialError, onConnected, }: H5ConnectionViewProps) { const [serverUrl, setServerUrl] = useState(initialServerUrl ?? '') const [token, setToken] = useState('') const [error, setError] = useState(initialError ?? '') const [submitting, setSubmitting] = useState(false) const handleSubmit = async (event: FormEvent) => { event.preventDefault() setSubmitting(true) setError('') try { await saveAndVerifyH5Connection(serverUrl, token) onConnected() } catch (submitError) { setError( submitError instanceof Error ? submitError.message : 'Unable to connect to the H5 server.', ) } finally { setSubmitting(false) } } return (

Connect to H5 Access

Enter the server URL and H5 access token from the desktop app.

setServerUrl(event.target.value)} autoComplete="url" required /> setToken(event.target.value)} autoComplete="current-password" required /> {error ? (
{error}
) : null}
) }