Skip to content

Commit

Permalink
Hack to support local results
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Mendoza <[email protected]>
  • Loading branch information
jeffmendoza committed Oct 16, 2024
1 parent fe9a554 commit 9d597e8
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions src/components/ProjectDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,42 @@ import { GITHUB } from "../constants/platforms";

import "../styles/ProjectDetails.css";

import scoredata from '../results.json';


function ProjectDetails() {
const params = useParams();
const { platform, org, repo, commitHash } = params;

Check warning on line 20 in src/components/ProjectDetails.tsx

View workflow job for this annotation

GitHub Actions / check

'commitHash' is assigned a value but never used

const { isLoading, error, data } = useQuery({
queryKey: ["projectData"],
queryFn: async () => {
const response = await fetch(
getScorecardUrl({ platform, org, repo, commitHash }),
);
if (response.status >= 500) {
throw new Error("An error ocurred. Invalid response from server");
}
return response.json();
},
});
// const { isLoading, error, data } = useQuery({
// queryKey: ["projectData"],
// queryFn: async () => {
// // const response = await fetch(
// // getScorecardUrl({ platform, org, repo, commitHash }),
// // );
// // if (response.status >= 500) {
// // throw new Error("An error ocurred. Invalid response from server");
// // }
// // return response.json();
// const result = scoredata.find((obj: any) => obj.repo.name === platform + '/' + org + '/' + repo);
// if(result === undefined) {
// throw new Error("An error ocurred. Repo not found");
// }
// return result;
// },
// });
const data = scoredata.find((obj: any) => obj.repo.name === platform + '/' + org + '/' + repo);
if(data === undefined) {
return <CommonError />;
}

if (isLoading) {
return <Loading />;
}
// if (isLoading) {
// return <Loading />;
// }

if (error) {
return <CommonError />;
}
// if (error) {
// return <CommonError />;
// }

return (
<>
Expand Down

0 comments on commit 9d597e8

Please sign in to comment.