switch to the js library
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 1m13s

This commit is contained in:
Lee 2024-04-14 21:10:33 +01:00
parent d50cd981b0
commit 01d0ad468a
5 changed files with 1992 additions and 72 deletions

View File

@ -14,6 +14,7 @@
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"lucide-react": "^0.368.0",
"mcutils-library": "^1.0.1",
"next": "14.2.1",
"next-themes": "^0.3.0",
"react": "^18",

2017
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@ export default function RootLayout({
<head />
<body>
<ThemeProvider attribute="class" defaultTheme="dark" enableSystem>
<ToastContainer theme="dark" />
<ToastContainer theme="dark" pauseOnFocusLoss={false} />
<Container>{children}</Container>
</ThemeProvider>
</body>

View File

@ -1,18 +0,0 @@
import { API_ENDPOINT } from "@/consts";
import axios from "axios";
export default class WebRequest {
private API_ENDPOINT: string = API_ENDPOINT;
/**
* Gets a response from the server
*
* @param endpoint the endpoint to send the request to
* @returns the response from the server
*/
public static get(endpoint: string) {
return axios.get(API_ENDPOINT + endpoint, {
validateStatus: () => true, // Do not throw an error on non-200 status codes
});
}
}

View File

@ -1,6 +1,6 @@
"use client";
import WebRequest from "@/common/web-request";
import mcUtils from "mcutils-library";
import Image from "next/image";
import Link from "next/link";
import { useState } from "react";
@ -17,22 +17,14 @@ export default function PlayerSearch() {
toast.error("Please enter a player ID");
return;
}
searchPlayer(playerId);
};
/**
* Searches for a player by their id
*
* @param playerId the player's id
*/
const searchPlayer = async (playerId: string) => {
const response = await WebRequest.get("/player/" + playerId);
if (response.status !== 200) {
toast.error("Player not found");
return;
}
const { player } = response.data;
setPlayer(player);
mcUtils.player
.getPlayer(playerId)
.then((response) => {
setPlayer(response.player);
})
.catch(() => {
toast.error("Player not found");
});
};
return (