Skip to content

Commit

Permalink
Enhance Civic Issue Finder with new features and refactoring
Browse files Browse the repository at this point in the history
- Updated ESLint configuration to relax TypeScript rules for better development experience.
- Refactored `Home` component into `HomeContent` and `HomePage` for improved structure and added suspense loading.
- Removed unused imports and components, including the deleted `EmbedPage`.
- Updated `AboutPage` to fix typographical errors and improve content clarity.
- Introduced `ProjectCard` component for displaying project details with a dialog interface.
- Enhanced API error handling in `issues` route and added logging for better debugging.
- Refactored `problems` route by removing unused interfaces to streamline code.
- Updated import paths for consistency and clarity across components.
  • Loading branch information
aliirz committed Dec 14, 2024
1 parent 5363c94 commit cae0748
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 55 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": ["next/core-web-vitals", "next/typescript"]
"extends": ["next/core-web-vitals", "next/typescript"],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off"
}
}
8 changes: 4 additions & 4 deletions app/about/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button } from "@/components/ui/button"
import { Card, CardContent } from "@/components/ui/card"
import { Github, Heart } from "lucide-react"
import { Github } from "lucide-react"
import Link from "next/link"

export default function AboutPage() {
Expand All @@ -18,7 +18,7 @@ export default function AboutPage() {
<p className="leading-7">
The Civic Issue Finder helps connect developers, designers, and civic innovators
with open source projects that make a difference in communities. Inspired by
Code for America's original civic issue finder, this tool aggregates GitHub issues
Code for America&apos;s original civic issue finder, this tool aggregates GitHub issues
from civic tech projects to help you find ways to contribute.
</p>

Expand Down Expand Up @@ -46,7 +46,7 @@ export default function AboutPage() {
</p>
<ol className="list-decimal pl-6 space-y-2">
<li>Read the issue description and project guidelines</li>
<li>Join the project's community (Discord, Slack, or discussions)</li>
<li>Join the project&apos;s community (Discord, Slack, or discussions)</li>
<li>Comment on the issue to express your interest</li>
<li>Fork the repository and start contributing!</li>
</ol>
Expand Down Expand Up @@ -91,7 +91,7 @@ export default function AboutPage() {

<div className="text-center text-muted-foreground">
<p className="flex items-center justify-center gap-2">
Inspired from(now deprecated) Code for America's original Civic Issue Finder
Inspired from (now deprecated) Code for America&apos;s original Civic Issue Finder
</p>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions app/api/issues/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export async function GET(request: Request) {
const data = await fetchGitHubIssues(page, per_page, language);
return NextResponse.json(data);
} catch (error) {
console.error(error);
return NextResponse.json(
{ error: 'Failed to fetch issues' },
{ status: 500 }
Expand Down
24 changes: 0 additions & 24 deletions app/api/problems/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,7 @@ const base = new Airtable({
endpointUrl: 'https://api.airtable.com',
}).base(process.env.AIRTABLE_BASE_ID!);

interface AirtableRecord {
id: string;
fields: {
Department?: string;
'Problem Statement'?: string;
Status?: string;
Year?: number;
'Github URL'?: string;
'Deployment URL'?: string;
Type?: string;
Published?: boolean;
};
}

interface Project {
id: string;
department: string;
problemStatement: string;
status: string;
year: number;
githubUrl?: string;
deploymentUrl?: string;
type: string;
isPublished: boolean;
}

export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
Expand Down
14 changes: 0 additions & 14 deletions app/embed/page.tsx

This file was deleted.

35 changes: 24 additions & 11 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
"use client"
import { Suspense } from 'react'
import { IssueCard } from "@/components/IssueCard"
import { Button } from "@/components/ui/button"
import { Skeleton } from "@/components/ui/skeleton"
import { ChevronLeft, ChevronRight, Loader2 } from "lucide-react"
import { useEffect, useState } from "react"
import { useSearchParams, useRouter } from 'next/navigation'
import type { GitHubIssue } from "@/lib/github"
import { LanguageFilter } from "@/components/LanguageFilter"
import { Card, CardHeader, CardContent, CardFooter } from "@/components/ui/card"

interface IssuesResponse {
items: GitHubIssue[];
total_count: number;
}

// Move this to a separate client component
function IssueCardSkeleton() {
return (
<Card className="flex flex-col h-full">
Expand Down Expand Up @@ -42,7 +34,19 @@ function IssueCardSkeleton() {
)
}

export default function Home() {
// Client component with all the hooks
import { useSearchParams, useRouter } from 'next/navigation'
import { useEffect, useState } from "react"
import { ChevronLeft, ChevronRight, Loader2 } from "lucide-react"
import type { GitHubIssue } from "@/lib/github"
import { LanguageFilter } from "@/components/LanguageFilter"

interface IssuesResponse {
items: GitHubIssue[];
total_count: number;
}

function HomeContent() {
const [issues, setIssues] = useState<IssuesResponse>({ items: [], total_count: 0 });
const [isLoading, setIsLoading] = useState(true);
const searchParams = useSearchParams();
Expand Down Expand Up @@ -142,3 +146,12 @@ export default function Home() {
</div>
);
}

// Server component
export default function HomePage() {
return (
<Suspense fallback={<div>Loading...</div>}>
<HomeContent />
</Suspense>
)
}
2 changes: 1 addition & 1 deletion app/problems/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use client"
import { ProjectCard } from "@/components/ProblemCard"
import { ProjectCard } from "@/components/ProjectCard"
import { Skeleton } from "@/components/ui/skeleton"
import { AlertCircle, Loader2 } from "lucide-react"
import { useEffect, useState } from "react"
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions lib/rate-limit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const ratelimit = new LRUCache({
})

export async function rateLimit(request: Request) {
console.log(request.headers)
const ip = headers().get('x-forwarded-for') ?? 'anonymous'
const tokenCount = ratelimit.get(ip) as number || 0

Expand Down

0 comments on commit cae0748

Please sign in to comment.