added update functions
This commit is contained in:
@ -30,7 +30,7 @@ import { z } from "zod";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { toast } from "../../ui/use-toast";
|
||||
import { getCurrentTrophies } from "./actions";
|
||||
import { getCurrentTrophies, updatePlayerTrophy } from "./actions";
|
||||
import { cozynet_chuni_static_trophies } from "@/prisma/schemas/artemis/generated/artemis";
|
||||
const getAvatarTextureSrc = (id: number | undefined) => {
|
||||
if (id === undefined) return "";
|
||||
@ -76,6 +76,14 @@ export const TrophyCustomization: FC<AvatarSelectionProps> = ({
|
||||
}, []);
|
||||
|
||||
function onSubmit(data: z.infer<typeof FormSchema>) {
|
||||
const unchangedNamePlateId = trophyID;
|
||||
const newNamePlateId = data.trophies ?? unchangedNamePlateId;
|
||||
|
||||
updatePlayerTrophy(newNamePlateId).then(() => {
|
||||
setTrophyId(newNamePlateId);
|
||||
});
|
||||
resetFormValues();
|
||||
|
||||
toast({
|
||||
title: "You submitted the following values:",
|
||||
description: (
|
||||
@ -84,6 +92,12 @@ export const TrophyCustomization: FC<AvatarSelectionProps> = ({
|
||||
</pre>
|
||||
),
|
||||
});
|
||||
|
||||
function resetFormValues() {
|
||||
form.reset({
|
||||
trophies: undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
Reference in New Issue
Block a user