-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
61 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { LoginForm } from "src/components/login/LoginForm"; | ||
|
||
export default async function Page() { | ||
return <LoginForm />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,25 @@ | ||
"use client"; | ||
|
||
import Sheet from "@mui/joy/Sheet"; | ||
import Typography from "@mui/joy/Typography"; | ||
import FormControl from "@mui/joy/FormControl"; | ||
import FormLabel from "@mui/joy/FormLabel"; | ||
import Input from "@mui/joy/Input"; | ||
import Button from "@mui/joy/Button"; | ||
import Link from "@mui/joy/Link"; | ||
import { useRouter } from "next/navigation"; | ||
import { useState } from "react"; | ||
import { toPage } from "src/utils/next/toPage"; | ||
|
||
export function LoginForm() { | ||
const [email, setEmail] = useState("opentrader"); | ||
const [password, setPassword] = useState(""); | ||
const router = useRouter(); | ||
|
||
const handleLogin = () => { | ||
window.localStorage.setItem("ADMIN_PASSWORD", password); | ||
router.replace(toPage("grid-bot")); | ||
}; | ||
|
||
return ( | ||
<Sheet | ||
sx={{ | ||
|
@@ -23,47 +36,42 @@ export function LoginForm() { | |
variant="outlined" | ||
> | ||
<Typography component="h1" level="h4"> | ||
Welcome! | ||
Welcome Trader! | ||
</Typography> | ||
<Typography level="body-sm">Sign in to continue.</Typography> | ||
|
||
<FormControl> | ||
<FormLabel>Email</FormLabel> | ||
<FormLabel>Username</FormLabel> | ||
|
||
<Input name="email" placeholder="[email protected]" type="email" /> | ||
<Input | ||
name="username" | ||
onChange={(e) => setEmail(e.target.value)} | ||
placeholder="username" | ||
type="text" | ||
value={email} | ||
/> | ||
</FormControl> | ||
|
||
<FormControl> | ||
<FormLabel>Password</FormLabel> | ||
|
||
<Input name="password" placeholder="password" type="password" /> | ||
<Input | ||
name="password" | ||
placeholder="password" | ||
type="password" | ||
value={password} | ||
onChange={(e) => setPassword(e.target.value)} | ||
/> | ||
</FormControl> | ||
|
||
<Button | ||
sx={{ | ||
mt: 1, | ||
}} | ||
onClick={handleLogin} | ||
> | ||
Log in | ||
</Button> | ||
<Button>Primary</Button> | ||
<Button color="neutral">Secondary</Button> | ||
<Button color="success">Success</Button> | ||
<Button color="danger">Danger</Button> | ||
<Button color="warning">Warning</Button> | ||
<Button color="neutral" variant="soft"> | ||
Light | ||
</Button> | ||
|
||
<Typography | ||
endDecorator={<Link href="/sign-up">Sign up</Link>} | ||
fontSize="sm" | ||
sx={{ | ||
alignSelf: "center", | ||
}} | ||
> | ||
Don't have an account? | ||
</Typography> | ||
</Sheet> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { TRPC_ERROR_CODES_BY_KEY } from "@trpc/server/rpc"; | ||
import type { TRPCApiError } from "src/ui/errors/types"; | ||
|
||
export function isUnauthorizedError(error: TRPCApiError) { | ||
return ( | ||
"code" in error.shape && | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- shape is any | ||
error.shape.code === TRPC_ERROR_CODES_BY_KEY.UNAUTHORIZED | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { toPage } from "src/utils/next/toPage"; | ||
|
||
export function isLoginPage() { | ||
return window.location.pathname === toPage("login"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters