diff --git a/src/const/texts.ts b/src/const/texts.ts index 13848fc..1f4b9dc 100644 --- a/src/const/texts.ts +++ b/src/const/texts.ts @@ -21,8 +21,8 @@ export type Texts = { YouLeftTheGame: string, UserLeftTheGame: string, SearchingOpponent: string, - PleaseWait : string, - GameDraw : string, + PleaseWait: string, + GameDraw: string, Anonymous: string, GameNotFound: string, Loading: string, @@ -32,6 +32,9 @@ export type Texts = { UCanOnlyPlayYourOwnPits: string, UMustWaitUntilCurrentMoveComplete: string, UCanNotPlayEmptyPit: string, + AreYouSureToLeaveGame: string, + Yes: string, + Cancel: string, } export const EnUs: Texts = { @@ -56,8 +59,8 @@ export const EnUs: Texts = { YouLeftTheGame: "You Left The Game", UserLeftTheGame: "Left The Game", SearchingOpponent: "Searching Opponent", - PleaseWait : "Please Wait", - GameDraw : "Draw", + PleaseWait: "Please Wait", + GameDraw: "Draw", Anonymous: "Anonymous", GameNotFound: "Game Not Found", Loading: "Loading", @@ -67,7 +70,9 @@ export const EnUs: Texts = { UCanOnlyPlayYourOwnPits: "You can only play your own pits", UMustWaitUntilCurrentMoveComplete: "You must wait until the current move is complete", UCanNotPlayEmptyPit: "You can not play empty pit", - + AreYouSureToLeaveGame: "Are you sure to leave game?", + Yes: "Yes", + Cancel: "Cancel", } export const TrTr: Texts = { @@ -93,7 +98,7 @@ export const TrTr: Texts = { UserLeftTheGame: "Oyundan Ayrıldı", SearchingOpponent: "Rakip Aranıyor", PleaseWait: "Lütfen Bekleyin", - GameDraw : "Berabere", + GameDraw: "Berabere", Anonymous: "Anonim", GameNotFound: "Oyun Bulunamadı", Loading: "Yükleniyor", @@ -103,4 +108,7 @@ export const TrTr: Texts = { UCanOnlyPlayYourOwnPits: "Sadece sana ait olan kuyular ile oynayabilirsin", UMustWaitUntilCurrentMoveComplete: "Devam eden haraketin bitmesini beklemelisin", UCanNotPlayEmptyPit: "Boş kuyu ile oynayamazsın", + AreYouSureToLeaveGame: "Oyundan ayrılmak istediğine emin misin?", + Yes: "Evet", + Cancel: "İptal" } \ No newline at end of file diff --git a/src/routes/GamePage.tsx b/src/routes/GamePage.tsx index f1de1b5..bdc2e2a 100644 --- a/src/routes/GamePage.tsx +++ b/src/routes/GamePage.tsx @@ -29,6 +29,7 @@ import BoardViewModel from '../viewmodel/BoardViewModel'; import Center from '../components/Center'; import { Game, GameUsersConnectionInfo } from '../models/Game'; import notyf from '../util/Notyf'; +import swal from 'sweetalert'; const GamePage: FunctionComponent<{ context: Context, @@ -138,7 +139,17 @@ const GamePage: FunctionComponent<{ const checkHasAnOngoingAction = () => hasOngoingAction; const onLeaveGameClick = () => { - context.rtmt.sendMessage(channel_leave_game, {}); + swal({ + title: context.texts.AreYouSureToLeaveGame, + icon: "warning", + buttons: [context.texts.Yes, context.texts.Cancel], + dangerMode: true, + }) + .then((cancel) => { + if (!cancel) { + context.rtmt.sendMessage(channel_leave_game, {}); + } + }); }; const onNewGameClick = () => { @@ -149,7 +160,7 @@ const GamePage: FunctionComponent<{ if (!game || isSpectator || !userKey) { return; } - if(game.mancalaGame.getPlayerIdByIndex(index) !== userKey) { + if (game.mancalaGame.getPlayerIdByIndex(index) !== userKey) { notyf.error(context.texts.UCanOnlyPlayYourOwnPits); return; }