fix(web): disable report button after successful submission

This commit is contained in:
yun-zhi-ztl 2026-03-19 10:54:32 +08:00 • committed by Xudong Sun
parent 1a5b8de196
commit a4cb9f0cf9
3 changed files with 6 additions and 2 deletions

View file

@ -695,6 +695,7 @@
"promotionAlreadyPromotedDescription": "This skill has already been promoted to the global namespace.",
"promotionErrorTitle": "Failed to submit promotion request",
"reportSkill": "Report Skill",
"reportedSkill": "Reported",
"reportDialogTitle": "Report skill",
"reportDialogDescription": "Provide a reason so administrators can review and act on it quickly.",
"reportReasonPlaceholder": "Reason, for example policy violation, misleading content, or infringement",

View file

@ -695,6 +695,7 @@
"promotionAlreadyPromotedDescription": "这个技能已经提升到全局命名空间,无需重复提交。",
"promotionErrorTitle": "提交提升申请失败",
"reportSkill": "举报技能",
"reportedSkill": "已举报",
"reportDialogTitle": "举报技能",
"reportDialogDescription": "请填写举报原因,帮助管理员快速判断和处理。",
"reportReasonPlaceholder": "举报原因,例如包含违规内容、恶意误导、侵权等",

View file

@ -93,6 +93,7 @@ export function SkillDetailPage() {
const [reportDialogOpen, setReportDialogOpen] = useState(false)
const [reportReason, setReportReason] = useState('')
const [reportDetails, setReportDetails] = useState('')
const [hasReported, setHasReported] = useState(false)
const [archiveConfirmOpen, setArchiveConfirmOpen] = useState(false)
const [unarchiveConfirmOpen, setUnarchiveConfirmOpen] = useState(false)
const [promotionConfirmOpen, setPromotionConfirmOpen] = useState(false)
@ -288,6 +289,7 @@ export function SkillDetailPage() {
setReportDialogOpen(false)
setReportReason('')
setReportDetails('')
setHasReported(true)
toast.success(t('skillDetail.reportSuccessTitle'), t('skillDetail.reportSuccessDescription'))
} catch (error) {
toast.error(t(resolveSkillActionErrorTitle('report')), error instanceof Error ? error.message : '')
@ -788,8 +790,8 @@ export function SkillDetailPage() {
<StarButton skillId={skill.id} starCount={skill.starCount} onRequireLogin={requireLogin} />
<RatingInput skillId={skill.id} onRequireLogin={requireLogin} />
{canReport ? (
<Button variant="outline" className="w-full" onClick={handleOpenReport} disabled={reportMutation.isPending}>
{reportMutation.isPending ? t('skillDetail.processing') : t('skillDetail.reportSkill')}
<Button variant="outline" className="w-full" onClick={handleOpenReport} disabled={hasReported || reportMutation.isPending}>
{hasReported ? t('skillDetail.reportedSkill') : reportMutation.isPending ? t('skillDetail.processing') : t('skillDetail.reportSkill')}
</Button>
) : null}
</>