fix: login UI
This commit is contained in:
@ -3,7 +3,7 @@ import { TextField } from "@kobalte/core/text-field";
|
|||||||
import { Navigate } from "@solidjs/router";
|
import { Navigate } from "@solidjs/router";
|
||||||
import { type Component, Show, createSignal } from "solid-js";
|
import { type Component, Show, createSignal } from "solid-js";
|
||||||
import { isTokenValid } from "./ProtectedRoute";
|
import { isTokenValid } from "./ProtectedRoute";
|
||||||
import { base, postCode, postLogin } from "./network";
|
import { postCode, postLogin } from "./network";
|
||||||
|
|
||||||
export const Login: Component = () => {
|
export const Login: Component = () => {
|
||||||
let form: HTMLFormElement | undefined;
|
let form: HTMLFormElement | undefined;
|
||||||
@ -32,8 +32,6 @@ export const Login: Component = () => {
|
|||||||
code.toString(),
|
code.toString(),
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(access, refresh);
|
|
||||||
|
|
||||||
localStorage.setItem("access", access);
|
localStorage.setItem("access", access);
|
||||||
localStorage.setItem("refresh", refresh);
|
localStorage.setItem("refresh", refresh);
|
||||||
|
|
||||||
@ -44,23 +42,37 @@ export const Login: Component = () => {
|
|||||||
const isAuthorized = isTokenValid();
|
const isAuthorized = isTokenValid();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
|
||||||
{base}
|
|
||||||
<Show when={!isAuthorized} fallback={<Navigate href="/" />}>
|
<Show when={!isAuthorized} fallback={<Navigate href="/" />}>
|
||||||
<form ref={form} onSubmit={onSubmit}>
|
<form
|
||||||
<TextField name="email">
|
ref={form}
|
||||||
<TextField.Label>Email</TextField.Label>
|
onSubmit={onSubmit}
|
||||||
<TextField.Input />
|
class="flex flex-col gap-2 mt-4 w-72"
|
||||||
|
>
|
||||||
|
<TextField name="email" class="flex flex-col gap-4">
|
||||||
|
<TextField.Label class="text-xl font-semibold">
|
||||||
|
Email
|
||||||
|
</TextField.Label>
|
||||||
|
<TextField.Input
|
||||||
|
pattern="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
|
||||||
|
type="email"
|
||||||
|
class="rounded px-1 py-2"
|
||||||
|
/>
|
||||||
</TextField>
|
</TextField>
|
||||||
<Show when={submitted()}>
|
<Show when={submitted()}>
|
||||||
<TextField name="code">
|
<TextField name="code" class="flex flex-col gap-2">
|
||||||
<TextField.Label>Code</TextField.Label>
|
<TextField.Label class="text-xl font-semibold">
|
||||||
<TextField.Input />
|
Code
|
||||||
|
</TextField.Label>
|
||||||
|
<TextField.Input class="rounded px-1 py-2" />
|
||||||
</TextField>
|
</TextField>
|
||||||
</Show>
|
</Show>
|
||||||
<Button type="submit">Submit</Button>
|
<Button
|
||||||
|
type="submit"
|
||||||
|
class="rounded-xl bg-slate-800 px-2 py-4 text-neutral-200"
|
||||||
|
>
|
||||||
|
Submit
|
||||||
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
</Show>
|
</Show>
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user