diff --git a/components.json b/components.json index 8ecaf9e..1e27100 100644 --- a/components.json +++ b/components.json @@ -11,7 +11,7 @@ "prefix": "" }, "aliases": { - "components": "@/components", - "utils": "@/lib/utils" + "components": "@/app/components", + "utils": "@/common/utils" } } diff --git a/package.json b/package.json index 6bc093e..d722dea 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "class-variance-authority": "^0.7.0", "clsx": "^2.1.0", "lucide-react": "^0.368.0", - "mcutils-library": "^1.1.1", + "mcutils-library": "^1.1.3", "next": "14.2.1", "next-themes": "^0.3.0", "react": "^18", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 24e7b94..2aa7acc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -21,8 +21,8 @@ dependencies: specifier: ^0.368.0 version: 0.368.0(react@18.2.0) mcutils-library: - specifier: ^1.1.1 - version: 1.1.1(@babel/core@7.24.4)(@types/node@20.12.7) + specifier: ^1.1.3 + version: 1.1.3(@babel/core@7.24.4)(@types/node@20.12.7) next: specifier: 14.2.1 version: 14.2.1(@babel/core@7.24.4)(react-dom@18.2.0)(react@18.2.0) @@ -3516,8 +3516,8 @@ packages: tmpl: 1.0.5 dev: false - /mcutils-library@1.1.1(@babel/core@7.24.4)(@types/node@20.12.7): - resolution: {integrity: sha512-OxZfC5KbqIYWcWJK+bikaCD9peCM3acgFP0e3OLLb+STU2czyaLMIt2sQ3yrqoS81emfKpaScQ5qK4nSTBGI1Q==} + /mcutils-library@1.1.3(@babel/core@7.24.4)(@types/node@20.12.7): + resolution: {integrity: sha512-LqTV8dbzShhJBD6xdZCg8S1TK0JZT3PcwwIaOZMgYVAt6bzGX3vf9lVI1JTreIhha9KQgKXTwnXxVuiLsFyueA==} dependencies: axios: 1.6.8 jest: 29.7.0(@types/node@20.12.7)(ts-node@10.9.2) diff --git a/src/app/(pages)/mojang/page.tsx b/src/app/(pages)/mojang/page.tsx new file mode 100644 index 0000000..874d3fa --- /dev/null +++ b/src/app/(pages)/mojang/page.tsx @@ -0,0 +1,72 @@ +import { Card } from "@/app/components/card"; +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/app/components/ui/table"; +import { cn } from "@/common/utils"; +import { getMojangEndpointStatus } from "mcutils-library"; +import { CachedEndpointStatus } from "mcutils-library/dist/types/cache/cachedEndpointStatus"; +import Link from "next/link"; + +async function getData(): Promise { + const status = await getMojangEndpointStatus(); + return status; +} + +/** + * Gets the color of the status + * + * @param status the status of the endpoint + * @returns the color of the status + */ +function getColor(status: any): string { + switch (status) { + case "ONLINE": + return "text-green-500"; + case "DEGRADED": + return "text-yellow-500"; + case "OFFLINE": + return "text-red-500"; + default: + return "text-gray-500"; + } +} + +export default async function Page(): Promise { + const { endpoints } = await getData(); + const endpointsSize = Object.entries(endpoints).length; + + return ( +
+ +

Mojang Status

+

The current status of Mojang Services

+ +
+ {endpointsSize === 0 &&

Unable to fetch endpoint statuses

} + {endpointsSize > 0 && ( + + + + Service + Status + + + + {Object.entries(endpoints).map(([url, status]) => { + return ( + + + + {url} + + + {status} + + ); + })} + +
+ )} +
+
+
+ ); +} diff --git a/src/app/(pages)/player/[id]/page.tsx b/src/app/(pages)/player/[id]/page.tsx index 7742350..e90d40d 100644 --- a/src/app/(pages)/player/[id]/page.tsx +++ b/src/app/(pages)/player/[id]/page.tsx @@ -54,7 +54,7 @@ export default async function Page({ params }: Params): Promise { - + {player == null && } {player != null && (
diff --git a/src/app/(pages)/server/[platform]/[hostname]/page.tsx b/src/app/(pages)/server/[platform]/[hostname]/page.tsx index ebc9bb5..d4e6320 100644 --- a/src/app/(pages)/server/[platform]/[hostname]/page.tsx +++ b/src/app/(pages)/server/[platform]/[hostname]/page.tsx @@ -75,7 +75,7 @@ export default async function Page({ params: { platform, hostname } }: Params):
- + {server == null && } {server != null && (
diff --git a/src/app/components/card.tsx b/src/app/components/card.tsx index a33f845..096796a 100644 --- a/src/app/components/card.tsx +++ b/src/app/components/card.tsx @@ -1,7 +1,11 @@ +import { cn } from "@/common/utils"; + export function Card({ children, + className, }: Readonly<{ children: React.ReactNode; + className?: string; }>): JSX.Element { - return
{children}
; + return
{children}
; } diff --git a/src/app/components/navbar.tsx b/src/app/components/navbar.tsx index 2d47a64..e0c3fe9 100644 --- a/src/app/components/navbar.tsx +++ b/src/app/components/navbar.tsx @@ -11,6 +11,7 @@ type Page = { const pages: Page[] = [ { title: "Player", url: "/player/Notch" }, { title: "Server", url: "/server/java/hypixel.net" }, + { title: "Mojang", url: "/mojang" }, ]; export default function NavBar(): JSX.Element { @@ -27,7 +28,7 @@ export default function NavBar(): JSX.Element {
-
+
>( + ({ className, ...props }, ref) => ( +
+ + + ) +); +Table.displayName = "Table"; + +const TableHeader = React.forwardRef>( + ({ className, ...props }, ref) => +); +TableHeader.displayName = "TableHeader"; + +const TableBody = React.forwardRef>( + ({ className, ...props }, ref) => ( + + ) +); +TableBody.displayName = "TableBody"; + +const TableFooter = React.forwardRef>( + ({ className, ...props }, ref) => ( + tr]:last:border-b-0", className)} {...props} /> + ) +); +TableFooter.displayName = "TableFooter"; + +const TableRow = React.forwardRef>( + ({ className, ...props }, ref) => ( + + ) +); +TableRow.displayName = "TableRow"; + +const TableHead = React.forwardRef>( + ({ className, ...props }, ref) => ( +
+ ) +); +TableHead.displayName = "TableHead"; + +const TableCell = React.forwardRef>( + ({ className, ...props }, ref) => ( + + ) +); +TableCell.displayName = "TableCell"; + +const TableCaption = React.forwardRef>( + ({ className, ...props }, ref) => ( +
+ ) +); +TableCaption.displayName = "TableCaption"; + +export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow };