Skip to content

feat: export buttons for json and text format #19

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

Merged
merged 8 commits into from
Aug 18, 2023

Conversation

piyushjha0409
Copy link
Contributor

Created a generate text function and a button to export it.
Added a button for downloading in json format as well. :)

@vercel
Copy link

vercel bot commented Aug 18, 2023

Someone is attempting to deploy a commit to a Personal Account owned by @Balastrong on Vercel.

@Balastrong first needs to authorize it.

Copy link
Member

@Balastrong Balastrong left a comment

Choose a reason for hiding this comment

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

I added a few comments but the overall logic seems correct! :)

Also please make sure to format the file (you can use npm run format:fix in your terminal) and restore the .env.example file :)

Comment on lines 167 to 180
{repositories?.map(({ repository, contributions }) => (
<div key={repository.name}>
<div key={repository.name} id="repo-content">
{repository.owner.login}/{repository.name} (
{contributions.totalCount})
<br />
{contributions.nodes.map(({ pullRequest }) => (
<span key={pullRequest.id}>
<span key={pullRequest.id} id="pr-content">
{pullRequest.title} - {pullRequest.state}
<br />
</span>
))}
<br />
</div>
))}
Copy link
Member

Choose a reason for hiding this comment

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

You can now replace all of this with generateText to make sure it is the exact same output

Suggested change
{repositories?.map(({ repository, contributions }) => (
<div key={repository.name}>
<div key={repository.name} id="repo-content">
{repository.owner.login}/{repository.name} (
{contributions.totalCount})
<br />
{contributions.nodes.map(({ pullRequest }) => (
<span key={pullRequest.id}>
<span key={pullRequest.id} id="pr-content">
{pullRequest.title} - {pullRequest.state}
<br />
</span>
))}
<br />
</div>
))}
{generateText()}
{pullRequest.title} - {pullRequest.state}
<br />
</span>
))}
<br />
</div>
))}
<button className="bg-blue-500 p-2 m-1 rounded hover:bg-blue-900" onClick={exportText}>Export as Text</button>
Copy link
Member

Choose a reason for hiding this comment

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

Can we put this button before the text? Same as you did for the JSON :)


text += "\n";
}
console.log(text)
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove this console.log?

@@ -80,35 +151,43 @@ export default function Stats() {
{isLoading ? (
<div>Loading...</div>
) : format === "cards" ? (
<div>
Copy link
Member

Choose a reason for hiding this comment

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

This duplicate div can be removed

@@ -2,7 +2,7 @@ import { RepositoryContributionsCard } from "@/components";
import { useGitHubPullRequests } from "@/hooks";
import { useSession } from "next-auth/react";
import { useRouter } from "next/router";
import { useState } from "react";
import { useEffect, useState } from "react";
Copy link
Member

Choose a reason for hiding this comment

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

useEffect is no longer used, can be removed

@piyushjha0409
Copy link
Contributor Author

I added a few comments but the overall logic seems correct! :)

Also please make sure to format the file (you can use npm run format:fix in your terminal) and restore the .env.example file :)

Sure

@piyushjha0409
Copy link
Contributor Author

I have done the changes, check it once!

@Balastrong Balastrong changed the title Export buttons for json and text format feat: export buttons for json and text format Aug 18, 2023
Copy link
Member

@Balastrong Balastrong left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you again! 🚀

@Balastrong Balastrong merged commit b9c9870 into DevLeonardoCommunity:main Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants