Move login page to server.
This commit is contained in:
parent
a34613a64a
commit
c59248f7a5
|
|
@ -14,7 +14,6 @@ import { Provider as JotaiProvider } from "jotai";
|
|||
import { Home } from "./Home.tsx";
|
||||
import { Video } from "./Video.tsx";
|
||||
import { Version } from "./Version.tsx";
|
||||
import { Login } from "./Login.tsx";
|
||||
import "./App.css";
|
||||
|
||||
function App() {
|
||||
|
|
@ -44,10 +43,6 @@ const router = createBrowserRouter([
|
|||
path: "/video",
|
||||
element: <Video />,
|
||||
},
|
||||
{
|
||||
path: "/login",
|
||||
element: <Login />,
|
||||
},
|
||||
]);
|
||||
|
||||
export default App;
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
//
|
||||
// Copyright 2026 James Pace
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
//
|
||||
// This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
// defined by the Mozilla Public License, v. 2.0.
|
||||
//
|
||||
import { Container, Row, Col, Card, Button, Form } from "react-bootstrap";
|
||||
import { atom, useAtomValue } from "jotai";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
export function Login() {
|
||||
return (
|
||||
<div>
|
||||
<Container className="vert-padded">
|
||||
<LoginForm />
|
||||
</Container>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function LoginForm() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const onSubmit = async (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
console.log(event.target);
|
||||
const formEntries = new FormData(event.target);
|
||||
const formData = Object.fromEntries(formEntries);
|
||||
console.log(formData);
|
||||
|
||||
const resp = await fetch("/api/login", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(formData),
|
||||
});
|
||||
if (resp.redirected) {
|
||||
navigate("/");
|
||||
}
|
||||
};
|
||||
return (
|
||||
<Form onSubmit={onSubmit}>
|
||||
<Form.Group controlId="passwordForm">
|
||||
<Form.Label>Password</Form.Label>
|
||||
<Form.Control name="password" type="password" />
|
||||
</Form.Group>
|
||||
|
||||
<Button type="submit">Submit</Button>
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
Loading…
Reference in New Issue