From 2c7db20f79dd8fe23746d32a5a1ed9b59c848229 Mon Sep 17 00:00:00 2001 From: Fascinated Date: Wed, 12 Jul 2023 18:15:13 +0100 Subject: [PATCH] fixed issue when discord was missing from the config --- package-lock.json | 120 ++++++++++++++++++++++++++++++++++ src/app/components/Avatar.tsx | 49 +++++++++----- 2 files changed, 154 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 88ba19f..c7c25c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4573,6 +4573,126 @@ "funding": { "url": "https://github.com/sponsors/colinhacks" } + }, + "node_modules/@next/swc-darwin-arm64": { + "version": "13.4.9", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.9.tgz", + "integrity": "sha512-TVzGHpZoVBk3iDsTOQA/R6MGmFp0+17SWXMEWd6zG30AfuELmSSMe2SdPqxwXU0gbpWkJL1KgfLzy5ReN0crqQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-darwin-x64": { + "version": "13.4.9", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.9.tgz", + "integrity": "sha512-aSfF1fhv28N2e7vrDZ6zOQ+IIthocfaxuMWGReB5GDriF0caTqtHttAvzOMgJgXQtQx6XhyaJMozLTSEXeNN+A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "13.4.9", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.9.tgz", + "integrity": "sha512-JhKoX5ECzYoTVyIy/7KykeO4Z2lVKq7HGQqvAH+Ip9UFn1MOJkOnkPRB7v4nmzqAoY+Je05Aj5wNABR1N18DMg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "13.4.9", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.9.tgz", + "integrity": "sha512-OOn6zZBIVkm/4j5gkPdGn4yqQt+gmXaLaSjRSO434WplV8vo2YaBNbSHaTM9wJpZTHVDYyjzuIYVEzy9/5RVZw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "13.4.9", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.9.tgz", + "integrity": "sha512-iA+fJXFPpW0SwGmx/pivVU+2t4zQHNOOAr5T378PfxPHY6JtjV6/0s1vlAJUdIHeVpX98CLp9k5VuKgxiRHUpg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "13.4.9", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.9.tgz", + "integrity": "sha512-rlNf2WUtMM+GAQrZ9gMNdSapkVi3koSW3a+dmBVp42lfugWVvnyzca/xJlN48/7AGx8qu62WyO0ya1ikgOxh6A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "13.4.9", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.9.tgz", + "integrity": "sha512-5T9ybSugXP77nw03vlgKZxD99AFTHaX8eT1ayKYYnGO9nmYhJjRPxcjU5FyYI+TdkQgEpIcH7p/guPLPR0EbKA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "13.4.9", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.9.tgz", + "integrity": "sha512-ojZTCt1lP2ucgpoiFgrFj07uq4CZsq4crVXpLGgQfoFq00jPKRPgesuGPaz8lg1yLfvafkU3Jd1i8snKwYR3LA==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } } } } diff --git a/src/app/components/Avatar.tsx b/src/app/components/Avatar.tsx index 65885c4..aa9644b 100644 --- a/src/app/components/Avatar.tsx +++ b/src/app/components/Avatar.tsx @@ -1,27 +1,18 @@ "use client"; import Image from "next/image"; +import { Fragment } from "react"; import { useLanyardWS } from "use-lanyard"; import Config from "../../../config.json"; +function LanyardWrapper(props: { children: any }) { + return {props.children}; +} + export default function Avatar(props: any) { const { avatar } = props; - - const discordId: any = Config.discord.id; - const lanyardData = useLanyardWS(discordId); - const hasLanyard = lanyardData != undefined; - - const statusColor = { - online: "bg-green-400", - offline: "bg-slate-400", - dnd: "bg-red-500", - idle: "bg-orange-400", - }; - const currentStatus = - lanyardData != undefined - ? statusColor[lanyardData.discord_status] - : undefined; + const { discord }: any = Config; return (
@@ -32,6 +23,34 @@ export default function Avatar(props: any) { height={120} className="rounded-full" /> + {discord ? ( + + + + ) : null} +
+ ); +} + +function LanyardComponent(props: { discord: any }) { + const { discord } = props; + const discordId = discord.id; + const lanyardData = useLanyardWS(discordId); + const hasLanyard = lanyardData !== undefined; + + const statusColor = { + online: "bg-green-400", + offline: "bg-slate-400", + dnd: "bg-red-500", + idle: "bg-orange-400", + }; + const currentStatus = + lanyardData !== undefined + ? statusColor[lanyardData.discord_status] + : undefined; + + return ( +
{hasLanyard && (