🔥
This commit is contained in:
77
src/routes/adminPeople/AdminPeople.css
Normal file
77
src/routes/adminPeople/AdminPeople.css
Normal file
@@ -0,0 +1,77 @@
|
||||
@import '../../components/variables.css';
|
||||
|
||||
.root {
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
margin: 0 auto;
|
||||
padding: 0 0 40px;
|
||||
max-width: var(--max-content-width);
|
||||
}
|
||||
|
||||
.formGroup {
|
||||
position: relative;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: inline-block;
|
||||
margin-bottom: 5px;
|
||||
max-width: 100%;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.input {
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
padding: 10px 16px;
|
||||
width: 100%;
|
||||
height: 46px;
|
||||
outline: 0;
|
||||
border: 1px solid var(--colour-grey);
|
||||
border-radius: 0;
|
||||
background-color: #fff;
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
color: #616161;
|
||||
font-size: 18px;
|
||||
line-height: 1.3333333;
|
||||
transition: border-color ease-in-out 0.15s,
|
||||
box-shadow ease-in-out 0.15s,
|
||||
background-color ease-in-out 0.15s;
|
||||
}
|
||||
|
||||
.input:focus {
|
||||
border-color: var(--colour-tertiary);
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(0, 116, 194, 0.6);
|
||||
}
|
||||
|
||||
.button {
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 10px 16px;
|
||||
width: 100%;
|
||||
outline: 0;
|
||||
border: 1px solid var(--colour-secondary);
|
||||
border-radius: 0;
|
||||
background: var(--colour-primary);;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
font-size: 18px;
|
||||
line-height: 1.3333333;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
background: var(--colour-secondary);
|
||||
}
|
||||
|
||||
.button:focus {
|
||||
border-color: var(--colour-tertiary);
|
||||
box-shadow: 0 0 8px var(--colour-secondary);
|
||||
}
|
||||
|
||||
|
||||
112
src/routes/adminPeople/AdminPeople.js
Normal file
112
src/routes/adminPeople/AdminPeople.js
Normal file
@@ -0,0 +1,112 @@
|
||||
import React, { PropTypes } from 'react';
|
||||
import withStyles from 'isomorphic-style-loader/lib/withStyles';
|
||||
import s from './AdminPeople.css';
|
||||
import Link from '../../components/Link';
|
||||
|
||||
class AdminPeople extends React.Component {
|
||||
static propTypes = {
|
||||
title: PropTypes.string.isRequired,
|
||||
people: PropTypes.arrayOf(PropTypes.shape({
|
||||
key: PropTypes.string.isRequired,
|
||||
firstname: PropTypes.string,
|
||||
lastname: PropTypes.string,
|
||||
completed: PropTypes.boolean,
|
||||
email: PropTypes.string,
|
||||
password: PropTypes.string,
|
||||
attending: PropTypes.boolean,
|
||||
})).isRequired,
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className={s.root}>
|
||||
<div className={s.container}>
|
||||
<h1>{this.props.title}</h1>
|
||||
|
||||
{this.props.people.length === 0 ? <p> No people yet ☹️</p> :
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Email</td>
|
||||
<td>Password</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{this.props.people.map(person => (
|
||||
<tr key={person.key}>
|
||||
<td><Link to={`/admin/person/${person.key}`}>{person.firstname} {person.lastname}</Link></td>
|
||||
<td>{person.email}</td>
|
||||
<td><Link to={`/rsvp/${person.password}`}>{person.password}</Link></td>
|
||||
<td>
|
||||
<form method="post" action="/admin/person/delete">
|
||||
<input type="hidden" name="key" value={person.key} />
|
||||
<button className={s.button} type="submit">
|
||||
Delete
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
<h2>Add Person</h2>
|
||||
<form method="post" action="/admin/person">
|
||||
<div className={s.formGroup}>
|
||||
<label className={s.label} htmlFor="firstname">
|
||||
First name:
|
||||
</label>
|
||||
<input
|
||||
className={s.input}
|
||||
id="firstname"
|
||||
type="text"
|
||||
name="firstname"
|
||||
/>
|
||||
</div>
|
||||
<div className={s.formGroup}>
|
||||
<label className={s.label} htmlFor="lastname">
|
||||
Last name:
|
||||
</label>
|
||||
<input
|
||||
className={s.input}
|
||||
id="lastname"
|
||||
type="text"
|
||||
name="lastname"
|
||||
/>
|
||||
</div>
|
||||
<div className={s.formGroup}>
|
||||
<label className={s.label} htmlFor="email">
|
||||
Email:
|
||||
</label>
|
||||
<input
|
||||
className={s.input}
|
||||
id="email"
|
||||
type="text"
|
||||
name="email"
|
||||
/>
|
||||
</div>
|
||||
<div className={s.formGroup}>
|
||||
<label className={s.label} htmlFor="password">
|
||||
Password (blank will autogenerate):
|
||||
</label>
|
||||
<input
|
||||
className={s.input}
|
||||
id="password"
|
||||
type="text"
|
||||
name="password"
|
||||
/>
|
||||
</div>
|
||||
<div className={s.formGroup}>
|
||||
<button className={s.button} type="submit">
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withStyles(s)(AdminPeople);
|
||||
32
src/routes/adminPeople/index.js
Normal file
32
src/routes/adminPeople/index.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import React from 'react';
|
||||
import Layout from '../../components/Layout';
|
||||
import fetchQL from '../../core/fetchQL';
|
||||
|
||||
const title = 'People';
|
||||
|
||||
export default {
|
||||
|
||||
path: '/admin/people',
|
||||
|
||||
async action() {
|
||||
const resp = await fetchQL('{getAllPersons{key,firstname,lastname,email,completed,password}}');
|
||||
|
||||
let people = await resp.json();
|
||||
if (people.data && people.data.getAllPersons) {
|
||||
people = people.data.getAllPersons;
|
||||
} else {
|
||||
people = [];
|
||||
}
|
||||
|
||||
const AdminPeople = await new Promise((resolve) => {
|
||||
require.ensure([], (require) => resolve(require('./AdminPeople').default), 'adminPeople');
|
||||
});
|
||||
|
||||
return {
|
||||
title,
|
||||
chunk: 'admin',
|
||||
component: <Layout><AdminPeople title={title} people={people} /></Layout>,
|
||||
};
|
||||
},
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user