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

[React] Post a resource #55

Closed
lpatmo opened this issue Nov 6, 2019 · 29 comments
Closed

[React] Post a resource #55

lpatmo opened this issue Nov 6, 2019 · 29 comments

Comments

@lpatmo
Copy link
Member

lpatmo commented Nov 6, 2019

Is your feature request related to a problem? Please describe.
Mock posting a resource from https://cb-react-concept.netlify.com/submit-resource

See: https://egghead.io/lessons/javascript-creating-demo-apis-with-json-server

Describe the solution you'd like

  1. User fills out the fields and clicks on "submit", and sees a success message
  2. User is redirected to /resources
  3. User sees the new resource they added

Essentially, we need to explore making a fake POST request to the /resources API endpoint.

@lpatmo lpatmo self-assigned this Nov 11, 2019
@peoray
Copy link
Member

peoray commented Nov 17, 2019

@lpatmo have you seen this?
https://fakejson.com/

@lpatmo
Copy link
Member Author

lpatmo commented Nov 17, 2019

@peoray We're using https://github.com/typicode/json-server right now, which is similar, except our DB lives in db.json flie. :)

I've got most of the steps working in the branch issue-55, but haven't had time to do form validation and display the success message yet. Feel free to take a look if you're interested!

@peoray
Copy link
Member

peoray commented Nov 19, 2019

Cool, will definitely take a look. Is it possible for two people to work on the same branch?

@wuworkshop
Copy link

@peoray Sorry for the late reply. Yes, it is possible for two people to work on the same branch. Since @lpatmo pushed her branch up to GitHub here https://github.com/codebuddies/react-concept/tree/issue-55, you should be able to checkout that branch and work on it.

@peoray
Copy link
Member

peoray commented Nov 30, 2019

I'm trying to do this but it doesn't work

alomo@alomo:~/Documents/code/oss/react-concept$ git checkout issue-55
error: pathspec 'issue-55' did not match any file(s) known to git

Btw, my repo is up to date with the main repo

@lpatmo
Copy link
Member Author

lpatmo commented Nov 30, 2019 via email

@lpatmo
Copy link
Member Author

lpatmo commented Dec 1, 2019

@peoray Does typing git remote -v already point to an upstream that's this repo? You'll probably have to git fetch upstream before you can check out the branch. Let me know if that works!

@peoray
Copy link
Member

peoray commented Dec 2, 2019

I already have it as an upstream and I'm using pull instead of fetch, does that mean a difference?

@lpatmo
Copy link
Member Author

lpatmo commented Dec 19, 2019

@peoray Sorry I missed your comment! Can you share what you see when you type git remote -v? Or did you already figure this out?

@peoray
Copy link
Member

peoray commented Dec 19, 2019

alomo@alomo:~/Documents/code/oss/react-concept$ grv
origin	https://github.com/peoray/react-concept.git (fetch)
origin	https://github.com/peoray/react-concept.git (push)
upstream	https://github.com/codebuddies/react-concept.git (fetch)
upstream	https://github.com/codebuddies/react-concept.git (push)
alomo@alomo:~/Documents/code/oss/react-concept$ 

@lpatmo
Copy link
Member Author

lpatmo commented Dec 20, 2019

@peoray I think if you git pull upstream and then git checkout issue-55 you should be able to see the branch.

@peoray
Copy link
Member

peoray commented Dec 20, 2019

Still not working...:(

gh1
gh-2

@lpatmo
Copy link
Member Author

lpatmo commented Dec 22, 2019

@peoray Thanks for sharing those screenshots! Can you try git checkout origin/issue-55?

@peoray
Copy link
Member

peoray commented Dec 22, 2019

Still doesn't work. Still not sure if the issue is from my side or not. I'd love for someone else to try and see if it will work on their end

@wuworkshop
Copy link

@peoray Looking at your screenshots, you didn't quite follow exactly what @lpatmo had written. She wrote git pull upstream. In your screenshot, you wrote git pull upstream master. Adding the master part will only pull in changes from upstream's master branch.

I just tested this out in my own fork. Here are the exact steps to follow to update your fork with all the branches in the upstream repo:

  1. git fetch upstream
    This will fetch ALL the branches from the upstream repo. When you run this command, you should see a longer list of branches as a result.

  2. git checkout master
    Then checkout your fork's local master branch.

  3. git merge upstream/master
    This will merge the changes from upstream/master into your local master branch. This brings your fork's master branch into sync with the upstream repository, without losing your local changes.

  4. git branch -r
    To verify you now have the issue-55 branch, the -r flag will list all remote branches. You should see issue-55 under origin and upstream.

  5. git checkout --track origin/issue-55
    To checkout the issue-55 branch.

  6. git push origin master
    To push the changes to your fork on GitHub.

References:
https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/syncing-a-fork

@wuworkshop
Copy link

@peoray btw, since you asked this question:

I'm using pull instead of fetch, does that mean a difference?

There is actually a difference between git pull and git fetch.

git pull is shorthand for git fetch followed by git merge FETCH_HEAD.
More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch.

References:
https://git-scm.com/docs/git-pull

@peoray
Copy link
Member

peoray commented Dec 23, 2019

Thank you @wuworkshop. That was the problem. It's working now :)

@peoray
Copy link
Member

peoray commented Dec 23, 2019

@lpatmo What do you have in mind as regards how to handle the validation?

@lpatmo
Copy link
Member Author

lpatmo commented Dec 24, 2019

@peoray I'm thinking of using react-form-hooks, based on this article:
https://blog.logrocket.com/react-hook-form-vs-formik-a-technical-and-performance-comparison/

A relevant thread: mui/material-ui#18269

I'm actually curious if anyone else has recommendations for validation with Material-UI too!

@BethanyG BethanyG assigned BethanyG and unassigned BethanyG Dec 25, 2019
@peoray
Copy link
Member

peoray commented Jan 1, 2020

Okay. If this is fine with everyone, I'd like to start working on this issue

@sebbel
Copy link
Contributor

sebbel commented Jan 31, 2020

@peoray hey do you need help to get started? We could pair on this if you'd like :)

@peoray
Copy link
Member

peoray commented Feb 1, 2020

@sebbel that would be awesome. Just sent you a message on slack :)

