Fixed type bugs in Reports form
This commit is contained in:
@@ -17,10 +17,7 @@ export const deleteEvent = async (id: Event["id"]) => {
|
||||
};
|
||||
|
||||
export const upsertAppointment = async (
|
||||
eventAppointment: Prisma.XOR<
|
||||
Prisma.EventAppointmentCreateInput,
|
||||
Prisma.EventAppointmentUncheckedCreateInput
|
||||
>,
|
||||
eventAppointment: Prisma.EventAppointmentUncheckedCreateInput,
|
||||
) => {
|
||||
const newEventAppointment = eventAppointment.id
|
||||
? await prisma.eventAppointment.update({
|
||||
|
||||
@@ -5,7 +5,6 @@ import { useForm } from "react-hook-form";
|
||||
import { KEYWORD_CATEGORY, Keyword } from "@repo/db";
|
||||
import { FileText } from "lucide-react";
|
||||
import { Input } from "../../../../_components/ui/Input";
|
||||
import { useState } from "react";
|
||||
import { deleteKeyword, upsertKeyword } from "../action";
|
||||
import { Button } from "../../../../_components/ui/Button";
|
||||
import { redirect } from "next/navigation";
|
||||
@@ -17,7 +16,6 @@ export const KeywordForm = ({ keyword }: { keyword?: Keyword }) => {
|
||||
resolver: zodResolver(KeywordOptionalDefaultsSchema),
|
||||
defaultValues: keyword,
|
||||
});
|
||||
const [deleteLoading, setDeleteLoading] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<form
|
||||
@@ -28,13 +26,13 @@ export const KeywordForm = ({ keyword }: { keyword?: Keyword }) => {
|
||||
})}
|
||||
className="grid grid-cols-6 gap-3"
|
||||
>
|
||||
<div className="card bg-base-200 shadow-xl col-span-6 ">
|
||||
<div className="card bg-base-200 col-span-6 shadow-xl">
|
||||
<div className="card-body">
|
||||
<h2 className="card-title">
|
||||
<FileText className="w-5 h-5" /> Allgemeines
|
||||
<FileText className="h-5 w-5" /> Allgemeines
|
||||
</h2>
|
||||
<label className="form-control w-full">
|
||||
<span className="label-text text-lg flex items-center gap-2">Kategorie</span>
|
||||
<span className="label-text flex items-center gap-2 text-lg">Kategorie</span>
|
||||
<select
|
||||
className="input-sm select select-bordered select-sm w-full"
|
||||
{...form.register("category")}
|
||||
@@ -70,7 +68,7 @@ export const KeywordForm = ({ keyword }: { keyword?: Keyword }) => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="card bg-base-200 shadow-xl col-span-6">
|
||||
<div className="card bg-base-200 col-span-6 shadow-xl">
|
||||
<div className="card-body">
|
||||
<div className="flex w-full gap-4">
|
||||
<Button
|
||||
@@ -83,7 +81,6 @@ export const KeywordForm = ({ keyword }: { keyword?: Keyword }) => {
|
||||
{keyword && (
|
||||
<Button
|
||||
onClick={async () => {
|
||||
setDeleteLoading(true);
|
||||
await deleteKeyword(keyword.id);
|
||||
redirect("/admin/keyword");
|
||||
}}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"use client";
|
||||
import { createReport } from "(app)/admin/report/actions";
|
||||
import { getUser } from "(app)/admin/user/action";
|
||||
import { Prisma } from "@repo/db";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { Select } from "_components/ui/Select";
|
||||
import { useSession } from "next-auth/react";
|
||||
@@ -11,11 +10,13 @@ import { useForm } from "react-hook-form";
|
||||
import { TriangleAlert } from "lucide-react";
|
||||
import toast from "react-hot-toast";
|
||||
import { Button } from "@repo/shared-components";
|
||||
import { ReportOptionalDefaults, ReportOptionalDefaultsSchema } from "@repo/db/zod";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
export const NewReportForm = ({
|
||||
defaultValues,
|
||||
}: {
|
||||
defaultValues?: Partial<Prisma.XOR<Prisma.ReportCreateInput, Prisma.ReportUncheckedCreateInput>>;
|
||||
defaultValues?: Partial<ReportOptionalDefaults>;
|
||||
}) => {
|
||||
const session = useSession();
|
||||
const [search, setSearch] = useState("");
|
||||
@@ -34,12 +35,11 @@ export const NewReportForm = ({
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
const router = useRouter();
|
||||
const form = useForm<Prisma.ReportUncheckedCreateInput>({
|
||||
const form = useForm({
|
||||
resolver: zodResolver(ReportOptionalDefaultsSchema),
|
||||
defaultValues: {
|
||||
text: "",
|
||||
reportedUserRole: "USER",
|
||||
senderUserId: session.data?.user.id,
|
||||
...defaultValues,
|
||||
reportedUserId: defaultValues?.reportedUserId || "",
|
||||
senderUserId: session.data?.user.id || "",
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user