Skip to content

Commit 9d597e8

Browse files
committed
Hack to support local results
Signed-off-by: Jeff Mendoza <[email protected]>
1 parent fe9a554 commit 9d597e8

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

src/components/ProjectDetails.tsx

+30-18
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,42 @@ import { GITHUB } from "../constants/platforms";
1212

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

15+
import scoredata from '../results.json';
16+
17+
1518
function ProjectDetails() {
1619
const params = useParams();
1720
const { platform, org, repo, commitHash } = params;
1821

19-
const { isLoading, error, data } = useQuery({
20-
queryKey: ["projectData"],
21-
queryFn: async () => {
22-
const response = await fetch(
23-
getScorecardUrl({ platform, org, repo, commitHash }),
24-
);
25-
if (response.status >= 500) {
26-
throw new Error("An error ocurred. Invalid response from server");
27-
}
28-
return response.json();
29-
},
30-
});
22+
// const { isLoading, error, data } = useQuery({
23+
// queryKey: ["projectData"],
24+
// queryFn: async () => {
25+
// // const response = await fetch(
26+
// // getScorecardUrl({ platform, org, repo, commitHash }),
27+
// // );
28+
// // if (response.status >= 500) {
29+
// // throw new Error("An error ocurred. Invalid response from server");
30+
// // }
31+
// // return response.json();
32+
// const result = scoredata.find((obj: any) => obj.repo.name === platform + '/' + org + '/' + repo);
33+
// if(result === undefined) {
34+
// throw new Error("An error ocurred. Repo not found");
35+
// }
36+
// return result;
37+
// },
38+
// });
39+
const data = scoredata.find((obj: any) => obj.repo.name === platform + '/' + org + '/' + repo);
40+
if(data === undefined) {
41+
return <CommonError />;
42+
}
3143

32-
if (isLoading) {
33-
return <Loading />;
34-
}
44+
// if (isLoading) {
45+
// return <Loading />;
46+
// }
3547

36-
if (error) {
37-
return <CommonError />;
38-
}
48+
// if (error) {
49+
// return <CommonError />;
50+
// }
3951

4052
return (
4153
<>

0 commit comments

Comments
 (0)