Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hack to support local results #453

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 30 additions & 18 deletions src/components/ProjectDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,53 @@
import { useParams } from "react-router-dom";
import { useQuery } from "@tanstack/react-query";

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

View workflow job for this annotation

GitHub Actions / check

'useQuery' is defined but never used

import { getScorecardUrl } from "../utils/getScorecardUrl";

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

View workflow job for this annotation

GitHub Actions / check

'getScorecardUrl' is defined but never used
import { formatDate } from "../utils/formatDate";
import CommonError from "./CommonError";
import Collapsible from "./Collapsable";
import Loading from "./Loading";

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

View workflow job for this annotation

GitHub Actions / check

'Loading' is defined but never used
import NoAvailableDataMark from "./NoAvailableDataMark";
import { ScoreElement } from "../types";
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
Loading