MalteMagnussen / CA2-FrontEnd

FrontEnd repo for Course Assignment 2. Hold Krykke.
https://holdkrykke.surge.sh
0 stars 2 forks source link

Implement deletePerson #50

Closed Runi-VN closed 4 years ago

Runi-VN commented 4 years ago

Fixes #7 Fixes #44

Changes in this PR

Current errors

The addUpdateButtons does not run 100% correctly.

If your first attempt to look up a person is correct ("FirstName LastName") it will display buttons as it should.

If you somehow messes up, then correct it, it will take not one, but two clicks on Get User to trigger the function.

Shown in GIF:

I believe the addUpdateButtons-function finishes before the singleuser-function is done, on which it is reliant.

Runi-VN commented 4 years ago

Must change URL back to proper one before merge

also need to fix this sh!tshow. pls give async/await

Runi-VN commented 4 years ago

Initial thoughts: Finish this as soon as possible and implement editPerson using the following: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch subsection Uploading JSON data

For this assignment, considering we cannot use async/await, it might not that much of an issue to:
a) save fetchData in a variable b) create multiple fetches c) Grabbing data right off the DOM d) I forgot

I like option a because I need a full json body for editPerson

@Castau and I agreed to bring this up during the final project meeting.

Castau commented 4 years ago

For this assignment, considering we cannot use async/await, it might not that much of an issue to: a) save fetchData in a variable b) create multiple fetches c) Grabbing data right off the DOM d) I forgot

Option a) and c) are not possible, I think. The writing of data to the DOM or a variable will happen at some time after the the code has run past the first fetching of data, so the data you "read in" in your next fetch will not exist yet. It's the exact same problem I had when i made the dropdown-data and the functions that use that data.

You can do fetch-in-fetch or callbacks from the first fetch, as I have understood. If you want the data presented to the user and then resubmitted (where the user has to pres a new button) I think you can get around this, since the user will have to have time to read, process and pres a button.

So a option e) might be:

Runi-VN commented 4 years ago

Ready to merge. Did not manager to prettify output, had a few attempts with bootstrap grid/flex, but it didnt work and its late.

GeneratePerson() could have been smarter made (lots of repeat code) but I'm out of time.