added reports page
This commit is contained in:
@@ -3,11 +3,12 @@ import { ExclamationTriangleIcon, PaperPlaneIcon } from "@radix-ui/react-icons";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { cn } from "helpers/cn";
|
||||
import { serverApi } from "helpers/axios";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { useLeftMenuStore } from "_store/leftMenuStore";
|
||||
import { asPublicUser } from "@repo/db";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getConnectedUserAPI } from "querys/connected-user";
|
||||
import { sendReportAPI } from "querys/report";
|
||||
|
||||
export const Report = () => {
|
||||
const { setChatOpen, setReportTabOpen, reportTabOpen, setOwnId } =
|
||||
@@ -106,18 +107,18 @@ export const Report = () => {
|
||||
e.preventDefault();
|
||||
if (message.length < 1 || !selectedPlayer) return;
|
||||
setSending(true);
|
||||
serverApi("/report", {
|
||||
method: "POST",
|
||||
data: {
|
||||
message,
|
||||
to: selectedPlayer,
|
||||
},
|
||||
sendReportAPI({
|
||||
text: message,
|
||||
senderUserId: session.data!.user.id,
|
||||
reportedUserId: selectedPlayer,
|
||||
})
|
||||
.then(() => {
|
||||
toast.success("Report gesendet");
|
||||
setMessage("");
|
||||
setSending(false);
|
||||
})
|
||||
.catch(() => {
|
||||
.catch((err) => {
|
||||
toast.error(`Fehler beim Senden des Reports: ${err}`);
|
||||
setSending(false);
|
||||
});
|
||||
}}
|
||||
|
||||
19
apps/dispatch/app/querys/report.ts
Normal file
19
apps/dispatch/app/querys/report.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Prisma, Report } from "@repo/db";
|
||||
import { serverApi } from "helpers/axios";
|
||||
|
||||
export const sendReportAPI = async (
|
||||
report:
|
||||
| (Prisma.Without<
|
||||
Prisma.ReportCreateInput,
|
||||
Prisma.ReportUncheckedCreateInput
|
||||
> &
|
||||
Prisma.ReportUncheckedCreateInput)
|
||||
| (Prisma.Without<
|
||||
Prisma.ReportUncheckedCreateInput,
|
||||
Prisma.ReportCreateInput
|
||||
> &
|
||||
Prisma.ReportCreateInput),
|
||||
) => {
|
||||
const repsonse = await serverApi.put("/report", report);
|
||||
return repsonse.data as Report;
|
||||
};
|
||||
Reference in New Issue
Block a user