add leave game dialog

This commit is contained in:
Halit Aksoy 2022-09-04 00:16:14 +03:00
parent 9ea7ecfe93
commit 886852611b
2 changed files with 27 additions and 8 deletions

View File

@ -32,6 +32,9 @@ export type Texts = {
UCanOnlyPlayYourOwnPits: string,
UMustWaitUntilCurrentMoveComplete: string,
UCanNotPlayEmptyPit: string,
AreYouSureToLeaveGame: string,
Yes: string,
Cancel: string,
}
export const EnUs: Texts = {
@ -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 = {
@ -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"
}

View File

@ -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 = () => {
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 = () => {