From fcb4221fca9e5de35c609cbe3943dc14358c9a25 Mon Sep 17 00:00:00 2001 From: dvelo <52332868+DeveloLongScript@users.noreply.github.com> Date: Fri, 3 Jan 2025 13:26:25 -0600 Subject: [PATCH] feat: new affiliate --- docs/advanced/tech-stack.mdx | 2 +- docs/guides/owning-a-server.mdx | 6 +- package.json | 1 + src/app/(main)/server/[server]/layout.tsx | 51 + .../server/[server]/statistics/page.tsx | 11 +- src/components/AfterServerView.tsx | 26 +- src/components/Icon.tsx | 533 ++-- src/components/ServerList.tsx | 2445 +++++++++-------- src/components/ServerView.tsx | 19 +- src/components/{ => charts}/NewChart.tsx | 81 +- src/components/charts/RelativeChart.tsx | 163 ++ src/components/misc/AffiliatePopup.tsx | 94 + src/components/misc/StickyTopbar.tsx | 2 +- src/components/ui/dialog.tsx | 11 +- src/config/banners.tsx | 119 +- src/lib/api.ts | 686 ++--- .../hooks/use-server-exists.tsx} | 21 + src/lib/list.ts | 2 +- .../v0/history/[server]/get-relative-data.ts | 97 + .../history/[server]/get-short-term-data.ts | 7 +- yarn.lock | 20 + 21 files changed, 2600 insertions(+), 1797 deletions(-) create mode 100644 src/app/(main)/server/[server]/layout.tsx rename src/components/{ => charts}/NewChart.tsx (70%) create mode 100644 src/components/charts/RelativeChart.tsx create mode 100644 src/components/misc/AffiliatePopup.tsx rename src/{components/misc/AffilatePopup.tsx => lib/hooks/use-server-exists.tsx} (74%) create mode 100644 src/pages/api/v0/history/[server]/get-relative-data.ts diff --git a/docs/advanced/tech-stack.mdx b/docs/advanced/tech-stack.mdx index a8bb2b4..f8768cc 100644 --- a/docs/advanced/tech-stack.mdx +++ b/docs/advanced/tech-stack.mdx @@ -11,7 +11,7 @@ The tech stack of MHSF is relatively modern to ensure MHSF keeps up with standar - **shadcn/ui** is the UI framework used to keep the whole website consistent. - **Contentlayer** manages all the pages used for documentation - **TailwindCSS** makes MHSF use (mostly) no CSS for better efficency -- **react-hot-toast** provides the Toast used for MHSF +- **Sonner** provides the Toast used for MHSF ## Back-end - **Inngest** runs periodic tasks diff --git a/docs/guides/owning-a-server.mdx b/docs/guides/owning-a-server.mdx index a60eae5..702f0df 100644 --- a/docs/guides/owning-a-server.mdx +++ b/docs/guides/owning-a-server.mdx @@ -14,4 +14,8 @@ If they match, you should see a button named Click to own. Press that button, an ## I can't link my server, because my server doesn't have a author -Your server must have an author in-order to be automagically linked, and if it doesn't have an author, that means you will have to manually link your server. To do that, make an issue on GitHub, showing that your server has no author, but needs to be linked. Show proof that you own the server, along with your account username, and your account will own the server you need. \ No newline at end of file +Your server must have an author in-order to be automagically linked, and if it doesn't have an author, that means you will have to manually link your server. To do that, make an issue on GitHub, showing that your server has no author, but needs to be linked. Show proof that you own the server, along with your account username, and your account will own the server you need. + +## There is an error while linking my server! +This most likely is because the Minehut API is blocking the server-side request to verify your the owner of that server, or your server [has no author](#i-cant-link-my-server-because-my-server-doesnt-have-a-author). +Try again in 30 minute intervals, or just make an issue on GitHub to link your server. \ No newline at end of file diff --git a/package.json b/package.json index bd4c935..4b62add 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "@unocss/postcss": "^0.61.5", "@unocss/transformer-directives": "^0.61.5", "@unocss/webpack": "^0.61.5", + "ag-grid-react": "^33.0.3", "contentlayer": "^0.3.4", "cron": "^3.1.7", "discord.js": "^14.15.3", diff --git a/src/app/(main)/server/[server]/layout.tsx b/src/app/(main)/server/[server]/layout.tsx new file mode 100644 index 0000000..eabbd18 --- /dev/null +++ b/src/app/(main)/server/[server]/layout.tsx @@ -0,0 +1,51 @@ +/* + * MHSF, Minehut Server List + * All external content is rather licensed under the ECA Agreement + * located here: https://mhsf.app/docs/legal/external-content-agreement + * + * All code under MHSF is licensed under the MIT License + * by open source contributors + * + * Copyright (c) 2024 dvelo + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +"use client"; + +import { LoadingSpinner } from "@/components/ui/loading-spinner"; +import { useServerExists } from "@/lib/hooks/use-server-exists"; +import { notFound } from "next/navigation"; + +export default function ServerLayout({ + params, + children, +}: { + params: { server: string }; + children: React.ReactNode; +}) { + const { serverExists, loading } = useServerExists(params.server); + + if (loading) return ; + + if (!serverExists) notFound(); + + return children; +} diff --git a/src/app/(main)/server/[server]/statistics/page.tsx b/src/app/(main)/server/[server]/statistics/page.tsx index a009481..6c80b7f 100644 --- a/src/app/(main)/server/[server]/statistics/page.tsx +++ b/src/app/(main)/server/[server]/statistics/page.tsx @@ -30,12 +30,12 @@ import Banner from "@/components/Banner"; import ColorProvider from "@/components/ColorProvider"; -import { NewChart } from "@/components/NewChart"; +import { NewChart } from "@/components/charts/NewChart"; import ServerView from "@/components/ServerView"; import TabServer from "@/components/misc/TabServer"; -import { Separator } from "@/components/ui/separator"; import type { Metadata, ResolvingMetadata } from "next"; import StickyTopbar from "@/components/misc/StickyTopbar"; +import { RelativeChart } from "@/components/charts/RelativeChart"; type Props = { params: { server: string }; @@ -101,17 +101,18 @@ export default function ServerPage({ params }: { params: { server: string } }) {
-
+
-
-
+
+
+
diff --git a/src/components/AfterServerView.tsx b/src/components/AfterServerView.tsx index 4021a23..8c82c6d 100644 --- a/src/components/AfterServerView.tsx +++ b/src/components/AfterServerView.tsx @@ -87,6 +87,7 @@ export default function AfterServerView({ server }: { server: string }) { getCommunityServerFavorites(server).then((c) => { mhsf.setFavorites(c); }); + setView(description !== "" || discord !== "" ? "desc" : "extra"); } fetch("https://api.minehut.com/server/" + server + "?byName=true").then( (c) => c.json().then((n) => setServerObject(n.server)) @@ -96,7 +97,7 @@ export default function AfterServerView({ server }: { server: string }) { }); setLoading(false); }); - }, []); + }, [description, discord]); if (loading) return <>; return ( @@ -216,20 +217,13 @@ export default function AfterServerView({ server }: { server: string }) { )} {discord != "" && view == "desc" && ( - - - Discord Server - -