Skip to content
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
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"error",
{
"singleQuote": true,
"endOfLine":"auto"
"endOfLine": "auto"
}
],
"react/no-unescaped-entities": 0
Expand Down
6 changes: 3 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ What benefit does this bring to the end user? Or, what benefit does this bring t

## This PR

Describe the changes required and any implementation choices you made to give context to reviewers.
Describe the changes required and any implementation choices you made to give context to reviewers.

## Screenshots

Provide screenshots of any new components, styling changes, or pages.
Provide screenshots of any new components, styling changes, or pages.

## Verification Steps

What steps did you take to verify your changes work? These should be clear enough for someone to be able to clone the branch and follow the steps themselves.
What steps did you take to verify your changes work? These should be clear enough for someone to be able to clone the branch and follow the steps themselves.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ node_js:
- 13.12.0
script:
- npm run travis
after_success:
after_success:
- npm run coveralls
2 changes: 1 addition & 1 deletion craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ module.exports = {
},
},
],
};
};
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"@types/jest": "^24.9.1",
"@types/node": "^12.12.50",
"@types/node": "^12.19.1",
"@types/react-dom": "^16.9.8",
"@types/react-helmet": "^6.0.0",
"@types/react-router-dom": "^5.1.5",
Expand Down
7 changes: 7 additions & 0 deletions src/App.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@
// need to use !important to overwrite .ant-layout
min-height: 100vh !important;
}

.content-container {
display: block;
padding: 24px;
max-width: 960px;
margin: auto;
}
4 changes: 4 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { Helmet } from 'react-helmet';
import 'antd/dist/antd.css';
import './App.less';
import Home from './containers/home/Home';
import Signup from './containers/signup/Signup';
import Login from './containers/login/Login';
import BlockTemplate from './containers/template-1-col-block/Template';
import GridTemplate from './containers/template-24-col-grid/Template';

