Skip to content

Commit b912c28

Browse files
committed
compatibility/avm2: Make files with English text client components
1 parent 48ac4e1 commit b912c28

File tree

5 files changed

+107
-63
lines changed

5 files changed

+107
-63
lines changed

src/app/compatibility/avm2/class_box.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import classes from "./avm2.module.css";
1414
import React from "react";
1515
import {
1616
ClassStatus,
17-
ProgressIcon,
1817
displayedPercentage,
1918
} from "@/app/compatibility/avm2/report_utils";
19+
import { ProgressIcon } from "@/app/compatibility/avm2/icons";
2020

2121
export function ClassBox(props: ClassStatus) {
2222
const [opened, { toggle }] = useDisclosure(false);

src/app/compatibility/avm2/icons.tsx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"use client";
2+
3+
import { rem, ThemeIcon } from "@mantine/core";
4+
import { IconCheck, IconProgress, IconX } from "@tabler/icons-react";
5+
6+
export function IconDone() {
7+
return (
8+
<ThemeIcon
9+
size={20}
10+
radius="xl"
11+
color="var(--mantine-color-green-9)"
12+
title="Done"
13+
>
14+
<IconCheck
15+
color="white"
16+
style={{ width: rem(12), height: rem(12) }}
17+
stroke={4}
18+
/>
19+
</ThemeIcon>
20+
);
21+
}
22+
23+
export function IconStub() {
24+
return (
25+
<ThemeIcon size={20} radius="xl" title="Partial">
26+
<IconProgress
27+
color="#3c1518"
28+
style={{ width: rem(12), height: rem(12) }}
29+
stroke={4}
30+
/>
31+
</ThemeIcon>
32+
);
33+
}
34+
35+
export function IconMissing() {
36+
return (
37+
<ThemeIcon size={20} radius="xl" color="#3c1518" title="Missing">
38+
<IconX
39+
color="white"
40+
style={{ width: rem(12), height: rem(12) }}
41+
stroke={4}
42+
/>
43+
</ThemeIcon>
44+
);
45+
}
46+
47+
export function ProgressIcon(type: "stub" | "missing" | "done") {
48+
switch (type) {
49+
case "stub":
50+
return <IconStub />;
51+
case "missing":
52+
return <IconMissing />;
53+
case "done":
54+
return <IconDone />;
55+
}
56+
}

src/app/compatibility/avm2/page.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use client";
2+
13
import {
24
Container,
35
Group,
@@ -8,16 +10,18 @@ import {
810
Title,
911
} from "@mantine/core";
1012
import Image from "next/image";
11-
import React from "react";
13+
import React, { useEffect, useState } from "react";
1214
import classes from "./avm2.module.css";
1315
import { ClassBox } from "@/app/compatibility/avm2/class_box";
1416
import {
1517
getReportByNamespace,
18+
NamespaceStatus,
19+
} from "@/app/compatibility/avm2/report_utils";
20+
import {
1621
IconDone,
1722
IconMissing,
1823
IconStub,
19-
NamespaceStatus,
20-
} from "@/app/compatibility/avm2/report_utils";
24+
} from "@/app/compatibility/avm2/icons";
2125
import Link from "next/link";
2226

2327
function NamespaceBox(props: NamespaceStatus) {
@@ -33,8 +37,21 @@ function NamespaceBox(props: NamespaceStatus) {
3337
);
3438
}
3539

36-
export default async function Page() {
37-
const byNamespace = await getReportByNamespace();
40+
export default function Page() {
41+
const [byNamespace, setByNamespace] = useState<
42+
{ [name: string]: NamespaceStatus } | undefined
43+
>(undefined);
44+
useEffect(() => {
45+
const fetchData = async () => {
46+
try {
47+
const byNamespace = await getReportByNamespace();
48+
setByNamespace(byNamespace);
49+
} catch (error) {
50+
console.error("Error fetching data", error);
51+
}
52+
};
53+
fetchData();
54+
}, []);
3855
return (
3956
<Container size="xl">
4057
<Stack gap="xl">

src/app/compatibility/avm2/report_utils.tsx

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,4 @@
1-
import { rem, ThemeIcon } from "@mantine/core";
2-
import { IconCheck, IconProgress, IconX } from "@tabler/icons-react";
3-
import { fetchReport } from "@/app/downloads/github";
4-
import React from "react";
5-
6-
export function IconDone() {
7-
return (
8-
<ThemeIcon
9-
size={20}
10-
radius="xl"
11-
color="var(--mantine-color-green-9)"
12-
title="Done"
13-
>
14-
<IconCheck
15-
color="white"
16-
style={{ width: rem(12), height: rem(12) }}
17-
stroke={4}
18-
/>
19-
</ThemeIcon>
20-
);
21-
}
22-
23-
export function IconStub() {
24-
return (
25-
<ThemeIcon size={20} radius="xl" title="Partial">
26-
<IconProgress
27-
color="#3c1518"
28-
style={{ width: rem(12), height: rem(12) }}
29-
stroke={4}
30-
/>
31-
</ThemeIcon>
32-
);
33-
}
34-
35-
export function IconMissing() {
36-
return (
37-
<ThemeIcon size={20} radius="xl" color="#3c1518" title="Missing">
38-
<IconX
39-
color="white"
40-
style={{ width: rem(12), height: rem(12) }}
41-
stroke={4}
42-
/>
43-
</ThemeIcon>
44-
);
45-
}
46-
47-
export function ProgressIcon(type: "stub" | "missing" | "done") {
48-
switch (type) {
49-
case "stub":
50-
return <IconStub />;
51-
case "missing":
52-
return <IconMissing />;
53-
case "done":
54-
return <IconDone />;
55-
}
56-
}
1+
import type { AVM2Report } from "@/app/downloads/config";
572

583
export interface SummaryStatistics {
594
max_points: number;
@@ -82,7 +27,8 @@ export async function getReportByNamespace(): Promise<
8227
{ [name: string]: NamespaceStatus } | undefined
8328
> {
8429
let byNamespace: { [name: string]: NamespaceStatus } = {};
85-
const report = await fetchReport();
30+
const reportReq = await fetch("/compatibility/fetch-report");
31+
const report: AVM2Report = await reportReq.json();
8632
if (!report) {
8733
return;
8834
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { NextResponse } from "next/server";
2+
import { fetchReport } from "@/app/downloads/github";
3+
import { AVM2Report } from "@/app/downloads/config";
4+
5+
let cachedReport: AVM2Report | undefined;
6+
7+
export async function GET() {
8+
if (cachedReport) {
9+
return NextResponse.json(cachedReport); // Return cached result
10+
}
11+
12+
try {
13+
const report = await fetchReport();
14+
cachedReport = report; // Cache the result
15+
return NextResponse.json(report);
16+
} catch (error) {
17+
console.error("Error fetching report:", error);
18+
return NextResponse.json(
19+
{ error: "Failed to fetch report" },
20+
{ status: 500 },
21+
);
22+
}
23+
}
24+
25+
export const dynamic = "force-static";

0 commit comments

Comments
 (0)