|
|
@@ -1,5 +1,7 @@
|
|
|
<script>
|
|
|
import "$lib/global.css";
|
|
|
+ import {PUBLIC_API_URL} from "$env/static/public";
|
|
|
+ import {goto} from "$app/navigation";
|
|
|
import favicon from "$lib/assets/favicon.png";
|
|
|
|
|
|
let name = $state("");
|
|
|
@@ -8,8 +10,28 @@
|
|
|
let confirmPassword = $state("");
|
|
|
let url = $state("");
|
|
|
|
|
|
- const submit = ()=>{
|
|
|
- console.log("submitting");
|
|
|
+ const submit = async ()=>{
|
|
|
+ const body = {
|
|
|
+ name: name,
|
|
|
+ email: email,
|
|
|
+ password: password,
|
|
|
+ confirm_password: confirmPassword,
|
|
|
+ url: url
|
|
|
+ };
|
|
|
+
|
|
|
+ const response = await fetch(`${PUBLIC_API_URL}/user`, {
|
|
|
+ method: "POST",
|
|
|
+ headers: {"Content-Type": "application/json"},
|
|
|
+ body: JSON.stringify(body)
|
|
|
+ });
|
|
|
+
|
|
|
+ const responseBody = await response.json();
|
|
|
+ if(!response.ok){
|
|
|
+ console.log("error");
|
|
|
+ console.log(responseBody);
|
|
|
+ }else{
|
|
|
+ goto("/login");
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
@@ -22,31 +44,31 @@
|
|
|
</a>
|
|
|
|
|
|
<div class="form-glow">
|
|
|
- <div id="register" class="standardForm" onsubmit={submit}>
|
|
|
- <h2>Join The Adventure</h2>
|
|
|
+ <form class="standardForm" onsubmit={submit}>
|
|
|
+ <h2>Join The Adventure</h2>
|
|
|
|
|
|
- <label>Name
|
|
|
- <input bind:value={name} type="text" required>
|
|
|
- </label>
|
|
|
+ <label>Name
|
|
|
+ <input bind:value={name} type="text" required>
|
|
|
+ </label>
|
|
|
|
|
|
- <label>Email
|
|
|
- <input bind:value={email} type="email" required>
|
|
|
- </label>
|
|
|
+ <label>Email
|
|
|
+ <input bind:value={email} type="email" required>
|
|
|
+ </label>
|
|
|
|
|
|
- <label>Password
|
|
|
- <input bind:value={password} type="password" required>
|
|
|
- </label>
|
|
|
+ <label>Password
|
|
|
+ <input bind:value={password} type="password" required>
|
|
|
+ </label>
|
|
|
|
|
|
- <label>Confirm Password
|
|
|
- <input bind:value={confirmPassword} type="password" required>
|
|
|
- </label>
|
|
|
+ <label>Confirm Password
|
|
|
+ <input bind:value={confirmPassword} type="password" required>
|
|
|
+ </label>
|
|
|
|
|
|
- <input bind:value={url} type="hidden" required>
|
|
|
+ <input bind:value={url} type="hidden" required>
|
|
|
|
|
|
- <button type="submit">Register</button>
|
|
|
+ <button type="submit">Register</button>
|
|
|
|
|
|
- <p>Already have an account? <a href="/login">Log in</a></p>
|
|
|
- </div>
|
|
|
+ <p>Already have an account? <a href="/login">Log in</a></p>
|
|
|
+ </form>
|
|
|
</div>
|
|
|
</main>
|
|
|
|