From 24a98062ee080e55478b92eed1a1865bf6ec1049 Mon Sep 17 00:00:00 2001 From: lobo Date: Tue, 29 Sep 2026 14:48:28 +0200 Subject: [PATCH] refactor(limits): server limits in one file, own texts for unknown errors --- src/components/AddGamePanel.jsx | 4 ++-- src/components/BacklogCard.jsx | 9 ++++--- src/components/GameCorrectionDialog.jsx | 11 ++++----- src/components/GameSearch.jsx | 6 ++--- src/components/ManualGameCard.jsx | 3 ++- src/components/PileOfShameCard.jsx | 3 ++- src/components/stats/OverviewStats.jsx | 2 +- src/pages/AdminHintsPage.jsx | 6 ++--- src/pages/GameLibrary.jsx | 5 ++-- src/pages/ImportPage.jsx | 6 ++--- src/pages/PublicProfilePage.jsx | 2 +- src/pages/RegistrationPage.jsx | 5 ++-- src/pages/RegistrationPage.test.jsx | 13 ++++++++-- src/pages/SettingsPage.jsx | 5 ++-- src/utils/backlog.js | 4 +--- src/utils/imports.js | 14 ++++------- src/utils/limits.js | 32 +++++++++++++++++++++++++ src/utils/manualGames.js | 3 --- 18 files changed, 84 insertions(+), 49 deletions(-) create mode 100644 src/utils/limits.js diff --git a/src/components/AddGamePanel.jsx b/src/components/AddGamePanel.jsx index 9755343..62d5a00 100644 --- a/src/components/AddGamePanel.jsx +++ b/src/components/AddGamePanel.jsx @@ -13,7 +13,7 @@ import GameCover from './GameCover.jsx'; import GameSearch from './GameSearch.jsx'; import useSessionExpired from '../hooks/useSessionExpired.js'; import useStartImport from '../hooks/useStartImport.js'; -import {GAME_STATUSES} from '../utils/backlog.js'; +import {GAME_STATUSES, MAX_PLATFORM_LENGTH} from '../utils/limits.js'; import {addGame, hoursToMinutes} from '../utils/manualGames.js'; import {loadFavoritePlatform, preselectPlatform} from '../utils/platforms.js'; @@ -145,7 +145,7 @@ function AddForm({hit, favorite, onBack, navigate, expireSession}) { ) : ( - setPlatform(e.target.value)}/> + setPlatform(e.target.value)}/> )}
diff --git a/src/components/BacklogCard.jsx b/src/components/BacklogCard.jsx index 4ae42fd..7d73e06 100644 --- a/src/components/BacklogCard.jsx +++ b/src/components/BacklogCard.jsx @@ -11,12 +11,11 @@ import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from '@/c import {Textarea} from '@/components/ui/textarea'; import {cn} from '@/lib/utils'; import {STATUS_META} from './GameStatusBadge.jsx'; -import {GAME_PRIORITIES, GAME_STATUSES, NO_PRIORITY, saveBacklogEntry, toBacklogRequest} from '../utils/backlog.js'; +import {NO_PRIORITY, saveBacklogEntry, toBacklogRequest} from '../utils/backlog.js'; +import {GAME_PRIORITIES, GAME_STATUSES, MAX_NOTES_LENGTH} from '../utils/limits.js'; import useSessionExpired from '../hooks/useSessionExpired.js'; import {hasSession} from '../utils/auth.js'; -const NOTES_MAX = 2000; - const toForm = (entry) => ({ status: entry.status ?? 'BACKLOG', rating: entry.rating ?? 0, @@ -133,12 +132,12 @@ export default function BacklogCard({game, onSaved}) {
- {form.notes.length} / {NOTES_MAX} + {form.notes.length} / {MAX_NOTES_LENGTH}