From e22708f98a845f82d9da8fdf5c96816834f0ac70 Mon Sep 17 00:00:00 2001 From: Polaris Date: Mon, 26 Aug 2024 20:06:33 -0400 Subject: [PATCH] changed form reset and fixed systemvoice --- .../avatarcustomization/page.tsx | 16 ++-------------- .../mapiconcustomization/actions.ts | 4 ++-- .../mapiconcustomization/page.tsx | 13 +++---------- .../nameplatecustomization/actions.ts | 2 -- .../nameplatecustomization/page.tsx | 11 ++--------- .../systemvoicecustomization/actions.ts | 18 +----------------- .../systemvoicecustomization/page.tsx | 13 +++---------- .../trophycustomization/actions.ts | 10 ++++------ .../trophycustomization/page.tsx | 11 ++--------- 9 files changed, 19 insertions(+), 79 deletions(-) diff --git a/components/(customization)/avatarcustomization/page.tsx b/components/(customization)/avatarcustomization/page.tsx index 31576b0..3749822 100644 --- a/components/(customization)/avatarcustomization/page.tsx +++ b/components/(customization)/avatarcustomization/page.tsx @@ -142,14 +142,11 @@ export const AvatarCustomization: FC = ({ toast({ title: "Avatar updated successfully!", description: ( -
-              
-                {JSON.stringify(data, null, 2)}
-              
+            
+              
Avatar updated
), }); - resetFormValues(); }) .catch((error) => { toast({ @@ -160,15 +157,6 @@ export const AvatarCustomization: FC = ({ }); } - function resetFormValues() { - form.reset({ - AvatarHeadAccessory: undefined, - AvatarFaceAccessory: undefined, - AvatarItemAccessory: undefined, - AvatarBackAccessory: undefined, - AvatarWearAccessory: undefined, - }); - } const getTexture = (id: number | undefined, defaultSrc: string) => { return id ? getAvatarTextureSrc(id) : defaultSrc; }; diff --git a/components/(customization)/mapiconcustomization/actions.ts b/components/(customization)/mapiconcustomization/actions.ts index 4a10439..48b2ec7 100644 --- a/components/(customization)/mapiconcustomization/actions.ts +++ b/components/(customization)/mapiconcustomization/actions.ts @@ -33,7 +33,7 @@ export async function updatePlayerMapIcon(mapIconId?: number) { } if (mapIconId === undefined) { - throw new Error("nameplateId is required"); + throw new Error("map icon is required"); } try { @@ -51,7 +51,7 @@ export async function updatePlayerMapIcon(mapIconId?: number) { return updatePlayerMapIconId; } catch (error) { - console.error("Error updating nameplate:", error); + console.error("Error updating map icon:", error); throw error; } } diff --git a/components/(customization)/mapiconcustomization/page.tsx b/components/(customization)/mapiconcustomization/page.tsx index 4eb2e45..7a408c2 100644 --- a/components/(customization)/mapiconcustomization/page.tsx +++ b/components/(customization)/mapiconcustomization/page.tsx @@ -64,7 +64,7 @@ export const MapIconCustomization: FC = ({ try { const data = await getCurrentMapIcon(); if (data.length > 0) { - setMapIconId(data[0].mapIconId ?? undefined); // Handle null as undefined + setMapIconId(data[0].mapIconId ?? undefined); form.setValue("mapIconId", data[0].mapIconId as number); } } catch (error) { @@ -82,22 +82,15 @@ export const MapIconCustomization: FC = ({ updatePlayerMapIcon(newMapIconId).then(() => { setMapIconId(newMapIconId); }); - resetFormValues(); toast({ title: "You submitted the following values:", description: ( -
-          {JSON.stringify(data, null, 2)}
+        
+          
Map icon updated
), }); - - function resetFormValues() { - form.reset({ - mapIconId: undefined, - }); - } } const getTexture = (id: number | undefined, defaultSrc: string) => { diff --git a/components/(customization)/nameplatecustomization/actions.ts b/components/(customization)/nameplatecustomization/actions.ts index f365022..fa722ed 100644 --- a/components/(customization)/nameplatecustomization/actions.ts +++ b/components/(customization)/nameplatecustomization/actions.ts @@ -49,8 +49,6 @@ export async function updatePlayerNamePlate(nameplateId?: number) { }, }); - console.log(updatePlayerNameplate); - return updatePlayerNameplate; } catch (error) { console.error("Error updating nameplate:", error); diff --git a/components/(customization)/nameplatecustomization/page.tsx b/components/(customization)/nameplatecustomization/page.tsx index fc58bea..e92870e 100644 --- a/components/(customization)/nameplatecustomization/page.tsx +++ b/components/(customization)/nameplatecustomization/page.tsx @@ -84,22 +84,15 @@ export const NameplateCustomization: FC = ({ updatePlayerNamePlate(newNamePlateId).then(() => { setNameplateId(newNamePlateId); }); - resetFormValues(); toast({ title: "You submitted the following values:", description: ( -
-          {JSON.stringify(data, null, 2)}
+        
+          Nameplate updated
         
), }); - - function resetFormValues() { - form.reset({ - nameplateId: undefined, - }); - } } const getTexture = (id: number | undefined, defaultSrc: string) => { diff --git a/components/(customization)/systemvoicecustomization/actions.ts b/components/(customization)/systemvoicecustomization/actions.ts index 823d255..2a2a064 100644 --- a/components/(customization)/systemvoicecustomization/actions.ts +++ b/components/(customization)/systemvoicecustomization/actions.ts @@ -36,20 +36,6 @@ export async function updatePlayerSystemVoiceId(voiceId: number) { throw new Error("nameplateId is required"); } - const checkIfSystemVoiceIsUnlocked = await artemis.chuni_item_item.findMany({ - where: { - itemKind: 10, - user: user.UserId, - }, - select: { - itemId: true, - }, - }); - - const unlockedSystemVoices = checkIfSystemVoiceIsUnlocked.map( - (item) => item.itemId, - ); - try { const updatePlayerNameplate = await artemis.chuni_profile_data.update({ where: { @@ -63,9 +49,7 @@ export async function updatePlayerSystemVoiceId(voiceId: number) { }, }); - console.log(updatePlayerNameplate); - - return unlockedSystemVoices; + return updatePlayerNameplate; } catch (error) { console.error("Error updating nameplate:", error); throw error; diff --git a/components/(customization)/systemvoicecustomization/page.tsx b/components/(customization)/systemvoicecustomization/page.tsx index 1a3fdf8..63a52f1 100644 --- a/components/(customization)/systemvoicecustomization/page.tsx +++ b/components/(customization)/systemvoicecustomization/page.tsx @@ -87,22 +87,15 @@ export const SystemVoiceCustomization: FC = ({ updatePlayerSystemVoiceId(newSystemVoiceId).then(() => { setSytemVoiceId(newSystemVoiceId); }); - resetFormValues(); toast({ title: "You submitted the following values:", description: ( -
-          {JSON.stringify(data, null, 2)}
+        
+          System voice updated
         
), }); - - function resetFormValues() { - form.reset({ - PlayerSystemVoice: undefined, - }); - } } const getTexture = (id: number | undefined, defaultSrc: string) => { @@ -116,7 +109,7 @@ export const SystemVoiceCustomization: FC = ({ form.watch("PlayerSystemVoice"), `systemVoiceThumbnails/CHU_UI_SystemVoice_${systemVoiceId.toString().padStart(8, "0")}.png`, ) - : `systemVoiceThumbnails/CHU_UI_SystemVoice_Default.png`, // Provide a default texture or handle the case when systemVoiceId is undefined + : `systemVoiceThumbnails/CHU_UI_SystemVoice_Default.png`, }, }; diff --git a/components/(customization)/trophycustomization/actions.ts b/components/(customization)/trophycustomization/actions.ts index d303a69..7427940 100644 --- a/components/(customization)/trophycustomization/actions.ts +++ b/components/(customization)/trophycustomization/actions.ts @@ -33,11 +33,11 @@ export async function updatePlayerTrophy(trophyId: number) { } if (trophyId === undefined) { - throw new Error("nameplateId is required"); + throw new Error("trophy is required"); } try { - const updatePlayerNameplate = await artemis.chuni_profile_data.update({ + const updatePlayerTrophies = await artemis.chuni_profile_data.update({ where: { user_version: { user: user.UserId, @@ -49,11 +49,9 @@ export async function updatePlayerTrophy(trophyId: number) { }, }); - console.log(updatePlayerNameplate); - - return updatePlayerNameplate; + return updatePlayerTrophies; } catch (error) { - console.error("Error updating nameplate:", error); + console.error("Error updating trophy:", error); throw error; } } diff --git a/components/(customization)/trophycustomization/page.tsx b/components/(customization)/trophycustomization/page.tsx index 88d18ca..cfe6212 100644 --- a/components/(customization)/trophycustomization/page.tsx +++ b/components/(customization)/trophycustomization/page.tsx @@ -78,22 +78,15 @@ export const TrophyCustomization: FC = ({ updatePlayerTrophy(newNamePlateId).then(() => { setTrophyId(newNamePlateId); }); - resetFormValues(); toast({ title: "You submitted the following values:", description: ( -
-          {JSON.stringify(data, null, 2)}
+        
+          Trophy updated
         
), }); - - function resetFormValues() { - form.reset({ - trophies: undefined, - }); - } } return (