Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 34 additions & 31 deletions src/components/ReportTagModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,37 +209,37 @@ if (reportedFields.length === 0 && comment.trim().length === 0) {
toast.error("Please change a tag or write a comment.");
return;
}

const payload = {
paperId,
reportedFields,
comment,
reporterEmail: email || undefined,
};
setLoading(true);

try {
const res = await axios.post("/api/report-tag", {
paperId,
reportedFields,
comment,
reporterEmail: email || undefined,
});

toast.success("Reported successfully. Thank you, We will work on that.");

modalSetOpen(false);
setComment("");
setEmail("");
setSelectedCategories([]);
setCategoryValues({});
} catch (err: any) {
console.error(err);

const msg =
err?.response?.data?.error ||
err?.message ||
"Failed to submit report.";

toast.error(msg);
} finally {
setLoading(false);
}

await toast.promise(
axios.post("/api/report-tag", payload),
{
loading: "Submitting your report...",
success: "Reported successfully. Thank you, We will work on that",
error: (err)=>{
return (
err?.response?.data?.error ||
err?.message ||
"Failed to submit report."
)
},
}
)
.then(() => {
modalSetOpen(false);
setComment("");
setEmail("");
setSelectedCategories([]);
setCategoryValues({});
})
.finally(() => {
setLoading(false);
});
};

return (
Expand Down Expand Up @@ -367,7 +367,7 @@ if (reportedFields.length === 0 && comment.trim().length === 0) {
label="Comment (optional)"
value={comment}
onChange={setComment}
placeholder="eg: Paper quality is not good"
placeholder="Describe the issue clearly (e.g., pages torn, print faded, incorrect paper, missing sections)"
/>

<LabeledInput
Expand All @@ -377,6 +377,9 @@ if (reportedFields.length === 0 && comment.trim().length === 0) {
placeholder="you@example.com"
type="email"
/>
{!canSubmit &&(<p className="text-xs text-gray-500 dark:text-red-400">
Submit button becomes active only if you update a tag or write a comment.
</p>)}

<div className="flex justify-end">
<Button
Expand Down