Skip to content

Commit 90d791e

Browse files
Merge pull request #423 from YOGESH-08/staging
fix: in ReportTag Modal
2 parents 683de22 + 9b557ec commit 90d791e

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed

src/components/ReportTagModal.tsx

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -209,37 +209,37 @@ if (reportedFields.length === 0 && comment.trim().length === 0) {
209209
toast.error("Please change a tag or write a comment.");
210210
return;
211211
}
212-
212+
const payload = {
213+
paperId,
214+
reportedFields,
215+
comment,
216+
reporterEmail: email || undefined,
217+
};
213218
setLoading(true);
214-
215-
try {
216-
const res = await axios.post("/api/report-tag", {
217-
paperId,
218-
reportedFields,
219-
comment,
220-
reporterEmail: email || undefined,
221-
});
222-
223-
toast.success("Reported successfully. Thank you, We will work on that.");
224-
225-
modalSetOpen(false);
226-
setComment("");
227-
setEmail("");
228-
setSelectedCategories([]);
229-
setCategoryValues({});
230-
} catch (err: any) {
231-
console.error(err);
232-
233-
const msg =
234-
err?.response?.data?.error ||
235-
err?.message ||
236-
"Failed to submit report.";
237-
238-
toast.error(msg);
239-
} finally {
240-
setLoading(false);
241-
}
242-
219+
await toast.promise(
220+
axios.post("/api/report-tag", payload),
221+
{
222+
loading: "Submitting your report...",
223+
success: "Reported successfully. Thank you, We will work on that",
224+
error: (err)=>{
225+
return (
226+
err?.response?.data?.error ||
227+
err?.message ||
228+
"Failed to submit report."
229+
)
230+
},
231+
}
232+
)
233+
.then(() => {
234+
modalSetOpen(false);
235+
setComment("");
236+
setEmail("");
237+
setSelectedCategories([]);
238+
setCategoryValues({});
239+
})
240+
.finally(() => {
241+
setLoading(false);
242+
});
243243
};
244244

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

373373
<LabeledInput
@@ -377,6 +377,9 @@ if (reportedFields.length === 0 && comment.trim().length === 0) {
377377
placeholder="[email protected]"
378378
type="email"
379379
/>
380+
{!canSubmit &&(<p className="text-xs text-gray-500 dark:text-red-400">
381+
Submit button becomes active only if you update a tag or write a comment.
382+
</p>)}
380383

381384
<div className="flex justify-end">
382385
<Button

0 commit comments

Comments
 (0)