many many many many changes

This commit is contained in:
Lee
2023-10-19 14:17:55 +01:00
parent 6acf6e8635
commit a031451fa3
36 changed files with 2743 additions and 174 deletions

View File

@ -1,12 +1,38 @@
import { connectMongo } from "@/database/mongo";
import { PlayerSchema } from "@/database/schemas/player";
import { triggerClient } from "@/trigger";
import * as Utils from "@/utils/numberUtils";
export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
const id = searchParams.get("id");
if (!id) {
return Response.json({ message: "No player provided" });
// Checks if there was an account provided
return Response.json({ error: true, message: "No player provided" });
}
// Simple account id validation
const isNumber = Utils.isNumber(id);
if (!isNumber) {
return Response.json({
error: true,
message: "Provided account id is not a number",
});
}
// Ensure we're connected to the database
await connectMongo();
// Checks if the player is already in the database
const player = await PlayerSchema.findById(id);
if (player !== null) {
return Response.json({
error: true,
message: "Account already exists",
});
}
// Send the event to Trigger to setup the user
triggerClient.sendEvent({
name: "user.add",
payload: {
@ -14,5 +40,8 @@ export async function GET(request: Request) {
},
});
return Response.json({ message: "Hello from Next.js!" });
return Response.json({
error: false,
message: "We're setting up your account",
});
}

View File

@ -0,0 +1,19 @@
import { searchByName } from "@/utils/scoresaber/api";
export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
const name = searchParams.get("name");
if (!name) {
return Response.json({ error: true, message: "No player provided" });
}
const players = await searchByName(name);
if (players === undefined) {
return Response.json({
error: true,
message: "No players with that name were found",
});
}
return Response.json({ error: false, players: players });
}

View File

@ -1,8 +1,9 @@
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import Image from "next/image";
import "./globals.css";
const inter = Inter({ subsets: ["latin"] });
const font = Inter({ subsets: ["latin-ext"], weight: "500" });
export const metadata: Metadata = {
title: {
@ -18,7 +19,20 @@ export default function RootLayout({
}) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
<body className={font.className}>
<div className="fixed left-0 top-0 z-0 h-full w-full blur-sm">
<Image
alt="Background image"
src={"https://cdn.fascinated.cc/W9jC5MLf.jpg"}
layout="fill"
objectFit="cover"
objectPosition="center"
quality={100}
/>
</div>
{children}
</body>
</html>
);
}

View File

@ -1,7 +1,7 @@
import Avatar from "@/components/Avatar";
import Container from "@/components/Container";
import { MagnifyingGlassIcon } from "@heroicons/react/24/solid";
import SearchPlayer from "@/components/SearchPlayer";
import { Metadata } from "next";
export const metadata: Metadata = {
@ -12,7 +12,7 @@ export default function Home() {
return (
<main>
<Container>
<div className="mt-2 bg-neutral-800 w-full flex flex-col items-center justify-center rounded-sm">
<div className="mt-2 flex w-full flex-col items-center justify-center rounded-sm bg-neutral-800">
<Avatar
className="m-6"
label="Player Avatar"
@ -22,20 +22,7 @@ export default function Home() {
<p className="text-xl">Stranger</p>
<p className="text mt-2">Find a player profile</p>
<form className="mt-6 flex gap-2">
<input
className="bg-transparent text-xs outline-none min-w-[14rem] border-b"
type="text"
placeholder="Enter a name or ScoreSaber profile..."
/>
<button className="bg-blue-600 hover:opacity-80 transition-all transform-gpu rounded-md p-1">
<MagnifyingGlassIcon
className="font-black"
width={18}
height={18}
/>
</button>
</form>
<SearchPlayer />
<div className="mb-6"></div>
</div>