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

feature: useStorage hook to persist data on frontend #83

Open
wants to merge 36 commits into
base: main
Choose a base branch
from

Conversation

AssahBismarkabah
Copy link
Collaborator

added useStorage to persist data on the frontend

@AssahBismarkabah
Copy link
Collaborator Author

hello sir @stephane-segning please waiting for review on this PR

Copy link
Contributor

@stephane-segning stephane-segning left a comment

Choose a reason for hiding this comment

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

This a good code, but the intended implementation. This doesn't make use of the react context features.

power-pay-frontend/src/components/useStorage.js Outdated Show resolved Hide resolved
@AssahBismarkabah
Copy link
Collaborator Author

hello sir @stephane-segning so we will have a StorageContext.ts? inside the {root}/src/contexts folder

@AssahBismarkabah
Copy link
Collaborator Author

hello sir @stephane-segning Added StorageContext global context for interacting with localStorage please review ths PR

@AssahBismarkabah
Copy link
Collaborator Author

AssahBismarkabah commented Mar 11, 2024

hello sir @stephane-segning please review this pull request

Copy link
Contributor

@stephane-segning stephane-segning left a comment

Choose a reason for hiding this comment

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

Create and managing state management inside of an app is always tricky. Working with react context is no exception. But we'll handle this. Take your time to review these points @AssahBismarkabah

power-pay-frontend/src/main.tsx Outdated Show resolved Hide resolved
power-pay-frontend/src/hooks/useStorage.ts Outdated Show resolved Hide resolved
power-pay-frontend/src/hooks/useStorage.ts Outdated Show resolved Hide resolved
power-pay-frontend/src/hooks/useStorage.ts Outdated Show resolved Hide resolved
power-pay-frontend/src/hooks/StorageContext.tsx Outdated Show resolved Hide resolved
power-pay-frontend/src/hooks/StorageContext.tsx Outdated Show resolved Hide resolved
power-pay-frontend/src/hooks/StorageContext.tsx Outdated Show resolved Hide resolved
power-pay-frontend/src/hooks/StorageContext.tsx Outdated Show resolved Hide resolved
power-pay-frontend/src/hooks/StorageContext.tsx Outdated Show resolved Hide resolved
power-pay-frontend/src/hooks/StorageContext.tsx Outdated Show resolved Hide resolved
@AssahBismarkabah
Copy link
Collaborator Author

hello sir @stephane-segning please waiting for your review on this PR

@AssahBismarkabah
Copy link
Collaborator Author

hello sir @stephane-segning please review this changes

power-pay-frontend/src/hooks/StorageContext.tsx Outdated Show resolved Hide resolved
power-pay-frontend/src/hooks/StorageContext.tsx Outdated Show resolved Hide resolved
power-pay-frontend/src/hooks/useStorage.ts Outdated Show resolved Hide resolved
power-pay-frontend/src/hooks/useStorage.ts Outdated Show resolved Hide resolved
@AssahBismarkabah
Copy link
Collaborator Author

hello sir @stephane-segning waiting for your review

Copy link
Contributor

@stephane-segning stephane-segning left a comment

Choose a reason for hiding this comment

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

Nice work @AssahBismarkabah @Christiantyemele ! Just these few points now

},
removeItem: async (key) => clearItem(key),
clear: async () => {
localStorage.clear();
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this line too

Comment on lines 21 to 23
if (storedValue !== undefined) {
setItem(key, storedValue);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Here you can remove the if condition there

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

You didn't removed this if

Comment on lines 21 to 23
if (storedValue !== undefined) {
setItem(key, storedValue);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You didn't removed this if

@Christiantyemele
Copy link
Collaborator

Christiantyemele commented Mar 22, 2024

hello sir @stephane-segning I have added the docs for the indexDB storage and requesting for review before further do

@Christiantyemele
Copy link
Collaborator

@AssahBismarkabah and @Motouom request and @stephane-segning please requesting for review on this PR

Copy link
Collaborator

@Motouom Motouom left a comment

Choose a reason for hiding this comment

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

Okay!

Comment on lines +15 to +17
const [storedValue, setStoredValue] = useState<T | undefined>(() => {
return item[key] ?? initialValue;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this and use item[key] directly instead of 'storedValue'

@Motouom
Copy link
Collaborator

Motouom commented Jun 14, 2024

@AssahBismarkabah @Christiantyemele please consider these changes that @stephane-segning asked

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.

4 participants