Skip to content

Update login and reset password UI #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions pages/forgot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NextRouter } from 'next/router';
import React, { useState } from 'react';

import { withDataAndRouter } from '../src/helpers/with-data';
import { BlankLayout } from '../src/layouts/blank-layout';
import { LoginLayout } from '../src/layouts/login-layout';

export interface IForgotPageProps {
router: NextRouter; // { how: UserLoginErrorCode }
Expand All @@ -12,20 +12,25 @@ function ForgotPage(props: IForgotPageProps): JSX.Element {
const [username, setUsername] = useState<string>('');

return (
<BlankLayout>
<b>Reset your password</b>
<br />
<br />
<form method="post" action="/x">
<input type="hidden" name="fnid" value="SW3mxENlH7rdjgxwWaobR5" />
<input type="hidden" name="fnop" value="forgot-password" />
username:{' '}
<input type="text" name="s" size={20} onChange={(e): void => setUsername(e.target.value)} />
<LoginLayout>
<div>
<b style={{display: 'flex', justifyContent:'center', alignItems:'center'}}>Reset your password</b>
<br />
<br />
<input type="submit" value="Send reset email" />
</form>
</BlankLayout>
<form method="post" action="/x" >
<input type="hidden" name="fnid" value="SW3mxENlH7rdjgxwWaobR5" />
<input type="hidden" name="fnop" value="forgot-password" />
<div style={{display: 'flex', justifyContent:'center', alignItems:'center'}} > username:{' '}
<input type="text" name="s" size={20} onChange={(e): void => setUsername(e.target.value)} />
</div>
<br />
<br />
<div style={{display: 'flex', justifyContent:'center', alignItems:'center'}}>
<input type="submit" value="Send reset email" />
</div>
</form>
</div>
</LoginLayout>
);
}

Expand Down
202 changes: 107 additions & 95 deletions pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
UserLoginErrorCode,
} from '../src/helpers/user-login-error-code';
import { withDataAndRouter } from '../src/helpers/with-data';
import { BlankLayout } from '../src/layouts/blank-layout';
import { LoginLayout } from '../src/layouts/login-layout';

import { store } from 'react-notifications-component';

Expand All @@ -31,8 +31,8 @@ function LoginPage(props: ILoginPageProps): JSX.Element {
const [loginPassword, setLoginPassword] = useState<string>('');
const [registerId, setRegisterId] = useState<string>('');
const [registerPassword, setRegisterPassword] = useState<string>('');
const [validationMessage, setValidationMessage] = useState<string>('');

const [loginValidationMessage, setLoginValidationMessage] = useState<string>('');
const [registerValidationMessage, setRegisterValidationMessage] = useState<string>('');
//const alert = useAlert();

const validateLogin = (e: React.FormEvent<HTMLFormElement>): void => {
Expand All @@ -45,7 +45,7 @@ function LoginPage(props: ILoginPageProps): JSX.Element {

} catch (err) {
e.preventDefault();
setValidationMessage(err.message);
setLoginValidationMessage(err.message);
}
}
};
Expand All @@ -59,104 +59,116 @@ function LoginPage(props: ILoginPageProps): JSX.Element {
validateNewUser({ id: registerId, password: registerPassword });
} catch (err) {
e.preventDefault();
setValidationMessage(err.message);
setRegisterValidationMessage(err.message);
}
}
};

