ManpreetSL / habit-tracker

Group habit tracker
habit-tracker-omega.vercel.app
MIT License
0 stars 0 forks source link

Add local storage functionality #53

Closed ManpreetSL closed 1 year ago

ManpreetSL commented 1 year ago

Currently, the app doesn't actually have the ability to save any data changes that are made in the UI. It just loads data from the habits.json file.

This PR adds functionality to fetch habits from local storage, and adds a button to save the sample habits data we already have in habits.json to local storage as a starting point for testing without having to manually populate data when running the app.

It is currently a rudimentary implementation just saves and retrieve all habits data each time. This is inefficient for removing or editing 1 habit out of 15, for example, but for now, saving each habit with its own unique key is going to take more work for little gain feature-wise.

Implements #52.

github-actions[bot] commented 1 year ago

Preview :) https://habit-tracker-40fwaa8rz-manpreetsl.vercel.app

github-actions[bot] commented 1 year ago

Preview :) https://habit-tracker-k93jiuwjj-manpreetsl.vercel.app

github-actions[bot] commented 1 year ago

Preview :) https://habit-tracker-mcbsjqisa-manpreetsl.vercel.app

ManpreetSL commented 1 year ago

@Harjot1Singh This has been updated to merge the local storage changes in with the add a habit changes in #55 (which also involved setting up a json habit factory). It seems to work but I just want the code checked over for best practice.

github-actions[bot] commented 1 year ago

Preview :) https://habit-tracker-p822ce54b-manpreetsl.vercel.app

ManpreetSL commented 1 year ago

Looks good. You may wish to add a test at some point

Part of the adapter pattern allows for easy plug n' play, but of course you may be noticing the main disadvantage when you don't have many adapter - keeping the adapter interface type up to date ;)

Yeah, I noticed that it can be a bit long to have to update the types each time, but it's also useful because it errors in the IDE and helps to make sure I've got everything named and linked up correctly.

My main annoyance with it though, is that I can't ctrl+click in a component to go to the source of a function - it goes to the types instead of the implementation.

github-actions[bot] commented 1 year ago

Preview :) https://habit-tracker-n6gx7rcvs-manpreetsl.vercel.app