Add toasts used in login page

This commit is contained in:
qowevisa 2024-11-02 18:42:45 +02:00
parent 2a2fd78d3b
commit 3be3b83712

View File

@ -1,5 +1,7 @@
<script> <script>
import { login } from "$lib/api"; import { login } from "$lib/api";
import { addSuccessToast } from "$lib/components/store";
import Toasts from "$lib/components/Toasts.svelte";
let username = $state(""); let username = $state("");
let password = $state(""); let password = $state("");
let error = $state(""); let error = $state("");
@ -13,7 +15,7 @@
} }
try { try {
const resp = await login(username, password); const resp = await login(username, password);
console.log("Login successful!1"); addSuccessToast("Login successful!");
console.log(resp); console.log(resp);
} catch (err) { } catch (err) {
if (err instanceof Error) { if (err instanceof Error) {
@ -27,6 +29,7 @@
$inspect("password = ", password); $inspect("password = ", password);
</script> </script>
<Toasts />
<div class="flex justify-center items-center min-h-screen bg-gray-100"> <div class="flex justify-center items-center min-h-screen bg-gray-100">
<div class="bg-white p-8 rounded-lg shadow-md w-full max-w-md"> <div class="bg-white p-8 rounded-lg shadow-md w-full max-w-md">
<h1 class="text-2xl font-bold text-center mb-6">Login</h1> <h1 class="text-2xl font-bold text-center mb-6">Login</h1>