return (
<BlankLayout>
{message && <p>{message}</p>}
{validationMessage && <p>{validationMessage}</p>}
<b>Login</b>
<br />
<br />
<form
method="post"
action="/login"
onSubmit={(e): void => validateLogin(e)}
style={{ marginBottom: '1em' }}
>
<input type="hidden" name="goto" value={routerQuery.goto || 'news'} />
<table style={{ border: '0px' }}>
<tbody>
<tr>
<td>username:</td>
<td>
<input
autoCapitalize="off"
autoCorrect="off"
name="id"
onChange={(e): void => setLoginId(e.target.value)}
size={20}
spellCheck={false}
type="text"
/>
</td>
</tr>
<tr>
<td>password:</td>
<td>
<input
type="password"
name="password"
onChange={(e): void => setLoginPassword(e.target.value)}
size={20}
/>
</td>
</tr>
</tbody>
</table>
<LoginLayout>
<div>
{message && <p style={{display: 'flex', justifyContent:'center', alignItems:'center'}}>{message}</p>}
<br />
<b style={{display: 'flex', justifyContent:'center', alignItems:'center'}}>Login</b>
<br />
<br />
<form
method="post"
action="/login"
onSubmit={(e): void => validateLogin(e)}
style={{ marginBottom: '2em' }}
>
<input type="hidden" name="goto" value={routerQuery.goto || 'news'} />
<table style={{ display: 'flex', justifyContent:'center', alignItems:'center', border: '0px' }}>
<tbody>
<tr>
<td>username:</td>
<td>
<input
autoCapitalize="off"
autoCorrect="off"
name="id"
onChange={(e): void => setLoginId(e.target.value)}
size={20}
spellCheck={false}
type="text"
/>
</td>
</tr>
<tr>
<td>password:</td>
<td>
<input
type="password"
name="password"
onChange={(e): void => setLoginPassword(e.target.value)}
size={20}
/>
</td>
</tr>
</tbody>
</table>
{loginValidationMessage && <p style={{ display: 'flex', justifyContent:'center', alignItems:'center', color: '#f1080e' }}>{loginValidationMessage}</p>}
<br />
<div style={{display: 'flex', justifyContent:'center', alignItems:'center'}} >
<input type="submit" value="login" />
</div>
</form>
<Link href="/forgot">
<a style={{display: 'flex', justifyContent:'center', alignItems:'center'}}>Forgot your password?</a>
</Link>
<br />
<br />
<hr></hr>
<br />
<br />
<b style={{display: 'flex', justifyContent:'center', alignItems:'center'}}>Create Account</b>
<br />
<input type="submit" value="login" />
</form>
<Link href="/forgot">
<a>Forgot your password?</a>
</Link>
<br />
<br />
<b>Create Account</b>
<br />
<br />
<form
method="post"
action="/register"
onSubmit={(e): void => validateRegister(e)}
style={{ marginBottom: '1em' }}
>
<table style={{ border: '0px' }}>
<tbody>
<tr>
<td>username:</td>
<td>
<input
type="text"
name="id"
onChange={(e): void => setRegisterId(e.target.value)}
size={20}
autoCorrect="off"
spellCheck={false}
autoCapitalize="off"
/>
</td>
</tr>
<tr>
<td>password:</td>
<td>
<input
type="password"
name="password"
onChange={(e): void => setRegisterPassword(e.target.value)}
size={20}
/>
</td>
</tr>
</tbody>
</table>
<br />
<input type="submit" value="create account" />
</form>
</BlankLayout>
<form
method="post"
action="/register"
onSubmit={(e): void => validateRegister(e)}
style={{ marginBottom: '2em' }}
>
<table style={{ display: 'flex', justifyContent:'center', alignItems:'center', border: '0px' }}>
<tbody>
<tr>
<td>username:</td>
<td>
<input
type="text"
name="id"
onChange={(e): void => setRegisterId(e.target.value)}
size={20}
autoCorrect="off"
spellCheck={false}
autoCapitalize="off"
/>
</td>
</tr>
<tr>
<td>password:</td>
<td>
<input
type="password"
name="password"
onChange={(e): void => setRegisterPassword(e.target.value)}
size={20}
/>
</td>
</tr>
</tbody>
</table>
{registerValidationMessage && <p style={{ display: 'flex', justifyContent:'center', alignItems:'center', color: '#f1080e' }}>{registerValidationMessage}</p>}
<br />
<div style={{display: 'flex', justifyContent:'center', alignItems:'center'}} >
<input type="submit" value="create account" />
</div>
<br />
</form>
</div>
</LoginLayout>
);
}

Expand Down
31 changes: 18 additions & 13 deletions src/components/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Link from 'next/link';
import * as React from 'react';

export function Footer(): JSX.Element {
export function Footer(props): JSX.Element {
const {isFooterNotVisible} = props;
return (
<tr>
<td style={{ padding: '0px' }}>
Expand Down Expand Up @@ -44,18 +45,22 @@ export function Footer(): JSX.Element {
</span>
<br />
<br />
<form method="get" action="//hn.algolia.com/" style={{ marginBottom: '1em' }}>
Search:
<input
type="text"
name="q"
size={17}
autoCorrect="off"
spellCheck={false}
autoCapitalize="off"
autoComplete="false"
/>
</form>
{isFooterNotVisible?
(null):
(<form method="get" action="//hn.algolia.com/" style={{ marginBottom: '1em' }}>
Search:
<input
type="text"
name="q"
size={17}
autoCorrect="off"
spellCheck={false}
autoCapitalize="off"
autoComplete="false"
/>
</form>)
}

</div>
</td>
</tr>
Expand Down
22 changes: 14 additions & 8 deletions src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function Header(props: IHeaderProps): JSX.Element {
<HeaderNav currentUrl={currentUrl} isNavVisible={isNavVisible} title={title} />
</td>
<td style={{ textAlign: 'right', padding: '0px', paddingRight: '4px' }}>
{me ? (
{ me?
<span className="pagetop">
<Link href={`/user?id=${me.id}`}>
<a>{me.id}</a>
Expand All @@ -81,13 +81,19 @@ export function Header(props: IHeaderProps): JSX.Element {
logout
</a>
</span>
) : (
<span className="pagetop">
<Link href={`/login?goto=${currentUrl}`}>
<a>login</a>
</Link>
</span>
)}
: [
(currentUrl=='login'
? null
: (
<span className="pagetop">
<Link href={`/login?goto=${currentUrl}`}>
<a>login</a>
</Link>
</span>
)
)
]
}
</td>
</tr>
</tbody>
Expand Down
Loading