Skip to content

Commit 0a24f94

Browse files
committed
Enhance PR section with type badges, state, merged status, and merged date
1 parent 9fa26a8 commit 0a24f94

1 file changed

Lines changed: 55 additions & 1 deletion

File tree

src/pages/Home/Home.tsx

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,34 @@ import {
2525
import { useTheme } from "@mui/material/styles";
2626
import { useGitHubAuth } from "../../hooks/useGitHubAuth";
2727
import { useGitHubData } from "../../hooks/useGitHubData";
28+
// Helper to extract PR type from title
29+
function getPRType(title: string): string {
30+
const lower = title.toLowerCase();
31+
if (lower.includes("feature")) return "Feature";
32+
if (lower.includes("fix")) return "Fix";
33+
if (lower.includes("cleanup") || lower.includes("refactor")) return "Cleanup";
34+
if (lower.includes("docs")) return "Docs";
35+
if (lower.includes("test")) return "Test";
36+
return "Other";
37+
}
38+
39+
// Tailwind class based on PR type
40+
function getBadgeStyle(type: string): string {
41+
switch (type) {
42+
case "Feature":
43+
return "bg-green-100 text-green-800";
44+
case "Fix":
45+
return "bg-red-100 text-red-800";
46+
case "Cleanup":
47+
return "bg-yellow-100 text-yellow-800";
48+
case "Docs":
49+
return "bg-blue-100 text-blue-800";
50+
case "Test":
51+
return "bg-purple-100 text-purple-800";
52+
default:
53+
return "bg-gray-100 text-gray-800";
54+
}
55+
}
2856

2957
const ROWS_PER_PAGE = 10;
3058

@@ -51,7 +79,7 @@ const Home: React.FC = () => {
5179
getOctokit,
5280
} = useGitHubAuth();
5381

54-
//const octokit = getOctokit();
82+
//const octokit = getOctokit();
5583

5684
const {
5785
issues,
@@ -262,9 +290,13 @@ const Home: React.FC = () => {
262290
<TableCell>Title</TableCell>
263291
<TableCell align="center">Repository</TableCell>
264292
<TableCell align="center">State</TableCell>
293+
<TableCell>Type</TableCell>
265294
<TableCell>Created</TableCell>
295+
{tab === 1 && <TableCell align="center">Merged</TableCell>}
296+
{tab === 1 && <TableCell>Merged Date</TableCell>}
266297
</TableRow>
267298
</TableHead>
299+
268300
<TableBody>
269301
{currentFilteredData.map((item) => (
270302
<TableRow key={item.id}>
@@ -285,10 +317,32 @@ const Home: React.FC = () => {
285317
<TableCell align="center">
286318
{item.pull_request?.merged_at ? "merged" : item.state}
287319
</TableCell>
320+
321+
{/* 🆕 PR Type Label */}
322+
<TableCell>
323+
<span className={`px-2 py-1 rounded-full text-xs font-semibold ${getBadgeStyle(getPRType(item.title))}`}>
324+
{getPRType(item.title)}
325+
</span>
326+
</TableCell>
327+
288328
<TableCell>{formatDate(item.created_at)}</TableCell>
329+
330+
{tab === 1 && (
331+
<TableCell align="center">
332+
{item.pull_request?.merged_at ? "Yes" : "No"}
333+
</TableCell>
334+
)}
335+
{tab === 1 && (
336+
<TableCell>
337+
{item.pull_request?.merged_at
338+
? formatDate(item.pull_request.merged_at)
339+
: "-"}
340+
</TableCell>
341+
)}
289342
</TableRow>
290343
))}
291344
</TableBody>
345+
292346
</Table>
293347
<TablePagination
294348
component="div"

0 commit comments

Comments
 (0)