- Draft Session #{matchId.substring(0, 8)}
+ {/* Обновленный заголовок сессии с данными оппонента */}
+
@@ -84,4 +140,4 @@ const DraftPage = () => {
);
};
-export default DraftPage;
+export default DraftPage;
\ No newline at end of file
diff --git a/src/pages/LoginPage.jsx b/src/pages/LoginPage.jsx
index b2825af..45f321f 100644
--- a/src/pages/LoginPage.jsx
+++ b/src/pages/LoginPage.jsx
@@ -89,7 +89,7 @@ export default function LoginPage() {
setIsLoading(false);
}
};
-
+ // git pull --recurse-submodules && git submodule update --remote --recursive
return (
diff --git a/src/pages/useMatchSession.js b/src/pages/useMatchSession.js
index 38579a7..46a6a58 100644
--- a/src/pages/useMatchSession.js
+++ b/src/pages/useMatchSession.js
@@ -3,6 +3,8 @@ import {useWebSocket} from '../context/WebSocketContext';
import {useMatchStore} from "./useMatchStore.js";
import {useNavigate} from "react-router-dom";
import toast from "react-hot-toast";
+import {api} from "../api/axiosConfig.js";
+import {useUser} from "../context/UserContext.jsx";
export const useMatchSession = (matchId) => {
const {isConnected, publish} = useWebSocket();
@@ -11,13 +13,31 @@ export const useMatchSession = (matchId) => {
const isRedirect = useMatchStore((state) => state.matchStarted);
const error = useMatchStore((state) => state.error);
const resetStore = useMatchStore((state) => state.resetStore);
-
+ const [opponent, setOpponent] = useState(null);
+ const {user} = useUser();
const [sessionData, setSessionData] = useState(null);
useEffect(() => {
// eslint-disable-next-line react-hooks/set-state-in-effect
setSessionData(draftSessionDTO?.draftSession);
}, [draftSessionDTO]);
+ useEffect(() => {
+ if (!sessionData || !user?.id) return;
+
+ const amIFirstUser = user.id === sessionData.firstUserId;
+ const opponentId = amIFirstUser ? sessionData.secondUserId : sessionData.firstUserId;
+
+ if (!opponentId) return;
+
+ api.get(`user/info/${opponentId}`)
+ .then(response => {
+ setOpponent(response.data);
+ })
+ .catch(err => {
+ console.error("Ошибка загрузки данных оппонента в хуке:", err);
+ });
+ }, [sessionData, user.id]);
+
useEffect(() => {
if (error?.message) {
toast.error(error?.message);
@@ -35,5 +55,5 @@ export const useMatchSession = (matchId) => {
publish(`/app/${matchId}/ban`, {category: category, banObject: value});
};
- return {sessionData, error, sendBan, isConnected};
+ return {sessionData, opponent, error, sendBan, isConnected};
};