Skip to content

Commit fe7529a

Browse files
author
Jimmy Lee
committed
Interface updates to match Expo application, adds some more data to api calls, excludes user sensitive information
1 parent 0583e7b commit fe7529a

File tree

15 files changed

+168
-32
lines changed

15 files changed

+168
-32
lines changed

api/controllers/comment.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ module.exports = {
2222
include: [
2323
{
2424
model: User,
25+
attributes: {
26+
exclude: ['salt', 'password'],
27+
},
28+
},
29+
{
30+
model: Post,
2531
},
2632
],
2733
});
@@ -43,6 +49,12 @@ module.exports = {
4349
include: [
4450
{
4551
model: User,
52+
attributes: {
53+
exclude: ['salt', 'password'],
54+
},
55+
},
56+
{
57+
model: Post,
4658
},
4759
],
4860
});
@@ -69,6 +81,12 @@ module.exports = {
6981
include: [
7082
{
7183
model: User,
84+
attributes: {
85+
exclude: ['salt', 'password'],
86+
},
87+
},
88+
{
89+
model: Post,
7290
},
7391
],
7492
order: [['createdAt', 'DESC']],

api/controllers/post.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,20 @@ module.exports = {
2525
include: [
2626
{
2727
model: User,
28+
attributes: {
29+
exclude: ['salt', 'password'],
30+
},
31+
},
32+
{
33+
model: Post,
2834
},
2935
],
3036
},
3137
{
3238
model: User,
39+
attributes: {
40+
exclude: ['salt', 'password'],
41+
},
3342
},
3443
],
3544
order: [['createdAt', 'DESC']],
@@ -51,11 +60,20 @@ module.exports = {
5160
include: [
5261
{
5362
model: User,
63+
attributes: {
64+
exclude: ['salt', 'password'],
65+
},
66+
},
67+
{
68+
model: Post,
5469
},
5570
],
5671
},
5772
{
5873
model: User,
74+
attributes: {
75+
exclude: ['salt', 'password'],
76+
},
5977
},
6078
],
6179
});

common/strings.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ export const toDate = string => {
1010
export const isEmpty = string => {
1111
return !string || string.length === 0;
1212
};
13+
14+
export const pluralize = (text: string, count: number) => {
15+
return count > 1 || count === 0 ? `${text}s` : text;
16+
};

components/Button.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ export default class Button extends React.Component {
2020
onClick={this.props.onClick}>
2121
<style jsx>{`
2222
.button {
23+
background: #0000FF;
24+
color: #FFFFFF;
25+
padding: 16px;
2326
cursor: pointer;
2427
line-height: 1;
2528
font-size: 16px;
2629
font-weight: 600;
27-
text-decoration: underline;
28-
background-color: transparent;
29-
color: rgba(0, 0, 0, 1);
3030
transition: 200ms all linear;
3131
transition-property: transform, color;
3232
}
3333
3434
.button:hover {
35-
color: rgba(0, 0, 0, 0.9);
35+
background: #1111AF;
3636
}
3737
3838
.button:active {

components/CommentList.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import CommentPreview from './CommentPreview';
34
import { connect } from 'react-redux';
45

56
class CommentList extends React.Component {
7+
static propTypes = {
8+
showResponse: PropTypes.bool,
9+
};
10+
611
render() {
712
const comments = this.props.comments.map(c => (
8-
<CommentPreview key={`cmmt-${c.id}`} {...c} />
13+
<CommentPreview
14+
key={`cmmt-${c.id}`}
15+
showResponse={this.props.showResponse}
16+
{...c}
17+
/>
918
));
1019

1120
return (

components/CommentPreview.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,14 @@ class CommentPreview extends React.Component {
7171
7272
.item {
7373
margin-right: 16px;
74+
color: #0000FF;
7475
cursor: pointer;
7576
text-decoration: underline;
77+
transition: color 200ms ease;
78+
79+
&:hover {
80+
color: #1111AF;
81+
}
7682
}
7783
7884
.actions {
@@ -90,10 +96,25 @@ class CommentPreview extends React.Component {
9096
font-size: 12px;
9197
margin-bottom: 8px;
9298
}
99+
100+
.response {
101+
margin-bottom: 16px;
102+
}
103+
104+
.title {
105+
font-weight: 600;
106+
}
93107
`}</style>
94108
<div>
109+
{this.props.showResponse
110+
? <blockquote className="response" onClick={this._handleView}>
111+
📮 In response to
112+
{' '}
113+
<span className="title">{this.props.Post.title}</span>
114+
</blockquote>
115+
: undefined}
95116
{!isEditing
96-
? <p onClick={this._handleView}>
117+
? <p>
97118
{this.state.content}
98119
</p>
99120
: undefined}

components/LoginForm.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ class LoginForm extends React.Component {
5757
/>
5858
<hr className="large-spacer" />
5959
<Button onClick={this._handleSubmit}>
60-
{Strings.isEmpty(this.state.username)
61-
? 'Fill out the fields to log in'
62-
: `Log in with ${this.state.username}`}
60+
Log in
6361
</Button>
6462
</div>
6563
);

components/Nav.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Nav extends React.Component {
2525
Users ({this.props.users.length})
2626
</Link>
2727
<Link className="link" onClick={this._handleLogout}>
28-
Logout
28+
Log out
2929
</Link>
3030
</NavLayout>
3131
);

components/NavLayout.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ export default class NavLayout extends React.Component {
1616
margin-right: 16px;
1717
text-decoration: underline;
1818
background-color: transparent;
19-
color: rgba(0, 0, 0, 1);
19+
color: #0000FF;
2020
transition: 200ms all linear;
2121
transition-property: transform, color;
2222
}
2323
2424
.nav-layout :global(.link:visited) {
25-
color: rgba(0, 0, 0, 1);
25+
color: #0000FF;
2626
}
2727
2828
.nav-layout :global(.link:hover) {
29-
color: rgba(0, 0, 0, 0.8);
29+
color: #1111AF;
3030
}
3131
3232
.nav-layout {

components/PostList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { connect } from 'react-redux';
55
class PostList extends React.Component {
66
render() {
77
const posts = this.props.posts.map(p => (
8-
<PostPreview key={`post-${p.id}`} {...p} />
8+
<PostPreview key={`post-${p.id}`} post={p} />
99
));
1010

1111
return (

0 commit comments

Comments
 (0)