Frontend: Show the country of a server in the result

This commit is contained in:
Braydon 2024-04-26 21:12:12 -04:00
parent 2e319488a9
commit 39407ac8b0
4 changed files with 32 additions and 10 deletions

Binary file not shown.

@ -9,6 +9,10 @@ const nextConfig = {
protocol: "https", protocol: "https",
hostname: "api.restfulmc.cc", hostname: "api.restfulmc.cc",
}, },
{
protocol: "https",
hostname: "flagcdn.com",
},
], ],
}, },
experimental: { experimental: {

@ -51,7 +51,7 @@
"react-syntax-highlighter": "^15.5.0", "react-syntax-highlighter": "^15.5.0",
"remark-gfm": "^4.0.0", "remark-gfm": "^4.0.0",
"remote-mdx": "^0.0.7", "remote-mdx": "^0.0.7",
"restfulmc-lib": "^1.1.3", "restfulmc-lib": "^1.1.4",
"shadcn-ui": "0.8.0", "shadcn-ui": "0.8.0",
"sharp": "^0.33.3", "sharp": "^0.33.3",
"sonner": "^1.4.41", "sonner": "^1.4.41",

@ -32,6 +32,7 @@ import config from "@/config";
import { minecraft } from "@/font/fonts"; import { minecraft } from "@/font/fonts";
import CodeDialog from "@/components/code/code-dialog"; import CodeDialog from "@/components/code/code-dialog";
import RawJson from "@/components/badge/raw-json"; import RawJson from "@/components/badge/raw-json";
import SimpleTooltip from "@/components/simple-tooltip";
/** /**
* The props for a server result. * The props for a server result.
@ -113,6 +114,22 @@ const ServerResult = ({ server }: ServerResultProps): ReactElement => {
</div> </div>
</div> </div>
{/* Country & Raw Json */}
<div className="flex justify-center items-center gap-5 sm:gap-10 transition-all transform-gpu">
{/* Server Geo Location */}
{server.geo && (
<SimpleTooltip
content={`Located in ${server.geo.country.name}`}
>
<Image
src={`https://flagcdn.com/w40/${server.geo.country.code.toLowerCase()}.png`}
alt={`Country Flag for ${server.geo.country.name}`}
width={36}
height={36}
/>
</SimpleTooltip>
)}
{/* Raw Json */} {/* Raw Json */}
<CodeDialog <CodeDialog
title="Raw Server Data" title="Raw Server Data"
@ -123,6 +140,7 @@ const ServerResult = ({ server }: ServerResultProps): ReactElement => {
{JSON.stringify(server, undefined, 4)} {JSON.stringify(server, undefined, 4)}
</CodeDialog> </CodeDialog>
</div> </div>
</div>
); );
}; };
export default ServerResult; export default ServerResult;