Skip to content

Commit f7f5f8e

Browse files
committed
added missing adminRequired #207
1 parent 2c6072f commit f7f5f8e

File tree

8 files changed

+87
-146
lines changed

8 files changed

+87
-146
lines changed

book/5-end/pages/admin/index.js

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,43 @@ import notify from '../../lib/notifier';
88

99
import withLayout from '../../lib/withLayout';
1010
import withAuth from '../../lib/withAuth';
11-
import {
12-
getBookList,
13-
} from '../../lib/api/admin';
11+
import { getBookList } from '../../lib/api/admin';
1412

15-
16-
const Index = ({
17-
books,
18-
}) => (
13+
const Index = ({ books }) => (
1914
<div style={{ padding: '10px 45px' }}>
2015
<div>
21-
<h2>Books</h2>
16+
<h2>
17+
Books
18+
</h2>
2219
<Link href="/admin/add-book">
23-
<Button variant="contained">Add book</Button>
20+
<Button variant="contained">
21+
Add book
22+
</Button>
2423
</Link>
2524
<p />
2625
<ul>
27-
{books.map(b => (
26+
{books.map((b) => (
2827
<li key={b._id}>
29-
<Link
30-
as={`/admin/book-detail/${b.slug}`}
31-
href={`/admin/book-detail?slug=${b.slug}`}
32-
>
33-
<a>{b.name}</a>
28+
<Link as={`/admin/book-detail/${b.slug}`} href={`/admin/book-detail?slug=${b.slug}`}>
29+
<a>
30+
{b.name}
31+
</a>
3432
</Link>
3533
</li>
36-
))}
34+
))}
3735
</ul>
3836
<br />
3937
</div>
4038
</div>
4139
);
4240

4341
Index.propTypes = {
44-
books: PropTypes.arrayOf(PropTypes.shape({
45-
name: PropTypes.string.isRequired,
46-
slug: PropTypes.string.isRequired,
47-
})).isRequired,
42+
books: PropTypes.arrayOf(
43+
PropTypes.shape({
44+
name: PropTypes.string.isRequired,
45+
slug: PropTypes.string.isRequired,
46+
}),
47+
).isRequired,
4848
};
4949

5050
class IndexWithData extends React.Component {
@@ -62,11 +62,7 @@ class IndexWithData extends React.Component {
6262
}
6363

6464
render() {
65-
return (
66-
<Index
67-
{...this.state}
68-
/>
69-
);
65+
return <Index {...this.state} />;
7066
}
7167
}
7268

book/6-end/pages/admin/index.js

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,9 @@ import notify from '../../lib/notifier';
88

99
import withLayout from '../../lib/withLayout';
1010
import withAuth from '../../lib/withAuth';
11-
import {
12-
getBookList,
13-
} from '../../lib/api/admin';
11+
import { getBookList } from '../../lib/api/admin';
1412

15-
16-
const Index = ({
17-
books,
18-
}) => (
13+
const Index = ({ books }) => (
1914
<div style={{ padding: '10px 45px' }}>
2015
<div>
2116
<h2>Books</h2>
@@ -24,27 +19,26 @@ const Index = ({
2419
</Link>
2520
<p />
2621
<ul>
27-
{books.map(b => (
22+
{books.map((b) => (
2823
<li key={b._id}>
29-
<Link
30-
as={`/admin/book-detail/${b.slug}`}
31-
href={`/admin/book-detail?slug=${b.slug}`}
32-
>
24+
<Link as={`/admin/book-detail/${b.slug}`} href={`/admin/book-detail?slug=${b.slug}`}>
3325
<a>{b.name}</a>
3426
</Link>
3527
</li>
36-
))}
28+
))}
3729
</ul>
3830
<br />
3931
</div>
4032
</div>
4133
);
4234

4335
Index.propTypes = {
44-
books: PropTypes.arrayOf(PropTypes.shape({
45-
name: PropTypes.string.isRequired,
46-
slug: PropTypes.string.isRequired,
47-
})).isRequired,
36+
books: PropTypes.arrayOf(
37+
PropTypes.shape({
38+
name: PropTypes.string.isRequired,
39+
slug: PropTypes.string.isRequired,
40+
}),
41+
).isRequired,
4842
};
4943

5044
class IndexWithData extends React.Component {
@@ -62,11 +56,7 @@ class IndexWithData extends React.Component {
6256
}
6357

6458
render() {
65-
return (
66-
<Index
67-
{...this.state}
68-
/>
69-
);
59+
return <Index {...this.state} />;
7060
}
7161
}
7262

book/6-start/pages/admin/index.js

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ import withLayout from '../../lib/withLayout';
1010
import withAuth from '../../lib/withAuth';
1111
import { getBookList } from '../../lib/api/admin';
1212

13-
14-
const Index = ({
15-
books,
16-
}) => (
13+
const Index = ({ books }) => (
1714
<div style={{ padding: '10px 45px' }}>
1815
<div>
1916
<h2>Books</h2>
@@ -22,27 +19,26 @@ const Index = ({
2219
</Link>
2320
<p />
2421
<ul>
25-
{books.map(b => (
22+
{books.map((b) => (
2623
<li key={b._id}>
27-
<Link
28-
as={`/admin/book-detail/${b.slug}`}
29-
href={`/admin/book-detail?slug=${b.slug}`}
30-
>
24+
<Link as={`/admin/book-detail/${b.slug}`} href={`/admin/book-detail?slug=${b.slug}`}>
3125
<a>{b.name}</a>
3226
</Link>
3327
</li>
34-
))}
28+
))}
3529
</ul>
3630
<br />
3731
</div>
3832
</div>
3933
);
4034

4135
Index.propTypes = {
42-
books: PropTypes.arrayOf(PropTypes.shape({
43-
name: PropTypes.string.isRequired,
44-
slug: PropTypes.string.isRequired,
45-
})).isRequired,
36+
books: PropTypes.arrayOf(
37+
PropTypes.shape({
38+
name: PropTypes.string.isRequired,
39+
slug: PropTypes.string.isRequired,
40+
}),
41+
).isRequired,
4642
};
4743

4844
class IndexWithData extends React.Component {
@@ -60,12 +56,8 @@ class IndexWithData extends React.Component {
6056
}
6157

6258
render() {
63-
return (
64-
<Index
65-
{...this.state}
66-
/>
67-
);
59+
return <Index {...this.state} />;
6860
}
6961
}
7062

71-
export default withAuth(withLayout(IndexWithData));
63+
export default withAuth(withLayout(IndexWithData), { adminRequired: true });

book/7-end/pages/admin/index.js

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,9 @@ import notify from '../../lib/notifier';
88

99
import withLayout from '../../lib/withLayout';
1010
import withAuth from '../../lib/withAuth';
11-
import {
12-
getBookList,
13-
} from '../../lib/api/admin';
11+
import { getBookList } from '../../lib/api/admin';
1412

15-
16-
const Index = ({
17-
books,
18-
}) => (
13+
const Index = ({ books }) => (
1914
<div style={{ padding: '10px 45px' }}>
2015
<div>
2116
<h2>Books</h2>
@@ -24,27 +19,26 @@ const Index = ({
2419
</Link>
2520
<p />
2621
<ul>
27-
{books.map(b => (
22+
{books.map((b) => (
2823
<li key={b._id}>
29-
<Link
30-
as={`/admin/book-detail/${b.slug}`}
31-
href={`/admin/book-detail?slug=${b.slug}`}
32-
>
24+
<Link as={`/admin/book-detail/${b.slug}`} href={`/admin/book-detail?slug=${b.slug}`}>
3325
<a>{b.name}</a>
3426
</Link>
3527
</li>
36-
))}
28+
))}
3729
</ul>
3830
<br />
3931
</div>
4032
</div>
4133
);
4234

4335
Index.propTypes = {
44-
books: PropTypes.arrayOf(PropTypes.shape({
45-
name: PropTypes.string.isRequired,
46-
slug: PropTypes.string.isRequired,
47-
})).isRequired,
36+
books: PropTypes.arrayOf(
37+
PropTypes.shape({
38+
name: PropTypes.string.isRequired,
39+
slug: PropTypes.string.isRequired,
40+
}),
41+
).isRequired,
4842
};
4943

5044
class IndexWithData extends React.Component {
@@ -62,11 +56,7 @@ class IndexWithData extends React.Component {
6256
}
6357

6458
render() {
65-
return (
66-
<Index
67-
{...this.state}
68-
/>
69-
);
59+
return <Index {...this.state} />;
7060
}
7161
}
7262

book/7-start/pages/admin/index.js

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,9 @@ import notify from '../../lib/notifier';
88

99
import withLayout from '../../lib/withLayout';
1010
import withAuth from '../../lib/withAuth';
11-
import {
12-
getBookList,
13-
} from '../../lib/api/admin';
11+
import { getBookList } from '../../lib/api/admin';
1412

15-
16-
const Index = ({
17-
books,
18-
}) => (
13+
const Index = ({ books }) => (
1914
<div style={{ padding: '10px 45px' }}>
2015
<div>
2116
<h2>Books</h2>
@@ -24,27 +19,26 @@ const Index = ({
2419
</Link>
2520
<p />
2621
<ul>
27-
{books.map(b => (
22+
{books.map((b) => (
2823
<li key={b._id}>
29-
<Link
30-
as={`/admin/book-detail/${b.slug}`}
31-
href={`/admin/book-detail?slug=${b.slug}`}
32-
>
24+
<Link as={`/admin/book-detail/${b.slug}`} href={`/admin/book-detail?slug=${b.slug}`}>
3325
<a>{b.name}</a>
3426
</Link>
3527
</li>
36-
))}
28+
))}
3729
</ul>
3830
<br />
3931
</div>
4032
</div>
4133
);
4234

4335
Index.propTypes = {
44-
books: PropTypes.arrayOf(PropTypes.shape({
45-
name: PropTypes.string.isRequired,
46-
slug: PropTypes.string.isRequired,
47-
})).isRequired,
36+
books: PropTypes.arrayOf(
37+
PropTypes.shape({
38+
name: PropTypes.string.isRequired,
39+
slug: PropTypes.string.isRequired,
40+
}),
41+
).isRequired,
4842
};
4943

5044
class IndexWithData extends React.Component {
@@ -62,11 +56,7 @@ class IndexWithData extends React.Component {
6256
}
6357

6458
render() {
65-
return (
66-
<Index
67-
{...this.state}
68-
/>
69-
);
59+
return <Index {...this.state} />;
7060
}
7161
}
7262

book/8-end/pages/index.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,28 @@ import Head from 'next/head';
55
import withAuth from '../lib/withAuth';
66
import withLayout from '../lib/withLayout';
77

8-
98
class Index extends React.Component {
109
static propTypes = {
1110
user: PropTypes.shape({
1211
displayName: PropTypes.string,
1312
email: PropTypes.string.isRequired,
1413
}),
15-
}
14+
};
1615

1716
static defaultProps = {
1817
user: null,
19-
}
18+
};
2019

2120
render() {
2221
const { user } = this.props;
2322
return (
2423
<div style={{ padding: '10px 45px' }}>
2524
<Head>
2625
<title>Settings</title>
27-
<meta
28-
name="description"
29-
content="List of purchased books."
30-
/>
26+
<meta name="description" content="List of purchased books." />
3127
</Head>
3228
<p>List of purchased books</p>
33-
<p>Email: {user.email}</p>
29+
<p>Email: {user.email} </p>
3430
</div>
3531
);
3632
}

0 commit comments

Comments
 (0)