blob: 755c180d24d060c1e0e39304efb9c213c287e4af (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
import { useContext, useCallback } from 'preact/hooks';
import { useSignal } from '@preact/signals';
import { route } from 'preact-router';
import { Pb } from '../context.ts';
import Header from '../components/Header.tsx';
import Content from '../components/Content.tsx';
import Form from '../components/Form.tsx';
import FormLabel from '../components/FormLabel.tsx';
import TextInput from '../components/TextInput.tsx';
import Button from '../components/Button.tsx';
import ArrowButton from '../components/ArrowButton.tsx';
const SignUp = () => {
const pb = useContext(Pb)!;
const username = useSignal('');
const email = useSignal('');
const password = useSignal('');
const confirm = useSignal('');
const onSubmit = useCallback(async (event: SubmitEvent) => {
event.preventDefault();
await pb.collection('users').create({
username: username.value,
email: email.value,
emailVisibility: true,
password: password.value,
passwordConfirm: confirm.value,
});
if (pb.authStore.isValid) {
route('/' + pb.authStore.model!.username);
}
}, []);
return (
<>
<Header title="DataNodes">
<Button kind="ghost" href="/play">Try Now</Button>
<Button kind="ghost" href="/login">Log In</Button>
</Header>
<Content>
<Form onSubmit={onSubmit}>
<h1>Sign Up</h1>
<p>
Already have an account? <a href="/login">Log in</a>
</p>
<hr />
<FormLabel>
Username
<TextInput placeholder="Username" signal={username} />
</FormLabel>
<FormLabel>
Email
<TextInput placeholder="Email" signal={email} />
</FormLabel>
<FormLabel>
Password
<TextInput type="password" placeholder="Password" signal={password} />
</FormLabel>
<FormLabel>
Confirm password
<TextInput type="password" placeholder="Confirm password" signal={confirm} />
</FormLabel>
<ArrowButton>Continue</ArrowButton>
</Form>
</Content>
</>
);
};
export default SignUp;
|