gbowne1 / codebooker

This is a book recommendation app created with React 18.2 and MUI for coders/programmers looking for reccomendations to books on programming/coding to read
MIT License
31 stars 57 forks source link

Get books from file and seed database when DB is empty #195

Closed Priyankaa2503 closed 1 year ago

Priyankaa2503 commented 1 year ago

Fixes Issue #179

This PR : 1) Seeds the database with default books using existing JSON data to prevent loading issues when the database is empty. 2) In addition to this, the user can see a "add book" option.

Screenshot 2023-10-22 at 8 01 01 PM
gbowne1 commented 1 year ago

yeah, I think it will be ok to merge this.

This should take care of several problems with this

gbowne1 commented 1 year ago

"I think if the db is empty the 'addbook' button should be displayed along with a message informing the user that the db is empty."

Yes, thats correct @BlackBond06

"Isn't this action (populating the UI with books from data.json file) suppose to happen when there is an actual error from the db and not when the db is empty?"

It should probably do both, but when the db is empty you should get a message saying it is empty and it needs to be populated. Normally this wouldn't happen, but.. one never knows when it might not, unless an outage is scheduled. Also because we will likely need some visible data in the UI during development several things can happen:

BlackBond06 commented 1 year ago

With the current state of app, changes in this PR will populate the UI from Json data, when the app loads, since the db is empty. After adding a book, the app state will change from displaying all that json data to showing only the added book. Don't know if this is a good user experience.

gbowne1 commented 1 year ago

It might not be the best UX, but I think it could be impoved upon with some work.

In production, it would be relatively unlikely there would be no books in the database as we would want 100% uptime or as near as possible, unless the database was down for maintenance.. and at that point the user would only have their library (if they had any) showing in their "Library" tab in the left nav drawer.

We still have to add that UI for the Library tab.

LOGESH-B commented 1 year ago

With the current state of app, changes in this PR will populate the UI from Json data, when the app loads, since the db is empty. After adding a book, the app state will change from displaying all that json data to showing only the added book. Don't know if this is a good user experience.

No, if you add a book both the data is shown(i.e from Json,added book) because the json data is added to the db at initial render

gbowne1 commented 1 year ago

Yeah, that sounds a lot more like it to me @LOGESH-B

BlackBond06 commented 1 year ago

With the current state of app, changes in this PR will populate the UI from Json data, when the app loads, since the db is empty. After adding a book, the app state will change from displaying all that json data to showing only the added book. Don't know if this is a good user experience.

No, if you add a book both the data is shown(i.e from Json,added book) because the json data is added to the db at initial render

Oh okay, that looks good then. Thank you for the clarification @LOGESH-B.

gbowne1 commented 1 year ago

@BlackBond06 @LOGESH-B can we now review this?