From aa3cafdf6c1a19351eb9dac1d80610efec9cf80c Mon Sep 17 00:00:00 2001 From: Suhani1234-5 Date: Mon, 28 Jul 2025 14:44:49 +0530 Subject: [PATCH] HomeUI --- src/pages/Home/Home.tsx | 534 +++++++++++++++++++++++----------------- 1 file changed, 308 insertions(+), 226 deletions(-) diff --git a/src/pages/Home/Home.tsx b/src/pages/Home/Home.tsx index d01792c..914a69d 100644 --- a/src/pages/Home/Home.tsx +++ b/src/pages/Home/Home.tsx @@ -1,30 +1,4 @@ import React, { useState } from "react"; -import { - Container, - Box, - TextField, - Button, - Paper, - Table, - TableBody, - TableCell, - TableContainer, - TableHead, - TableRow, - TablePagination, - Link, - CircularProgress, - Alert, - Tabs, - Tab, - Select, - MenuItem, - FormControl, - InputLabel, -} from "@mui/material"; -import { useGitHubAuth } from "../../hooks/useGitHubAuth"; -import { useGitHubData } from "../../hooks/useGitHubData"; -import { usePagination } from "../../hooks/usePagination"; const ROWS_PER_PAGE = 10; @@ -39,6 +13,31 @@ interface GitHubItem { html_url: string; } +// Mock hooks for demonstration +const useGitHubAuth = () => ({ + username: "", + setUsername: (val: string) => {}, + token: "", + setToken: (val: string) => {}, + error: null, + getOctokit: () => null, +}); + +const useGitHubData = (octokit: any) => ({ + issues: [] as GitHubItem[], + prs: [] as GitHubItem[], + loading: false, + error: null, + fetchData: (username: string) => {}, +}); + +const usePagination = (rowsPerPage: number) => ({ + page: 0, + itemsPerPage: rowsPerPage, + handleChangePage: (event: unknown, newPage: number) => {}, + paginateData: (data: GitHubItem[]) => data.slice(0, rowsPerPage), +}); + const Home: React.FC = () => { // Hooks for managing user authentication const { @@ -123,6 +122,28 @@ const Home: React.FC = () => { return filteredData; }; + // Get state chip color and icon + const getStateChip = (item: GitHubItem) => { + if (item.pull_request?.merged_at) { + return ( + + Merged + + ); + } + + const isOpen = item.state === 'open'; + return ( + + {item.state.charAt(0).toUpperCase() + item.state.slice(1)} + + ); + }; + // Determine the current tab's data const currentData = tab === 0 ? filterData(issues, issueFilter) : filterData(prs, prFilter); @@ -132,206 +153,267 @@ const Home: React.FC = () => { // Main UI rendering return ( - - {/* Authentication Form */} - -
- - setUsername(e.target.value)} - required - sx={{ flex: 1 }} - /> - setToken(e.target.value)} - type="password" - required - sx={{ flex: 1 }} - /> - - -
-
- - {/* Filters Section */} - - {/* Search Title */} - setSearchTitle(e.target.value)} - sx={{ - flexBasis: { xs: "100%", sm: "100%", md: "48%", lg: "23%" }, - flexGrow: 1, - }} - /> - - {/* Repository */} - setSelectedRepo(e.target.value)} - sx={{ - flexBasis: { xs: "100%", sm: "100%", md: "48%", lg: "23%" }, - flexGrow: 1, - }} - /> - - {/* Start Date */} - setStartDate(e.target.value)} - InputLabelProps={{ shrink: true }} - sx={{ - flexBasis: { xs: "100%", sm: "100%", md: "48%", lg: "23%" }, - flexGrow: 1, - }} - /> - - {/* End Date */} - setEndDate(e.target.value)} - InputLabelProps={{ shrink: true }} - sx={{ - flexBasis: { xs: "100%", sm: "100%", md: "48%", lg: "23%" }, - flexGrow: 1, - }} - /> - - - -{/* Tabs and State Dropdown */} - - setTab(newValue)} - variant="scrollable" - scrollButtons="auto" - sx={{ flexGrow: 1, minWidth: "200px" }} - > - - - - - - State - - - - - -{/* Error Alert */} -{(authError || dataError) && ( - - {authError || dataError} - -)} - -{/* Table Section */} -{loading ? ( - - - -) : ( - - - - - - - Title - Repository - State - Created - - - - {displayData.map((item: GitHubItem) => ( - - - - {item.title} - - - - {item.repository_url.split("/").slice(-1)[0]} - - - {item.pull_request?.merged_at ? "merged" : item.state} - - {formatDate(item.created_at)} - - ))} - -
- -
-
- -
- )} -
+
+
+ {/* Header */} +
+

