-
-
Notifications
You must be signed in to change notification settings - Fork 43
Add GitHub organization search feature GitHub org search feature #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,84 @@ | ||
| #root { | ||
| max-width: 1280px; | ||
| margin: 0 auto; | ||
| padding: 2rem; | ||
| width: 100%; | ||
| } | ||
|
|
||
| .app-container { | ||
| min-height: 100vh; | ||
| min-height: 100dvh; | ||
|
|
||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
|
|
||
| padding: 40px; | ||
|
|
||
| background-color: #111; | ||
| color: white; | ||
| } | ||
|
|
||
| .app-container h1 { | ||
| margin-bottom: 30px; | ||
| font-size: 3rem; | ||
| } | ||
|
|
||
| form { | ||
| display: flex; | ||
| gap: 12px; | ||
| margin-bottom: 30px; | ||
| } | ||
|
|
||
| input { | ||
| padding: 12px; | ||
| width: 300px; | ||
|
|
||
| border: none; | ||
| border-radius: 10px; | ||
|
|
||
| font-size: 16px; | ||
| } | ||
|
|
||
| button { | ||
| padding: 12px 20px; | ||
|
|
||
| border: none; | ||
| border-radius: 10px; | ||
|
|
||
| cursor: pointer; | ||
|
|
||
| font-size: 16px; | ||
| font-weight: bold; | ||
| } | ||
|
|
||
| .org-card { | ||
| max-width: 500px; | ||
|
|
||
| padding: 30px; | ||
|
|
||
| border-radius: 16px; | ||
|
|
||
| background-color: #1d1d1d; | ||
|
|
||
| text-align: center; | ||
| } | ||
|
|
||
| .org-card img { | ||
| border-radius: 50%; | ||
| margin-bottom: 20px; | ||
| } | ||
|
|
||
| .org-card h2 { | ||
| margin-bottom: 10px; | ||
| } | ||
|
|
||
| .org-card p { | ||
| margin-bottom: 12px; | ||
| } | ||
|
|
||
| .org-card a { | ||
| color: #4ea1ff; | ||
| text-decoration: none; | ||
| } | ||
|
|
||
| .org-card a:hover { | ||
| text-decoration: underline; | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,12 +1,53 @@ | ||||||||||||||||||||||||
| import { useState } from 'react' | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import './App.css' | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import OrgCard from './components/orgcard' | ||||||||||||||||||||||||
| import SearchBar from './components/serachbar' | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import { fetchOrganization } from './services/githubapi' | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import type { GitHubOrg } from './types/github' | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| function App() { | ||||||||||||||||||||||||
| const [organization, setOrganization] = | ||||||||||||||||||||||||
| useState<GitHubOrg | null>(null) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const [loading, setLoading] = useState(false) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const [error, setError] = useState('') | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| async function handleSearch(orgName: string) { | ||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||
| setLoading(true) | ||||||||||||||||||||||||
| setError('') | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const data = await fetchOrganization(orgName) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| setOrganization(data) | ||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||
| setOrganization(null) | ||||||||||||||||||||||||
| setError('Organization not found') | ||||||||||||||||||||||||
|
Comment on lines
+28
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Capture and handle the error for better diagnostics. The 🔍 Proposed fix- } catch {
+ } catch (err) {
setOrganization(null)
- setError('Organization not found')
+ setError(
+ err instanceof Error
+ ? err.message
+ : 'Failed to fetch organization'
+ )
} finally {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| } finally { | ||||||||||||||||||||||||
| setLoading(false) | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||
| <> | ||||||||||||||||||||||||
| <h1>Hello, OrgExplorer!</h1> | ||||||||||||||||||||||||
| </> | ||||||||||||||||||||||||
| <div className="app-container"> | ||||||||||||||||||||||||
| <h1>OrgExplorer</h1> | ||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Externalize user-facing strings for internationalization. The title "OrgExplorer", loading message "Loading...", and error messages are hardcoded. As per coding guidelines, user-visible strings should be externalized to resource files for i18n support. Also applies to: 42-42, 44-44 🤖 Prompt for AI Agents |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| <SearchBar onSearch={handleSearch} /> | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| {loading && <p>Loading...</p>} | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| {error && <p>{error}</p>} | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| {organization && ( | ||||||||||||||||||||||||
| <OrgCard organization={organization} /> | ||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| export default App | ||||||||||||||||||||||||
| export default App | ||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||
| import type { GitHubOrg } from '../types/github' | ||||||
|
|
||||||
| interface OrgCardProps { | ||||||
| organization: GitHubOrg | ||||||
| } | ||||||
|
|
||||||
| function OrgCard({ organization }: OrgCardProps) { | ||||||
| return ( | ||||||
| <div className="org-card"> | ||||||
| <img | ||||||
| src={organization.avatar_url} | ||||||
| alt={organization.login} | ||||||
| width={120} | ||||||
| /> | ||||||
|
Comment on lines
+10
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add height attribute to prevent layout shift. The 🎨 Proposed fix <img
src={organization.avatar_url}
alt={organization.login}
width={120}
+ height={120}
/>🤖 Prompt for AI Agents |
||||||
|
|
||||||
| <h2>{organization.login}</h2> | ||||||
|
|
||||||
| <p>{organization.description}</p> | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add null/undefined handling for optional fields. The 🛡️ Proposed fix- <p>{organization.description}</p>
+ <p>{organization.description || 'No description available'}</p>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| <p>Followers: {organization.followers}</p> | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Externalize user-facing strings for internationalization. Labels like "Followers:", "Public Repositories:", and "Visit GitHub Profile" are hardcoded. As per coding guidelines, user-visible strings should be externalized to resource files for i18n support. Also applies to: 22-22, 29-29 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| <p>Public Repositories: {organization.public_repos}</p> | ||||||
|
|
||||||
| <a | ||||||
| href={organization.html_url} | ||||||
| target="_blank" | ||||||
| rel="noreferrer" | ||||||
| > | ||||||
| Visit GitHub Profile | ||||||
| </a> | ||||||
| </div> | ||||||
| ) | ||||||
| } | ||||||
|
|
||||||
| export default OrgCard | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial | 💤 Low value
Address Stylelint formatting warnings.
Stylelint is flagging empty lines before declarations throughout the file. While these are minor style issues, consider running
stylelint --fixto auto-correct them for consistency with your project's linting rules.Also applies to: 13-13, 15-15, 34-34, 37-37, 43-43, 46-46, 48-48, 55-55, 57-57, 59-59, 61-61
🧰 Tools
🪛 Stylelint (17.11.0)
[error] 9-9: Expected no empty line before declaration (declaration-empty-line-before)
(declaration-empty-line-before)
🤖 Prompt for AI Agents