Add confirmation dialog for resign button

- Add window.confirm() before resigning to prevent accidental resignation
- Add 'resignConfirm' translation key in all 5 languages (EN, DE, FR, IT, PL)
- Messages are localized and warn that the action cannot be undone
This commit is contained in:
Stefan
2025-12-03 09:05:17 +01:00
parent 41ca7ae187
commit 6aa7d5bdd8
2 changed files with 12 additions and 1 deletions
+6 -1
View File
@@ -601,6 +601,11 @@ export default function ChessGame({ gameId, initialFen, initialPgn, initialPerso
const handleResign = useCallback(async () => {
if (gameOverState) return;
// Show confirmation dialog
const confirmed = window.confirm(t.game.resignConfirm);
if (!confirmed) return;
setIsAnalyzing(false);
const currentFen = gameRef.current.fen();
@@ -630,7 +635,7 @@ export default function ChessGame({ gameId, initialFen, initialPgn, initialPerso
result,
winner,
});
}, [gameOverState, moveHistory, playerColor, stockfish, stockfishDepth, t.game.resignation]);
}, [gameOverState, moveHistory, playerColor, stockfish, stockfishDepth, t.game.resignConfirm, t.game.resignation]);
const handleDownloadPGN = () => {
const pgn = gameRef.current.pgn();
+6
View File
@@ -63,6 +63,7 @@ export interface Translations {
depth: string;
undoMove: string;
resign: string;
resignConfirm: string;
resignation: string;
gameHistory: string;
analyze: string;
@@ -238,6 +239,7 @@ const en: Translations = {
depth: 'Depth',
undoMove: 'Undo Last Move',
resign: 'Resign',
resignConfirm: 'Are you sure you want to resign? This action cannot be undone.',
resignation: 'You resigned.',
gameHistory: 'Game History',
analyze: 'Analyze',
@@ -408,6 +410,7 @@ const de: Translations = {
depth: 'Tiefe',
undoMove: 'Letzten Zug rückgängig',
resign: 'Aufgeben',
resignConfirm: 'Möchtest du wirklich aufgeben? Diese Aktion kann nicht rückgängig gemacht werden.',
resignation: 'Du hast aufgegeben.',
gameHistory: 'Spielverlauf',
analyze: 'Analysieren',
@@ -578,6 +581,7 @@ const fr: Translations = {
depth: 'Profondeur',
undoMove: 'Annuler le dernier coup',
resign: 'Abandonner',
resignConfirm: 'Êtes-vous sûr de vouloir abandonner ? Cette action est irréversible.',
resignation: 'Vous avez abandonné.',
gameHistory: 'Historique de la partie',
analyze: 'Analyser',
@@ -748,6 +752,7 @@ const it: Translations = {
depth: 'Profondità',
undoMove: 'Annulla ultima mossa',
resign: 'Abbandona',
resignConfirm: 'Sei sicuro di voler abbandonare? Questa azione non può essere annullata.',
resignation: 'Hai abbandonato.',
gameHistory: 'Cronologia partita',
analyze: 'Analizza',
@@ -918,6 +923,7 @@ const pl: Translations = {
depth: 'Głębokość',
undoMove: 'Cofnij ruch',
resign: 'Poddaj partię',
resignConfirm: 'Czy na pewno chcesz się poddać? Tej akcji nie można cofnąć.',
resignation: 'Poddano partię.',
gameHistory: 'Historia partii',
analyze: 'Analizuj',