refactor: type EventPrizesManager form with EventPrizeInput

This commit is contained in:
openhands committed 2026-07-18 20:31:18 +02:00
1 parent 41f5269b4e
commit 0d027dba99
1 file changed
+5 -4
+5 -4
View File
@@ -16,6 +16,7 @@ import {
SelectValue, SelectValue,
} from "@/components/ui/select"; } from "@/components/ui/select";
import { useServerAction } from "@/hooks/use-server-action"; import { useServerAction } from "@/hooks/use-server-action";
import type { EventPrizeInput } from "@/lib/validators/event";
type PrizeType = "badge" | "credits" | "pixels" | "points" | "item"; type PrizeType = "badge" | "credits" | "pixels" | "points" | "item";
@@ -39,9 +40,10 @@ interface Props {
export function EventPrizesManager({ eventId, prizes }: Props) { export function EventPrizesManager({ eventId, prizes }: Props) {
const { run, isPending } = useServerAction(); const { run, isPending } = useServerAction();
const [showForm, setShowForm] = useState(false); const [showForm, setShowForm] = useState(false);
const [form, setForm] = useState({ const [form, setForm] = useState<EventPrizeInput>({
eventId,
position: prizes.length + 1, position: prizes.length + 1,
prizeType: "badge" as PrizeType, prizeType: "badge",
badgeCode: "", badgeCode: "",
credits: 0, credits: 0,
pixels: 0, pixels: 0,
@@ -51,8 +53,7 @@ export function EventPrizesManager({ eventId, prizes }: Props) {
function handleAdd(e: React.FormEvent) { function handleAdd(e: React.FormEvent) {
e.preventDefault(); e.preventDefault();
// biome-ignore lint/suspicious/noExplicitAny: explicitly chosen here, see surrounding code run(() => addEventPrize(form), {
run(() => addEventPrize({ eventId, ...form } as any), {
successMessage: "Prize added!", successMessage: "Prize added!",
onSuccess: () => { onSuccess: () => {
setShowForm(false); setShowForm(false);