Sync React frontend into git
- Replace stale TanStack Router scaffold with working react-router-dom app - Add all 9 page components + cyber theme CSS - Remove routeTree.gen.ts, add index.css, query.ts
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { useState } from "react";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { api } from "../lib/api";
|
||||
|
||||
export default function LoginPage() {
|
||||
const [mailbox, setMailbox] = useState("");
|
||||
const [pin, setPin] = useState("");
|
||||
const [error, setError] = useState("");
|
||||
const login = useMutation({ mutationFn: () => api.login(mailbox, pin) });
|
||||
const submit = (e: React.FormEvent) => { e.preventDefault(); setError(""); login.mutate(undefined, { onSuccess: () => { window.location.href = "/"; }, onError: (err) => setError((err as Error).message) }); };
|
||||
return (
|
||||
<div className="wrap">
|
||||
<div className="card">
|
||||
{error && <div className="err">{error}</div>}
|
||||
<form onSubmit={submit}>
|
||||
<label>Mailbox number</label><input value={mailbox} onChange={(e) => setMailbox(e.target.value)} inputMode="numeric" />
|
||||
<label>PIN</label><input type="password" value={pin} onChange={(e) => setPin(e.target.value)} inputMode="numeric" />
|
||||
<div className="row"><button type="submit" className="primary">Log in</button></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user