Skip to content
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

34 feedback component #61

Merged
merged 21 commits into from
Oct 2, 2019
Merged

34 feedback component #61

merged 21 commits into from
Oct 2, 2019

Conversation

MohammadAlhalaq
Copy link
Collaborator

Create feedback component with style

@MohammadAlhalaq MohammadAlhalaq added the In progress This issue/PR represents a technical task that is currently being worked on label Sep 29, 2019
@MohammadAlhalaq MohammadAlhalaq added Awaiting Review This PR is waiting to be reviewed and removed In progress This issue/PR represents a technical task that is currently being worked on labels Sep 30, 2019
export default () => (
<Router>
<Switch>
<Route path="/" exact component={Feedback} />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Route path="/" exact component={Feedback} />
<Route exact path="/feedback" component={Feedback} />

You should also pass the table number which will be stored in the state after the user logs in as a prop to display it in the feedback page.

Also, find a way to pass the order number to the feedback component (which also will be displayed in it)

body: JSON.stringify(data),
})
.then(res => res.json())
.then(status => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the status coming from the res.json(), but it is the response's payload

Suggested change
.then(status => {
.then(payload => {

or

Suggested change
.then(status => {
.then(resBody => {

or

Suggested change
.then(status => {
.then(response => {

.then(res => res.json())
.then(status => {
if (status.statusCode === 201) {
this.setState({ errorMessage: '' });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why update the state while you are redirecting the user immediately, especially because setState is an async function which means the redaricting will occur before the execution of setState!

}
})
.catch(err => {
this.setState({ errorMessage: err });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err's origin here may differ depending on the generator of the error, which here may be from the fetch (network error) or a validation error (generated by @hapi/joi).

According to what I said above in all the cases of an error getting generated the value of err will be an object!!! which is a disaster as you render the whole error object to the user!

fetch('/api/v1/post-feedback', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use @hapi/joi to validate the user's input before sending it.

.table-number{
width:40vw
}
form{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use tag name selectors in css!!

package.json Outdated
@@ -36,10 +36,13 @@
"dependencies": {
"@hapi/joi": "^16.1.4",
"cookie-parser": "^1.4.4",
"cors": "^2.8.5",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After using proxy in react there is no need for this module/package

Suggested change
"cors": "^2.8.5",

package.json Outdated
"env2": "^2.2.2",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"pg": "^7.12.1"
"pg": "^7.12.1",
"react-router-dom": "^5.1.1",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is react-router-dom and react-stars installed in the backend?!?!?!?!!?!??!?!?!
It's obviously a mistake and not intended, but you must fix it before pushing it!!

server/app.js Outdated
@@ -1,13 +1,14 @@
const express = require('express');
const cookieParser = require('cookie-parser');
const cros = require('cors');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for cors anymore as I mentioned in a previous comment

client/src/components/feedback/index.js Show resolved Hide resolved
@ahmedisam99 ahmedisam99 added Changes Requested This PR has some changed that must be done before the next review and removed Awaiting Review This PR is waiting to be reviewed labels Sep 30, 2019
@MohammadAlhalaq MohammadAlhalaq added Awaiting Review This PR is waiting to be reviewed and removed Changes Requested This PR has some changed that must be done before the next review labels Oct 1, 2019
@MohammadAlhalaq MohammadAlhalaq self-assigned this Oct 1, 2019
.then(res => res.json())
.then(payload => {
return payload.statusCode === 201
? history.push('/')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the popup must be shown after the submission success and the button inside this popup will redirect to the home.

@ahmedisam99 ahmedisam99 added Approved This PR has been review and is approved for merging and removed Awaiting Review This PR is waiting to be reviewed labels Oct 2, 2019
@MohammadAlhalaq MohammadAlhalaq merged commit ff63a04 into master Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved This PR has been review and is approved for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants