Skip to content

Conversation

@chosnekk
Copy link
Collaborator

@chosnekk chosnekk commented Mar 5, 2021

Configured cors, so that app can connect to mock api.
Deleted body-parser due to supporting its features by express from 4.16.
Added new hook useOptions to fetch data from server using react-query.
Added types for options.

@chosnekk chosnekk changed the title refactor: used cors and deleted body-parser Added fetching data to setup initialOptions. Refactored server. refs #94 Mar 5, 2021
@chosnekk
Copy link
Collaborator Author

chosnekk commented Mar 5, 2021

I'm sorry, I probably messed up this pull request with commits but I'm totally new to pull requests.
As for changes, I'd love to have some feedback, I'm only starting with typescript, so I'd appreciate any tips

@tiagostutz
Copy link
Contributor

Hi there @adam-p-git!
First of all, don't worry about mistakes; this is a Poppins Project, so it is the right place to "learn by doing". Mistakes are embraced here.

Second, I didn't see any mistake on your commits, they all look great to me. Separated commits for refactor and feature, good message linked to the issue and PR. Awesome.!

I'll take a look at the code asap and will give some feedback here. Thanks a lot for your contribution.

PS - I invited you to be a team member of the project. Have you received the invite?

@chosnekk
Copy link
Collaborator Author

chosnekk commented Mar 5, 2021

Thanks a lot, Tiago!
Yes, I've received the invite and I accepted it.

Copy link
Contributor

@tiagostutz tiagostutz left a comment

Choose a reason for hiding this comment

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

Checking your code I'm thinking about changing one thing on the architecture... instead of having the "model" approach, for example in the app/src/routes/useChoiceBoardModel.ts, we could move the state that is in there ([selectedItems, setSelectedItems]) to the componente itself, ChoiceBoard.ts.
This way, the ChoiceBoard.ts would have the state and would have the reference to useOptions().

What do you think?


// fetches options and return only choices
const getOptions = async () => {
const { data } = await axios({
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use the more "native" fetch instead of axios to make the requests? Any thoughts?
I'm asking it because every package we add to the project increases the bundle size.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, I'm just used to axios, but sure, I can rewrite this with fetch. Keeping bundle size as small as possible makes sense

var app = express();
app.use(bodyParser.json());
app.use(
cors({
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@chosnekk
Copy link
Collaborator Author

chosnekk commented Mar 6, 2021

Checking your code I'm thinking about changing one thing on the architecture... instead of having the "model" approach, for example in the app/src/routes/useChoiceBoardModel.ts, we could move the state that is in there ([selectedItems, setSelectedItems]) to the componente itself, ChoiceBoard.ts.
This way, the ChoiceBoard.ts would have the state and would have the reference to useOptions().

What do you think?

I'm not sure if I understand this correctly, so please correct me if I'm mistaken. The idea is to move all state into ChoiceBoard.tsx and use useOptions hook there. And in future, we could also for example post selected items to server in that component. Of course progress bar would be included there as well. Right? In another words, 'useChoiceBoardModel.ts` would not be needed

@tiagostutz
Copy link
Contributor

tiagostutz commented Mar 6, 2021

Exactly that, @adam-p-git ! Perfect.

@chosnekk
Copy link
Collaborator Author

chosnekk commented Mar 6, 2021

Oh, great. That was actually what I did in my other project but in javascript. I'll probably have more questions about the app, but I will take a closer look at it tomorrow.
It's amazing to develop my skills in this project, thanks for the opportunity!

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.

2 participants