fix
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
import { Button } from "@kobalte/core/button";
|
import { Button } from "@kobalte/core/button";
|
||||||
import { TextField } from "@kobalte/core/text-field";
|
import { TextField } from "@kobalte/core/text-field";
|
||||||
import { createSignal, Show, type Component } from "solid-js";
|
import { createSignal, Show, type Component } from "solid-js";
|
||||||
import { postCode, postLogin } from "./network";
|
import { base, postCode, postLogin } from "./network";
|
||||||
import { isTokenValid } from "./ProtectedRoute";
|
import { isTokenValid } from "./ProtectedRoute";
|
||||||
import { Navigate } from "@solidjs/router";
|
import { Navigate } from "@solidjs/router";
|
||||||
|
|
||||||
@ -40,20 +40,23 @@ export const Login: Component = () => {
|
|||||||
const isAuthorized = isTokenValid();
|
const isAuthorized = isTokenValid();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Show when={!isAuthorized} fallback={<Navigate href="/" />}>
|
<>
|
||||||
<form ref={form} onSubmit={onSubmit}>
|
{base}
|
||||||
<TextField name="email">
|
<Show when={!isAuthorized} fallback={<Navigate href="/" />}>
|
||||||
<TextField.Label>Email</TextField.Label>
|
<form ref={form} onSubmit={onSubmit}>
|
||||||
<TextField.Input />
|
<TextField name="email">
|
||||||
</TextField>
|
<TextField.Label>Email</TextField.Label>
|
||||||
<Show when={submitted()}>
|
|
||||||
<TextField name="code">
|
|
||||||
<TextField.Label>Code</TextField.Label>
|
|
||||||
<TextField.Input />
|
<TextField.Input />
|
||||||
</TextField>
|
</TextField>
|
||||||
</Show>
|
<Show when={submitted()}>
|
||||||
<Button type="submit">Submit</Button>
|
<TextField name="code">
|
||||||
</form>
|
<TextField.Label>Code</TextField.Label>
|
||||||
</Show>
|
<TextField.Input />
|
||||||
|
</TextField>
|
||||||
|
</Show>
|
||||||
|
<Button type="submit">Submit</Button>
|
||||||
|
</form>
|
||||||
|
</Show>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -17,8 +17,12 @@ type BaseRequestParams = Partial<{
|
|||||||
method: "GET" | "POST";
|
method: "GET" | "POST";
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
export const base = import.meta.env.DEV
|
||||||
|
? "http://localhost:3040"
|
||||||
|
: "https://haystack.johncosta.tech";
|
||||||
|
|
||||||
const getBaseRequest = ({ path, body, method }: BaseRequestParams): Request => {
|
const getBaseRequest = ({ path, body, method }: BaseRequestParams): Request => {
|
||||||
return new Request(`http://localhost:3040/${path}`, {
|
return new Request(`${base}/${path}`, {
|
||||||
body,
|
body,
|
||||||
method,
|
method,
|
||||||
});
|
});
|
||||||
@ -29,7 +33,7 @@ const getBaseAuthorizedRequest = ({
|
|||||||
body,
|
body,
|
||||||
method,
|
method,
|
||||||
}: BaseRequestParams): Request => {
|
}: BaseRequestParams): Request => {
|
||||||
return new Request(`http://localhost:3040/${path}`, {
|
return new Request(`${base}/${path}`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${localStorage.getItem("access")?.toString()}`,
|
Authorization: `Bearer ${localStorage.getItem("access")?.toString()}`,
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user