From 705f0676e64bc15be5c2c1c564486c08f5fd2d46 Mon Sep 17 00:00:00 2001 From: Egor Date: Sun, 18 Jan 2026 06:54:25 +0300 Subject: [PATCH] Update Support.tsx --- src/pages/Support.tsx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/pages/Support.tsx b/src/pages/Support.tsx index 80226cd..e161c40 100644 --- a/src/pages/Support.tsx +++ b/src/pages/Support.tsx @@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next' import { ticketsApi } from '../api/tickets' import { infoApi } from '../api/info' import { logger } from '../utils/logger' +import { checkRateLimit, getRateLimitResetTime, RATE_LIMIT_KEYS } from '../utils/rateLimit' import type { TicketDetail, TicketMessage } from '../types' const log = logger.createLogger('Support') @@ -132,6 +133,7 @@ export default function Support() { const [newTitle, setNewTitle] = useState('') const [newMessage, setNewMessage] = useState('') const [replyMessage, setReplyMessage] = useState('') + const [rateLimitError, setRateLimitError] = useState(null) // Media attachment states const [createAttachment, setCreateAttachment] = useState(null) @@ -507,6 +509,13 @@ export default function Support() {
{ e.preventDefault() + setRateLimitError(null) + // Rate limit: max 3 tickets per 60 seconds + if (!checkRateLimit(RATE_LIMIT_KEYS.TICKET_CREATE, 3, 60000)) { + const resetTime = getRateLimitResetTime(RATE_LIMIT_KEYS.TICKET_CREATE) + setRateLimitError(t('support.tooManyRequests', { seconds: resetTime }) || `Слишком много запросов. Подождите ${resetTime} сек.`) + return + } createMutation.mutate() }} className="space-y-4" @@ -567,6 +576,12 @@ export default function Support() { )} + {rateLimitError && ( +
+ {rateLimitError} +
+ )} +
+ {rateLimitError && ( +
+ {rateLimitError} +
+ )}
)}