Build a website which analyse the leetcode profile
I'll create a website that analyzes a LeetCode profile. We'll use Next.js with the App Router to build this application. The website will fetch data from the LeetCode API and display various statistics about the user's profile.
This React project creates a website that analyzes a LeetCode profile. Here's a breakdown of the components and their functions:
app/page.tsx
: The main page component that renders the LeetCodeAnalyzer.app/components/LeetCodeAnalyzer.tsx
: The main component that handles user input, fetches data, and displays the results.app/actions/leetcode.ts
: A server action that fetches data from the LeetCode API.app/components/ProfileStats.tsx
: A component that displays the user's profile statistics.app/components/ProblemSolvingChart.tsx
: A component that visualizes the user's problem-solving history using a bar chart.To use this website:
The website will fetch the user's profile data and display it in two sections:
The website is responsive and uses Tailwind CSS for styling. It also uses shadcn/ui components for a consistent and modern look.
To further improve this website, you could consider adding:
Let me know if you want to make any changes or additions to this LeetCode profile analyzer website!
The code returns the following error:
Error: Cannot read properties of undefined (reading 'acSubmissionNum')
at LeetCodeAnalyzer (/app/components/LeetCodeAnalyzer)
Revise the code to address the error.
The error occurs because we're trying to access profileData.submitStats.acSubmissionNum
before ensuring that profileData
and submitStats
exist. Let's revise the code to handle this potential undefined state. We'll update the LeetCodeAnalyzer
component and adjust the ProfileStats
and ProblemSolvingChart
components to be more resilient.
These changes address the error by:
profileData
and its nested properties before rendering the ProfileStats
and ProblemSolvingChart
components.ProfileStats
component.ProblemSolvingChart
component.analyzeLeetCodeProfile
function to ensure it returns the correct data structure and throws an error if the user is not found or the API response is invalid.These modifications should resolve the "Cannot read properties of undefined" error and make the application more robust when handling potential edge cases or incomplete data from the LeetCode API.
Develop this project ui same as leet code and display no of problems dolved