@billglover billglover added this to To do in CodeBuddies Feb 15, 2020
@angelocordon angelocordon added this to To do in v30.1 Mar 1, 2020
@angelocordon angelocordon added this to the v3.0.1 milestone Mar 1, 2020
@angelocordon angelocordon added this to To do in Resources Mar 1, 2020
@lpatmo
Copy link
Member Author

lpatmo commented Jul 26, 2020

@bkbuilt and I paired on this on Twitch earlier today: https://www.twitch.tv/videos/691444610

We jotted down a couple of TODOs we'll tackle in a future pairing session, including:

// TODO : // when type, store values on change // decide what happens on successful submit (redirect to created resource, alert like "congrats you submitted resource..") // validation (follow auth implementation) (as type, post-submit) // display failed submissions to the user (if not already) // test for posting to mock up successful response // ensure these are all desired fields for forms

@lpatmo lpatmo added this to High priority in V3 Priorities Aug 23, 2020
@stale
Copy link

stale bot commented Sep 6, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 6, 2020
@tgrrr
Copy link

tgrrr commented Sep 9, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Bump because I think this is an open ongoing issue

@stale stale bot removed the stale label Sep 9, 2020
tgrrr added a commit that referenced this issue Sep 9, 2020
What:

submitResource.js:
- fix console errors: name missing in url component. Fixed with name in `ref` on line 172
- add defaultValues: initialState
- refactor initialState
- add button type submit
- cleaned up db.json

ResourceCard:
- fix Card class -> className
- update `created` PropTypes
    Note: this will fail if an invalid date is submitted to db.json
    (validation is yet to be done)

Why:
- No more console errors
- Now generates errors on fields that are required or have validation
- Submits form to populate db.json

- [x] User fills out the fields and clicks on "submit",
  - [ ] user sees a success message
- [x] User is redirected to /resources
- [x] User sees the new resource they added

Note: The user doesn't see a success message, because they are redirected too quickly

Still to complete:
- [ ] Validation
- [ ] unit tests
- [ ] e2e tests

#55
@tgrrr tgrrr self-assigned this Sep 9, 2020
@tgrrr
Copy link

tgrrr commented Sep 9, 2020

I got on top of the bugs for this Linda @lpatmo. It still needs more work, including validation and tests to be written.

@lpatmo
Copy link
Member Author

lpatmo commented Sep 10, 2020

Thanks so much for taking a look! Will take a look at the issue-55 branch (where I assume you made the commits)

@lpatmo
Copy link
Member Author

lpatmo commented Sep 10, 2020

@tgrrr So sorry again about the confusion with the branches! I probably should have deleted issue-55. issue55-post contains the more updated work involving useReducer and the React Query refactor and the validation that a user is logged in before they can post. I'll dig into it again on stream sometime.

@angelocordon angelocordon moved this from High priority to High Priority In Progress in V3 Priorities Sep 12, 2020
@angelocordon angelocordon self-assigned this Sep 13, 2020
@stale
Copy link

stale bot commented Oct 13, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 13, 2020
@stale stale bot closed this as completed Oct 20, 2020
CodeBuddies automation moved this from To do to Done Oct 20, 2020
Resources automation moved this from To do to Done Oct 20, 2020
V3 Priorities automation moved this from High Priority In Progress to Done Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
CodeBuddies
  
Done
Resources
  
Done
V3 Priorities
  
Done
v30.1
  
To do
Development

No branches or pull requests

8 participants