Skip to content
Closed
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
62 changes: 42 additions & 20 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import SignUpPage from './components/pages/SignUpPage';
import { supabase } from './lib/supabaseClient';
import ForgotPasswordPage from './components/pages/ForgotPasswordPage';
import ResetPasswordPage from './components/pages/ResetPasswordPage';
import { useLocation } from 'react-router-dom';
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Consolidate duplicate import from 'react-router-dom'.

The useLocation import on line 21 creates a second import statement from 'react-router-dom', when it should be added to the existing import on line 2.

🔎 Proposed fix
-import { BrowserRouter as Router, Routes, Route, Navigate, Outlet } from 'react-router-dom';
+import { BrowserRouter as Router, Routes, Route, Navigate, Outlet, useLocation } from 'react-router-dom';

Remove line 21:

-import { useLocation } from 'react-router-dom';
-
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { useLocation } from 'react-router-dom';
import { BrowserRouter as Router, Routes, Route, Navigate, Outlet, useLocation } from 'react-router-dom';
🤖 Prompt for AI Agents
In frontend/src/App.tsx around line 21, there's a duplicate import from
'react-router-dom' for useLocation; remove the separate import on line 21 and
add useLocation to the existing import declaration at the top of the file (line
2) so all react-router-dom imports are consolidated into a single import
statement.



// Define proper TypeScript interfaces
interface RepositoryData {
Expand Down Expand Up @@ -101,26 +103,46 @@ function App() {
setRepoData(null);
};

const ProtectedLayout = () => (
<div className="flex">
<Sidebar
isOpen={isSidebarOpen}
setIsOpen={setIsSidebarOpen}
onLogout={handleLogout}
/>
<main
className={`transition-all duration-300 flex-1 ${
isSidebarOpen ? 'ml-64' : 'ml-20'
}`}
>
<div className="p-8">
<AnimatePresence mode="wait">
<Outlet />
</AnimatePresence>
</div>
</main>
</div>
);
const ProtectedLayout = () => {
const location = useLocation();

const landingAllowedRoutes = [
'/dashboard',
'/contributors',
'/analytics',
'/prs',
];

const shouldShowLanding =
!repoData && landingAllowedRoutes.includes(location.pathname);

return (
<div className="flex">
<Sidebar
isOpen={isSidebarOpen}
setIsOpen={setIsSidebarOpen}
onLogout={handleLogout}
/>

<main
className={`transition-all duration-300 flex-1 ${isSidebarOpen ? 'ml-64' : 'ml-20'
}`}
>
<div className="p-8">
{/* Conditional Landing Page */}
{shouldShowLanding && (
<LandingPage setRepoData={setRepoData} />
)}

<AnimatePresence mode="wait">
<Outlet />
</AnimatePresence>
</div>
</main>
</div>
);
};


return (
<Router>
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/contributors/ContributorsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const ContributorsPage: React.FC<Props> = ({ repoData }) => {
};

if (!repoData) {
return <div>No data available. Please analyze a repository first.</div>;
return <div >No data available. Please analyze a repository first.</div>;
}

if (loading) {
Expand All @@ -50,15 +50,15 @@ const ContributorsPage: React.FC<Props> = ({ repoData }) => {
<p className="text-gray-400 mt-2">Manage and track contributor activity</p>
</div>
<div className="flex space-x-4">
<motion.button
<motion.button
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
onClick={handleExportReport}
className="px-4 py-2 bg-gray-800 hover:bg-gray-700 rounded-lg transition-colors"
>
Export Report
</motion.button>
<motion.button
<motion.button
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
onClick={handleInviteContributor}
Expand All @@ -72,7 +72,7 @@ const ContributorsPage: React.FC<Props> = ({ repoData }) => {
{/* Contributors Grid */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{contributors.map((contributor) => (
<ContributorCard
<ContributorCard
key={contributor.login}
name={contributor.login}
avatar={contributor.avatar_url}
Expand Down
16 changes: 8 additions & 8 deletions frontend/src/components/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Dashboard: React.FC<Props> = ({ repoData }) => {
>
<div className="flex items-center justify-between mb-8">
<h1 className="text-3xl font-bold">Dashboard Overview</h1>
<motion.button
<motion.button
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
onClick={handleNewIntegration}
Expand All @@ -38,25 +38,25 @@ const Dashboard: React.FC<Props> = ({ repoData }) => {

{/* Stats Section */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
<StatCard
<StatCard
icon={<Users size={24} />}
title="Active Contributors"
value={repoData.contributors?.length || 0}
trend={12}
/>
<StatCard
<StatCard
icon={<GitPullRequest size={24} />}
title="Open PRs"
value={repoData.pull_requests?.open || 0}
trend={repoData.pull_requests?.open || 0}
/>
<StatCard
<StatCard
icon={<MessageSquare size={24} />}
title="Community Posts"
value="892" // Placeholder, replace with dynamic if available
trend={8}
/>
<StatCard
<StatCard
icon={<Activity size={24} />}
title="Response Rate"
value="94%" // Placeholder, replace with dynamic if available
Expand All @@ -67,21 +67,21 @@ const Dashboard: React.FC<Props> = ({ repoData }) => {
{/* Quick Actions */}
<h2 className="text-2xl font-bold mb-6">Quick Actions</h2>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<BotIntegration
<BotIntegration
platform="GitHub"
icon={<Github size={24} />}
connected={true}
description="Automate your GitHub workflow"
features={['Issue triage', 'PR reviews', 'Welcome messages']}
/>
<BotIntegration
<BotIntegration
platform="Discord"
icon={<MessageSquare size={24} />}
connected={false}
description="Engage with your community"
features={['Support channels', 'Role management', 'Event notifications']}
/>
<BotIntegration
<BotIntegration
platform="Slack"
icon={<Slack size={24} />}
connected={true}
Expand Down