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