2021-12-30 16:34:50 +01:00
|
|
|
<script lang="ts">
|
2021-12-31 11:38:06 +01:00
|
|
|
let username: string | undefined;
|
|
|
|
let password: string | undefined;
|
2021-12-30 16:34:50 +01:00
|
|
|
|
2021-12-31 11:38:06 +01:00
|
|
|
const onSubmit = () => {
|
|
|
|
if (username === undefined || username.trim() === "") {
|
|
|
|
return;
|
|
|
|
}
|
2021-12-30 16:34:50 +01:00
|
|
|
|
2021-12-31 11:38:06 +01:00
|
|
|
if (password === undefined || password.trim() === "") {
|
2021-12-30 16:34:50 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-31 11:38:06 +01:00
|
|
|
fetch("/api/register", {
|
|
|
|
method: "POST",
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
|
|
|
body: JSON.stringify({
|
|
|
|
username,
|
|
|
|
password,
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
.then((resp) => resp.json())
|
|
|
|
.then((data) => {
|
|
|
|
console.log(data);
|
|
|
|
});
|
|
|
|
};
|
2021-12-30 16:34:50 +01:00
|
|
|
</script>
|
|
|
|
|
2022-03-18 19:43:41 +01:00
|
|
|
<div class="page-card">
|
|
|
|
<div class="page-card-content">
|
|
|
|
<h1 class="page-card-header">Create account</h1>
|
2022-03-19 21:33:52 +01:00
|
|
|
<form class="account-form" on:submit|preventDefault={onSubmit}>
|
2022-03-18 19:43:41 +01:00
|
|
|
<label for="username">Username</label>
|
|
|
|
<input name="username" bind:value={username} />
|
|
|
|
<label for="password">Password</label>
|
|
|
|
<input type="password" name="password" bind:value={password} />
|
2022-03-19 21:33:52 +01:00
|
|
|
<button type="submit">Submit</button>
|
2022-03-18 19:43:41 +01:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<style lang="scss">
|
2022-03-19 21:33:52 +01:00
|
|
|
@import "src/styles/account_forms.scss";
|
2022-03-18 19:43:41 +01:00
|
|
|
</style>
|