From 23bbef4d001fcd7a497fa5a33b940aa00afa18a0 Mon Sep 17 00:00:00 2001 From: Polaris Date: Mon, 22 Jul 2024 20:59:17 -0400 Subject: [PATCH] reee --- app/(authenticated)/chunithm/page.tsx | 6 +- components/avatarcustomization/page.tsx | 170 +----------------------- lib/api.ts | 52 +++++++- 3 files changed, 55 insertions(+), 173 deletions(-) diff --git a/app/(authenticated)/chunithm/page.tsx b/app/(authenticated)/chunithm/page.tsx index 7f9c446..b9acb8d 100644 --- a/app/(authenticated)/chunithm/page.tsx +++ b/app/(authenticated)/chunithm/page.tsx @@ -1,4 +1,4 @@ -import { AvatarCustomization } from "@/components/avatarcustomization/page"; +import AvatarCustomization from "@/components/avatarcustomization/page"; import ChunithmScorePlaylog from "@/components/scoreplaylog/page"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; @@ -14,9 +14,7 @@ const ChunithmPage = () => { -
- -
+
diff --git a/components/avatarcustomization/page.tsx b/components/avatarcustomization/page.tsx index ae39fe3..ef49ffc 100644 --- a/components/avatarcustomization/page.tsx +++ b/components/avatarcustomization/page.tsx @@ -1,167 +1,7 @@ -"use client"; +import React from "react"; -import { zodResolver } from "@hookform/resolvers/zod"; -import { Check, ChevronsUpDown } from "lucide-react"; -import { useForm } from "react-hook-form"; -import { z } from "zod"; +const AvatarCustomization = () => { + return
AvatarCustomization
; +}; -import { cn } from "@/lib/utils"; -import { Button } from "@/components/ui/button"; -import { - Command, - CommandEmpty, - CommandGroup, - CommandInput, - CommandItem, - CommandList, -} from "@/components/ui/command"; -import { - Form, - FormControl, - FormDescription, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form"; -import { - Popover, - PopoverContent, - PopoverTrigger, -} from "@/components/ui/popover"; -import { toast } from "@/components/ui/use-toast"; -import { chuni_static_avatar } from "@/prisma/schemas/artemis/generated/artemis"; - -type chunithmAvatars = chuni_static_avatar; - -const AvatarParts = [ - { label: "Head", value: "avatarHead", src: "/path/to/head.png" }, - { label: "Body", value: "avatarBody", src: "/path/to/body.png" }, - { label: "Face", value: "avatarFace", src: "/path/to/face.png" }, - { label: "Back", value: "avatarBack", src: "/path/to/back.png" }, -] as const; - -const FormSchema = z.object({ - AvatarHead: z.string({ - required_error: "Please select a head item.", - }), - AvatarBody: z.string({ - required_error: "Please select a body item.", - }), - AvatarFace: z.string({ - required_error: "Please select a face item.", - }), - AvatarBack: z.string({ - required_error: "Please select a back item.", - }), -}); - -export function AvatarCustomization() { - const form = useForm>({ - resolver: zodResolver(FormSchema), - }); - - function onSubmit(data: z.infer) { - toast({ - title: "You submitted the following values:", - description: ( -
-          {JSON.stringify(data, null, 2)}
-        
- ), - }); - } - - return ( -
-
-
-
- {AvatarParts.map(({ value, src }) => ( -
- {value} -
- ))} -
-
-
-
- - {AvatarParts.map((part) => ( - } - render={({ field }) => ( - - {`Avatar ${part.label} Item`} - - - - - - - - - - - - No {part.label.toLowerCase()} item found. - - - {AvatarParts.map((item) => ( - { - form.setValue( - part.value as keyof z.infer< - typeof FormSchema - >, - item.value - ); - }} - > - - {item.label} - - ))} - - - - - - - - )} - /> - ))} - - - -
- ); -} +export default AvatarCustomization; diff --git a/lib/api.ts b/lib/api.ts index 7077690..8d45286 100644 --- a/lib/api.ts +++ b/lib/api.ts @@ -180,9 +180,10 @@ export async function getAllAimeCards() { return aimeUser; } - - -export async function getAvatarParts(avatarAccessoryId: number) { +export async function test(data?: FormData) { + console.log(data); +} +export async function setAvatarPart(avatarAccessoryId: number) { const { user } = await getAuth(); if (!user || !user.accessCode) { @@ -191,7 +192,7 @@ export async function getAvatarParts(avatarAccessoryId: number) { const avatarParts = await artemis.chuni_static_avatar.findMany({ where: { - avatarAccessoryId: avatarAccessoryId, + avatarAccessoryId: avatarAccessoryId }, select: { name: true, @@ -205,6 +206,49 @@ export async function getAvatarParts(avatarAccessoryId: number) { } +export async function GetSpecificAvatarParts(category: number) { + const { user } = await getAuth(); + + if (!user || !user.accessCode) { + throw new Error("User is not authenticated or accessCode is missing"); + } + + const avatarParts = await artemis.chuni_static_avatar.findMany({ + where: { category }, + select: { + name: true, + category: true, + version: true, + iconPath: true, + texturePath: true, + }, + }); + + return avatarParts; +} + +export async function getCurrentPlayerAvatarParts() { + const { user } = await getAuth(); + + if (!user || !user.accessCode) { + throw new Error("User is not authenticated or accessCode is missing"); + } + + const avatarParts = await artemis.chuni_profile_data.findMany({ + select: { + avatarBack: true, + avatarFace: true, + avatarItem: true, + avatarHead: true, + avatarWear: true, + }, + }); + + return avatarParts; +} + + + export async function verifyAimeCodeAgainstArtemis() { const { user } = await getAuth();