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

Allow exporting or importing data to a json file. #4

Open
sameer1612 opened this issue Oct 17, 2023 · 13 comments · May be fixed by #10
Open

Allow exporting or importing data to a json file. #4

sameer1612 opened this issue Oct 17, 2023 · 13 comments · May be fixed by #10
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest

Comments

@sameer1612
Copy link
Owner

Group 1(1)

Add two buttons that will export the current state to a JSON file and this file can later be imported back to initialize the redux toolkit state.

@sameer1612 sameer1612 added enhancement New feature or request good first issue Good for newcomers hacktoberfest labels Oct 17, 2023
@sergomen
Copy link

@sameer1612 Please assign it to me.

@sameer1612
Copy link
Owner Author

@sergomen Assigning to you. I'll be reviewing PRs this saturday.

Feel free to drop a comment in case of any doubt. Thanks!

@sergomen
Copy link

@sergomen Assigning to you. I'll be reviewing PRs this saturday.

Feel free to drop a comment in case of any doubt. Thanks!

Hi sameer. I not able to solve this issue in time (this Saturday). I'm not familiar with Redux. Can you please give me additional time (2-3 days)? I will try to do my best.

@sameer1612
Copy link
Owner Author

@sergomen If you are stuck somewhere. Feel free to reach out, I can help you get to speed.

@sergomen
Copy link

sergomen commented Oct 21, 2023

@sameer1612, I added some updates with ussues. I understand a little bit how to work with Redux, but can you pls check my updates (https://github.com/sergomen/tiers-of-joy/blob/main/src/components/import-json/import-json.tsx)

I'm trying to dispatch custom json string from modal to reducer. I get array of arrays. But I need to get array of objects. I think this is the issue.
const newTiles = lines.map((line) => { const tokens = line.split(","); console.log("Length", tokens.length) if (tokens.length !== 1) { return { url: tokens[2], title: tokens[1], tier: tokens[0] }; }

I will continue tomorrow.

#upd. 10.22.23 7:00am GMT. I fixed this issue.

@sergomen
Copy link

sergomen commented Oct 22, 2023

This is the first iteration what I want to do.
Now it looks like:

The.first.iteration.tiers.of.joy.mp4

@sameer1612
Copy link
Owner Author

@sergomen this looks good. Can we not simply import a file instead of copy pasting its contents? Like by using a file picker.

@sergomen
Copy link

@sergomen this looks good. Can we not simply import a file instead of copy pasting its contents? Like by using a file picker.

Yeah, sure. It's just the first iteration.

@sergomen
Copy link

@sameer1612, can you give me some advice how to 'catch' data for exporting json? It seems, I haven't any idea how to do it.

@sameer1612
Copy link
Owner Author

@sergomen I can catch up for a quick 10m session tomorrow to clear your conceptual doubts. Please mail me a Google calendar invite at cyber726337@gmail.com.

Happy to help!

@sergomen
Copy link

sergomen commented Oct 24, 2023

Thanks, @sameer1612, for your advice. Now it works. This is the second iteration. I remember I need to add a file picker and clean code.

second.iteration.tiers.of.joy.mp4

@sameer1612
Copy link
Owner Author

This looks good @sergomen. Nice work!

One worth change here is to do a check while importing so that the situation at end of this video doesn't happen where we have duplicates in lhs and rhs.

When you implement file picker, replace the entire state, removing all existing entries before import.

@sergomen
Copy link

sergomen commented Oct 29, 2023

Hi @sameer1612 . I have added changes.

@sameer1612 sameer1612 linked a pull request Oct 30, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants