Skip to content

Commit

Permalink
better login page
Browse files Browse the repository at this point in the history
  • Loading branch information
kayra1 committed Jul 29, 2024
1 parent 089c572 commit a699087
Showing 1 changed file with 48 additions and 33 deletions.
81 changes: 48 additions & 33 deletions ui/src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useMutation, useQuery } from "react-query"
import { useState, ChangeEvent } from "react"
import { useCookies } from "react-cookie"
import { useRouter } from "next/navigation"
import { Logo } from "../nav"

type statusResponse = {
initialized: boolean
Expand Down Expand Up @@ -40,41 +41,55 @@ export default function LoginPage() {
const handleUsernameChange = (event: ChangeEvent<HTMLInputElement>) => { setUsername(event.target.value) }
const handlePasswordChange = (event: ChangeEvent<HTMLInputElement>) => { setPassword(event.target.value) }
return (
<div style={{
display: "flex",
alignContent: "center",
justifyContent: "center",
flexWrap: "wrap",
height: "100vh",
}}>
<div className="p-panel" style={{
width: "25rem",
minWidth: "min-content",
minHeight: "min-content",
}}>
<div className="p-panel__header is-sticky">
<h4 className="p-panel__title">Login</h4>
<>
<div style={{ backgroundColor: "#262626", height: "7.5vh" }}>
<div style={{ marginLeft: "30px" }}>
<Logo />
</div>
<div className="p-panel__content">
<div className="u-fixed-width">
<form>
<label htmlFor="InputUsername">Username</label>
<input type="text" id="InputUsername" name="InputUsername" onChange={handleUsernameChange} />
<label htmlFor="InputPassword">Password</label>
<input type="password" id="InputPassword" name="InputPassword" placeholder="******" autoComplete="current-password" onChange={handlePasswordChange} />
{errorText &&
<div className="p-notification--negative">
<div className="p-notification__content">
<h5 className="p-notification__title">Error</h5>
<p className="p-notification__message">{errorText.split("error: ")}</p>
</div>
</div>
}
<button type="submit" name="submit" onClick={(event) => { event.preventDefault(); mutation.mutate({ username: username, password: password }) }}>Submit</button>
</form>
</div>
<div style={{
display: "flex",
alignContent: "center",
justifyContent: "center",
flexWrap: "wrap",
height: "92.5vh",
}}>
<div className="p-panel" style={{
width: "35rem",
minWidth: "min-content",
minHeight: "min-content",
}}>
<div className="p-panel__header is-sticky">
{/* topBar?*/}
</div>
</div>
<div className="p-panel__content">
<div className="u-fixed-width">
<form className="p-form">
<fieldset>
<h2 className="p-panel__title">Login</h2>
<label htmlFor="InputUsername">Username</label>
<input type="text" id="InputUsername" name="InputUsername" onChange={handleUsernameChange} />
<label htmlFor="InputPassword">Password</label>
<input type="password" id="InputPassword" name="InputPassword" placeholder="******" autoComplete="current-password" onChange={handlePasswordChange} />
{errorText &&
<div className="p-notification--negative">
<div className="p-notification__content">
<h5 className="p-notification__title">Error</h5>
<p className="p-notification__message">{errorText.split("error: ")}</p>
</div>
</div>
}
{password.length != 0 && username.length != 0 ? (
<button className="p-button--positive" type="submit" name="submit" onClick={(event) => { event.preventDefault(); mutation.mutate({ username: username, password: password }) }}>Log In</button>
) : (
<button disabled={true} className="p-button--positive" type="submit" name="submit" onClick={(event) => { event.preventDefault(); mutation.mutate({ username: username, password: password }) }}>Log In</button>
)}
</fieldset>
</form>
</div>
</div>
</div >
</div >
</div >
</>
)
}

0 comments on commit a699087

Please sign in to comment.