mirror of
https://github.com/DeveloLongScript/MHSF.git
synced 2026-05-15 09:18:01 -05:00
feat: new affiliate
This commit is contained in:
parent
c95aa8c777
commit
fcb4221fca
@ -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
|
||||
|
||||
@ -15,3 +15,7 @@ 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.
|
||||
|
||||
## 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.
|
||||
@ -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",
|
||||
|
||||
51
src/app/(main)/server/[server]/layout.tsx
Normal file
51
src/app/(main)/server/[server]/layout.tsx
Normal file
@ -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 <LoadingSpinner />;
|
||||
|
||||
if (!serverExists) notFound();
|
||||
|
||||
return children;
|
||||
}
|
||||
@ -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 } }) {
|
||||
<ColorProvider server={params.server}>
|
||||
<div className={"pt-[300px] xl:px-[100px]"}>
|
||||
<Banner server={params.server} />
|
||||
<div className="pt-8 z-10 relative">
|
||||
<div className="pt-8 z-1 relative">
|
||||
<ServerView server={params.server} />
|
||||
</div>
|
||||
|
||||
<StickyTopbar scrollElevation={100} className="pt-4">
|
||||
<TabServer server={params.server} tabDef="statistics" />
|
||||
</StickyTopbar>
|
||||
<Separator />
|
||||
<br />
|
||||
<div className="p-4 gap-4">
|
||||
<div className="p-4 gap-4 relative z-1">
|
||||
<NewChart server={params.server} />
|
||||
<br />
|
||||
<RelativeChart server={params.server} />
|
||||
</div>
|
||||
</div>
|
||||
</ColorProvider>
|
||||
|
||||
@ -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 }) {
|
||||
</Card>
|
||||
)}
|
||||
{discord != "" && view == "desc" && (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Discord Server</CardTitle>
|
||||
<CardDescription className="p-4 prose dark:prose-invert">
|
||||
<iframe
|
||||
src={`https://discord.com/widget?id=${discord}&theme=${resolvedTheme}`}
|
||||
height="500"
|
||||
allowTransparency={true}
|
||||
className="rounded-lg max-sm:w-[100px] max-md:w-[250px]"
|
||||
className="rounded-lg max-md:w-full"
|
||||
sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"
|
||||
/>
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
</Card>
|
||||
)}{" "}
|
||||
{view == "achievements" && (
|
||||
<div className="col-span-4">
|
||||
@ -452,7 +446,7 @@ export default function AfterServerView({ server }: { server: string }) {
|
||||
</tr>
|
||||
<tr>
|
||||
<th className="border p-2">Server ID</th>
|
||||
<td className="border p-2">
|
||||
<td className="border p-2 break-all">
|
||||
{serverObject?._id == undefined ? (
|
||||
"? (unknown)"
|
||||
) : (
|
||||
|
||||
@ -305,6 +305,41 @@ export function BrandingGenericIcon(props: SVGProps<SVGSVGElement>) {
|
||||
}
|
||||
}
|
||||
|
||||
export function BadgeOfAffiliation(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg
|
||||
width="81"
|
||||
height="81"
|
||||
viewBox="0 0 81 81"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
{...props}
|
||||
>
|
||||
<rect width="81" height="81" rx="34" fill="url(#paint0_linear_1_12)" />
|
||||
<path
|
||||
d="M29.5 36.5H26C25.0717 36.5 24.1815 36.1313 23.5251 35.4749C22.8687 34.8185 22.5 33.9283 22.5 33V26C22.5 25.0717 22.8687 24.1815 23.5251 23.5251C24.1815 22.8687 25.0717 22.5 26 22.5H54C54.9283 22.5 55.8185 22.8687 56.4749 23.5251C57.1313 24.1815 57.5 25.0717 57.5 26V33C57.5 33.9283 57.1313 34.8185 56.4749 35.4749C55.8185 36.1313 54.9283 36.5 54 36.5H50.5M29.5 43.5H26C25.0717 43.5 24.1815 43.8687 23.5251 44.5251C22.8687 45.1815 22.5 46.0717 22.5 47V54C22.5 54.9283 22.8687 55.8185 23.5251 56.4749C24.1815 57.1313 25.0717 57.5 26 57.5H54C54.9283 57.5 55.8185 57.1313 56.4749 56.4749C57.1313 55.8185 57.5 54.9283 57.5 54V47C57.5 46.0717 57.1313 45.1815 56.4749 44.5251C55.8185 43.8687 54.9283 43.5 54 43.5H50.5M29.5 29.5H29.5175M29.5 50.5H29.5175M41.75 29.5L34.75 40H45.25L38.25 50.5"
|
||||
stroke="white"
|
||||
stroke-width="3"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
<defs>
|
||||
<linearGradient
|
||||
id="paint0_linear_1_12"
|
||||
x1="40.5"
|
||||
y1="0"
|
||||
x2="40.5"
|
||||
y2="81"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop stop-color="#37B14F" />
|
||||
<stop offset="1" stop-color="#3D4B17" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export const Discord = (props: SVGProps<SVGSVGElement>) => (
|
||||
<svg
|
||||
viewBox="0 0 256 199"
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
"use client";
|
||||
import { BorderBeam } from "@/components/effects/border-beam";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { AgGridReact, CustomCellRendererProps } from "ag-grid-react";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@ -39,6 +40,15 @@ import {
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
AllCommunityModule,
|
||||
ModuleRegistry,
|
||||
colorSchemeDarkBlue,
|
||||
colorSchemeDarkWarm,
|
||||
colorSchemeLightCold,
|
||||
colorSchemeLightWarm,
|
||||
themeQuartz,
|
||||
} from "ag-grid-community";
|
||||
import {
|
||||
Menubar,
|
||||
MenubarCheckboxItem,
|
||||
@ -74,8 +84,10 @@ import {
|
||||
ArrowDownZA,
|
||||
Check,
|
||||
CircleUser,
|
||||
Copy,
|
||||
ImageIcon,
|
||||
Info,
|
||||
Layers,
|
||||
LogIn,
|
||||
Network,
|
||||
Sun,
|
||||
@ -103,6 +115,14 @@ import { Skeleton } from "./ui/skeleton";
|
||||
import { affiliates } from "@/config/affiliates";
|
||||
import { LoadingSpinner } from "./ui/loading-spinner";
|
||||
import StickyTopbar from "./misc/StickyTopbar";
|
||||
import { HoverCard } from "@radix-ui/react-hover-card";
|
||||
import { HoverCardTrigger } from "./ui/hover-card";
|
||||
|
||||
// ag-grid
|
||||
ModuleRegistry.registerModules([AllCommunityModule]);
|
||||
|
||||
const themeLightWarm = themeQuartz.withPart(colorSchemeLightWarm);
|
||||
const themeDarkWarm = themeQuartz.withPart(colorSchemeDarkBlue);
|
||||
|
||||
const features = [
|
||||
{
|
||||
@ -164,12 +184,15 @@ export default function ServerList() {
|
||||
const { user, isSignedIn } = useUser();
|
||||
const [pOS, setpOS] = useState(false);
|
||||
const [ipr, setIPR] = useState<string>("4");
|
||||
const [presentationMode, setPresentationMode] = useState<"table" | "grid">(
|
||||
"grid",
|
||||
);
|
||||
const [am, setAM] = useState(false);
|
||||
const [filters, setFilters] = useState<
|
||||
Array<(server: OnlineServer) => Promise<boolean>>
|
||||
>([]);
|
||||
const [randomData, setRandomData] = useState<OnlineServer | undefined>(
|
||||
undefined
|
||||
undefined,
|
||||
);
|
||||
const { resolvedTheme } = useTheme();
|
||||
const [color, setColor] = useState("#ffffff");
|
||||
@ -344,14 +367,14 @@ export default function ServerList() {
|
||||
<br className="hidden md:block" /> in less than 10 minutes.
|
||||
</p>
|
||||
<div className="relative flex h-[300px] w-full flex-col items-center justify-center overflow-hidden rounded-lg bg-background ">
|
||||
<Marquee className="[--duration:30s]">
|
||||
<Marquee className="[--duration:30s]" pauseOnHover>
|
||||
{serverList.currentServers.slice(0, 20).map((server) => (
|
||||
<div
|
||||
key={server.name}
|
||||
className={cn(
|
||||
"relative w-64 cursor-pointer overflow-hidden rounded-xl border no-underline " +
|
||||
"border-gray-950/[.1] bg-gray-950/[.01] hover:bg-gray-950/[.05] " +
|
||||
"dark:border-gray-50/[.1] dark:bg-gray-50/[.10] dark:hover:bg-gray-50/[.15]"
|
||||
"dark:border-gray-50/[.1] dark:bg-gray-50/[.10] dark:hover:bg-gray-50/[.15]",
|
||||
)}
|
||||
onClick={() =>
|
||||
router.push(pageFind(`Server:${server.name}`))
|
||||
@ -378,14 +401,14 @@ export default function ServerList() {
|
||||
</div>
|
||||
))}
|
||||
</Marquee>
|
||||
<Marquee reverse className="[--duration:30s]">
|
||||
<Marquee reverse className="[--duration:30s]" pauseOnHover>
|
||||
{serverList.currentServers.slice(0, 20).map((server) => (
|
||||
<div
|
||||
key={server.name}
|
||||
className={cn(
|
||||
"relative w-64 cursor-pointer overflow-hidden rounded-xl border no-underline " +
|
||||
"border-gray-950/[.1] bg-gray-950/[.01] hover:bg-gray-950/[.05] " +
|
||||
"dark:border-gray-50/[.1] dark:bg-gray-50/[.10] dark:hover:bg-gray-50/[.15]"
|
||||
"dark:border-gray-50/[.1] dark:bg-gray-50/[.10] dark:hover:bg-gray-50/[.15]",
|
||||
)}
|
||||
onClick={() => router.push(`/server/${server.name}`)}
|
||||
>
|
||||
@ -572,7 +595,7 @@ export default function ServerList() {
|
||||
c.forEach(
|
||||
(b: { server: string; motd: string }) => {
|
||||
updatedSL[b.server] = b.motd;
|
||||
}
|
||||
},
|
||||
);
|
||||
setMotdList(updatedSL);
|
||||
setServers(serverList.currentServers);
|
||||
@ -588,7 +611,7 @@ export default function ServerList() {
|
||||
success: "Succesfully refreshed servers",
|
||||
loading: "Refreshing...",
|
||||
error: "Error while refreshing",
|
||||
}
|
||||
},
|
||||
);
|
||||
}}
|
||||
>
|
||||
@ -638,7 +661,7 @@ export default function ServerList() {
|
||||
c.forEach(
|
||||
(b: { server: string; motd: string }) => {
|
||||
updatedSL[b.server] = b.motd;
|
||||
}
|
||||
},
|
||||
);
|
||||
setMotdList(updatedSL);
|
||||
setServers(serverList.currentServers);
|
||||
@ -680,7 +703,7 @@ export default function ServerList() {
|
||||
c.forEach(
|
||||
(b: { server: string; motd: string }) => {
|
||||
updatedSL[b.server] = b.motd;
|
||||
}
|
||||
},
|
||||
);
|
||||
setMotdList(updatedSL);
|
||||
setServers(serverList.currentServers);
|
||||
@ -722,7 +745,7 @@ export default function ServerList() {
|
||||
c.forEach(
|
||||
(b: { server: string; motd: string }) => {
|
||||
updatedSL[b.server] = b.motd;
|
||||
}
|
||||
},
|
||||
);
|
||||
setMotdList(updatedSL);
|
||||
setServers(serverList.currentServers);
|
||||
@ -735,7 +758,7 @@ export default function ServerList() {
|
||||
error: "Error while changing filters",
|
||||
loading: "Changing filters...",
|
||||
success: "Changed filters!",
|
||||
}
|
||||
},
|
||||
);
|
||||
}}
|
||||
value={(() => {
|
||||
@ -822,7 +845,7 @@ export default function ServerList() {
|
||||
c.forEach(
|
||||
(b: { server: string; motd: string }) => {
|
||||
updatedSL[b.server] = b.motd;
|
||||
}
|
||||
},
|
||||
);
|
||||
setMotdList(updatedSL);
|
||||
setServers(serverList.currentServers);
|
||||
@ -899,7 +922,23 @@ export default function ServerList() {
|
||||
<MenubarTrigger>View</MenubarTrigger>
|
||||
<MenubarContent>
|
||||
<MenubarSub>
|
||||
<MenubarSubTrigger>Grid</MenubarSubTrigger>
|
||||
<MenubarSubTrigger>Mode</MenubarSubTrigger>
|
||||
<MenubarSubContent>
|
||||
<MenubarRadioGroup
|
||||
value={presentationMode}
|
||||
onValueChange={(v) =>
|
||||
setPresentationMode(v as "grid" | "table")
|
||||
}
|
||||
>
|
||||
<MenubarRadioItem value="grid">Grid</MenubarRadioItem>
|
||||
<MenubarRadioItem value="table">Table</MenubarRadioItem>
|
||||
</MenubarRadioGroup>
|
||||
</MenubarSubContent>
|
||||
</MenubarSub>
|
||||
<MenubarSub>
|
||||
<MenubarSubTrigger disabled={presentationMode === "table"} className={presentationMode === "table" ? "text-muted-foreground" : ""}>
|
||||
Grid
|
||||
</MenubarSubTrigger>
|
||||
<MenubarSubContent>
|
||||
<MenubarRadioGroup
|
||||
value={ipr}
|
||||
@ -913,7 +952,7 @@ export default function ServerList() {
|
||||
onClick: () =>
|
||||
router.push("/account/settings/options"),
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
setIPR(v);
|
||||
}}
|
||||
@ -945,7 +984,7 @@ export default function ServerList() {
|
||||
onClick: () =>
|
||||
router.push("/account/settings/options"),
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
setPadding(v);
|
||||
}}
|
||||
@ -968,24 +1007,6 @@ export default function ServerList() {
|
||||
</MenubarCheckboxItem>
|
||||
</MenubarSubContent>
|
||||
</MenubarSub>
|
||||
<MenubarSub>
|
||||
<MenubarSubTrigger>Sort</MenubarSubTrigger>
|
||||
<MenubarSubContent>
|
||||
<MenubarRadioGroup
|
||||
value="joins"
|
||||
onValueChange={(c) => {
|
||||
if (c === "favorites") router.push("/sort/favorites");
|
||||
}}
|
||||
>
|
||||
<MenubarRadioItem value="joins">
|
||||
Players Online
|
||||
</MenubarRadioItem>
|
||||
<MenubarRadioItem value="favorites">
|
||||
Favorites
|
||||
</MenubarRadioItem>
|
||||
</MenubarRadioGroup>
|
||||
</MenubarSubContent>
|
||||
</MenubarSub>
|
||||
<MenubarSeparator />
|
||||
<SignedIn>
|
||||
<MenubarCheckboxItem
|
||||
@ -1076,7 +1097,7 @@ export default function ServerList() {
|
||||
onClick={() => {
|
||||
setTextCopied(true);
|
||||
clipboard.writeText(
|
||||
randomData.name + ".mshf.minehut.gg"
|
||||
randomData.name + ".mshf.minehut.gg",
|
||||
);
|
||||
toast.success("Copied!");
|
||||
setTimeout(() => setTextCopied(false), 1000);
|
||||
@ -1096,6 +1117,7 @@ export default function ServerList() {
|
||||
</Dialog>
|
||||
|
||||
<br />
|
||||
{presentationMode === "grid" && (
|
||||
<InfiniteScroll
|
||||
dataLength={serverList.currentServers.length}
|
||||
hasMore={serverList.hasMore}
|
||||
@ -1149,6 +1171,7 @@ export default function ServerList() {
|
||||
>
|
||||
{servers.map((b: any, i: number) => (
|
||||
<>
|
||||
{/* <>
|
||||
{i === Number(ipr) && affiliates.length != 0 && (
|
||||
<div
|
||||
className="border rounded h-[450px] shadow p-10 max-w-full dark:prose-invert prose grid grid-cols-3 max-xl:hidden"
|
||||
@ -1185,18 +1208,158 @@ export default function ServerList() {
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
)} </> */}
|
||||
<ServerCard b={b} motd={motdList[b.name]} />
|
||||
</>
|
||||
))}
|
||||
</div>
|
||||
</ClientFadeIn>
|
||||
</InfiniteScroll>
|
||||
)}
|
||||
{presentationMode === "table" && (
|
||||
<div className="h-[calc(100vh-430px)]">
|
||||
<AgGridReact
|
||||
rowData={serverList.servers}
|
||||
columnDefs={[
|
||||
{
|
||||
field: "name",
|
||||
cellRenderer: (c: CustomCellRendererProps) => {
|
||||
return (
|
||||
<>
|
||||
<Tooltip>
|
||||
<TooltipTrigger>
|
||||
<HoverCard>
|
||||
<HoverCardTrigger>
|
||||
{c.data?.name}
|
||||
</HoverCardTrigger>
|
||||
</HoverCard>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>{c.data?.name}</TooltipContent>
|
||||
</Tooltip>
|
||||
</>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "playerData.playerCount",
|
||||
headerName: "Players",
|
||||
cellRenderer: (params: CustomCellRendererProps) => {
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
{params.value == 0 ? (
|
||||
<div
|
||||
className="items-center border"
|
||||
style={{
|
||||
width: ".5rem",
|
||||
height: ".5rem",
|
||||
borderRadius: "9999px",
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<div
|
||||
className="items-center"
|
||||
style={{
|
||||
backgroundColor: "#0cce6b",
|
||||
width: ".5rem",
|
||||
height: ".5rem",
|
||||
borderRadius: "9999px",
|
||||
}}
|
||||
/>
|
||||
)}{" "}
|
||||
{params.value}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
headerName: "Owner",
|
||||
valueGetter: (p) => p.data?.author ?? "--",
|
||||
cellRenderer: (c: CustomCellRendererProps) => {
|
||||
if (c.data.author === "--") {
|
||||
return <>--</>;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip>
|
||||
<TooltipTrigger>{c.data?.author}</TooltipTrigger>
|
||||
<TooltipContent>{c.data?.author}</TooltipContent>
|
||||
</Tooltip>
|
||||
</>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
headerName: "Tags",
|
||||
valueGetter: (p) => (
|
||||
<TagShower server={p.data as OnlineServer} />
|
||||
),
|
||||
cellRenderer: TagCR,
|
||||
minWidth: 249,
|
||||
},
|
||||
{
|
||||
headerName: "Actions",
|
||||
minWidth: 107,
|
||||
cellRenderer: (c: CustomCellRendererProps) => {
|
||||
return (
|
||||
<div>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="secondary"
|
||||
className="md:min-w-[128px] md:max-w-[328px] h-[32px] mt-1 ml-2"
|
||||
onClick={() => {
|
||||
clipboard.writeText(
|
||||
c.data.name + ".mshf.minehut.gg",
|
||||
);
|
||||
toast.success("Copied IP to clipboard");
|
||||
}}
|
||||
>
|
||||
<Copy size={18} />
|
||||
<code className="ml-2 max-md:hidden">
|
||||
{c.data.name}
|
||||
</code>
|
||||
</Button>
|
||||
<Tooltip>
|
||||
<TooltipTrigger>
|
||||
<Link href={"/server/" + c.data.name}>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="secondary"
|
||||
className="w-[32px] h-[32px] mt-1 ml-2"
|
||||
>
|
||||
<Layers size={18} />
|
||||
</Button>
|
||||
</Link>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
Open up the server page to see more information
|
||||
about the server
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
]}
|
||||
pagination={true}
|
||||
paginationPageSize={50}
|
||||
paginationPageSizeSelector={[10, 25, 50, 100]}
|
||||
theme={resolvedTheme === "dark" ? themeDarkWarm : themeLightWarm}
|
||||
defaultColDef={{
|
||||
flex: 1,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function TagCR(params: CustomCellRendererProps) {
|
||||
return <span className="w-full">{params.value}</span>;
|
||||
}
|
||||
|
||||
export function TagShower(props: {
|
||||
server: OnlineServer;
|
||||
className?: string;
|
||||
@ -1257,8 +1420,8 @@ export function TagShower(props: {
|
||||
|
||||
return (
|
||||
<div className="font-normal tracking-normal ">
|
||||
{compatiableTags.map((t) => (
|
||||
<>
|
||||
{compatiableTags.map((t, i) => (
|
||||
<span key={i} className="mx-2">
|
||||
{props.unclickable && (
|
||||
<Badge variant={t.role} className={props.className}>
|
||||
{t.name}
|
||||
@ -1298,7 +1461,7 @@ export function TagShower(props: {
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)}
|
||||
</>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -58,8 +58,9 @@ import IconDisplay from "./IconDisplay";
|
||||
import { useClerk, useUser } from "@clerk/nextjs";
|
||||
import { LoaderIcon } from "react-hot-toast";
|
||||
import { Separator } from "./ui/separator";
|
||||
import { convert } from "@/components/NewChart";
|
||||
import { convert } from "@/components/charts/NewChart";
|
||||
import { LoadingSpinner } from "./ui/loading-spinner";
|
||||
import { BadgeOfAffiliation } from "./Icon";
|
||||
|
||||
export default function ServerView(props: { server: string }) {
|
||||
const [single, setSingle] = useState(new ServerSingle(props.server));
|
||||
@ -169,6 +170,22 @@ export default function ServerView(props: { server: string }) {
|
||||
/>
|
||||
)}
|
||||
{props.server}
|
||||
{props.server === "CoreBoxx" && (
|
||||
<Tooltip>
|
||||
<TooltipTrigger>
|
||||
<BadgeOfAffiliation className="size-8 pl-2" />
|
||||
</TooltipTrigger>
|
||||
<TooltipContent className="font-normal tracking-normal flex items-center">
|
||||
|
||||
<BadgeOfAffiliation className="size-8 pr-2" />
|
||||
<span>
|
||||
CoreBoxx is an official affiliate of MHSF. This server was
|
||||
<br /> found to be a high-quality server and should be a
|
||||
good join for any player!
|
||||
</span>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
)}
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
{/* 1704088800000 is the Unix time (in milliseconds) of (GMT) Monday, January 1, 2024 6:00:00 AM */}
|
||||
|
||||
@ -31,7 +31,14 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts";
|
||||
import {
|
||||
CartesianGrid,
|
||||
Line,
|
||||
LineChart,
|
||||
XAxis,
|
||||
YAxis,
|
||||
ReferenceLine,
|
||||
} from "recharts";
|
||||
|
||||
import {
|
||||
Card,
|
||||
@ -49,8 +56,16 @@ import {
|
||||
import { useEffectOnce } from "@/lib/useEffectOnce";
|
||||
import { ServerResponse } from "@/lib/types/mh-server";
|
||||
import { getCommunityServerFavorites, getShortTermData } from "@/lib/api";
|
||||
import { Skeleton } from "./ui/skeleton";
|
||||
import { Skeleton } from "../ui/skeleton";
|
||||
import FadeIn from "react-fade-in/lib/FadeIn";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectGroup,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
|
||||
const chartConfig = {
|
||||
player_count: {
|
||||
@ -68,15 +83,20 @@ export function NewChart({ server }: { server: string }) {
|
||||
React.useState<keyof typeof chartConfig>("player_count");
|
||||
|
||||
const [chartData, setChartData] = React.useState<any>([]);
|
||||
const [allData, setAllData] = React.useState<any>([]);
|
||||
const [joins, setJoins] = React.useState<any>(0);
|
||||
const [loading, setLoading] = React.useState(true);
|
||||
const [dataMax, setDataMax] = React.useState(0);
|
||||
const [favorites, setFavorites] = React.useState<any>(0);
|
||||
const [filter, setFilter] = React.useState("60");
|
||||
|
||||
const allNums = { player_count: joins, favorites };
|
||||
useEffectOnce(() => {
|
||||
getShortTermData(server, ["player_count", "favorites", "date"]).then(
|
||||
(c) => {
|
||||
setChartData(c);
|
||||
setAllData(c.data);
|
||||
setChartData(c.data.slice(-60));
|
||||
setDataMax(c.dataMax);
|
||||
getCommunityServerFavorites(server).then((b) => setFavorites(b));
|
||||
fetch("https://api.minehut.com/server/" + server + "?byName=true").then(
|
||||
(k) => {
|
||||
@ -90,6 +110,14 @@ export function NewChart({ server }: { server: string }) {
|
||||
);
|
||||
});
|
||||
|
||||
React.useEffect(() => {
|
||||
if (filter === "all") {
|
||||
setChartData(allData);
|
||||
} else {
|
||||
setChartData(allData.slice(Number(filter) * -1));
|
||||
}
|
||||
}, [filter, allData]);
|
||||
|
||||
if (loading)
|
||||
return (
|
||||
<>
|
||||
@ -105,7 +133,29 @@ export function NewChart({ server }: { server: string }) {
|
||||
<CardTitle>
|
||||
{chartConfig[activeChart].label} Chart for {server}
|
||||
</CardTitle>
|
||||
<CardDescription>Showing the past 30 entries.</CardDescription>
|
||||
<CardDescription className="flex items-center">
|
||||
Showing {filter !== "all" && <>the last</>}{" "}
|
||||
<Select value={filter} onValueChange={setFilter}>
|
||||
{" "}
|
||||
<SelectTrigger className="max-w-[80px] mx-2">
|
||||
<SelectValue placeholder="60" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup className="max-h-[200px]">
|
||||
<SelectItem value="30">30</SelectItem>
|
||||
<SelectItem value="60">60</SelectItem>
|
||||
<SelectItem value="90">90</SelectItem>
|
||||
<SelectItem value="120">120</SelectItem>
|
||||
<SelectItem value="150">150</SelectItem>
|
||||
<SelectItem value="180">180</SelectItem>
|
||||
<SelectItem value="210">210</SelectItem>
|
||||
<SelectItem value="240">240</SelectItem>
|
||||
<SelectItem value="all">all</SelectItem>
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>{" "}
|
||||
{filter === "all" && <>of the</>} entries.
|
||||
</CardDescription>
|
||||
</div>
|
||||
<div className="flex">
|
||||
{["player_count", "favorites"].map((key) => {
|
||||
@ -149,9 +199,7 @@ export function NewChart({ server }: { server: string }) {
|
||||
tickMargin={8}
|
||||
minTickGap={32}
|
||||
tickFormatter={(value) => {
|
||||
return new Date(value).toLocaleTimeString("en-US", {
|
||||
timeStyle: "short",
|
||||
});
|
||||
return `${new Date(value).getMonth() + 1}/${new Date(value).getDate()}`;
|
||||
}}
|
||||
/>
|
||||
<YAxis
|
||||
@ -166,6 +214,9 @@ export function NewChart({ server }: { server: string }) {
|
||||
: ` ${value == 1 ? "favorite" : "favrts."}`)
|
||||
);
|
||||
}}
|
||||
domain={
|
||||
activeChart === "player_count" ? [0, dataMax + 10] : undefined
|
||||
}
|
||||
/>
|
||||
<ChartTooltip
|
||||
content={
|
||||
@ -174,13 +225,25 @@ export function NewChart({ server }: { server: string }) {
|
||||
nameKey={activeChart}
|
||||
indicator="line"
|
||||
labelFormatter={(value) => {
|
||||
return new Date(value).toLocaleTimeString("en-US", {
|
||||
return `${new Date(value).toLocaleDateString("en-US", {
|
||||
day: "numeric",
|
||||
month: "short",
|
||||
})} ${new Date(value).toLocaleTimeString("en-US", {
|
||||
timeStyle: "short",
|
||||
});
|
||||
})}`;
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{activeChart === "player_count" && (
|
||||
<ReferenceLine
|
||||
y={dataMax}
|
||||
stroke={`var(--color-${activeChart})`}
|
||||
strokeWidth={2}
|
||||
label="all-time max"
|
||||
strokeDasharray="3 3"
|
||||
/>
|
||||
)}
|
||||
<Line
|
||||
dataKey={activeChart}
|
||||
type="monotone"
|
||||
163
src/components/charts/RelativeChart.tsx
Normal file
163
src/components/charts/RelativeChart.tsx
Normal file
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* 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 { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts";
|
||||
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import {
|
||||
ChartContainer,
|
||||
ChartTooltip,
|
||||
ChartTooltipContent,
|
||||
} from "@/components/ui/chart";
|
||||
import { Skeleton } from "../ui/skeleton";
|
||||
import { useEffect, useState } from "react";
|
||||
import { getRelativeServerData } from "@/lib/api";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip";
|
||||
import { Info } from "lucide-react";
|
||||
|
||||
export function RelativeChart({ server }: { server: string }) {
|
||||
const [chartData, setChartData] = useState<
|
||||
Array<{ relativePercentage: number; date: string }>
|
||||
>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
getRelativeServerData(server).then((d) => {
|
||||
const newv: Array<{ relativePercentage: number; date: string }> = [];
|
||||
|
||||
d.forEach((c) =>
|
||||
newv.push({
|
||||
relativePercentage: c.relativePrecentage * 100,
|
||||
date: c.date,
|
||||
})
|
||||
);
|
||||
setChartData(newv);
|
||||
setLoading(false);
|
||||
});
|
||||
}, [server]);
|
||||
|
||||
if (loading)
|
||||
return (
|
||||
<>
|
||||
<Skeleton className="w-full h-[437px]" />
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader className="w-full relative">
|
||||
<CardTitle>Relative percentage of {server}</CardTitle>
|
||||
<CardDescription className="flex items-center">
|
||||
Shows the last 30 entries.{" "}
|
||||
<Tooltip>
|
||||
<TooltipTrigger>
|
||||
<Info className="size-4 ml-2" />
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
This is the percentage of players on your server <br />
|
||||
compared to the entire Minehut network. <br />
|
||||
<code>Server players / Minehut players</code>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<ChartContainer
|
||||
config={{
|
||||
relativePercentage: {
|
||||
label: "Relative percentage",
|
||||
color: "hsl(var(--chart-2))",
|
||||
},
|
||||
}}
|
||||
className="h-[250px] w-full aspect-auto"
|
||||
>
|
||||
<LineChart
|
||||
accessibilityLayer
|
||||
data={chartData}
|
||||
margin={{
|
||||
left: 12,
|
||||
right: 12,
|
||||
}}
|
||||
>
|
||||
<CartesianGrid vertical={false} />
|
||||
<XAxis
|
||||
dataKey="date"
|
||||
tickLine={false}
|
||||
axisLine={false}
|
||||
tickMargin={8}
|
||||
tickFormatter={(value) =>
|
||||
`${new Date(value).toLocaleTimeString("en-US", {
|
||||
timeStyle: "short",
|
||||
})}`
|
||||
}
|
||||
/>
|
||||
<YAxis
|
||||
dataKey="relativePercentage"
|
||||
tickLine={false}
|
||||
axisLine={false}
|
||||
tickFormatter={(value) => `${value}%`}
|
||||
/>
|
||||
<ChartTooltip
|
||||
content={
|
||||
<ChartTooltipContent
|
||||
className="w-[150px]"
|
||||
nameKey="relativePercentage"
|
||||
indicator="line"
|
||||
labelFormatter={(value) => {
|
||||
return `${new Date(value).toLocaleDateString("en-US", {
|
||||
day: "numeric",
|
||||
month: "short",
|
||||
})} ${new Date(value).toLocaleTimeString("en-US", {
|
||||
timeStyle: "short",
|
||||
})}`;
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<Line
|
||||
dataKey="relativePercentage"
|
||||
type="natural"
|
||||
stroke="var(--color-relativePercentage)"
|
||||
strokeWidth={2}
|
||||
dot={false}
|
||||
/>
|
||||
</LineChart>
|
||||
</ChartContainer>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
94
src/components/misc/AffiliatePopup.tsx
Normal file
94
src/components/misc/AffiliatePopup.tsx
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import {
|
||||
DialogDescription,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog";
|
||||
import { useState } from "react";
|
||||
import useClipboard from "@/lib/useClipboard";
|
||||
import { Button } from "../ui/button";
|
||||
import { Check } from "lucide-react";
|
||||
|
||||
export default function AffiliatePopup() {
|
||||
const [textCopied, setTextCopied] = useState(false);
|
||||
const clipboard = useClipboard();
|
||||
|
||||
return (
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-black dark:text-white">CoreBoxx</DialogTitle>
|
||||
<DialogDescription className="text-black dark:text-white text-md">
|
||||
We won't claim to be a "unique server" or any of that. But we do aim to
|
||||
give you the highest quality BoxPvP! Here's what we have: <br /> - 50
|
||||
progression mines over 11 worlds, plus many more for events and other
|
||||
items <br /> - Balanced gear sets - just because someone is a bit ahead
|
||||
of you doesn't mean you deserve to die in one shot <br /> - We're
|
||||
non-P2W, and we mean it! All perks are for convenience or benefit
|
||||
everyone online! <br /> - A rapidly-growing, tight-knit community with
|
||||
events and giveaways <br /> - Quests and storyline in development, in
|
||||
case mining gets boring <br />
|
||||
<br />
|
||||
<code className="border my-2 p-3 flex rounded">
|
||||
CoreBoxx.minehut.gg{" "}
|
||||
</code>
|
||||
<div
|
||||
className="border rounded p-2 mb-8 text-sm"
|
||||
style={{ backgroundColor: "hsl(var(--background))" }}
|
||||
>
|
||||
CoreBoxx is an official affiliate of MHSF. This server was found to be
|
||||
a high-quality server and should be a good join for any player!
|
||||
</div>
|
||||
</DialogDescription>
|
||||
<span className="w-full grid grid-cols-3 gap-2 opacity-80 backdrop-blur">
|
||||
<Button onClick={() => window.open("/server/CoreBoxx", "_blank")}>
|
||||
Open Page
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setTextCopied(true);
|
||||
clipboard.writeText("CoreBoxx.mhsf.minehut.gg");
|
||||
setTimeout(() => setTextCopied(false), 1000);
|
||||
}}
|
||||
>
|
||||
{textCopied ? (
|
||||
<Check size={16} className="flex items-center" />
|
||||
) : (
|
||||
<p>Copy IP</p>
|
||||
)}
|
||||
</Button>
|
||||
<DialogTrigger asChild>
|
||||
<Button variant="outline">Close</Button>
|
||||
</DialogTrigger>
|
||||
</span>
|
||||
</DialogHeader>
|
||||
);
|
||||
}
|
||||
@ -61,7 +61,7 @@ export default function StickyTopbar({
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`transition-all duration-300 ${isSticky ? "fixed left-0 w-full backdrop-blur shadow-lg " + className : "block w-full bg-transparent"}`}
|
||||
className={`transition-all duration-300 z-[9] ${isSticky ? "fixed left-0 w-full backdrop-blur shadow-lg " + className : "block w-full bg-transparent"}`}
|
||||
style={{
|
||||
top: isSticky ? `${bannerSize * 32 + 38}px` : undefined,
|
||||
}}
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
*/
|
||||
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
||||
import { X } from "lucide-react";
|
||||
@ -52,7 +51,7 @@ const DialogOverlay = React.forwardRef<
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 backdrop-blur",
|
||||
className,
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
@ -69,7 +68,7 @@ const DialogContent = React.forwardRef<
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
||||
className,
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
@ -90,7 +89,7 @@ const DialogHeader = ({
|
||||
<div
|
||||
className={cn(
|
||||
"flex flex-col space-y-1.5 text-center sm:text-left",
|
||||
className,
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
@ -104,7 +103,7 @@ const DialogFooter = ({
|
||||
<div
|
||||
className={cn(
|
||||
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
||||
className,
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
@ -119,7 +118,7 @@ const DialogTitle = React.forwardRef<
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"text-lg font-semibold leading-none tracking-tight",
|
||||
className,
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
|
||||
@ -1,41 +1,104 @@
|
||||
import GradientBanner from "@/components/effects/gradient-banner";
|
||||
import MainBanner from "@/components/feat/MainBanner";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import Link from "next/link";
|
||||
import { useState, useEffect } from "react";
|
||||
import { DialogContent, Dialog } from "@/components/ui/dialog";
|
||||
import AffiliatePopup from "@/components/misc/AffiliatePopup";
|
||||
import { Gradient } from "stripe-gradient";
|
||||
|
||||
export const defaultBanners: {
|
||||
bannerSpace: number;
|
||||
bannerContent: React.ReactNode;
|
||||
}[] = [
|
||||
// The sponsor banner ALWAYS has to be first.
|
||||
// {
|
||||
// bannerSpace: 2,
|
||||
// bannerContent: (
|
||||
// <MainBanner size={2} className="max-h-[4rem] border-0">
|
||||
// {" "}
|
||||
// <GradientBanner>
|
||||
// <strong>???</strong> — <i>an official affiliate of MHSF</i>{" "}
|
||||
// <br />
|
||||
// Lorem ipsum odor amet, consectetuer adipiscing elit. — check it out
|
||||
// </GradientBanner>
|
||||
// </MainBanner>
|
||||
// ),
|
||||
// },
|
||||
// The affilation banner ALWAYS has to be first.
|
||||
{
|
||||
bannerSpace: 2,
|
||||
bannerContent: (
|
||||
<>
|
||||
<AffiliateBanner />
|
||||
</>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
function AffiliateBanner() {
|
||||
const [isOpen, setOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const gradient = new Gradient();
|
||||
|
||||
const initializeGradient = () => {
|
||||
const canvasElement = document.getElementById(
|
||||
"gradient-dialog"
|
||||
) as HTMLCanvasElement;
|
||||
if (canvasElement) gradient.initGradient("#gradient-dialog");
|
||||
};
|
||||
|
||||
if (isOpen) {
|
||||
const timeoutId = setTimeout(initializeGradient, 100); // Delay to ensure canvas is ready
|
||||
return () => clearTimeout(timeoutId); // Cleanup timeout
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Dialog open={isOpen} onOpenChange={setOpen}>
|
||||
<DialogContent>
|
||||
<>
|
||||
<canvas
|
||||
id="gradient-dialog"
|
||||
className="h-full absolute w-[512px] rounded blur-sm"
|
||||
style={
|
||||
{
|
||||
"--gradient-color-1": "#6ec3f4",
|
||||
"--gradient-color-2": "#3a3aff",
|
||||
"--gradient-color-3": "#ff61ab",
|
||||
"--gradient-color-4": "#E63946",
|
||||
webKitMaskImage:
|
||||
"linear-gradient(to top, black 0%, transparent 25%, transparent 80%, black 100%)",
|
||||
maskImage:
|
||||
"linear-gradient(to top, black 0%, transparent 25%, transparent 80%, black 100%)",
|
||||
} as React.CSSProperties
|
||||
}
|
||||
/>
|
||||
<div className="relative z-10">
|
||||
<AffiliatePopup />
|
||||
</div>
|
||||
</>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
<div onClick={() => setOpen(true)} className="cursor-pointer">
|
||||
<MainBanner size={2} className="max-h-[4rem] border-0">
|
||||
<GradientBanner>
|
||||
<strong>CoreBoxx</strong> — <i>an official affiliate of MHSF</i>{" "}
|
||||
<br />
|
||||
Season 3 is out the doors for the best box server on Minehut
|
||||
</GradientBanner>
|
||||
</MainBanner>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export const bannerHooks: (() =>
|
||||
| { bannerSpace: number; bannerContent: React.ReactNode }
|
||||
| undefined)[] = [
|
||||
() => {
|
||||
// if (process.env.NEXT_PUBLIC_VERCEL_ENV !== "production")
|
||||
// return {
|
||||
// bannerSpace: 1,
|
||||
// bannerContent: (
|
||||
// <MainBanner className="bg-orange-600">
|
||||
// Your not in production!{" "}
|
||||
// <Link href="https://mhsf.app">
|
||||
// <Button variant="link" className="dark:text-black">
|
||||
// Go to production
|
||||
// </Button>
|
||||
// </Link>
|
||||
// </MainBanner>
|
||||
// ),
|
||||
// };
|
||||
if (process.env.NEXT_PUBLIC_VERCEL_ENV !== "production")
|
||||
return {
|
||||
bannerSpace: 1,
|
||||
bannerContent: (
|
||||
<MainBanner className="bg-orange-600">
|
||||
Your not in production!{" "}
|
||||
<Link href="https://mhsf.app">
|
||||
<Button variant="link" className="dark:text-black">
|
||||
Go to production
|
||||
</Button>
|
||||
</Link>
|
||||
</MainBanner>
|
||||
),
|
||||
};
|
||||
return undefined;
|
||||
},
|
||||
];
|
||||
|
||||
@ -39,14 +39,14 @@ import { Achievement } from "./types/achievement";
|
||||
|
||||
const connector = (
|
||||
endpoint: string,
|
||||
options: { version: number; starting?: string },
|
||||
options: { version: number; starting?: string }
|
||||
) =>
|
||||
`${options.starting == undefined ? "/" : `${options.starting}/`}api/v${options.version}${endpoint}`;
|
||||
|
||||
async function apiConstructor<K>(
|
||||
connector: string,
|
||||
requestInit: RequestInit,
|
||||
modifier: (data: any) => K,
|
||||
modifier: (data: any) => K
|
||||
): Promise<K> {
|
||||
try {
|
||||
const response = await fetch(connector, requestInit);
|
||||
@ -60,7 +60,7 @@ async function apiConstructor<K>(
|
||||
}
|
||||
}
|
||||
export async function getMOTDFromServer(
|
||||
list: Array<{ server: string; motd: string }>,
|
||||
list: Array<{ server: string; motd: string }>
|
||||
): Promise<Array<{ server: string; motd: string }>> {
|
||||
const result = await fetch(
|
||||
process.env.NEXT_PUBLIC_ALTERNATE_MOTD_ENDPOINT ??
|
||||
@ -71,15 +71,26 @@ export async function getMOTDFromServer(
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
let json = await result.json();
|
||||
return json.result;
|
||||
}
|
||||
|
||||
export async function getRelativeServerData(
|
||||
server: string
|
||||
): Promise<Array<{ date: string; relativePrecentage: number }>> {
|
||||
const result = await fetch(
|
||||
connector("/history/" + server + "/get-relative-data", { version: 0 })
|
||||
);
|
||||
|
||||
const json = await result.json();
|
||||
return json.data;
|
||||
}
|
||||
|
||||
export async function getCommunityServerFavorites(
|
||||
server: string,
|
||||
server: string
|
||||
): Promise<number> {
|
||||
const result = await fetch(
|
||||
connector(`/favorites/${server}/community-favorites`, { version: 0 }),
|
||||
@ -88,7 +99,7 @@ export async function getCommunityServerFavorites(
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
let json = await result.json();
|
||||
@ -105,7 +116,7 @@ export async function favoriteServer(server: string) {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
} catch {
|
||||
throw Error("Not authenticated with a user.");
|
||||
@ -122,7 +133,7 @@ export async function isFavorited(server: string): Promise<boolean> {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return (await response.json()).result;
|
||||
@ -141,7 +152,7 @@ export async function getAccountFavorites(): Promise<Array<string>> {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return (await response.json()).result;
|
||||
@ -155,7 +166,7 @@ export async function getAccountFavorites(): Promise<Array<string>> {
|
||||
*/
|
||||
export async function getHistoricalData(
|
||||
server: string,
|
||||
scopes: Array<"player_count" | "favorites" | "server" | "time">,
|
||||
scopes: Array<"player_count" | "favorites" | "server" | "time">
|
||||
): Promise<
|
||||
Array<{
|
||||
player_count?: number;
|
||||
@ -172,7 +183,7 @@ export async function getHistoricalData(
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return (await response.json()).data;
|
||||
@ -180,15 +191,16 @@ export async function getHistoricalData(
|
||||
|
||||
export async function getShortTermData(
|
||||
server: string,
|
||||
scopes: Array<"player_count" | "favorites" | "server" | "date">,
|
||||
): Promise<
|
||||
Array<{
|
||||
scopes: Array<"player_count" | "favorites" | "server" | "date">
|
||||
): Promise<{
|
||||
data: Array<{
|
||||
player_count?: number;
|
||||
favorites?: number;
|
||||
server?: string;
|
||||
time?: number;
|
||||
}>
|
||||
> {
|
||||
}>;
|
||||
dataMax: number;
|
||||
}> {
|
||||
const response = await fetch(
|
||||
connector(`/history/${server}/get-short-term-data`, { version: 0 }),
|
||||
{
|
||||
@ -197,14 +209,14 @@ export async function getShortTermData(
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return (await response.json()).data;
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
export async function getMetaShortTerm(
|
||||
scopes: Array<"total_players" | "total_servers" | "date">,
|
||||
scopes: Array<"total_players" | "total_servers" | "date">
|
||||
): Promise<
|
||||
Array<{
|
||||
total_players?: number;
|
||||
@ -220,7 +232,7 @@ export async function getMetaShortTerm(
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return (await response.json()).data;
|
||||
@ -237,7 +249,7 @@ export async function linkMCAccount(code: string): Promise<string | undefined> {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ code }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (response.status == 400) {
|
||||
@ -260,13 +272,13 @@ export async function unlinkMCAccount(): Promise<boolean> {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return true;
|
||||
} catch {
|
||||
throw Error(
|
||||
"Not authenticated with a user or user already linked account.",
|
||||
"Not authenticated with a user or user already linked account."
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -281,7 +293,7 @@ export async function serverOwned(server: string): Promise<boolean> {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ server }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return (await response.json()).owned;
|
||||
@ -301,7 +313,7 @@ export async function userOwnedServer(server: string): Promise<boolean> {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ server }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return (await response.json()).result;
|
||||
@ -321,7 +333,7 @@ export async function ownServer(server: string): Promise<boolean> {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ server }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (response.status >= 400) {
|
||||
@ -345,7 +357,7 @@ export async function unownServer(server: string): Promise<boolean> {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ server }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (response.status == 400) {
|
||||
@ -361,7 +373,7 @@ export async function unownServer(server: string): Promise<boolean> {
|
||||
/** requires authentication */
|
||||
export async function setCustomization(
|
||||
server: string,
|
||||
customization: any,
|
||||
customization: any
|
||||
): Promise<boolean | Error> {
|
||||
try {
|
||||
const response = await fetch(
|
||||
@ -372,7 +384,7 @@ export async function setCustomization(
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ customization }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (response.status == 400) {
|
||||
@ -395,7 +407,7 @@ export async function getCustomization(server: string): Promise<any> {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (response.status == 400) {
|
||||
@ -419,7 +431,7 @@ export async function sortedFavorites(): Promise<
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (response.status == 400) {
|
||||
@ -434,7 +446,7 @@ export async function sortedFavorites(): Promise<
|
||||
|
||||
export async function reportServer(
|
||||
server: string,
|
||||
reason: string,
|
||||
reason: string
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
const response = await fetch(connector(`/report-server`, { version: 1 }), {
|
||||
@ -457,7 +469,7 @@ export async function reportServer(
|
||||
|
||||
export async function setAccountSL(
|
||||
data: number | boolean | null,
|
||||
type: "srv" | "ipr" | "pad",
|
||||
type: "srv" | "ipr" | "pad"
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
const response = await fetch(
|
||||
@ -468,7 +480,7 @@ export async function setAccountSL(
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ data, type }),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (response.status === 400) {
|
||||
@ -485,5 +497,5 @@ export const getAchievements = async (server: string) =>
|
||||
apiConstructor<{ _id: string; name: string; achievements: Achievement[] }[]>(
|
||||
connector(`/achievements/${server}`, { version: 0 }),
|
||||
{},
|
||||
(data) => data.result,
|
||||
(data) => data.result
|
||||
);
|
||||
|
||||
@ -27,3 +27,24 @@
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export function useServerExists(server: string) {
|
||||
const [serverExists, setServerExists] = useState(true);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
fetch("https://api.minehut.com/server/" + server + "?byName=true")
|
||||
.then((c) => c.json())
|
||||
.then((d) => {
|
||||
setServerExists(d.server != null);
|
||||
setLoading(false);
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
serverExists,
|
||||
loading,
|
||||
};
|
||||
}
|
||||
@ -5,7 +5,7 @@ import MiniMessage from "minimessage-js";
|
||||
var numberOfItemsInView = 20;
|
||||
|
||||
export default class ServersList {
|
||||
private servers: Array<OnlineServer> = [];
|
||||
servers: Array<OnlineServer> = [];
|
||||
currentServers: Array<OnlineServer> = [];
|
||||
private filters: Array<(server: OnlineServer) => Promise<boolean>> = [];
|
||||
extraData: any = { total_players: 0, total_servers: 0 };
|
||||
|
||||
97
src/pages/api/v0/history/[server]/get-relative-data.ts
Normal file
97
src/pages/api/v0/history/[server]/get-relative-data.ts
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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.
|
||||
*//*
|
||||
* MHSF, Minehut Server List
|
||||
* All external content is rather licensed under the ECA Agreement
|
||||
* located here: https://list.mlnehut.com/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.
|
||||
*/
|
||||
|
||||
import { MongoClient } from "mongodb";
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
const client = new MongoClient(process.env.MONGO_DB as string);
|
||||
const db = client.db("mhsf").collection("history");
|
||||
const mh = client.db("mhsf").collection("mh");
|
||||
const server = req.query.server as string;
|
||||
|
||||
const allData = await db.find({ server }).toArray();
|
||||
const data: any[] = [];
|
||||
if (server === "peww") console.log(allData.slice(-30));
|
||||
|
||||
for (const d of allData.slice(-30)) {
|
||||
const dateOfEntry = new Date(d.date);
|
||||
const result = await mh
|
||||
.find({
|
||||
date: {
|
||||
$gte: new Date(dateOfEntry.getTime() - 1000 * 60 * 60),
|
||||
$lt: new Date(dateOfEntry.getTime() + 1000 * 60 * 60),
|
||||
},
|
||||
})
|
||||
.toArray();
|
||||
|
||||
if (result.length > 0) {
|
||||
const resultedData = result[0];
|
||||
data.push({
|
||||
relativePrecentage: d.player_count / resultedData.total_players,
|
||||
date: dateOfEntry,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
client.close();
|
||||
res.send({ data });
|
||||
}
|
||||
@ -38,11 +38,16 @@ export default async function handler(
|
||||
const client = new MongoClient(process.env.MONGO_DB as string);
|
||||
const db = client.db("mhsf").collection("history");
|
||||
const server = req.query.server as string;
|
||||
let dataMax = 0;
|
||||
const scopes: Array<string> = checkForInfoOrLeave(res, req.body.scopes);
|
||||
|
||||
const allData = await db.find({ server }).toArray();
|
||||
const data: any[] = [];
|
||||
|
||||
dataMax = (
|
||||
await db.find({ server }).sort({ player_count: -1 }).limit(1).toArray()
|
||||
)[0].player_count;
|
||||
|
||||
allData.forEach((d) => {
|
||||
const result: any = {};
|
||||
scopes.forEach((b) => {
|
||||
@ -52,7 +57,7 @@ export default async function handler(
|
||||
});
|
||||
|
||||
client.close();
|
||||
res.send({ data });
|
||||
res.send({ data, dataMax });
|
||||
}
|
||||
|
||||
function checkForInfoOrLeave(res: NextApiResponse, info: any) {
|
||||
|
||||
20
yarn.lock
20
yarn.lock
@ -2639,6 +2639,26 @@ acorn@^8.9.0:
|
||||
resolved "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz"
|
||||
integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==
|
||||
|
||||
ag-charts-types@11.0.3:
|
||||
version "11.0.3"
|
||||
resolved "https://registry.yarnpkg.com/ag-charts-types/-/ag-charts-types-11.0.3.tgz#a4aa4825b298014c1323a1e5832dec0ef4e5e135"
|
||||
integrity sha512-q7O2viQXPyO014QVH7KjFCUmQ/NvMBx9ReZtramQ44u+/aAa0ttLi/coK+V0Hse4/MG1eB/2XhgymdooQ0Kalg==
|
||||
|
||||
ag-grid-community@33.0.3:
|
||||
version "33.0.3"
|
||||
resolved "https://registry.yarnpkg.com/ag-grid-community/-/ag-grid-community-33.0.3.tgz#51511d5b048eedf24b3de596967e74a3272bfe88"
|
||||
integrity sha512-HZeVmVieZ5Gm9j09Itecqm+OIX8X6cU4TJToUbsXv3DxdO9SK5/s8aAJAwBHtNRXOhHrhqQYwrY2yc3OtzWwcQ==
|
||||
dependencies:
|
||||
ag-charts-types "11.0.3"
|
||||
|
||||
ag-grid-react@^33.0.3:
|
||||
version "33.0.3"
|
||||
resolved "https://registry.yarnpkg.com/ag-grid-react/-/ag-grid-react-33.0.3.tgz#24f0c65ba48363e53db915aab13bb537b8e35025"
|
||||
integrity sha512-6IcraSVqsUG/hzTeZ0D0dtddAcZKcWdN75ek/O+lCA6r22abJPe33nHBYVezkTV8k6D3JhA24mlTwduzn0GZLQ==
|
||||
dependencies:
|
||||
ag-grid-community "33.0.3"
|
||||
prop-types "^15.8.1"
|
||||
|
||||
ajv@^6.12.4:
|
||||
version "6.12.6"
|
||||
resolved "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user