+ GitHub Dashboard +

+

+ Track your issues and pull requests in style +

+
+ + {/* Authentication Card */} +
+

+ 🔐 GitHub Authentication +

+
+
+ + setUsername(e.target.value)} + className="w-full px-4 py-3 rounded-xl bg-white/20 border border-white/30 text-white placeholder-purple-200 focus:outline-none focus:ring-2 focus:ring-purple-400 focus:border-transparent backdrop-blur-sm transition-all duration-300 hover:bg-white/25" + placeholder="Enter your username" + /> +
+
+ + setToken(e.target.value)} + className="w-full px-4 py-3 rounded-xl bg-white/20 border border-white/30 text-white placeholder-purple-200 focus:outline-none focus:ring-2 focus:ring-purple-400 focus:border-transparent backdrop-blur-sm transition-all duration-300 hover:bg-white/25" + placeholder="Enter your token" + /> +
+ +
+
+ + {/* Filters Card */} +
+

+ 🔍 Filters & Search +

+ +
+
+ + setSearchTitle(e.target.value)} + placeholder="🔍 Search by title..." + className="w-full px-4 py-3 rounded-xl bg-white/20 border border-white/30 text-white placeholder-purple-200 focus:outline-none focus:ring-2 focus:ring-purple-400 focus:border-transparent backdrop-blur-sm transition-all duration-300 hover:bg-white/25" + /> +
+ +
+ + setSelectedRepo(e.target.value)} + className="w-full px-4 py-3 rounded-xl bg-white/20 border border-white/30 text-white placeholder-purple-200 focus:outline-none focus:ring-2 focus:ring-purple-400 focus:border-transparent backdrop-blur-sm transition-all duration-300 hover:bg-white/25" + placeholder="Repository name" + /> +
+ +
+ + setStartDate(e.target.value)} + className="w-full px-4 py-3 rounded-xl bg-white/20 border border-white/30 text-white focus:outline-none focus:ring-2 focus:ring-purple-400 focus:border-transparent backdrop-blur-sm transition-all duration-300 hover:bg-white/25" + /> +
+ +
+ + setEndDate(e.target.value)} + className="w-full px-4 py-3 rounded-xl bg-white/20 border border-white/30 text-white focus:outline-none focus:ring-2 focus:ring-purple-400 focus:border-transparent backdrop-blur-sm transition-all duration-300 hover:bg-white/25" + /> +
+
+ +
+ + {/* Tabs and State Filter */} +
+
+ + +
+ +
+ + +
+
+
+ + {/* Error Alert */} + {(authError || dataError) && ( +
+
+ ⚠️ + {authError || dataError} +
+
+ )} + + {/* Data Table Card */} +
+ {loading ? ( +
+
+

+ Loading your GitHub data... +

+
+ ) : ( +
+
+ + + + + + + + + + + + {displayData.map((item: GitHubItem, index) => ( + + + + + + + + ))} + +
TitleRepositoryStateCreatedActions
+
+ {item.title} +
+
+ + {item.repository_url.split("/").slice(-1)[0]} + + + {getStateChip(item)} + + + {formatDate(item.created_at)} + + + + 🔗 View + +
+ + {/* Pagination */} +
+
+ Showing 1 to {Math.min(itemsPerPage, currentData.length)} of {currentData.length} entries +
+
+ + +
+
+
+
+ )} +
+
+
); }; -export default Home; +export default Home; \ No newline at end of file