-
Notifications
You must be signed in to change notification settings - Fork 16
Read-only profile page #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
package.json
Outdated
| "graphcool": "^0.11.5" | ||
| } | ||
| }, | ||
| "proxy": "http://192.168.99.100:60000" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woops. Shouldn't be there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this! This is a great first step for GDPR compliancy
src/scenes/UserProfile/queries.js
Outdated
|
|
||
| export const getAllPersonalData = graphql(getAllPersonalDataQuery, { | ||
| skip: props => !auth.getUserProfile(), | ||
| options: props => ({variables: {auth0UserId: auth.getUserProfile().sub}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of auth0UserId, you should use directly the graphcool ID. You can get it using auth.getUserNodeId()
src/scenes/UserProfile/queries.js
Outdated
| ` | ||
|
|
||
| export const getAllPersonalData = graphql(getAllPersonalDataQuery, { | ||
| skip: props => !auth.getUserProfile(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need to skip the request because /user-profile is a PrivateRoute so it will only render if the user is authenticated
| createdAt | ||
| node { | ||
| id | ||
| question { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add the attribute id of question in order to allow apollo to retrieve it from cache
| createdAt | ||
| type | ||
| node { | ||
| question { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here with id of node and question
| createdAt | ||
| node { | ||
| id | ||
| question { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, you need to query the id
| } | ||
| }))) | ||
| .reduce((all, entities) => all.concat(entities)) | ||
| .sort((a, b) => a.at < b.at ? 1 : a.at > b.at ? -1 : 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a small comment on what this does would be useful for futur contributors?
| {userLog.map(({type, id, at, question}) => ( | ||
| <tr key={id}> | ||
| <td>{type}</td> | ||
| <td style={{whiteSpace: 'nowrap'}}>{at}</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the moment library to format the timestamp:
moment(at).format('DD/MM/YYYY HH:MM') (See moment's documentation for more formats)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The format you mention only makes sense in France. I'd rather stick with ISO 8601.
| } | ||
|
|
||
| if (User === null) { | ||
| return <NotFound {...props} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If User === null, we should show an error instead of a 'NotFound', as this isn't a normal case
|
|
||
| .card .card-table td { | ||
| padding: 0.5em; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure theses css rules should be in Card.css as they only help the user-profile page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I made them generic enough I think. Any table in a card will look the same.
| const UserProfile = props => { | ||
| if (!props.data) { | ||
| props.history.push('/auth/login') | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need this condition if you don't skip the request (see other review comment for explanation)
| <tr key={id}> | ||
| <td>{type}</td> | ||
| <td style={{whiteSpace: 'nowrap'}}>{at}</td> | ||
| <td style={{wordBreak: 'break-word'}}><Link to={question.link}>{question.title}</Link></td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to show emojis, you will need to use services/markdown and call markdown.title(question.title)
Because the component is on a private route.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is some changes to be done to make the profile page "pretty", but it can be done is another PR
A first step towards GDPR compliancy (see #36).