forked from PolarisPyra/daphnis
changed form reset and fixed systemvoice
This commit is contained in:
parent
bfe2403076
commit
e22708f98a
@ -142,14 +142,11 @@ export const AvatarCustomization: FC<AvatarSelectionProps> = ({
|
||||
toast({
|
||||
title: "Avatar updated successfully!",
|
||||
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="mt-2 w-[340px] rounded-md p-4">
|
||||
<div className="text-white">Avatar updated</div>
|
||||
</pre>
|
||||
),
|
||||
});
|
||||
resetFormValues();
|
||||
})
|
||||
.catch((error) => {
|
||||
toast({
|
||||
@ -160,15 +157,6 @@ export const AvatarCustomization: FC<AvatarSelectionProps> = ({
|
||||
});
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ export const MapIconCustomization: FC<SystemVoiceSelectionProps> = ({
|
||||
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<SystemVoiceSelectionProps> = ({
|
||||
updatePlayerMapIcon(newMapIconId).then(() => {
|
||||
setMapIconId(newMapIconId);
|
||||
});
|
||||
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="mt-2 w-[340px] rounded-md p-4">
|
||||
<div className="text-white">Map icon updated</div>
|
||||
</pre>
|
||||
),
|
||||
});
|
||||
|
||||
function resetFormValues() {
|
||||
form.reset({
|
||||
mapIconId: undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const getTexture = (id: number | undefined, defaultSrc: string) => {
|
||||
|
@ -49,8 +49,6 @@ export async function updatePlayerNamePlate(nameplateId?: number) {
|
||||
},
|
||||
});
|
||||
|
||||
console.log(updatePlayerNameplate);
|
||||
|
||||
return updatePlayerNameplate;
|
||||
} catch (error) {
|
||||
console.error("Error updating nameplate:", error);
|
||||
|
@ -84,22 +84,15 @@ export const NameplateCustomization: FC<NamePlateSelectionProps> = ({
|
||||
updatePlayerNamePlate(newNamePlateId).then(() => {
|
||||
setNameplateId(newNamePlateId);
|
||||
});
|
||||
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="mt-2 w-[340px] rounded-md p-4">
|
||||
<code className="text-white">Nameplate updated</code>
|
||||
</pre>
|
||||
),
|
||||
});
|
||||
|
||||
function resetFormValues() {
|
||||
form.reset({
|
||||
nameplateId: undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const getTexture = (id: number | undefined, defaultSrc: string) => {
|
||||
|
@ -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;
|
||||
|
@ -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`,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -78,22 +78,15 @@ export const TrophyCustomization: FC<AvatarSelectionProps> = ({
|
||||
updatePlayerTrophy(newNamePlateId).then(() => {
|
||||
setTrophyId(newNamePlateId);
|
||||
});
|
||||
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="mt-2 w-[340px] rounded-md p-4">
|
||||
<code className="text-white">Trophy updated</code>
|
||||
</pre>
|
||||
),
|
||||
});
|
||||
|
||||
function resetFormValues() {
|
||||
form.reset({
|
||||
trophies: undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user