Expand Down Expand Up @@ -34,6 +36,8 @@ const App: React.FC = () => {
<Route path="/" exact component={Home} />
<Route path="/block-template" exact component={BlockTemplate} />
<Route path="/grid-template" exact component={GridTemplate} />
<Route path="/login" exact component={Login} />
<Route path="/signup" exact component={Signup} />
<Route path="*" exact component={NotFound} />
</Switch>
</div>
Expand Down
10 changes: 9 additions & 1 deletion src/auth/authAPI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@ interface LoginRequest {
readonly password: string;
}

interface SignupRequest {
readonly username: string;
readonly email: string;
readonly password: string;
readonly firstName: string;
readonly lastName: string;
}

export const login = async (user: LoginRequest) =>
Axios.post(ROUTES.LOGIN, user).then((response) => {
Token.setAccessToken(response.data.accessToken);
Token.setRefreshToken(response.data.refreshToken);
});

export const signup = async (user: LoginRequest) =>
export const signup = async (user: SignupRequest) =>
Axios.post(ROUTES.SIGNUP, user).then((response) => {
Token.setAccessToken(response.data.accessToken);
Token.setRefreshToken(response.data.refreshToken);
Expand Down
2 changes: 1 addition & 1 deletion src/auth/axios.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import tokenService from './token';
import requestInterceptor from './axios';
import { requestInterceptor } from './axios';

describe('Request Interceptor Tests', () => {
/*
Expand Down
20 changes: 20 additions & 0 deletions src/components/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const NavBar: React.FC = () => {
return '2';
case '/grid-template':
return '3';
case '/login':
return '4';
case '/signup':
return '5';
default:
return '1';
}
Expand Down Expand Up @@ -52,6 +56,22 @@ const NavBar: React.FC = () => {
>
Grid Template
</Menu.Item>
<Menu.Item
key="4"
onClick={() => {
history.push('/login');
}}
>
Login
</Menu.Item>
<Menu.Item
key="5"
onClick={() => {
history.push('/signup');
}}
>
Sign Up
</Menu.Item>
</Menu>
</Header>
);
Expand Down
15 changes: 2 additions & 13 deletions src/containers/home/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Helmet } from 'react-helmet';
import './home.less';
import { Button, Checkbox, Form, Input, Typography } from 'antd';
import { Button, Form, Input, Typography } from 'antd';
import { login } from '../../auth/authAPI';
const { Title } = Typography;

Expand All @@ -17,18 +17,11 @@ const Home: React.FC = () => {
<meta name="description" content="Description goes here." />
</Helmet>
<div className="content-container">
{/*
Place relevant components in here
*/}
<Title>Code4Community Frontend Scaffold</Title>
<Title level={3}>
Built with React.js, Typescript, and AntD components.
</Title>
<Form
name="basic"
initialValues={{ remember: true }}
onFinish={onFinish}
>
<Form name="basic" onFinish={onFinish}>
<Form.Item
label="Username"
name="username"
Expand All @@ -45,10 +38,6 @@ const Home: React.FC = () => {
<Input.Password />
</Form.Item>

<Form.Item name="remember" valuePropName="checked">
<Checkbox>Remember me</Checkbox>
</Form.Item>

<Form.Item>
<Button type="primary" htmlType="submit">
Submit
Expand Down
6 changes: 0 additions & 6 deletions src/containers/home/home.less
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
.content-container {
display: block;
padding: 24px;
max-width: 960px;
margin: auto;
}
66 changes: 66 additions & 0 deletions src/containers/login/Login.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React from 'react';
import { Helmet } from 'react-helmet';
import './login.less';
import { Button, Form, Input, Typography } from 'antd';
import { login } from '../../auth/authAPI';
import { Link } from 'react-router-dom';
const { Title, Paragraph } = Typography;

const Login: React.FC = () => {
const onFinish = (values: any) => {
login({ email: values.username, password: values.password });
};

return (
<>
<Helmet>
<title>Login</title>
<meta name="description" content="Description goes here." />
</Helmet>
<div className="content-container">
<Title>Login</Title>
<Form name="basic" onFinish={onFinish}>
<Form.Item
label="Username"
name="username"
rules={[{ required: true, message: 'Please input your username!' }]}
>
<Input />
</Form.Item>

<Form.Item
label="Password"
name="password"
rules={[{ required: true, message: 'Please input your password!' }]}
>
<Input.Password />
</Form.Item>

<Paragraph>
Need an account? Sign up{' '}
<Link to="/signup" component={Typography.Link}>
here
</Link>
!
</Paragraph>

<Paragraph>
Forgot your password? Click{' '}
<Link to="/" component={Typography.Link}>
here
</Link>{' '}
to reset it.
</Paragraph>

<Form.Item>
<Button type="primary" htmlType="submit">
Submit
</Button>
</Form.Item>
</Form>
</div>
</>
);
};

export default Login;
Empty file added src/containers/login/login.less
Empty file.
6 changes: 0 additions & 6 deletions src/containers/not-found/not-found.less
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
.content-container {
display: block;
padding: 24px;
max-width: 960px;
margin: auto;
}
100 changes: 100 additions & 0 deletions src/containers/signup/Signup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import React from 'react';
import { Helmet } from 'react-helmet';
import './signup.less';
import { Button, Form, Input, Typography } from 'antd';
import { signup } from '../../auth/authAPI';
import { Link } from 'react-router-dom';
const { Title, Paragraph } = Typography;

const Signup: React.FC = () => {
const onFinish = (values: any) => {
// TODO: what if backend says the values are invalid? need to handle this
signup({
username: values.username,
email: values.email,
password: values.password,
firstName: values.firstName,
lastName: values.lastName,
});
};

return (
<>
<Helmet>
<title>Sign Up</title>
<meta name="description" content="Description goes here." />
</Helmet>
<div className="content-container">
{/*
Place relevant components in here
*/}
<Title>Sign Up</Title>
<Form name="basic" onFinish={onFinish}>
<Form.Item
label="First Name"
name="firstName"
rules={[{ required: true, message: 'Required' }]}
>
<Input />
</Form.Item>

<Form.Item
label="Last Name"
name="lastName"
rules={[{ required: true, message: 'Required' }]}
>
<Input />
</Form.Item>

<Form.Item
label="Email"
name="email"
rules={[{ required: true, message: 'Required' }]}
>
<Input />
</Form.Item>

<Form.Item
label="Username"
name="username"
rules={[{ required: true, message: 'Required' }]}
>
<Input />
</Form.Item>

<Form.Item
label="Password"
name="password"
rules={[{ required: true, message: 'Required' }]}
>
<Input.Password />
</Form.Item>

<Form.Item
label="Confirm Password"
name="confirmPassword"
rules={[{ required: true, message: 'Required' }]}
>
<Input.Password />
</Form.Item>

<Paragraph>
Already have an account? Log in{' '}
<Link to="/login" component={Typography.Link}>
here
</Link>
!
</Paragraph>

<Form.Item>
<Button type="primary" htmlType="submit">
Submit
</Button>
</Form.Item>
</Form>
</div>
</>
);
};

export default Signup;
Empty file.
6 changes: 0 additions & 6 deletions src/containers/template-1-col-block/template.less
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
.content-container {
display: block;
padding: 24px;
max-width: 960px;
margin: auto;
}