userbox v1

This commit is contained in:
Polaris
2024-07-26 15:15:13 -04:00
parent ce82e860bd
commit de16235316
7 changed files with 506 additions and 12 deletions

View File

@ -1,7 +1,6 @@
"use client";
import React, { FC, useEffect, useState } from "react";
import { chuni_static_avatar } from "@/prisma/schemas/artemis/generated/artemis";
import { Check, ChevronsUpDown } from "lucide-react";
import { getCurrentNameplate } from "./actions";
import { cn } from "@/lib/utils";
@ -64,7 +63,7 @@ export const NameplateCustomization: FC<AvatarSelectionProps> = ({
const [nameplateId, setNameplateId] = useState<number | undefined>(undefined);
useEffect(() => {
const fetchAvatarParts = async () => {
const fetchNamePlates = async () => {
try {
const data = await getCurrentNameplate();
if (data.length > 0) {
@ -75,7 +74,7 @@ export const NameplateCustomization: FC<AvatarSelectionProps> = ({
}
};
fetchAvatarParts();
fetchNamePlates();
}, []);
function onSubmit(data: z.infer<typeof FormSchema>) {
@ -95,11 +94,12 @@ export const NameplateCustomization: FC<AvatarSelectionProps> = ({
const AvatarTextures = {
AvatarHeadAccessory: {
src: getTexture(
form.watch("PlayerNamePlateId"),
`namePlates/CHU_UI_NamePlate_000${nameplateId}.png`
),
className: "avatar_head",
src: nameplateId
? getTexture(
form.watch("PlayerNamePlateId"),
`namePlates/CHU_UI_NamePlate_${nameplateId.toString().padStart(8, "0")}.png`
)
: `systemVoiceThumbnails/CHU_UI_SystemVoice_Default.png`,
},
};
@ -112,7 +112,7 @@ export const NameplateCustomization: FC<AvatarSelectionProps> = ({
name="PlayerNamePlateId"
render={({ field }) => (
<FormItem className="flex flex-col">
<FormLabel>Name plate Item</FormLabel>
<FormLabel>Select Nameplate</FormLabel>
<Popover>
<PopoverTrigger asChild>
<FormControl>
@ -128,7 +128,7 @@ export const NameplateCustomization: FC<AvatarSelectionProps> = ({
? playerNamePlateSelectionData.namePlates.find(
(part) => part.id === field.value
)?.str
: "Select Name plate Item"}
: "Select Name Plate"}
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
</Button>
</FormControl>