Skip to content

Commit cb5e472

Browse files
committed
compatibility: Make files with English text client components
1 parent 6d1d203 commit cb5e472

File tree

2 files changed

+58
-24
lines changed

2 files changed

+58
-24
lines changed

src/app/compatibility/avm.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use client";
2+
13
import classes from "./avm.module.css";
24
import {
35
Button,
@@ -24,7 +26,10 @@ function AvmProgress(props: AvmProgressPropsFull) {
2426
return (
2527
<Group align="center" justify="spread-between" mt={props.mt}>
2628
<Text size="sm" className={classes.progressName}>
27-
{props.name}: {props.done}%
29+
{props.name}:{" "}
30+
{typeof props.done === "number" && props.done > 0
31+
? `${props.done}%`
32+
: "Loading..."}
2833
</Text>
2934
<ProgressRoot size="xl" radius={10} className={classes.progress}>
3035
<ProgressSection
@@ -33,7 +38,7 @@ function AvmProgress(props: AvmProgressPropsFull) {
3338
color="var(--mantine-color-green-9)"
3439
title={`${props.done}% done`}
3540
></ProgressSection>
36-
{props.stubbed && (
41+
{typeof props.stubbed === "number" && props.stubbed > 0 && (
3742
<ProgressSection
3843
striped
3944
value={props.stubbed}

src/app/compatibility/page.tsx

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,67 @@
1+
"use client";
2+
3+
import React, { useEffect, useState } from "react";
14
import { Container, Flex, Group, Stack, Text } from "@mantine/core";
25
import classes from "./compatibility.module.css";
36
import { AvmBlock } from "@/app/compatibility/avm";
47
import Image from "next/image";
5-
import React from "react";
68
import { Title } from "@mantine/core";
79
import { List, ListItem } from "@mantine/core";
810
import { WeeklyContributions } from "@/app/compatibility/weekly_contributions";
911
import {
10-
fetchReport,
1112
getAVM1Progress,
1213
getWeeklyContributions,
1314
} from "@/app/downloads/github";
1415

15-
export default async function Downloads() {
16-
const contributions = await getWeeklyContributions();
17-
const data = contributions.data.map((item) => {
18-
return {
19-
week: new Date(item.week * 1000).toISOString().split("T")[0],
20-
Commits: item.total,
16+
interface DataPoint {
17+
week: string;
18+
Commits: number;
19+
}
20+
21+
export default function Downloads() {
22+
const [data, setData] = useState<DataPoint[]>([]);
23+
const [avm1ApiDone, setAvm1ApiDone] = useState<number>(0);
24+
const [avm2ApiDone, setAvm2ApiDone] = useState<number>(0);
25+
const [avm2ApiStubbed, setAvm2ApiStubbed] = useState<number>(0);
26+
useEffect(() => {
27+
const fetchData = async () => {
28+
try {
29+
// Fetch weekly contributions
30+
const contributionsRes = await getWeeklyContributions();
31+
const contributionsData = contributionsRes.data.map((item) => ({
32+
week: new Date(item.week * 1000).toISOString().split("T")[0],
33+
Commits: item.total,
34+
}));
35+
setData(contributionsData);
36+
37+
// Fetch AVM1 progress
38+
const avm1ApiRes = await getAVM1Progress();
39+
setAvm1ApiDone(avm1ApiRes);
40+
41+
// Fetch report
42+
const reportReq = await fetch("/compatibility/fetch-report");
43+
const reportRes = await reportReq.json();
44+
if (reportRes) {
45+
const { summary } = reportRes;
46+
const maxPoints = summary.max_points;
47+
const implPoints = summary.impl_points;
48+
const stubPenalty = summary.stub_penalty;
49+
50+
const avm2ApiDone = Math.round(
51+
((implPoints - stubPenalty) / maxPoints) * 100,
52+
);
53+
setAvm2ApiDone(avm2ApiDone);
54+
55+
const avm2ApiStubbed = Math.round((stubPenalty / maxPoints) * 100);
56+
setAvm2ApiStubbed(avm2ApiStubbed);
57+
}
58+
} catch (error) {
59+
console.error("Error fetching data", error);
60+
}
2161
};
22-
});
23-
const avm1ApiDone = await getAVM1Progress();
24-
const report = await fetchReport();
25-
if (!report) {
26-
return;
27-
}
28-
const summary = report.summary;
29-
const maxPoints = summary.max_points;
30-
const implPoints = summary.impl_points;
31-
const stubPenalty = summary.stub_penalty;
32-
const avm2ApiDone = Math.round(
33-
((implPoints - stubPenalty) / maxPoints) * 100,
34-
);
35-
const avm2ApiStubbed = Math.round((stubPenalty / maxPoints) * 100);
62+
63+
fetchData();
64+
}, []);
3665

3766
return (
3867
<Container size="xl" className={classes.container}>

0 commit comments

Comments
 (0)