diff --git a/bob_party/src/components/GameComponent.tsx b/bob_party/src/components/GameComponent.tsx
index a5134d9..c26d778 100644
--- a/bob_party/src/components/GameComponent.tsx
+++ b/bob_party/src/components/GameComponent.tsx
@@ -11,9 +11,11 @@ import styles from './style/Game.style';
import LobbySolo from "../screens/LobbySolo"
import ManagerMatch from "../services/matchServices/managerMatch"
import MatchCreator from "../core/Match/matchCreator"
-import { MANAGER_USER } from "../../App"
+import { MANAGER_MATCH, MANAGER_USER } from "../../App"
+import { useMatchStore } from "../context/matchContext"
export const GameComponent :
+
/*
* game : Game that must be displayed
* nav : tool needed to allow the navigation between the screens
@@ -21,25 +23,33 @@ export const GameComponent :
FC<{game: Game, nav: any}> =
({game, nav}) =>
{
+
+ const setMatch = useMatchStore((state) => state.setMatch);
+
+ async function createNewMatchSolo(game : Game, nav: any) {
+ const m=new MatchCreator();
+ let tmp=MANAGER_USER.getCurrentUser();
+ if (tmp!=null){
+ let match=await m.createMatch(tmp, game);
+ MANAGER_MATCH.setCurrentMatch(match);
+ setMatch(match);
+ nav.navigate("LobbySolo");
+ }
+ }
+
return (
createNewMatchSolo(game, nav)}>
{game.getName()}
- )
+ )
+
+
}
-function createNewMatchSolo(game : Game, nav: any) {
- const m=new MatchCreator();
- let tmp=MANAGER_USER.getCurrentUser();
- if (tmp!=null){
- let match=m.createMatch(tmp, game);
- nav.navigate("LobbySolo");
- }
-}
\ No newline at end of file
diff --git a/bob_party/src/context/matchContext.tsx b/bob_party/src/context/matchContext.tsx
new file mode 100644
index 0000000..32a4f45
--- /dev/null
+++ b/bob_party/src/context/matchContext.tsx
@@ -0,0 +1,18 @@
+import React from "react";
+import create from "zustand";
+import { Match } from "../core/Match/match";
+
+
+// Define store types
+interface MatchState {
+ match: Match | null;
+ setMatch: (match: Match|null) => void;
+ resetMatch: () => void;
+ }
+
+// Define store data and methods
+export const useMatchStore = create()((set, get) => ({
+ match: null,
+ setMatch: (match) => set((state) => ({ match: match })),
+ resetMatch: () => set((state) => ({ match: null })),
+}));
diff --git a/bob_party/src/context/userContext.tsx b/bob_party/src/context/userContext.tsx
index 1f81bef..ccf307d 100644
--- a/bob_party/src/context/userContext.tsx
+++ b/bob_party/src/context/userContext.tsx
@@ -14,5 +14,5 @@ interface UserState {
export const useUserStore = create()((set, get) => ({
user: null,
setUser: (user) => set((state) => ({ user: user })),
- resetUser: () => set((state) => ({ user: undefined })),
+ resetUser: () => set((state) => ({ user: null })),
}));