Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ dist-ssr
*.njsproj
*.sln
*.sw?

# Local Netlify folder
.netlify
.env
1 change: 0 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import ContactPage from './pages/ContactPage';
import AboutUs from './pages/AboutUs';

function App() {
console.log(window.location.pathname)
return (
<Router>
<Routes>
Expand Down
2 changes: 1 addition & 1 deletion src/api/github.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Use environment variable for the base URL
const BACKEND_URL = import.meta.env.VITE_BACKEND_URL || process.env.REACT_APP_BACKEND_URL;
const BACKEND_URL = import.meta.env.VITE_BACKEND_URL;

// Function for starting GitHub authentication
export const startGithubAuthentication = async () => {
Expand Down
16 changes: 11 additions & 5 deletions src/components/Chart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,22 @@ const chartSetting = {

// Function to create a dataset for BarChart
const createDataset = (contributionsData) => {
return contributionsData.flatMap(repo => {
const issues = repo.contributions.issues !== null ? repo.contributions.issues : 0;
const pulls = repo.contributions.pulls !== null ? repo.contributions.pulls : 0;
return contributionsData.flatMap((repo) => {
const { contributions } = repo;

// Ensure issues and pulls default to empty arrays if null or undefined
const issues = contributions?.issues || [];
const pulls = contributions?.pulls || [];

// Return formatted dataset entries with counts
return [
{ day: repo.repo_name + " - Issues", count: issues },
{ day: repo.repo_name + " - Pull Requests", count: pulls },
{ day: `${repo.repo_name} - Issues`, count: issues.length },
{ day: `${repo.repo_name} - Pull Requests`, count: pulls.length },
];
});
};


const ContributionChart = ({ contributions }) => {
const dataset = createDataset(contributions); // Create dataset from contributions prop

Expand Down
105 changes: 76 additions & 29 deletions src/components/Contributions.jsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,80 @@
export const Contributions = ({data}) => {
export const Contributions = ({ data }) => {
return (
<div className="space-y-2">
{data.map((repo, index) => (

<div key={index} className="flex flex-col gap-2 bg-white bg-opacity-10 p-2 rounded-lg">
<h3 className="text-base font-bold">{repo.repo_name}</h3>
<div>
<strong>Issues:</strong>
{repo.contributions.issues ? (
repo.contributions.issues.map((issue, i) => (
<div key={i}>
<a href={issue.html_url} className="text-blue-500 underline">{issue.title}</a>
<p>State: {issue.state}</p>
<p>Created: {new Date(issue.created_at).toLocaleDateString()}</p>
<p>Updated: {new Date(issue.updated_at).toLocaleDateString()}</p>
{data.map((repo, index) => (
<div
key={index}
className="flex flex-col gap-2 bg-white bg-opacity-10 p-2 rounded-lg"
>
<h3 className="text-base font-bold">{repo.repo_name}</h3>

{/* Issues Section */}
<div>
<strong>Issues:</strong>
{Array.isArray(repo.contributions?.issues) &&
repo.contributions.issues.length > 0 ? (
repo.contributions.issues.map((issue, i) => (
<div key={i} className="ml-4">
<a
href={issue.html_url}
className="text-blue-500 underline"
target="_blank"
rel="noopener noreferrer"
>
{issue.title}
</a>
<p>State: {issue.state}</p>
<p>
Created:{" "}
{new Date(issue.created_at).toLocaleDateString()}
</p>
<p>
Updated:{" "}
{new Date(issue.updated_at).toLocaleDateString()}
</p>
</div>
))
) : (
<p className="ml-4 text-gray-500">
No issues found for this repository.
</p>
)}
</div>

{/* Pull Requests Section */}
<div>
<strong>Pulls:</strong>
{Array.isArray(repo.contributions?.pulls) &&
repo.contributions.pulls.length > 0 ? (
repo.contributions.pulls.map((pull, i) => (
<div key={i} className="ml-4">
<a
href={pull.html_url}
className="text-blue-500 underline"
target="_blank"
rel="noopener noreferrer"
>
{pull.title}
</a>
<p>State: {pull.state}</p>
<p>
Created:{" "}
{new Date(pull.created_at).toLocaleDateString()}
</p>
<p>
Updated:{" "}
{new Date(pull.updated_at).toLocaleDateString()}
</p>
</div>
))
) : (
<p className="ml-4 text-gray-500">
No pull requests found for this repository.
</p>
)}
</div>
</div>
))
) : (
<p>No contributions available</p>
)}
</div>
<div>
<strong>Pulls:</strong>
{repo.contributions.pulls ? <p>{repo.contributions.pulls}</p> : <p>No contributions available</p>}
</div>
))}
</div>
))}
</div>

)
}

);
};
1 change: 0 additions & 1 deletion src/pages/ContactPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const ContactPage = () => {

const handleSubmit = (e) => {
e.preventDefault();
console.log('Form submitted:', formData);
setFormData({
name: '',
email: '',
Expand Down
6 changes: 1 addition & 5 deletions src/pages/Dashboardpage.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import React, { useState, useEffect } from "react";
import { Avatar, Dialog, DialogTitle, DialogContent, DialogActions, Button } from "@mui/material";

import { BarChart } from "@mui/x-charts/BarChart";
import { axisClasses } from "@mui/x-charts/ChartsAxis";

import Hero from '../components/Hero';
import { Contributions } from "../components/Contributions";

import { getContributions, getProfileUrl } from "../api/github";
import SpinnerLoader from "../components/Loader";
import Stats from "../components/StatCard";
Expand Down Expand Up @@ -35,6 +30,7 @@ const DashboardPage = () => {
setTotalStats(getTotalContributions(data));
setProfileUrl(profileUrl.avatar_url);
setLoading(false);

} catch (err) {
setError("Failed to load stats.");
}
Expand Down
8 changes: 4 additions & 4 deletions src/pages/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ const Navbar = () => {
DASHBOARD
</Link>

<Link
{/* <Link
to="/team"
className="text-gray-700 hover:text-green-500 relative pb-1 border-b-2 border-transparent hover:border-green-500 transition duration-300"
>
TEAM
</Link>
</Link> */}

<Link
to="/contact"
Expand All @@ -81,7 +81,7 @@ const Navbar = () => {
className="h-10 w-10 rounded-full cursor-pointer"
onClick={toggleDropdown}
/>
{dropdownOpen && (
{/* {dropdownOpen && (
<div className="absolute right-0 mt-2 w-48 bg-white rounded-lg shadow-lg py-2 z-10">
<Link
to="/dashboard"
Expand All @@ -96,7 +96,7 @@ const Navbar = () => {
Profile Page
</Link>
</div>
)}
)} */}
</div>

{/* Hamburger Menu for Mobile */}
Expand Down
26 changes: 15 additions & 11 deletions src/utils/calculateContribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,26 @@ export const getTotalContributions = (data) => {
let totalIssues = 0;
let totalPulls = 0;

data.forEach(repo => {
// Only count the repository if there are issues or pulls
if (repo.contributions.issues !== null || repo.contributions.pulls !== null) {
totalRepos += 1; // Count this repo
if (repo.contributions.issues !== null) {
totalIssues += repo.contributions.issues;
}
if (repo.contributions.pulls !== null) {
totalPulls += repo.contributions.pulls;
data.forEach((repo) => {
const { contributions } = repo;

// Check if contributions exist
if (contributions) {
const issues = contributions.issues || [];
const pulls = contributions.pulls || [];

// Increment counts based on array lengths
if (issues.length > 0 || pulls.length > 0) {
totalRepos += 1; // Count the repository only if it has issues or pulls
}
totalIssues += issues.length; // Add total issues
totalPulls += pulls.length; // Add total pull requests
}
});

return {
totalRepos,
totalIssues,
totalPulls
totalPulls,
};
};
};