File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616 "@emotion/styled" : " ^11.11.0" ,
1717 "@mui/icons-material" : " ^5.15.6" ,
1818 "@mui/material" : " ^5.15.6" ,
19- "@primer/octicons-react" : " ^19.15.5 " ,
19+ "@primer/octicons-react" : " ^19.25.0 " ,
2020 "@vitejs/plugin-react" : " ^4.3.3" ,
2121 "axios" : " ^1.7.7" ,
2222 "framer-motion" : " ^12.23.12" ,
Original file line number Diff line number Diff line change @@ -7,8 +7,11 @@ export const useGitHubAuth = () => {
77 const [ error , setError ] = useState ( '' ) ;
88
99 const octokit = useMemo ( ( ) => {
10- if ( ! username || ! token ) return null ;
10+ if ( ! username ) return null ;
11+ if ( token ) {
1112 return new Octokit ( { auth : token } ) ;
13+ }
14+ return new Octokit ( ) ;
1215 } , [ username , token ] ) ;
1316
1417 const getOctokit = ( ) => octokit ;
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ export const useGitHubData = (getOctokit: () => any) => {
3030
3131 const octokit = getOctokit ( ) ;
3232
33- if ( ! octokit || ! username || rateLimited ) return ;
33+ if ( ! octokit || ! username ) return ;
3434
3535 setLoading ( true ) ;
3636 setError ( '' ) ;
@@ -45,18 +45,27 @@ export const useGitHubData = (getOctokit: () => any) => {
4545 setPrs ( prRes . items ) ;
4646 setTotalIssues ( issueRes . total ) ;
4747 setTotalPrs ( prRes . total ) ;
48+ setRateLimited ( false ) ;
4849 } catch ( err : any ) {
50+ const errorMessage = err . message ?. toLowerCase ( ) || "" ;
4951 if ( err . status === 403 ) {
50- setError ( 'GitHub API rate limit exceeded. Please wait or use a token.' ) ;
51- setRateLimited ( true ) ; // Prevent further fetches
52- } else {
52+ setError ( 'GitHub API rate limit exceeded. Please provide a PAT to continue.' ) ;
53+ setRateLimited ( true ) ;
54+ } else if ( errorMessage . includes ( "do not exist" ) ) {
55+ setError ( 'User not found. Please check the spelling of the GitHub username.' ) ;
56+ } else if ( err . status === 401 || errorMessage . includes ( "permission" ) ) {
57+ setError ( 'Private repository detected. Please input PAT.' ) ;
58+ } else if ( err . status === 404 ) {
59+ setError ( 'Resource not found.' ) ;
60+ }
61+ else {
5362 setError ( err . message || 'Failed to fetch data' ) ;
5463 }
5564 } finally {
5665 setLoading ( false ) ;
5766 }
5867 } ,
59- [ getOctokit , rateLimited ]
68+ [ getOctokit ]
6069 ) ;
6170
6271 return {
Original file line number Diff line number Diff line change @@ -180,7 +180,6 @@ const Home: React.FC = () => {
180180 value = { token }
181181 onChange = { ( e ) => setToken ( e . target . value ) }
182182 type = "password"
183- required
184183 sx = { { flex : 1 , minWidth : 150 } }
185184 />
186185 < Button type = "submit" variant = "contained" sx = { { minWidth : "120px" } } >
You can’t perform that action at this time.
0 commit comments