|
@@ -1,12 +1,31 @@
|
|
|
<script>
|
|
<script>
|
|
|
- import "$lib/global.css";
|
|
|
|
|
import favicon from "$lib/assets/favicon.png";
|
|
import favicon from "$lib/assets/favicon.png";
|
|
|
|
|
+ import {toast} from "$lib/toast.svelte.js";
|
|
|
|
|
+ import {PUBLIC_API_URL} from "$env/static/public";
|
|
|
|
|
+ import {goto} from "$app/navigation";
|
|
|
|
|
|
|
|
let email = $state("");
|
|
let email = $state("");
|
|
|
let password = $state("");
|
|
let password = $state("");
|
|
|
|
|
|
|
|
const submit = async ()=>{
|
|
const submit = async ()=>{
|
|
|
- console.log("submit");
|
|
|
|
|
|
|
+ const body = {
|
|
|
|
|
+ email: email,
|
|
|
|
|
+ password: password
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const response = await fetch(`${PUBLIC_API_URL}/user/login`, {
|
|
|
|
|
+ method: "POST",
|
|
|
|
|
+ headers: {"Content-Type": "application/json"},
|
|
|
|
|
+ credentials: "include",
|
|
|
|
|
+ body: JSON.stringify(body)
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ const responseBody = await response.json();
|
|
|
|
|
+ if(!response.ok){
|
|
|
|
|
+ toast(responseBody.error.message, "error");
|
|
|
|
|
+ }else{
|
|
|
|
|
+ goto("/dashboard");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|