diff --git a/backend/database/__init__.py b/backend/database/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 9f70aa6c..ebd8d11a 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -160,12 +160,12 @@ function App() { isAuthenticated ? : } > - } /> - } /> + } /> + } /> } /> - } /> - } /> - } /> + } /> + } /> + } /> } /> } /> } /> diff --git a/frontend/src/components/contributors/ContributorsPage.tsx b/frontend/src/components/contributors/ContributorsPage.tsx index d0ee0e2f..195081fc 100644 --- a/frontend/src/components/contributors/ContributorsPage.tsx +++ b/frontend/src/components/contributors/ContributorsPage.tsx @@ -2,12 +2,14 @@ import React, { useEffect, useState } from 'react'; import { motion } from 'framer-motion'; import { toast } from 'react-hot-toast'; import ContributorCard from './ContributorCard'; +import LandingPage from '../landing/LandingPage'; interface Props { repoData: any; // Fetched repository stats + setRepoData?: (data: any) => void; } -const ContributorsPage: React.FC = ({ repoData }) => { +const ContributorsPage: React.FC = ({ repoData, setRepoData }) => { const [contributors, setContributors] = useState([]); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); @@ -27,7 +29,7 @@ const ContributorsPage: React.FC = ({ repoData }) => { }; if (!repoData) { - return
No data available. Please analyze a repository first.
; + return {})} message="Please analyze a repository first to get started." />; } if (loading) { diff --git a/frontend/src/components/dashboard/Dashboard.tsx b/frontend/src/components/dashboard/Dashboard.tsx index a758cdc8..1a084a13 100644 --- a/frontend/src/components/dashboard/Dashboard.tsx +++ b/frontend/src/components/dashboard/Dashboard.tsx @@ -4,14 +4,16 @@ import { toast } from 'react-hot-toast'; import { Users, GitPullRequest, MessageSquare, Activity, Github, Slack } from 'lucide-react'; import StatCard from './StatCard'; import BotIntegration from '../integration/BotIntegration'; +import LandingPage from '../landing/LandingPage'; interface Props { repoData: any; // Fetched repository stats + setRepoData?: (data: any) => void; // Function to pass data to parent } -const Dashboard: React.FC = ({ repoData }) => { +const Dashboard: React.FC = ({ repoData,setRepoData }) => { if (!repoData) { - return
No data available. Please analyze a repository first.
; + return {})} message="Please analyze a repository first to get started." />; } const handleNewIntegration = () => { diff --git a/frontend/src/components/landing/LandingPage.tsx b/frontend/src/components/landing/LandingPage.tsx index 0b586566..e015fe7c 100644 --- a/frontend/src/components/landing/LandingPage.tsx +++ b/frontend/src/components/landing/LandingPage.tsx @@ -5,10 +5,12 @@ import { toast } from 'react-hot-toast'; import { useNavigate } from 'react-router-dom'; interface Props { - setRepoData: (data: any) => void; // Function to pass data to parent + setRepoData?: (data: any) => void; + message: string; } -const LandingPage: React.FC = ({ setRepoData }) => { +const LandingPage: React.FC = ({ setRepoData, message="Enter a GitHub repository URL to analyze its stats." }) => { + const safeSetRepoData = setRepoData ?? (() => {}); const [repoUrl, setRepoUrl] = useState(''); const [loading, setLoading] = useState(false); const navigate = useNavigate(); @@ -21,7 +23,7 @@ const LandingPage: React.FC = ({ setRepoData }) => { setLoading(true); try { const response = await axios.post('http://localhost:8000/api/repo-stats', { repo_url: repoUrl }); - setRepoData(response.data); // Pass fetched data to parent + safeSetRepoData(response.data); toast.success('Repository stats fetched successfully!'); navigate('/dashboard'); // Navigate to dashboard } catch (error) { @@ -40,7 +42,7 @@ const LandingPage: React.FC = ({ setRepoData }) => { >

Welcome to Devr.AI

-

Enter a GitHub repository URL to analyze its stats.

+

{message}

void; } -const AnalyticsPage: React.FC = ({ repoData }) => { - if (!repoData || !repoData.pull_requests) { - return
No data available. Please analyze a repository first.
; - } +const AnalyticsPage: React.FC = ({ repoData, setRepoData }) => { + if (!repoData) { + return {})} message='Please analyze a repository first to get started.' />; + } + if (!repoData.pull_requests) { + return ( +
+ No data available for pull requests. Please analyze a repository + first. +
+ ); + } const [selectedRange, setSelectedRange] = React.useState('Last Week'); const [activeIndex, setActiveIndex] = React.useState(0); @@ -349,7 +358,7 @@ const AnalyticsPage: React.FC = ({ repoData }) => {
); -} +}; const renderActiveShape = (props: any) => { const { diff --git a/frontend/src/components/pages/PullRequestsPage.tsx b/frontend/src/components/pages/PullRequestsPage.tsx index 1859f501..764cc39a 100644 --- a/frontend/src/components/pages/PullRequestsPage.tsx +++ b/frontend/src/components/pages/PullRequestsPage.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import LandingPage from '../landing/LandingPage'; import { motion } from 'framer-motion'; interface PullRequest { @@ -17,11 +18,15 @@ interface PullRequest { interface Props { repoData: { pull_requests: { details: PullRequest[] } } | null; + setRepoData?: (data: any) => void; } -const PullRequestsPage: React.FC = ({ repoData }) => { - if (!repoData || !repoData.pull_requests) { - return
No data available. Please analyze a repository first.
; +const PullRequestsPage: React.FC = ({ repoData, setRepoData }) => { + if (!repoData) { + return {})} message='Please analyze a repository first to get started.' />; + } + if (!repoData.pull_requests) { + return
No data available for pull requests. Please analyze a repository first.
; } const prs = repoData.pull_requests.details;