57 lines
1.8 KiB
TypeScript
Raw Normal View History

2022-08-10 09:42:15 -05:00
import React, { useState } from 'react'
import { useNavigate } from 'react-router-dom'
import Button from '@mui/material/Button'
import FormControl from '@mui/material/FormControl'
2022-08-09 21:57:29 -05:00
import Typography from '@mui/material/Typography'
2022-08-10 09:42:15 -05:00
import TextField from '@mui/material/TextField'
import { v4 as uuid } from 'uuid'
2022-08-09 21:28:46 -05:00
export function Home() {
2022-08-10 09:42:15 -05:00
const [roomName, setRoomName] = useState(uuid())
const navigate = useNavigate()
2022-08-10 09:42:15 -05:00
const handleRoomNameChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const { value } = event.target
setRoomName(value)
}
const handleFormSubmit = (event: React.SyntheticEvent<HTMLFormElement>) => {
event.preventDefault()
navigate(`/public/${roomName}`)
}
2022-08-09 21:57:29 -05:00
return (
<div className="Home">
<header className="max-w-3xl text-center mx-auto">
<Typography variant="h1">chitchatter</Typography>
<Typography variant="body1">
This is a communication tool that is free, open source, and designed
for maximum security. All communication between you and your online
peers is encrypted and ephemeral.
</Typography>
2022-08-09 22:14:59 -05:00
<Typography variant="body1">
chitchatter is still a work in progress and not yet ready to be used!
</Typography>
2022-08-09 21:57:29 -05:00
</header>
2022-08-10 09:42:15 -05:00
<main className="mt-8 max-w-3xl text-center mx-auto">
<form onSubmit={handleFormSubmit} className="max-w-xl mx-auto">
<FormControl fullWidth>
<TextField
label="Room name"
variant="outlined"
value={roomName}
onChange={handleRoomNameChange}
size="medium"
/>
</FormControl>
<div className="block pt-4">
<Button variant="contained" type="submit">
Go to public room
</Button>
</div>
</form>
2022-08-10 09:42:15 -05:00
</main>
2022-08-09 21:57:29 -05:00
</div>
)
2022-08-09 21:28:46 -05:00
}