added display of current gameversion in the gameversion selection setting card

This commit is contained in:
Polaris 2024-08-25 17:05:09 -04:00
parent ee4ec5d651
commit 1004cdd742

View File

@ -36,11 +36,9 @@ type ChunithmGameVersionSelectionProps = {
gameVersions: { gameVersion: GameVersion }[];
};
};
export function PlayerChangableChunithmGameVersionSelection({
chunithmGameVersionNumber,
}: ChunithmGameVersionSelectionProps) {
export function PlayerChangableChunithmGameVersionSelection({}: ChunithmGameVersionSelectionProps) {
const FormSchema = z.object({
mapIconId: z.string({
gameVersion: z.string({
required_error: "Please select a Game Version.",
}),
});
@ -52,7 +50,7 @@ export function PlayerChangableChunithmGameVersionSelection({
string | undefined
>(Object.values(GameVersion)[0]);
function onSubmit(data: z.infer<typeof FormSchema>) {
const newGameVersion = data.mapIconId ?? selectedGameVersion;
const newGameVersion = data.gameVersion ?? selectedGameVersion;
// console.log("Submitted Game Version:", newGameVersion);
@ -72,7 +70,7 @@ export function PlayerChangableChunithmGameVersionSelection({
setSelectedGameVersion(newGameVersion);
form.reset({
mapIconId: undefined,
gameVersion: undefined,
});
})
.catch((error) => {
@ -94,10 +92,17 @@ export function PlayerChangableChunithmGameVersionSelection({
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
<FormField
control={form.control}
name="mapIconId"
name="gameVersion"
render={({ field }) => (
<FormItem className="flex flex-col">
<FormLabel className="pb-2">Chunithm</FormLabel>
<FormLabel className="pb-2">
Chunithm:
{selectedGameVersion
? GameVersion[
selectedGameVersion as keyof typeof GameVersion
]
: "No game version... Please select a game version"}
</FormLabel>{" "}
<Popover>
<PopoverTrigger asChild>
<FormControl>
@ -126,7 +131,7 @@ export function PlayerChangableChunithmGameVersionSelection({
value={version}
key={version}
onSelect={() => {
form.setValue("mapIconId", version);
form.setValue("gameVersion", version);
setSelectedGameVersion(version);
}}
>
@ -146,7 +151,6 @@ export function PlayerChangableChunithmGameVersionSelection({
</Command>
</PopoverContent>
</Popover>
<FormMessage />
</FormItem>
)}