import { CheckCircleIcon } from "@heroicons/react/24/solid"; import { type AccountFragment, AccountReportReason, useReportAccountMutation } from "@hey/indexer"; import { useState } from "react"; import { z } from "zod"; import SingleAccount from "@/components/Shared/Account/SingleAccount"; import { Button, Card, 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 ReportAccountProps { account?: AccountFragment; } const ReportAccount = ({ account }: ReportAccountProps) => { const [reason, setReason] = useState(""); const form = useZodForm({ schema: ValidationSchema }); const [createReport, { data, error, loading }] = useReportAccountMutation({ onError: (error) => errorToast(error) }); const reportAccount = async ({ additionalComment }: z.infer) => { const response = await createReport({ variables: { request: { account: account?.address, additionalComment, reason: reason as AccountReportReason } } }); return response; }; return (
{data?.reportAccount === null ? ( } message="Account reported" /> ) : account ? (
{error ? ( ) : null}
Type