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
77 changes: 74 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
},
"dependencies": {
"react": "^19.2.0",
"react-dom": "^19.2.0"
"react-dom": "^19.2.0",
"react-router-dom": "^7.15.0"
},
"devDependencies": {
"@eslint/js": "^9.39.1",
Expand Down
84 changes: 81 additions & 3 deletions src/App.css
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;
Copy link
Copy Markdown

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 --fix to 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
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/App.css` at line 9, Stylelint is flagging extra empty lines before CSS
declarations in App.css (e.g., the rule containing "display: flex;" and other
declarations at the lines referenced); fix by removing the blank lines that
precede each declaration so declarations immediately follow their selector or
previous property, or run stylelint --fix to auto-correct; update the
selectors/rules that include "display: flex;" and the other noted declarations
so they conform to the project's Stylelint formatting rules.

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;
}
49 changes: 45 additions & 4 deletions src/App.tsx
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Capture and handle the error for better diagnostics.

The catch block ignores the error parameter, losing valuable information about the failure (e.g., network error vs. 404 vs. rate limiting). This makes debugging difficult and provides a generic error message to users regardless of the actual problem.

🔍 Proposed fix
-    } catch {
+    } catch (err) {
       setOrganization(null)
-      setError('Organization not found')
+      setError(
+        err instanceof Error 
+          ? err.message 
+          : 'Failed to fetch organization'
+      )
     } finally {
📝 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
} catch {
setOrganization(null)
setError('Organization not found')
} catch (err) {
setOrganization(null)
setError(
err instanceof Error
? err.message
: 'Failed to fetch organization'
)
} finally {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/App.tsx` around lines 28 - 30, The catch block swallows the thrown error;
update it to accept and use the error parameter (e.g., catch (err)) so you can
log the full error and provide a more informative message via setError and
preserve state with setOrganization(null); specifically, in the block that
currently calls setOrganization(null) and setError('Organization not found'),
change it to capture the error object, call console.error or a logger with err
(or err.message), and setError to include a clearer diagnostic (e.g., include
err.message or a mapped user-facing message) while still calling
setOrganization(null).

} finally {
setLoading(false)
}
}

return (
<>
<h1>Hello, OrgExplorer!</h1>
</>
<div className="app-container">
<h1>OrgExplorer</h1>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/App.tsx` at line 38, Hardcoded user-facing strings in the App component
(the <h1>OrgExplorer</h1>, the "Loading..." text and the error messages shown in
render) must be moved to i18n resource keys and referenced from code; replace
the literal strings in App (the h1 element and wherever loading/error messages
are rendered) with calls to your localization API (e.g.,
useTranslation()/t('...') or a getString('...') helper) using clear keys like
title.orgExplorer, loading.message, and error.fetchFailed, and add those keys
with appropriate values to the locale resource file(s); update any imports
(e.g., import { useTranslation } from 'react-i18next' or your project
equivalent) and ensure the component uses the translation function to render the
strings.


<SearchBar onSearch={handleSearch} />

{loading && <p>Loading...</p>}

{error && <p>{error}</p>}

{organization && (
<OrgCard organization={organization} />
)}
</div>
)
}

export default App
export default App
35 changes: 35 additions & 0 deletions src/components/orgcard.tsx
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add height attribute to prevent layout shift.

The <img> tag has a width but no height attribute, which can cause Cumulative Layout Shift (CLS) as the image loads. As per coding guidelines, code should follow best practices recommended by lighthouse for performance.

🎨 Proposed fix
       <img
         src={organization.avatar_url}
         alt={organization.login}
         width={120}
+        height={120}
       />
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/orgcard.tsx` around lines 10 - 14, The img element rendering
organization.avatar_url is missing a height attribute which can cause layout
shift; update the OrgCard component (the JSX containing <img
src={organization.avatar_url} alt={organization.login} width={120} />) to
include a matching height attribute (or explicit aspect-ratio-preserving
dimensions) so width and height are both set (or computed from known avatar
dimensions) to prevent CLS.


<h2>{organization.login}</h2>

<p>{organization.description}</p>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add null/undefined handling for optional fields.

The description field may be null or undefined for some GitHub organizations, which would render "null" or "undefined" as text. Consider adding conditional rendering or a fallback.

🛡️ Proposed fix
-      <p>{organization.description}</p>
+      <p>{organization.description || 'No description available'}</p>
📝 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
<p>{organization.description}</p>
<p>{organization.description || 'No description available'}</p>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/orgcard.tsx` at line 18, The organization description may be
null/undefined and currently renders literal "null"/"undefined"; update the
OrgCard component in src/components/orgcard.tsx to guard rendering of
organization.description (the organization object and its description property)
and provide a fallback string or omit the element—e.g., conditionally render the
<p> only when organization.description is truthy or render
organization.description ?? 'No description provided'—so the UI never shows
"null" or "undefined".


<p>Followers: {organization.followers}</p>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/orgcard.tsx` at line 20, The hardcoded user-facing labels in
the OrgCard component (e.g., the JSX lines rendering "Followers:", "Public
Repositories:" and "Visit GitHub Profile") must be externalized for i18n;
replace those literal strings in the OrgCard (component/function name: OrgCard
or OrganizationCard where it renders organization.followers,
organization.public_repos and the GitHub link) with lookups to the localization
resource (e.g., import a locale/strings object or use the app's t() translator)
and update the JSX to use those keys (followers, publicRepositories,
visitGitHubProfile), ensuring the organization props remain unchanged.


<p>Public Repositories: {organization.public_repos}</p>

<a
href={organization.html_url}
target="_blank"
rel="noreferrer"
>
Visit GitHub Profile
</a>
</div>
)
}

export default OrgCard
Loading
Loading