Skip to content

Commit d2afc90

Browse files
committed
Revert client to working state from commit 0f8ac86
1 parent f2ce42b commit d2afc90

10 files changed

Lines changed: 57 additions & 151 deletions

File tree

client/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@
1111
},
1212
"dependencies": {
1313
"@tonconnect/ui-react": "^2.3.0",
14-
"buffer": "^6.0.3",
15-
"colyseus.js": "^0.16.19",
1614
"prop-types": "^15.8.1",
1715
"react": "^18.2.0",
18-
"react-dom": "^18.2.0",
19-
"ton": "^13.9.0",
20-
"ton-core": "^0.53.0"
16+
"react-dom": "^18.2.0"
2117
},
2218
"devDependencies": {
2319
"@types/react": "^18.2.43",

client/src/App.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function App() {
2929

3030
const checkAuth = () => {
3131
if (authService.isAuthenticated()) {
32+
// In a real app, you'd fetch the user profile here
3233
setCurrentScreen('main-menu');
3334
}
3435
};

client/src/main.jsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ import React from 'react'
22
import ReactDOM from 'react-dom/client'
33
import App from './App.jsx'
44
import './styles/globals.css'
5-
import { Buffer } from 'buffer'
6-
7-
// Полифил для Buffer в браузере
8-
window.Buffer = Buffer
95

106
if (window.Telegram && window.Telegram.WebApp) {
117
window.Telegram.WebApp.ready()

client/src/screens/MainMenu/MainMenu.jsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
1-
import { useState, useEffect } from 'react';
1+
import { useState } from 'react';
22
import PropTypes from 'prop-types';
33
import ProfileCard from './components/ProfileCard';
44
import ActionButtons from './components/ActionButtons';
55
import RoomList from './components/RoomList';
66
import TonConnectButton from './components/TonConnectButton';
77
import CreateRoomModal from './components/CreateRoomModal';
8-
// import { // analyticsService } from '../../services/// analyticsService';
98
import '../../styles/MainMenu.css';
109

1110
const MainMenu = ({ user }) => {
1211
const [isModalOpen, setIsModalOpen] = useState(false);
1312

14-
// Track screen view when component mounts
15-
useEffect(() => {
16-
// analyticsService.trackScreenView('main-menu');
17-
}, []);
18-
1913
const handleOpenModal = () => {
2014
setIsModalOpen(true);
21-
// analyticsService.trackButtonClick('create_room', 'main-menu');
22-
// analyticsService.trackEvent('create_room_modal_opened');
2315
};
2416

2517
const handleCloseModal = () => {
2618
setIsModalOpen(false);
27-
// analyticsService.trackEvent('create_room_modal_closed');
2819
};
2920

3021
return (

client/src/screens/MainMenu/components/ActionButtons.jsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import PropTypes from 'prop-types'
2-
// import { // analyticsService } from '../../../services/// analyticsService'
32
import '../../../styles/ActionButtons.css'
43

54
// Кнопки управления игрой
65
const ActionButtons = ({ onCreateGame }) => {
76
const handleCreateGame = () => {
87
console.log('Создание новой игры')
9-
// analyticsService.trackButtonClick('create_game', 'main-menu')
10-
// analyticsService.trackEvent('create_game_button_clicked')
118
if (onCreateGame) {
129
onCreateGame()
1310
}
Lines changed: 35 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,60 @@
1-
import PropTypes from 'prop-types';
2-
import { useState } from 'react';
3-
import '../../../styles/CreateRoomModal.css';
4-
import { useWalletBalances } from '../../../hooks/useWalletBalances';
5-
// import { // analyticsService } from '../../../services/// analyticsService';
1+
2+
import PropTypes from 'prop-types';
3+
import { useState } from 'react'
4+
import '../../../styles/CreateRoomModal.css'
65

76
// Модальное окно для создания комнаты
87
const CreateRoomModal = ({ isOpen, onClose }) => {
9-
const [betAmount, setBetAmount] = useState('');
10-
const [currency, setCurrency] = useState('TON');
11-
const { balanceTon, balanceRuble } = useWalletBalances();
8+
const [betAmount, setBetAmount] = useState('')
9+
const [currency, setCurrency] = useState('TON')
1210

1311
// Проверка валидности суммы ставки
1412
const isValidBetAmount = () => {
15-
if (!betAmount || betAmount === '') return false;
16-
const amount = parseFloat(betAmount);
17-
if (isNaN(amount) || amount <= 0) return false;
18-
19-
const selectedBalance = currency === 'TON' ? balanceTon : balanceRuble;
20-
if (amount > selectedBalance) {
21-
return false; // Ставка не может превышать баланс
22-
}
23-
13+
if (!betAmount || betAmount === '') return false
14+
const amount = parseFloat(betAmount)
15+
if (isNaN(amount) || amount <= 0) return false
16+
2417
if (currency === 'TON') {
25-
return amount >= 1.0;
18+
return amount >= 1.0
2619
} else {
27-
return amount >= 100;
20+
return amount >= 100
2821
}
29-
};
22+
}
3023

3124
const handleSubmit = (e) => {
32-
e.preventDefault();
25+
e.preventDefault()
3326
if (isValidBetAmount()) {
34-
console.log('Creating a room:', { betAmount, currency });
35-
// analyticsService.trackRoomCreated('public', 2);
36-
// analyticsService.trackEvent('room_creation_attempt', {
37-
// bet_amount: parseFloat(betAmount),
38-
// currency: currency
39-
// });
27+
console.log('Creating a room:', { betAmount, currency })
4028
// Здесь будет логика создания комнаты
41-
onClose();
42-
setBetAmount('');
43-
setCurrency('TON');
44-
} else {
45-
// analyticsService.trackError('validation', 'invalid_bet_amount', 'create_room_modal');
29+
onClose()
30+
setBetAmount('')
31+
setCurrency('TON')
4632
}
47-
};
33+
}
4834

4935
const handleClose = () => {
50-
// analyticsService.trackButtonClick('cancel', 'create_room_modal');
51-
onClose();
52-
setBetAmount('');
53-
setCurrency('TON');
54-
};
36+
onClose()
37+
setBetAmount('')
38+
setCurrency('TON')
39+
}
5540

56-
if (!isOpen) return null;
57-
58-
const selectedBalance = currency === 'TON' ? balanceTon : balanceRuble;
41+
if (!isOpen) return null
5942

6043
return (
6144
<div className="modal-overlay" onClick={handleClose}>
6245
<div className="create-room-modal" onClick={(e) => e.stopPropagation()}>
46+
6347
<form onSubmit={handleSubmit} className="modal-form">
6448
<div className="form-group">
49+
6550
<div className="radio-group">
6651
<label className={`radio-option ${currency === 'TON' ? 'selected' : ''}`}>
6752
<input
6853
type="radio"
6954
name="currency"
7055
value="TON"
7156
checked={currency === 'TON'}
72-
onChange={(e) => {
73-
setCurrency(e.target.value);
74-
// analyticsService.trackEvent('currency_selected', { currency: 'TON' });
75-
}}
57+
onChange={(e) => setCurrency(e.target.value)}
7658
/>
7759
<span className="radio-label">TON</span>
7860
</label>
@@ -82,16 +64,13 @@ const CreateRoomModal = ({ isOpen, onClose }) => {
8264
name="currency"
8365
value="RUBLE"
8466
checked={currency === 'RUBLE'}
85-
onChange={(e) => {
86-
setCurrency(e.target.value);
87-
// analyticsService.trackEvent('currency_selected', { currency: 'RUBLE' });
88-
}}
67+
onChange={(e) => setCurrency(e.target.value)}
8968
/>
9069
<span className="radio-label">RUBLE</span>
9170
</label>
9271
</div>
9372
</div>
94-
73+
9574
<div className="form-group">
9675
<input
9776
type="number"
@@ -102,17 +81,14 @@ const CreateRoomModal = ({ isOpen, onClose }) => {
10281
onChange={(e) => setBetAmount(e.target.value)}
10382
placeholder={currency === 'TON' ? 'Enter amount (min 1.0)' : 'Enter amount (min 100)'}
10483
/>
105-
<div className="balance-info">
106-
Available: {selectedBalance.toFixed(2)} {currency}
107-
</div>
10884
</div>
109-
85+
11086
<div className="modal-actions">
11187
<button type="button" onClick={handleClose} className="cancel-button">
11288
Cancel
11389
</button>
114-
<button
115-
type="submit"
90+
<button
91+
type="submit"
11692
className={`create-button ${!isValidBetAmount() ? 'disabled' : ''}`}
11793
disabled={!isValidBetAmount()}
11894
>
@@ -122,8 +98,8 @@ const CreateRoomModal = ({ isOpen, onClose }) => {
12298
</form>
12399
</div>
124100
</div>
125-
);
126-
};
101+
)
102+
}
127103

128104
CreateRoomModal.propTypes = {
129105
isOpen: PropTypes.bool.isRequired,
@@ -132,4 +108,4 @@ CreateRoomModal.propTypes = {
132108
// Добавьте другие пропсы, если они есть
133109
};
134110

135-
export default CreateRoomModal;
111+
export default CreateRoomModal

client/src/screens/MainMenu/components/ProfileCard.jsx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import PropTypes from 'prop-types';
22
import '../../../styles/ProfileCard.css';
3-
import { useWalletBalances } from '../../../hooks/useWalletBalances';
43

54
// Функция для форматирования баланса (1234 -> 1.2k, 1234567 -> 1.2M)
65
const formatBalance = (num) => {
@@ -10,17 +9,11 @@ const formatBalance = (num) => {
109
if (num >= 1000) {
1110
return (num / 1000).toFixed(1).replace(/\.0$/, '') + 'k';
1211
}
13-
// Округляем до 2 знаков после запятой для чисел меньше 1000
14-
if (num > 0 && num < 1000) {
15-
return parseFloat(num.toFixed(2));
16-
}
1712
return num;
1813
};
1914

2015
// Компонент профиля пользователя
2116
const ProfileCard = ({ user }) => {
22-
const { balanceTon, balanceRuble, isLoading } = useWalletBalances();
23-
2417
// Показываем заглушку, если данные пользователя еще не загружены
2518
if (!user) {
2619
return (
@@ -35,6 +28,8 @@ const ProfileCard = ({ user }) => {
3528
}
3629

3730
const { username, winrate, wins, loses, avatar } = user;
31+
const balanceTon = 0; // Заглушка, пока баланс не приходит с бэка
32+
const balanceRuble = 0; // Заглушка
3833

3934
const truncatedUsername =
4035
username && username.length > 15 ? `${username.substring(0, 15)}...` : username;
@@ -53,15 +48,11 @@ const ProfileCard = ({ user }) => {
5348
<div className="balances-container">
5449
<div className="balance-item">
5550
<span className="currency-badge currency-ton">TON</span>
56-
<span className="balance-amount">
57-
{isLoading ? '...' : formatBalance(balanceTon)}
58-
</span>
51+
<span className="balance-amount">{formatBalance(balanceTon)}</span>
5952
</div>
6053
<div className="balance-item">
6154
<span className="currency-badge currency-ruble">RUBLE</span>
62-
<span className="balance-amount">
63-
{isLoading ? '...' : formatBalance(balanceRuble)}
64-
</span>
55+
<span className="balance-amount">{formatBalance(balanceRuble)}</span>
6556
</div>
6657
</div>
6758
</div>
Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,16 @@
1-
import { useState, useEffect } from 'react';
2-
import { colyseusService } from '../../../services/colyseusService';
3-
import RoomCard from './RoomCard';
4-
import '../../../styles/RoomList.css';
1+
import { useState } from 'react'
2+
import { mockRooms } from '../../../data/mockData'
3+
import RoomCard from './RoomCard'
4+
import '../../../styles/RoomList.css'
55

66
// Список активных игровых комнат
77
const RoomList = () => {
8-
const [rooms, setRooms] = useState([]);
9-
10-
useEffect(() => {
11-
const connectAndListen = async () => {
12-
await colyseusService.connect();
13-
14-
const unsubscribe = colyseusService.onRoomsChange(
15-
(allRooms) => {
16-
setRooms(allRooms);
17-
},
18-
(roomId, room) => {
19-
setRooms((prevRooms) => [...prevRooms, room]);
20-
},
21-
(roomId) => {
22-
setRooms((prevRooms) => prevRooms.filter((room) => room.roomId !== roomId));
23-
}
24-
);
25-
26-
// Возвращаем функцию для очистки при размонтировании компонента
27-
return () => {
28-
unsubscribe();
29-
colyseusService.disconnect();
30-
};
31-
};
32-
33-
const cleanupPromise = connectAndListen();
34-
35-
return () => {
36-
cleanupPromise.then(cleanup => cleanup && cleanup());
37-
};
38-
}, []);
8+
const [rooms, setRooms] = useState(mockRooms)
399

4010
const handleEnterRoom = (roomId) => {
41-
console.log(`Вход в комнату ${roomId}`);
42-
// Здесь будет логика входа в комнату Colyseus
43-
// Например: await colyseusService.joinRoom(roomId);
44-
};
11+
console.log(`Вход в комнату ${roomId}`)
12+
setRooms(rooms.filter(room => room.id !== roomId))
13+
}
4514

4615
return (
4716
<div className="rooms-section">
@@ -52,10 +21,10 @@ const RoomList = () => {
5221

5322
<div className="rooms-container">
5423
{rooms.length > 0 ? (
55-
rooms.map((room) => (
24+
rooms.map(room => (
5625
<RoomCard
57-
key={room.roomId} // Используем roomId от Colyseus
58-
room={room} // Передаем весь объект комнаты
26+
key={room.id}
27+
room={room}
5928
onEnter={handleEnterRoom}
6029
/>
6130
))
@@ -67,7 +36,7 @@ const RoomList = () => {
6736
)}
6837
</div>
6938
</div>
70-
);
71-
};
39+
)
40+
}
7241

73-
export default RoomList;
42+
export default RoomList

client/src/screens/SplashScreen/SplashScreen.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ SplashScreen.propTypes = {
3434
error: PropTypes.string,
3535
};
3636

37-
export default SplashScreen;
37+
export default SplashScreen;

0 commit comments

Comments
 (0)