diff options
Diffstat (limited to 'frontend/src/routes')
| -rw-r--r-- | frontend/src/routes/Login.tsx | 21 | ||||
| -rw-r--r-- | frontend/src/routes/teams/Edit.tsx | 19 | ||||
| -rw-r--r-- | frontend/src/routes/teams/New.tsx | 19 | ||||
| -rw-r--r-- | frontend/src/routes/users/Edit.tsx | 22 |
4 files changed, 80 insertions, 1 deletions
diff --git a/frontend/src/routes/Login.tsx b/frontend/src/routes/Login.tsx index 1945abe..f3fa00e 100644 --- a/frontend/src/routes/Login.tsx +++ b/frontend/src/routes/Login.tsx @@ -1,4 +1,4 @@ -import { Form } from "react-router-dom"; +import { redirect, Form, ActionFunctionArgs } from "react-router-dom"; export default function Login() { return ( @@ -17,3 +17,22 @@ export default function Login() { </div> ); }; + +export async function loginAction({ request }: ActionFunctionArgs) { + const formData = await request.formData(); + const username = formData.get("username"); + const password = formData.get("password"); + + const res = await fetch("/api/login", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ username, password }), + }); + if (!res.ok) { + throw res; + } + const { userId } = await res.json(); + return redirect(`/users/${userId}/`); +}; diff --git a/frontend/src/routes/teams/Edit.tsx b/frontend/src/routes/teams/Edit.tsx new file mode 100644 index 0000000..0b3ed74 --- /dev/null +++ b/frontend/src/routes/teams/Edit.tsx @@ -0,0 +1,19 @@ +import { Form } from "react-router-dom"; + +export default function Edit() { + return ( + <div> + <h1>Albatross.swift</h1> + <h2> + Team Edit + </h2> + <Form method="post"> + <label>Team name</label> + <input type="text" name="name" /> + <label>Icon</label> + <input type="text" name="icon" disabled /> + <button type="submit">Save</button> + </Form> + </div> + ); +}; diff --git a/frontend/src/routes/teams/New.tsx b/frontend/src/routes/teams/New.tsx new file mode 100644 index 0000000..2712cd5 --- /dev/null +++ b/frontend/src/routes/teams/New.tsx @@ -0,0 +1,19 @@ +import { Form } from "react-router-dom"; + +export default function New() { + return ( + <div> + <h1>Albatross.swift</h1> + <h2> + Team New + </h2> + <Form method="post"> + <label>Team name</label> + <input type="text" name="name" /> + <label>Icon</label> + <input type="text" name="icon" disabled /> + <button type="submit">Create</button> + </Form> + </div> + ); +}; diff --git a/frontend/src/routes/users/Edit.tsx b/frontend/src/routes/users/Edit.tsx new file mode 100644 index 0000000..fa2a826 --- /dev/null +++ b/frontend/src/routes/users/Edit.tsx @@ -0,0 +1,22 @@ +import { Form, Link } from "react-router-dom"; + +export default function Edit() { + return ( + <div> + <h1>Albatross.swift</h1> + <h2> + User Edit + </h2> + <Form method="post"> + <label>Display name</label> + <input type="text" name="display_name" /> + <label>Icon</label> + <input type="text" name="icon" disabled /> + <button type="submit">Save</button> + </Form> + <p> + <Link to="/teams/new/">Create a new team</Link> + </p> + </div> + ); +}; |
