79 lines
2.0 KiB
TypeScript
79 lines
2.0 KiB
TypeScript
import { useState } from 'react';
|
|
|
|
export const ConnectionForm = ({
|
|
onSubmit,
|
|
}: {
|
|
onSubmit: (
|
|
nick: string,
|
|
channel: string,
|
|
host: string,
|
|
ssl: boolean,
|
|
port: number,
|
|
password: string,
|
|
) => void;
|
|
}) => {
|
|
const [nick, setNick] = useState('testuser');
|
|
const [host, setHost] = useState('ws.irc.icynet.eu');
|
|
const [channel, setChannel] = useState('#squeebot');
|
|
const [port, setPort] = useState(443);
|
|
const [password, setPassword] = useState('');
|
|
const [ssl, setSSL] = useState(true);
|
|
|
|
return (
|
|
<div>
|
|
<h1>teemant</h1>
|
|
<form
|
|
onSubmit={() => {
|
|
onSubmit(nick, channel, host, ssl, port, password);
|
|
}}
|
|
>
|
|
<label htmlFor="nick">Nickname</label>
|
|
<input
|
|
id="nick"
|
|
name="nick"
|
|
value={nick}
|
|
onChange={(e) => setNick(e.target.value)}
|
|
/>
|
|
<label htmlFor="channel">Channel</label>
|
|
<input
|
|
id="channel"
|
|
name="channel"
|
|
value={channel}
|
|
onChange={(e) => setChannel(e.target.value)}
|
|
/>
|
|
<label htmlFor="host">Hostname</label>
|
|
<input
|
|
id="host"
|
|
name="host"
|
|
value={host}
|
|
onChange={(e) => setHost(e.target.value)}
|
|
/>
|
|
<label htmlFor="port">Port</label>
|
|
<input
|
|
id="port"
|
|
name="port"
|
|
value={port}
|
|
onChange={(e) => setPort(parseInt(e.target.value, 10))}
|
|
/>
|
|
<label htmlFor="password">Password</label>
|
|
<input
|
|
id="password"
|
|
type="password"
|
|
name="password"
|
|
value={password}
|
|
onChange={(e) => setPassword(e.target.value)}
|
|
/>
|
|
<label htmlFor="ssl">Use SSL</label>
|
|
<input
|
|
id="ssl"
|
|
type="checkbox"
|
|
name="ssl"
|
|
checked={ssl}
|
|
onChange={(e) => setSSL(e.target.checked)}
|
|
/>
|
|
<button type="submit">Connect</button>
|
|
</form>
|
|
</div>
|
|
);
|
|
};
|