import { CheckCircleIcon } from "@heroicons/react/24/solid"; import { PostReportReason, useReportPostMutation } from "@hey/indexer"; import { useState } from "react"; import { z } from "zod"; import { Button, EmptyState, ErrorMessage, Form, Select, TextArea, useZodForm } from "@/components/Shared/UI"; import convertToTitleCase from "@/helpers/convertToTitleCase"; import errorToast from "@/helpers/errorToast"; import stopEventPropagation from "@/helpers/stopEventPropagation"; const ValidationSchema = z.object({ additionalComment: z.string().max(260, { message: "Additional comments should not exceed 260 characters" }) }); interface ReportPostProps { postId?: string; } const ReportPost = ({ postId }: ReportPostProps) => { const [reason, setReason] = useState(""); const form = useZodForm({ schema: ValidationSchema }); const [createReport, { data, error, loading }] = useReportPostMutation({ onError: (error) => errorToast(error) }); const reportPost = async ({ additionalComment }: z.infer) => { return await createReport({ variables: { request: { additionalComment, post: postId, reason: reason as PostReportReason } } }); }; return (
{data?.reportPost === null ? ( } message="Post reported" /> ) : postId ? (
{error ? ( ) : null}
Type