From aba168d210d0d026f4d15f3bbaa440f0528b4446 Mon Sep 17 00:00:00 2001 From: Yogesh Date: Sat, 6 Dec 2025 22:09:29 +0530 Subject: [PATCH 1/2] fix: ReportModal-toast A Loading Toast when report is being submitted. A static warning message near the submit button in red color, saying to either check any boxes or to comment, to enable the submit button --- src/components/ReportTagModal.tsx | 65 ++++++++++++++++--------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/src/components/ReportTagModal.tsx b/src/components/ReportTagModal.tsx index d4eb306..845486c 100644 --- a/src/components/ReportTagModal.tsx +++ b/src/components/ReportTagModal.tsx @@ -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 ( @@ -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, missing items)" /> + {!canSubmit &&(

+ Submit button becomes active only if you update a tag or write a comment. +

)}