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

Wokers list #7

Merged
merged 8 commits into from
Dec 10, 2020
Merged

Wokers list #7

merged 8 commits into from
Dec 10, 2020

Conversation

GTabala
Copy link
Collaborator

@GTabala GTabala commented Dec 10, 2020

Proposal

Workers list is added. Nothing more.

Related card on Trello. We need a list of cleaners so later on admin can select specific cleaner, update, assign to a job.

Checklist

  • I have made this pull request to the master branch
  • I have run npm run lint and there are no errors

@GTabala GTabala requested a review from g1st December 10, 2020 00:58
@GTabala
Copy link
Collaborator Author

GTabala commented Dec 10, 2020

Here is one problem with eslint. Like there: jsx-eslint/eslint-plugin-react#2654

Copy link
Collaborator

@g1st g1st left a comment

Choose a reason for hiding this comment

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

Thanks for this. For missing props validation we would need to install another package called prop-types. More info on that in react docs here. So to add that proptype for ShowWorkers it would look something like:

ShowWorkers.propTypes = {
	kick: PropTypes.bool
};

Also, currently the table on mobile screen size would be needed to scroll horizontally, should we add specific CSS for a small screens to display it somehow differently? Or this would not be possible with a table approach? If this is something that we should fix later on I am fine also.


export function App() {
const [kick, setKick] = useState(false);
const workersHandle = () => setKick(!kick);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we name this a bit more descriptive, maybe triggerFetch or triggerRefetch?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to "trigger".

Comment on lines 7 to 9

export const getWorkers = async (data) => {
const response = await get("/workers", data);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need to pass data to this function and to get method as this service is GET method and we are not sending anything to backend. They can be removed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed.

.catch((err) => console.error(err)),[kick]);


if (list) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Empty array is a truthy value so this if statement will always execute.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed.

Comment on lines 8 to 10
useEffect(() => getWorkers()
.then((data) => setList(data.workers))
.catch((err) => console.error(err)),[kick]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am thinking to have custom hook like form here https://www.digitalocean.com/community/tutorials/creating-a-custom-usefetch-react-hook. Then we would reuse it through our app and we would have loading, error and success states. On loading we could show bootstrap's Spinner. But we can add that later.

Copy link
Collaborator

@Harriethw Harriethw left a comment

Choose a reason for hiding this comment

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

Thanks for this @GTabala ! It's a good start...I'm not able to give detailed feedback right now, but I would like to ask that the team try to add more description to your commit messages and the PR - at least link to the Trello card. As I'm not in the day-to-day running of the team, it would make it easier for me to get the context of why this work is being done.

This is an invaluable skill to have as a developer working with professionals, and even just for yourself - if you were to revisit this code in 6 months would you remember why you made these decisions?

@@ -1,2 +1,3 @@
export { default as CreateWorkerForm } from "./CreateWorkerForm";

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please could you explain why you've added this commit? Thanks to version control there isn't any need to add white space - if you absolutely need to add a TODO you can add commented out lines.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just fixed the code according to all the comments from the reviews.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Harriethw I originally added that file to make it more clear and tidy when we will import them inside App.js or /pages. More info here https://www.digitalocean.com/community/tutorials/react-index-js-public-interfaces#using-indexjs

Copy link
Collaborator

Choose a reason for hiding this comment

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

@g1st ah I just meant that we don't need empty white space, which is all this commit seems to add unless I'm missing something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yesterday we made a customer list with Hadiyah. It doesn't work on her computer. I made the same code for workers and it works. I added empty spaces for her code. :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh sorry @Harriethw yes I agree. I already proposed @GTabala to use Prettier and it can take care of those empty spaces for us!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Prettier doesn't delete empty lines.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, I don't know who does it then but when I save a file with loads of empty lines they get deleted for me.

@GTabala
Copy link
Collaborator Author

GTabala commented Dec 10, 2020

I'm not sure that a manager will use a mobile device, but anyway, this is not time to talk about it. Even I did not create a separate component for table rows, and this should be done before the adaptation for mobile.

@g1st
Copy link
Collaborator

g1st commented Dec 10, 2020

Looks good!

@g1st g1st merged commit 7e2eaed into HadiyahL:master Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants