Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit c6d4ea2

Browse files
committed
Added registration page frontend
1 parent 4037e29 commit c6d4ea2

File tree

12 files changed

+192
-168
lines changed

12 files changed

+192
-168
lines changed

client/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<meta name="viewport" content="width=device-width,initial-scale=1">
77
<meta name="mobile-web-app-capable" content="yes">
88
<meta name="apple-mobile-web-app-capable" content="yes">
9+
<link href="https://fonts.googleapis.com/css?family=Nunito+Sans:200,300,400,600,700" rel="stylesheet">
10+
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet">
911
</head>
1012
<body>
1113
<script src="<%= htmlWebpackPlugin.options.view.assetsPrefix %><%= htmlWebpackPlugin.files.chunks['bundle'].entry %>"></script>

client/src/api/auth.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { request } from './index'
2+
3+
export const login = ({ teamToken }) => {
4+
return request('POST', '/auth/verify', {
5+
teamToken
6+
})
7+
}
8+
9+
export const signup = ({ email, name, division, register }) => {
10+
return request('POST', '/auth/signup', {
11+
email,
12+
name,
13+
division
14+
})
15+
}

client/src/api/index.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
import { route } from 'preact-router'
22
import preactLocalStorage from 'preact-localstorage'
3+
import config from '../config'
34

45
const badToken = () => {
5-
preactLocalStorage.get('token', 'AUTH_TOKEN_HERE')
6+
preactLocalStorage.remove('token')
67
route('/login')
78
}
89

910
export const request = (method, endpoint, data) => {
1011
// fetch endpoint with HTTP method, data as body
11-
12-
badToken()
12+
return fetch(config.apiEndpoint + endpoint, {
13+
method,
14+
headers: {
15+
'Content-Type': 'application/json',
16+
Authorization: 'Bearer ' + preactLocalStorage.get('token')
17+
},
18+
body: JSON.stringify(data)
19+
})
20+
.json()
21+
.catch(err => {
22+
console.debug(err)
23+
badToken()
24+
})
1325
}

client/src/api/login.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

client/src/components/header.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Component } from 'preact'
2+
import withStyles from './jss'
3+
4+
export default withStyles({
5+
6+
}, class Header extends Component {
7+
render ({ classes }) {
8+
return (
9+
<div class='tab-container tabs-center'>
10+
<ul>
11+
<li><a>Home</a></li>
12+
<li><a>About</a></li>
13+
<li><a>Register</a></li>
14+
<li><a>Login</a></li>
15+
</ul>
16+
</div>
17+
)
18+
}
19+
})
File renamed without changes.

client/src/components/registration.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { Component } from 'preact'
2+
import withStyles from './jss'
3+
4+
export default withStyles({
5+
root: {
6+
padding: '25px'
7+
},
8+
submit: {
9+
'margin-top': '25px'
10+
}
11+
}, class Register extends Component {
12+
componentDidMount () {
13+
document.title = 'Registration'
14+
}
15+
16+
render ({ classes }) {
17+
return (
18+
<div class='row u-center'>
19+
<div class={classes.root + ' col-6'}>
20+
<div class='form-section'>
21+
<div class='input-control'>
22+
<input class='input-contains-icon' id='name' name='name' placeholder='Team Name' type='text' value='' />
23+
<span class='icon'>
24+
<i class='fa fa-wrapper fa-user-circle small' />
25+
</span>
26+
</div>
27+
<div class='input-control'>
28+
<input class='input-contains-icon' id='email' name='email' placeholder='Email' type='text' value='' />
29+
<span class='icon'>
30+
<i class='fa fa-wrapper fa-envelope-open small' />
31+
</span>
32+
</div>
33+
<div class='input-control'>
34+
<select class='select'>
35+
<option value='' disabled selected>Division</option>
36+
<option value='0'>High School</option>
37+
<option value='1'>College</option>
38+
<option value='2'>Other</option>
39+
</select>
40+
</div>
41+
</div>
42+
<button class={classes.submit + ' btn-info u-center'} name='btn' value='register' type='submit'>Sign Up</button>
43+
<span class='fg-danger info' />
44+
</div>
45+
</div>
46+
)
47+
}
48+
})

client/src/config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
apiEndpoint: '/api/v1'
3+
}

client/src/index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
import Router from 'preact-router'
2-
import Login from './login'
2+
import Registration from './components/registration'
3+
import Header from './components/header'
34
import 'promise-polyfill/src/polyfill'
45
import 'unfetch/polyfill/index'
56
import 'regenerator-runtime/runtime'
67
import { Component } from 'preact'
78

9+
import 'cirrus-ui'
10+
import 'font-awesome/css/font-awesome.css'
11+
812
export default class App extends Component {
913
render () {
1014
return (
11-
<Router>
12-
<Login path='/login' />
13-
</Router>
15+
<div id='app'>
16+
<Header />
17+
<Router>
18+
<Registration path='/register' />
19+
</Router>
20+
</div>
1421
)
1522
}
1623
}

client/src/login.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"license": "MIT",
66
"private": true,
77
"scripts": {
8-
"lint": "standard",
8+
"lint": "standard --env browser",
99
"start": "node index.js",
1010
"migrate": "node-pg-migrate --database-url-var=RCTF_DATABASE_URL",
1111
"build": "sh client/build.sh",
@@ -22,6 +22,7 @@
2222
},
2323
"dependencies": {
2424
"ajv": "^6.11.0",
25+
"cirrus-ui": "^0.5.5",
2526
"email-validator": "^2.0.4",
2627
"express": "^4.17.1",
2728
"mustache": "^4.0.0",
@@ -35,6 +36,7 @@
3536
"devDependencies": {
3637
"ava": "^3.3.0",
3738
"dotenv": "^8.2.0",
39+
"font-awesome": "^4.7.0",
3840
"husky": "^4.2.1",
3941
"jss": "^10.0.4",
4042
"jss-camel-case": "^6.1.0",

0 commit comments

Comments
 (0)