(event: FormEvent<HTMLFormElement>)
| 2829 | } |
| 2830 | |
| 2831 | async function submitPairing(event: FormEvent<HTMLFormElement>) { |
| 2832 | event.preventDefault(); |
| 2833 | const code = pairingCode.trim(); |
| 2834 | if (!code) { |
| 2835 | setPairingError("Enter the pairing code from the SimDeck terminal."); |
| 2836 | return; |
| 2837 | } |
| 2838 | setPairingBusy(true); |
| 2839 | setPairingError(""); |
| 2840 | try { |
| 2841 | await pairBrowser(code); |
| 2842 | setPairingCode(""); |
| 2843 | await refresh(); |
| 2844 | } catch (error) { |
| 2845 | setPairingError( |
| 2846 | error instanceof ApiError && error.status === 401 |
| 2847 | ? "Pairing code did not match." |
| 2848 | : error instanceof Error |
| 2849 | ? error.message |
| 2850 | : "Pairing failed.", |
| 2851 | ); |
| 2852 | } finally { |
| 2853 | setPairingBusy(false); |
| 2854 | } |
| 2855 | } |
| 2856 | |
| 2857 | return ( |
| 2858 | <div className="app"> |
nothing calls this directly
no test coverage detected