pwa fixes
This commit is contained in:
parent
6b41eafc55
commit
9bbc8cd0b3
2 changed files with 127 additions and 118 deletions
|
|
@ -1,13 +1,13 @@
|
|||
<script lang="ts">
|
||||
import { login } from '$lib/api/auth';
|
||||
import { goto } from '$app/navigation';
|
||||
import { auth } from '$lib/auth/store.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import { today } from '$lib/utils/date';
|
||||
import { login } from "$lib/api/auth";
|
||||
import { goto } from "$app/navigation";
|
||||
import { auth } from "$lib/auth/store.svelte";
|
||||
import { onMount } from "svelte";
|
||||
import { today } from "$lib/utils/date";
|
||||
|
||||
let username = $state('');
|
||||
let password = $state('');
|
||||
let error = $state('');
|
||||
let username = $state("");
|
||||
let password = $state("");
|
||||
let error = $state("");
|
||||
let loading = $state(false);
|
||||
|
||||
onMount(() => {
|
||||
|
|
@ -16,13 +16,13 @@
|
|||
|
||||
async function handleSubmit(e: SubmitEvent) {
|
||||
e.preventDefault();
|
||||
error = '';
|
||||
error = "";
|
||||
loading = true;
|
||||
try {
|
||||
await login(username, password);
|
||||
goto(`/diary/${today()}`);
|
||||
} catch (err: unknown) {
|
||||
error = 'Invalid username or password';
|
||||
error = "Invalid username or password";
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
|
|
@ -35,7 +35,10 @@
|
|||
|
||||
<form onsubmit={handleSubmit} class="space-y-4">
|
||||
<div>
|
||||
<label for="username" class="block text-sm font-medium text-zinc-400 mb-1">Username</label>
|
||||
<label
|
||||
for="username"
|
||||
class="block text-sm font-medium text-zinc-400 mb-1">Username</label
|
||||
>
|
||||
<input
|
||||
id="username"
|
||||
type="text"
|
||||
|
|
@ -47,7 +50,10 @@
|
|||
</div>
|
||||
|
||||
<div>
|
||||
<label for="password" class="block text-sm font-medium text-zinc-400 mb-1">Password</label>
|
||||
<label
|
||||
for="password"
|
||||
class="block text-sm font-medium text-zinc-400 mb-1">Password</label
|
||||
>
|
||||
<input
|
||||
id="password"
|
||||
type="password"
|
||||
|
|
@ -67,13 +73,15 @@
|
|||
disabled={loading}
|
||||
class="w-full bg-green-600 hover:bg-green-500 disabled:opacity-50 rounded-xl py-3 font-semibold transition-colors"
|
||||
>
|
||||
{loading ? 'Signing in…' : 'Sign in'}
|
||||
{loading ? "Signing in…" : "Sign in"}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<p class="text-center mt-6 text-zinc-500 text-sm">
|
||||
No account?
|
||||
<a href="/register" class="text-green-500 hover:text-green-400">Register</a>
|
||||
<a href="/register" class="text-green-500 hover:text-green-400"
|
||||
>Register</a
|
||||
>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ export default defineConfig({
|
|||
display: 'standalone',
|
||||
orientation: 'portrait',
|
||||
start_url: '/diary/today',
|
||||
scope: '/',
|
||||
id: '/',
|
||||
categories: ['health', 'food'],
|
||||
icons: [
|
||||
|
|
|
|||
Loading…
Reference in a new issue