fmt: use biome
This commit is contained in:
@@ -1,40 +1,40 @@
|
||||
import { Component, createSignal } from 'solid-js';
|
||||
import { Button } from './ui/Button';
|
||||
import { Card } from './ui/Card';
|
||||
import { Input } from './ui/Input';
|
||||
import { Component, createSignal } from "solid-js";
|
||||
import { Button } from "./ui/Button";
|
||||
import { Card } from "./ui/Card";
|
||||
import { Input } from "./ui/Input";
|
||||
|
||||
interface LoginProps {
|
||||
onLoginSuccess: (token: string) => void;
|
||||
}
|
||||
|
||||
const Login: Component<LoginProps> = (props) => {
|
||||
const [password, setPassword] = createSignal('');
|
||||
const [error, setError] = createSignal('');
|
||||
const [password, setPassword] = createSignal("");
|
||||
const [error, setError] = createSignal("");
|
||||
const [isLoading, setIsLoading] = createSignal(false);
|
||||
|
||||
const handleSubmit = async (e: Event) => {
|
||||
e.preventDefault();
|
||||
setError('');
|
||||
setError("");
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
const response = await fetch('/admin/api/login', {
|
||||
method: 'POST',
|
||||
const response = await fetch("/admin/api/login", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ password: password() }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => ({ error: 'Login failed' }));
|
||||
throw new Error(errorData.error || 'Invalid password');
|
||||
const errorData = await response.json().catch(() => ({ error: "Login failed" }));
|
||||
throw new Error(errorData.error || "Invalid password");
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
props.onLoginSuccess(data.token);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Login failed');
|
||||
setError(err instanceof Error ? err.message : "Login failed");
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
@@ -43,9 +43,7 @@ const Login: Component<LoginProps> = (props) => {
|
||||
return (
|
||||
<div class="min-h-screen bg-gray-100 flex items-center justify-center">
|
||||
<Card class="p-8 w-96">
|
||||
<h1 class="text-2xl font-bold text-gray-900 mb-6 text-center">
|
||||
My Linspirer Admin Login
|
||||
</h1>
|
||||
<h1 class="text-2xl font-bold text-gray-900 mb-6 text-center">My Linspirer Admin Login</h1>
|
||||
|
||||
<form onSubmit={handleSubmit}>
|
||||
<div class="mb-4">
|
||||
@@ -69,12 +67,8 @@ const Login: Component<LoginProps> = (props) => {
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
size="lg"
|
||||
disabled={isLoading()}
|
||||
>
|
||||
{isLoading() ? 'Logging in...' : 'Login'}
|
||||
<Button type="submit" size="lg" disabled={isLoading()}>
|
||||
{isLoading() ? "Logging in..." : "Login"}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user