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