diff --git a/README.md b/README.md index 7cb9cea..8c27c4e 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ - **Fully Browser-Based** — Runs entirely in the browser using GitHub APIs with no backend server required. - **Organization Overview Dashboard** — Explore repositories, contributors, activity trends, tech stack distribution, and organization growth insights. +- **Smart Organization Search with Autocomplete** — GitHub org suggestions with real-time dropdown search - **Advanced Repository Analytics** — Analyze repository activity, contributor density, issue and PR trends, health metrics, and lifecycle status. diff --git a/src/pages/HomePage.jsx b/src/pages/HomePage.jsx index cffcbd3..208127a 100644 --- a/src/pages/HomePage.jsx +++ b/src/pages/HomePage.jsx @@ -1,142 +1,205 @@ -import React, { useState } from 'react' -import { useNavigate } from 'react-router-dom' -import { FiSearch, FiX } from 'react-icons/fi' -import { useApp } from '../context/AppContext' -import { C, Spinner } from '../components/UI' + import React, { useState,useEffect } from 'react' + import { useNavigate } from 'react-router-dom' + import { FiSearch, FiX } from 'react-icons/fi' + import { useApp } from '../context/AppContext' + import { C, Spinner } from '../components/UI' + import { searchOrgs } from '../services/github' -const QUICK = ['AOSSIE-Org', 'DjedAlliance', 'StabilityNexus'] + const QUICK = ['AOSSIE-Org', 'DjedAlliance', 'StabilityNexus'] -export default function HomePage() { - const { explore, loading, loadMsg, error } = useApp() - const navigate = useNavigate() - const [input, setInput] = useState('') - const [chips, setChips] = useState([]) + export default function HomePage() { + const { explore, loading, loadMsg, error } = useApp() + const navigate = useNavigate() + const [input, setInput] = useState('') + const [chips, setChips] = useState([]) + const[suggestions, setSuggestions] = useState([]) + const[showSuggestion, setShowSuggestions] = useState(false) - const recent = JSON.parse(localStorage.getItem('oe_recent') || '[]') + useEffect(() => { + if (!input.trim()) { + setSuggestions([]) + return + } + const t = setTimeout(async () => { + const result = await searchOrgs(input.trim()) + setSuggestions(result.slice(0,6)) + setShowSuggestions(true) + }, 300) + return () => clearTimeout(t) + }, [input]) - const addChip = raw => { - const parts = raw.split(/[,+\s]+/).map(s => s.trim()).filter(Boolean) - setChips(prev => [...new Set([...prev, ...parts])]) - setInput('') - } + const selectSuggestion = (login) => { + setChips(prev => [...new Set([...prev,login])]) + setInput('') + setSuggestion([]) + setShowSuggestions(false) + } - const removeChip = c => setChips(prev => prev.filter(x => x !== c)) + const recent = JSON.parse(localStorage.getItem('oe_recent') || '[]') - const handleKey = e => { - if ((e.key === 'Enter' || e.key === ',') && input.trim()) { - e.preventDefault() - addChip(input) - } - if (e.key === 'Backspace' && !input && chips.length) { - setChips(prev => prev.slice(0, -1)) + const addChip = raw => { + const parts = raw.split(/[,+\s]+/).map(s => s.trim()).filter(Boolean) + setChips(prev => [...new Set([...prev, ...parts])]) + setInput('') } - } - const go = async (targets) => { - const orgs = targets || (chips.length ? chips : input.trim() ? [input.trim()] : []) - if (!orgs.length) return - const success = await explore(orgs) - if(success) navigate('/overview') - } + const removeChip = c => setChips(prev => prev.filter(x => x !== c)) - return ( -
- Unified analytics across one or many GitHub organizations. Multi-org portfolio analysis, contributor network graphs, time-series trends, and governance audits — entirely in the browser. -
-- Type an org name and press Enter or comma to add. Add multiple orgs to analyze as a unified portfolio. -
- {error &&{error}
} -{loadMsg}
+ return ( ++ Unified analytics across one or many GitHub organizations. Multi-org portfolio analysis, contributor network graphs, time-series trends, and governance audits — entirely in the browser. +
+ Type an org name and press Enter or comma to add. Add multiple orgs to analyze as a unified portfolio. +
+ {error &&{error}
} + {showSuggestion && suggestions.length > 0 && ( +{loadMsg}