From e95a26746c2136ef91d7ab50fdacdde7b61f852e Mon Sep 17 00:00:00 2001 From: Thomas Chazot Date: Tue, 10 Jan 2023 14:00:33 +0100 Subject: [PATCH] Correction bug bdd docker --- api-rest/initBdd.php | 5 +++-- bob_party/src/components/LobbyComponent.tsx | 2 +- bob_party/src/components/UserPreview.tsx | 1 - bob_party/src/screens/GameChoice.tsx | 18 +++++++++++++++--- .../loaderConversationApi.ts | 2 +- .../src/services/gameService/loaderGameApi.ts | 6 +++--- 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/api-rest/initBdd.php b/api-rest/initBdd.php index 901443e..bb58654 100644 --- a/api-rest/initBdd.php +++ b/api-rest/initBdd.php @@ -29,7 +29,8 @@ $conn->query("CREATE TABLE `T_H_CONVERSATION_COV` ( $conn->query("CREATE TRIGGER `before_delete_conversation` BEFORE DELETE ON `T_H_CONVERSATION_COV` FOR EACH ROW DELETE FROM T_H_MESSAGE_MSG WHERE PK_ID = (SELECT FK_MESSAGE FROM T_J_CONTAIN_MESSAGE_CMG -WHERE FK_CONVERSATION=OLD.PK_ID);"); +WHERE FK_CONVERSATION=OLD.PK_ID); +END;"); $conn->query("CREATE TABLE `T_H_MESSAGE_MSG` ( `PK_ID` int(11) NOT NULL, @@ -84,7 +85,7 @@ $conn->query("CREATE TABLE `T_S_USER_USR` ( );"); -$conn->query("CREATE TRIGGER `after_insert_user` AFTER INSERT ON `T_S_USER_USR` FOR EACH ROW INSERT INTO T_J_OWN_SKIN_OWN VALUES(NEW.PK_ID,1);"); +$conn->query("CREATE TRIGGER `after_insert_user` AFTER INSERT ON `T_S_USER_USR` FOR EACH ROW INSERT INTO T_J_OWN_SKIN_OWN VALUES(NEW.PK_ID,1); END;"); $conn->query("ALTER TABLE `T_E_GAME_GAM` diff --git a/bob_party/src/components/LobbyComponent.tsx b/bob_party/src/components/LobbyComponent.tsx index 11b8090..e13b738 100644 --- a/bob_party/src/components/LobbyComponent.tsx +++ b/bob_party/src/components/LobbyComponent.tsx @@ -66,7 +66,7 @@ FC<{nav: any}> = getUsers(); return( - Match ID : {MANAGER_MATCH.getCurrentMatch()?.getCode()} + Match ID : {useMatchStore().match?.getCode()} usr?.getUsername() || usr} diff --git a/bob_party/src/components/UserPreview.tsx b/bob_party/src/components/UserPreview.tsx index 3d6ed28..c2212da 100644 --- a/bob_party/src/components/UserPreview.tsx +++ b/bob_party/src/components/UserPreview.tsx @@ -19,7 +19,6 @@ export const UserPreview : FC<{user: User | null}> = ({user}) => { - console.log(user); if(user !== null){ return ( diff --git a/bob_party/src/screens/GameChoice.tsx b/bob_party/src/screens/GameChoice.tsx index 01cabf5..4ceed55 100644 --- a/bob_party/src/screens/GameChoice.tsx +++ b/bob_party/src/screens/GameChoice.tsx @@ -1,5 +1,5 @@ import { StatusBar } from 'expo-status-bar' -import {View, FlatList, Text} from 'react-native' +import {View, FlatList, Text, Alert} from 'react-native' import React, { useState } from 'react'; import { TopBar } from '../components/TopBar'; import { BotBar } from '../components/BotBar'; @@ -8,13 +8,25 @@ import { ScreenIndicator } from '../components/ScreenIndicator'; import { TextInput } from 'react-native-gesture-handler'; import stylesScreen from './style/screens.style' import styles from './style/GameChoice.style' -import { MANAGER_GAME } from '../../appManagers'; +import { MANAGER_GAME, MANAGER_MATCH, MANAGER_USER } from '../../appManagers'; import { GameList } from '../components/GameList'; function GameChoice(props: { navigation: any}) { const { navigation} = props const [matchId, setMatchId] = useState(''); + + async function joinMatch(id:string){ + const newId = parseInt(id); + const tmp=MANAGER_USER.getCurrentUser(); + if (tmp !== null){ + await MANAGER_MATCH.getsaverMatch().joinMatch(tmp, newId).then((res) =>{ + if (res===null){ + Alert.alert() + } + }); + } + } if(MANAGER_GAME.currentGameType === "solo" ){ return ( @@ -48,7 +60,7 @@ function GameChoice(props: { navigation: any}) { /> Rejoindre un match - setMatchId(val)} autoCapitalize='none' /> + setMatchId(val)} onSubmitEditing={(val) => {joinMatch(val)}} autoCapitalize='none' /> { let tab: Game[]=[]; - const url=this.baseUrl+"http://localhost:8888/api-rest/index.php/getGames"; + const url=this.baseUrl+"getGames"; await this.axios({ method: 'get', url: url, }) .then(function (response: any) { - if (response.data != null || response.data != undefined){ - + if (response.data != null && response.data != undefined){ response.data.forEach(game => { + switch(game.type){ case "GameSolo": let mapSolo = new Map();