changed form reset and fixed systemvoice

This commit is contained in:
Polaris
2024-08-26 20:06:33 -04:00
parent bfe2403076
commit e22708f98a
9 changed files with 19 additions and 79 deletions

View File

@ -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;

View File

@ -87,22 +87,15 @@ export const SystemVoiceCustomization: FC<SystemVoiceSelectionProps> = ({
updatePlayerSystemVoiceId(newSystemVoiceId).then(() => {
setSytemVoiceId(newSystemVoiceId);
});
resetFormValues();
toast({
title: "You submitted the following values:",
description: (
<pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
<code className="text-white">{JSON.stringify(data, null, 2)}</code>
<pre className="rounded-mdp-4 mt-2 w-[340px]">
<code className="text-white">System voice updated</code>
</pre>
),
});
function resetFormValues() {
form.reset({
PlayerSystemVoice: undefined,
});
}
}
const getTexture = (id: number | undefined, defaultSrc: string) => {
@ -116,7 +109,7 @@ export const SystemVoiceCustomization: FC<SystemVoiceSelectionProps> = ({
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`,
},
};