From 503ff386a195d50d8f3f50e1bd52aa4d1a8371a2 Mon Sep 17 00:00:00 2001 From: majean5 Date: Mon, 12 Dec 2022 16:13:46 +0100 Subject: [PATCH 1/4] suppression d'un file inutile --- bob_party/App.tsx | 2 -- bob_party/tsconfig.test.json | 28 ---------------------------- 2 files changed, 30 deletions(-) delete mode 100644 bob_party/tsconfig.test.json diff --git a/bob_party/App.tsx b/bob_party/App.tsx index 0006c10..cc7a067 100644 --- a/bob_party/App.tsx +++ b/bob_party/App.tsx @@ -14,8 +14,6 @@ import SaverMatchApi from './src/services/matchServices/saverMatchApi' import LoaderGameApi from './src/services/gameService/loaderGameApi' import ManagerGame from './src/services/gameService/managerGame' import { useFonts } from 'expo-font'; -import * as SplashScreen from 'expo-splash-screen'; -import { View } from 'react-native' export const MANAGER_USER = new ManagerUser(new LoaderUserApi, new FakeSaverUser); diff --git a/bob_party/tsconfig.test.json b/bob_party/tsconfig.test.json deleted file mode 100644 index 7446974..0000000 --- a/bob_party/tsconfig.test.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "compilerOptions": { - "allowJs": true, - "allowSyntheticDefaultImports": true, - "jsx": "react", - "lib": [ - "dom", - "es2017" - ], - "module": "esnext", - "moduleResolution": "node", - "noEmit": true, - "noUnusedLocals": false, - "noUnusedParameters": false, - "preserveConstEnums": true, - "removeComments": false, - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "target": "esnext" - }, - "include": [ - "**/*.ts", - "**/*.tsx" - , "tsconfig.test.json" ], - "extends": "expo/tsconfig.base" - } - \ No newline at end of file From 3287c124032d8ccdfc5bcc23103df6a1144f66b5 Mon Sep 17 00:00:00 2001 From: Thomas Chazot Date: Mon, 12 Dec 2022 16:14:50 +0100 Subject: [PATCH 2/4] =?UTF-8?q?R=C3=A9duction=20des=20require=20cycles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bob_party/App.tsx | 17 ----------------- bob_party/appManagers.ts | 16 ++++++++++++++++ .../src/Games/CookieClicker/cookieClicker.tsx | 2 +- bob_party/src/components/BotBar.tsx | 2 +- .../src/components/ConversationComponent.tsx | 2 -- bob_party/src/components/GameComponent.tsx | 2 +- bob_party/src/components/Skin.tsx | 6 +++--- bob_party/src/components/TopBar.tsx | 5 +---- bob_party/src/context/conversationContext.tsx | 1 - bob_party/src/context/gameContext.tsx | 6 +----- bob_party/src/core/Match/matchCasino.ts | 4 ++-- bob_party/src/core/Match/matchCreator.ts | 3 +-- bob_party/src/core/Match/matchMulti.ts | 4 ++-- bob_party/src/core/Match/matchSolo.ts | 4 ++-- bob_party/src/core/User/userCoinsModifier.ts | 5 ++--- bob_party/src/core/User/userCreator.ts | 2 +- .../src/core/User/userModificationManager.ts | 2 +- bob_party/src/core/User/userSkinModifier.ts | 2 +- bob_party/src/screens/Chat.tsx | 2 -- bob_party/src/screens/GameChoice.tsx | 6 +----- bob_party/src/screens/Home.tsx | 6 ++---- bob_party/src/screens/LobbySolo.tsx | 1 - bob_party/src/screens/Profile.tsx | 1 - bob_party/src/screens/Settings.tsx | 2 +- bob_party/src/screens/SignIn.tsx | 2 +- bob_party/src/screens/SkinList.tsx | 2 +- bob_party/src/screens/Store.tsx | 5 ----- 27 files changed, 42 insertions(+), 70 deletions(-) create mode 100644 bob_party/appManagers.ts diff --git a/bob_party/App.tsx b/bob_party/App.tsx index 0006c10..654dfe5 100644 --- a/bob_party/App.tsx +++ b/bob_party/App.tsx @@ -1,27 +1,10 @@ import MainTabNavigator from './src/navigation/AppNavigator' import store from './src/redux/store' import { Provider } from 'react-redux' -import LoaderUserApi from './src/services/userServices/loaderUserApi' -import ManagerUser from './src/services/userServices/managerUser' -import FakeSaverUser from './src/services/userServices/fakeSaverUser' import React, { useCallback } from 'react'; -import ManagerConversation from './src/services/conversationService/managerConversation' -import { LoaderConversationApi } from './src/services/conversationService/loaderConversationApi' -import { FakeSaverConversation } from './src/services/conversationService/fakeSaverConversation' -import ManagerMatch from './src/services/matchServices/managerMatch' -import LoaderMatchApi from './src/services/matchServices/loaderMatchApi' -import SaverMatchApi from './src/services/matchServices/saverMatchApi' -import LoaderGameApi from './src/services/gameService/loaderGameApi' -import ManagerGame from './src/services/gameService/managerGame' import { useFonts } from 'expo-font'; -import * as SplashScreen from 'expo-splash-screen'; -import { View } from 'react-native' -export const MANAGER_USER = new ManagerUser(new LoaderUserApi, new FakeSaverUser); -export const MANAGER_CONVERSATION = new ManagerConversation(new LoaderConversationApi, new FakeSaverConversation); -export const MANAGER_MATCH = new ManagerMatch(new LoaderMatchApi, new SaverMatchApi); -export const MANAGER_GAME = new ManagerGame(new LoaderGameApi); export default function App() { diff --git a/bob_party/appManagers.ts b/bob_party/appManagers.ts new file mode 100644 index 0000000..baaba56 --- /dev/null +++ b/bob_party/appManagers.ts @@ -0,0 +1,16 @@ +import { FakeSaverConversation } from "./src/services/conversationService/fakeSaverConversation"; +import { LoaderConversationApi } from "./src/services/conversationService/loaderConversationApi"; +import ManagerConversation from "./src/services/conversationService/managerConversation"; +import LoaderGameApi from "./src/services/gameService/loaderGameApi"; +import ManagerGame from "./src/services/gameService/managerGame"; +import LoaderMatchApi from "./src/services/matchServices/loaderMatchApi"; +import ManagerMatch from "./src/services/matchServices/managerMatch"; +import SaverMatchApi from "./src/services/matchServices/saverMatchApi"; +import FakeSaverUser from "./src/services/userServices/fakeSaverUser"; +import LoaderUserApi from "./src/services/userServices/loaderUserApi"; +import ManagerUser from "./src/services/userServices/managerUser"; + +export const MANAGER_USER = new ManagerUser(new LoaderUserApi, new FakeSaverUser); +export const MANAGER_CONVERSATION = new ManagerConversation(new LoaderConversationApi, new FakeSaverConversation); +export const MANAGER_MATCH = new ManagerMatch(new LoaderMatchApi, new SaverMatchApi); +export const MANAGER_GAME = new ManagerGame(new LoaderGameApi); diff --git a/bob_party/src/Games/CookieClicker/cookieClicker.tsx b/bob_party/src/Games/CookieClicker/cookieClicker.tsx index b899886..7b4b3ec 100644 --- a/bob_party/src/Games/CookieClicker/cookieClicker.tsx +++ b/bob_party/src/Games/CookieClicker/cookieClicker.tsx @@ -9,7 +9,7 @@ import { TouchableHighlight, Alert, } from 'react-native' -import { MANAGER_MATCH, MANAGER_USER } from '../../../App'; +import { MANAGER_MATCH, MANAGER_USER } from '../../../appManagers'; import { useMatchStore } from '../../context/matchContext'; import { useUserStore } from '../../context/userContext'; import { Match } from '../../core/Match/match'; diff --git a/bob_party/src/components/BotBar.tsx b/bob_party/src/components/BotBar.tsx index ab85349..fdd5444 100644 --- a/bob_party/src/components/BotBar.tsx +++ b/bob_party/src/components/BotBar.tsx @@ -7,9 +7,9 @@ import React from "react" */ import styles from './style/BotBar.style'; import { useStoreStore } from "../context/storeContext"; -import { MANAGER_CONVERSATION, MANAGER_USER } from "../../App"; import tabSkinApp from "../constSkin"; import { useConversationStore } from "../context/conversationContext"; +import { MANAGER_CONVERSATION, MANAGER_USER } from "../../appManagers"; /* Images that are required to create a bottom bar diff --git a/bob_party/src/components/ConversationComponent.tsx b/bob_party/src/components/ConversationComponent.tsx index 9320f96..4e99e0e 100644 --- a/bob_party/src/components/ConversationComponent.tsx +++ b/bob_party/src/components/ConversationComponent.tsx @@ -9,8 +9,6 @@ import { Conversation } from "../core/conversation" */ import styles from "./style/ConverstationComponent.style" import { SkinComponent } from "./Skin" -import { User } from "../core/User/user" -import { MANAGER_USER } from "../../App" export const ConversationComponent : /* Parameters : diff --git a/bob_party/src/components/GameComponent.tsx b/bob_party/src/components/GameComponent.tsx index 6b7b5da..a3543e5 100644 --- a/bob_party/src/components/GameComponent.tsx +++ b/bob_party/src/components/GameComponent.tsx @@ -11,8 +11,8 @@ 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_MATCH, MANAGER_USER } from "../../App" import { useMatchStore } from "../context/matchContext" +import { MANAGER_MATCH, MANAGER_USER } from "../../appManagers" export const GameComponent : diff --git a/bob_party/src/components/Skin.tsx b/bob_party/src/components/Skin.tsx index bb5b1d8..6b8e0b2 100644 --- a/bob_party/src/components/Skin.tsx +++ b/bob_party/src/components/Skin.tsx @@ -8,12 +8,12 @@ import { Skin } from "../core/skin" */ import styles from "./style/Skin.style" import { useDispatch, useSelector } from "react-redux" -import { MANAGER_USER } from "../../App" import { useUserStore } from "../context/userContext" -import { ManagerCoinsUser } from "../core/User/userCoinsModifier" +import { UserCoinsModifier } from "../core/User/userCoinsModifier" import UserSkinModifier from "../core/User/userSkinModifier" import { useStoreStore } from "../context/storeContext" import tabSkinApp from "../constSkin" +import { MANAGER_USER } from "../../appManagers" @@ -68,7 +68,7 @@ export const SkinComponent: async function buySkin(skin: Skin) { const mSkin = new UserSkinModifier(); - const mCoins = new ManagerCoinsUser(); + const mCoins = new UserCoinsModifier(); const tmp = MANAGER_USER.getCurrentUser(); if (tmp !== null) { diff --git a/bob_party/src/components/TopBar.tsx b/bob_party/src/components/TopBar.tsx index 8e8aeb9..31492bd 100644 --- a/bob_party/src/components/TopBar.tsx +++ b/bob_party/src/components/TopBar.tsx @@ -9,11 +9,8 @@ import { User } from "../core/User/user" Import the correct stylesheet */ import styles from './style/TopBar.style'; -import { useSelector } from "react-redux" -import { RootState } from "../redux/store" -import { MANAGER_USER } from "../../App" -import { useUserStore } from "../context/userContext" import { useMatchStore } from "../context/matchContext" +import { MANAGER_USER } from "../../appManagers" /* Images required diff --git a/bob_party/src/context/conversationContext.tsx b/bob_party/src/context/conversationContext.tsx index 215674e..0391530 100644 --- a/bob_party/src/context/conversationContext.tsx +++ b/bob_party/src/context/conversationContext.tsx @@ -1,6 +1,5 @@ import React from "react"; import create from "zustand"; -import { MANAGER_USER } from "../../App"; import { Conversation } from "../core/conversation"; diff --git a/bob_party/src/context/gameContext.tsx b/bob_party/src/context/gameContext.tsx index 28a88f0..ea3a2d2 100644 --- a/bob_party/src/context/gameContext.tsx +++ b/bob_party/src/context/gameContext.tsx @@ -1,10 +1,6 @@ -import React from "react"; import create from "zustand"; -import { MANAGER_USER } from "../../App"; -import tabSkinApp from "../constSkin"; import { Game } from "../core/game"; -import { Skin } from "../core/Skin"; -import { User } from "../core/User/user"; + // Define store types diff --git a/bob_party/src/core/Match/matchCasino.ts b/bob_party/src/core/Match/matchCasino.ts index 6376812..b8dec35 100644 --- a/bob_party/src/core/Match/matchCasino.ts +++ b/bob_party/src/core/Match/matchCasino.ts @@ -2,7 +2,7 @@ import { Match } from "./match"; import { User } from "../User/user"; import { Game } from "../game"; import { GameCasino } from "../gameCasino"; -import { ManagerCoinsUser } from "../User/userCoinsModifier"; +import { UserCoinsModifier } from "../User/userCoinsModifier"; export default class MatchCasino extends Match{ @@ -11,7 +11,7 @@ export default class MatchCasino extends Match{ } updatePostMatch(user:User, points: number): void { - const manage= new ManagerCoinsUser(); + const manage= new UserCoinsModifier(); manage.addCoins(user, this.getGame().coinsCalculator(points)); } diff --git a/bob_party/src/core/Match/matchCreator.ts b/bob_party/src/core/Match/matchCreator.ts index 5803af0..d598bf8 100644 --- a/bob_party/src/core/Match/matchCreator.ts +++ b/bob_party/src/core/Match/matchCreator.ts @@ -1,5 +1,4 @@ -import { MANAGER_MATCH } from "../../../App"; -import ManagerMatch from "../../services/matchServices/managerMatch"; +import { MANAGER_MATCH } from "../../../appManagers"; import { Game } from "../game"; import { User } from "../User/user"; import { Match } from "./match"; diff --git a/bob_party/src/core/Match/matchMulti.ts b/bob_party/src/core/Match/matchMulti.ts index c72ba66..b028777 100644 --- a/bob_party/src/core/Match/matchMulti.ts +++ b/bob_party/src/core/Match/matchMulti.ts @@ -2,7 +2,7 @@ import { Match } from "./match"; import { User } from "../User/user"; import { Game } from "../game"; import { GameMulti } from "../gameMulti"; -import { ManagerCoinsUser } from "../User/userCoinsModifier"; +import { UserCoinsModifier } from "../User/userCoinsModifier"; export default class MatchMulti extends Match{ @@ -11,7 +11,7 @@ export default class MatchMulti extends Match{ } updatePostMatch(user:User, points: number): void { - const manage= new ManagerCoinsUser(); + const manage= new UserCoinsModifier(); manage.addCoins(user, this.getGame().coinsCalculator(points)); } } \ No newline at end of file diff --git a/bob_party/src/core/Match/matchSolo.ts b/bob_party/src/core/Match/matchSolo.ts index fef2170..b74b2c6 100644 --- a/bob_party/src/core/Match/matchSolo.ts +++ b/bob_party/src/core/Match/matchSolo.ts @@ -2,7 +2,7 @@ import { Match } from "./match"; import { GameSolo } from "../gameSolo"; import { User } from "../User/user"; import { Game } from "../game"; -import { ManagerCoinsUser } from "../User/userCoinsModifier"; +import { UserCoinsModifier } from "../User/userCoinsModifier"; export default class MatchSolo extends Match{ @@ -11,7 +11,7 @@ export default class MatchSolo extends Match{ } updatePostMatch(user:User, points: number): void { - const manage= new ManagerCoinsUser(); + const manage= new UserCoinsModifier(); manage.addCoins(user, this.getGame().coinsCalculator(points)); } } \ No newline at end of file diff --git a/bob_party/src/core/User/userCoinsModifier.ts b/bob_party/src/core/User/userCoinsModifier.ts index 1bb0e1b..c596704 100644 --- a/bob_party/src/core/User/userCoinsModifier.ts +++ b/bob_party/src/core/User/userCoinsModifier.ts @@ -1,8 +1,7 @@ -import { MANAGER_USER } from "../../../App"; -import ManagerUser from "../../services/userServices/managerUser"; +import { MANAGER_USER } from "../../../appManagers"; import { User } from "./user"; -export class ManagerCoinsUser{ +export class UserCoinsModifier{ async addCoins(u:User, coins:number){ diff --git a/bob_party/src/core/User/userCreator.ts b/bob_party/src/core/User/userCreator.ts index 4c5104d..44830db 100644 --- a/bob_party/src/core/User/userCreator.ts +++ b/bob_party/src/core/User/userCreator.ts @@ -2,7 +2,7 @@ import { User } from "./user"; import tabSkinApp from "../../constSkin"; import { Conversation } from "../conversation"; import ManagerUser from "../../services/userServices/managerUser"; -import { MANAGER_USER } from "../../../App"; +import { MANAGER_USER } from "../../../appManagers"; export class UserCreator{ diff --git a/bob_party/src/core/User/userModificationManager.ts b/bob_party/src/core/User/userModificationManager.ts index 26af738..081df89 100644 --- a/bob_party/src/core/User/userModificationManager.ts +++ b/bob_party/src/core/User/userModificationManager.ts @@ -1,4 +1,4 @@ -import { MANAGER_USER } from "../../../App"; +import { MANAGER_USER } from "../../../appManagers"; import { User } from "./user"; diff --git a/bob_party/src/core/User/userSkinModifier.ts b/bob_party/src/core/User/userSkinModifier.ts index 871afc4..8db7adb 100644 --- a/bob_party/src/core/User/userSkinModifier.ts +++ b/bob_party/src/core/User/userSkinModifier.ts @@ -1,4 +1,4 @@ -import { MANAGER_USER } from '../../../App'; +import { MANAGER_USER } from '../../../appManagers'; import { Skin } from '../Skin' import { User } from './user' diff --git a/bob_party/src/screens/Chat.tsx b/bob_party/src/screens/Chat.tsx index b2cc9d1..1e014da 100644 --- a/bob_party/src/screens/Chat.tsx +++ b/bob_party/src/screens/Chat.tsx @@ -6,8 +6,6 @@ import { TopBar } from '../components/TopBar'; import { BotBar } from '../components/BotBar'; import { FlatList } from 'react-native-gesture-handler'; import { ConversationComponent } from '../components/ConversationComponent'; -import { Conversation } from '../core/conversation'; -import { MANAGER_CONVERSATION, MANAGER_USER } from '../../App'; import { useConversationStore } from '../context/conversationContext'; function Chat(props: { navigation: any; }) { diff --git a/bob_party/src/screens/GameChoice.tsx b/bob_party/src/screens/GameChoice.tsx index d87c690..38f7be5 100644 --- a/bob_party/src/screens/GameChoice.tsx +++ b/bob_party/src/screens/GameChoice.tsx @@ -6,14 +6,10 @@ import { Skin } from '../core/skin'; import { TopBar } from '../components/TopBar'; import { BotBar } from '../components/BotBar'; import { GameComponent } from '../components/GameComponent'; -import { User } from '../core/User/user'; -import tabSkinApp from '../constSkin'; import { Conversation } from '../core/conversation'; -import { GameSolo } from '../core/gameSolo'; import { ScreenIndicator } from '../components/ScreenIndicator'; import stylesScreen from './style/screens.style' -import { MANAGER_GAME } from '../../App'; -import { useGameStore } from '../context/gameContext'; +import { MANAGER_GAME } from '../../appManagers'; let tabConv:Conversation[]=[]; diff --git a/bob_party/src/screens/Home.tsx b/bob_party/src/screens/Home.tsx index cd7d3da..e24091c 100644 --- a/bob_party/src/screens/Home.tsx +++ b/bob_party/src/screens/Home.tsx @@ -6,11 +6,9 @@ import { TopBar } from '../components/TopBar'; import { BotBar } from '../components/BotBar'; import { Conversation } from '../core/conversation'; import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice'; -import { MANAGER_GAME } from '../../App'; import { useGameStore } from '../context/gameContext'; -import { GameSolo } from '../core/gameSolo'; -import { Game } from '../core/game'; -import game from '../testGameSolo'; +import { MANAGER_GAME } from '../../appManagers'; + diff --git a/bob_party/src/screens/LobbySolo.tsx b/bob_party/src/screens/LobbySolo.tsx index 7609175..e352fab 100644 --- a/bob_party/src/screens/LobbySolo.tsx +++ b/bob_party/src/screens/LobbySolo.tsx @@ -6,7 +6,6 @@ import { TopBar } from '../components/TopBar'; import { BotBar } from '../components/BotBar'; import { Conversation } from '../core/conversation'; import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice'; -import { MANAGER_MATCH } from '../../App'; import { useMatchStore } from '../context/matchContext'; diff --git a/bob_party/src/screens/Profile.tsx b/bob_party/src/screens/Profile.tsx index 45e0975..fc71bea 100644 --- a/bob_party/src/screens/Profile.tsx +++ b/bob_party/src/screens/Profile.tsx @@ -8,7 +8,6 @@ import { BotBar } from '../components/BotBar'; import { SkinComponent } from '../components/Skin'; import { ButtonGreySmall } from '../components/ButtonGreySmall'; import { ScreenIndicator } from '../components/ScreenIndicator'; -import { MANAGER_USER } from '../../App'; import { useUserStore } from '../context/userContext'; const coin = require('../../assets/Icons/Coin.png') diff --git a/bob_party/src/screens/Settings.tsx b/bob_party/src/screens/Settings.tsx index 256a22b..bbe1eb4 100644 --- a/bob_party/src/screens/Settings.tsx +++ b/bob_party/src/screens/Settings.tsx @@ -10,10 +10,10 @@ import { RootState } from '../redux/store'; import Dialog from "react-native-dialog" import RNPickerSelect from "react-native-picker-select"; import { PickerGreySmall } from '../components/PickerGreySmall'; -import { MANAGER_USER } from '../../App'; import { useUserStore } from '../context/userContext'; import DialogInput from 'react-native-dialog-input'; import UserModificationManager from '../core/User/userModificationManager'; +import { MANAGER_USER } from '../../appManagers'; function Settings(props: { navigation: any; }) { const { navigation } = props diff --git a/bob_party/src/screens/SignIn.tsx b/bob_party/src/screens/SignIn.tsx index 2c1fe73..9579961 100644 --- a/bob_party/src/screens/SignIn.tsx +++ b/bob_party/src/screens/SignIn.tsx @@ -9,8 +9,8 @@ import { loginUser } from '../redux/features/currentUserSlice'; import { RootState } from '../redux/store'; import { updateIncorrectCredentials } from '../redux/features/credentialErrorsSlice'; import Dialog from "react-native-dialog"; -import { MANAGER_USER } from '../../App'; import { useUserStore } from '../context/userContext'; +import { MANAGER_USER } from '../../appManagers'; diff --git a/bob_party/src/screens/SkinList.tsx b/bob_party/src/screens/SkinList.tsx index 6b34a4f..f39428b 100644 --- a/bob_party/src/screens/SkinList.tsx +++ b/bob_party/src/screens/SkinList.tsx @@ -8,7 +8,7 @@ import { FlatList } from 'react-native-gesture-handler'; import { SkinComponent } from '../components/Skin'; import tabSkinApp from '../constSkin'; import { ScreenIndicator } from '../components/ScreenIndicator'; -import { MANAGER_USER } from '../../App'; +import { MANAGER_USER } from '../../appManagers'; diff --git a/bob_party/src/screens/Store.tsx b/bob_party/src/screens/Store.tsx index 02b5b27..29ebeee 100644 --- a/bob_party/src/screens/Store.tsx +++ b/bob_party/src/screens/Store.tsx @@ -7,11 +7,6 @@ import { BotBar } from '../components/BotBar'; import { FlatList } from 'react-native-gesture-handler'; import { SkinComponent } from '../components/Skin'; import { ScreenIndicator } from '../components/ScreenIndicator'; -import { useSelector } from 'react-redux'; -import { RootState } from '../redux/store'; -import tabSkinApp from '../constSkin'; -import { MANAGER_USER } from '../../App'; -import { useUserStore } from '../context/userContext'; import { useStoreStore } from '../context/storeContext'; From e3cbd209b2799ac6c0c746606b3e9936ba8c25b1 Mon Sep 17 00:00:00 2001 From: aguilhot Date: Mon, 12 Dec 2022 16:22:32 +0100 Subject: [PATCH 3/4] Update: changeNationality et changeSexe dans le screen Settings --- bob_party/src/screens/Settings.tsx | 41 ++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/bob_party/src/screens/Settings.tsx b/bob_party/src/screens/Settings.tsx index bbe1eb4..ace321a 100644 --- a/bob_party/src/screens/Settings.tsx +++ b/bob_party/src/screens/Settings.tsx @@ -29,26 +29,45 @@ function Settings(props: { navigation: any; }) { async function changeUsername(username:string){ - const m = new UserModificationManager(); - const tmp=MANAGER_USER.getCurrentUser(); - if (tmp!==null){ - await m.changeUsername(tmp, username); + let userManager = new UserModificationManager(); + let tmp=MANAGER_USER.getCurrentUser(); + if (tmp!=null){ + await userManager.changeUsername(tmp, username); setUser(tmp); MANAGER_USER.setCurrentUser(tmp); } } async function changePassword(password:string){ - const m = new UserModificationManager(); - const tmp=MANAGER_USER.getCurrentUser(); - if (tmp!==null){ - await m.changePassword(tmp, password); + let userManager = new UserModificationManager(); + let tmp=MANAGER_USER.getCurrentUser(); + if (tmp!=null){ + await userManager.changePassword(tmp, password); + setUser(tmp); + MANAGER_USER.setCurrentUser(tmp); + } + } + + async function changeSexe(sexe:string){ + let userManager = new UserModificationManager(); + let tmp=MANAGER_USER.getCurrentUser(); + if (tmp!=null){ + await userManager.changeSexe(tmp, sexe); + setUser(tmp); + MANAGER_USER.setCurrentUser(tmp); + } + } + + async function changeNationality(nationality:string){ + let userManager = new UserModificationManager(); + let tmp=MANAGER_USER.getCurrentUser(); + if (tmp!=null){ + await userManager.changeNationality(tmp, nationality); setUser(tmp); MANAGER_USER.setCurrentUser(tmp); } } - const dispatch=useDispatch(); return ( @@ -72,11 +91,11 @@ function Settings(props: { navigation: any; }) { Nationalité: {useUserStore().user?.getNationality()} - setSelectedNationality(value)} donePress={() => dispatch(updateNationality(selectedNationality))} values={["Francais", "Anglais"]} /> + setSelectedNationality(value)} donePress={() => changeNationality(selectedNationality)} values={["Francais", "Anglais"]} /> Sexe: {useUserStore().user?.getSexe()} - setSelectedSex(value)} donePress={() => dispatch(updateSex(selectedSex))} values={["Homme", "Femme", "Autre"]} /> + setSelectedSex(value)} donePress={() => changeSexe(selectedSex)} values={["Homme", "Femme", "Autre"]} /> ID: {useUserStore().user?.getId()} From 388cf44e88fcfcb18d182c8c65e5dedc67127b5a Mon Sep 17 00:00:00 2001 From: aguilhot Date: Mon, 12 Dec 2022 16:39:29 +0100 Subject: [PATCH 4/4] FIX: values sexe and nationality in Settings --- bob_party/src/screens/Settings.tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/bob_party/src/screens/Settings.tsx b/bob_party/src/screens/Settings.tsx index ace321a..733f659 100644 --- a/bob_party/src/screens/Settings.tsx +++ b/bob_party/src/screens/Settings.tsx @@ -5,10 +5,6 @@ import stylesScreen from './style/screens.style'; import styles from './style/Settings.style'; import { TopBar } from '../components/TopBar'; import { ButtonGreySmall } from '../components/ButtonGreySmall'; -import { useDispatch, useSelector } from 'react-redux'; -import { RootState } from '../redux/store'; -import Dialog from "react-native-dialog" -import RNPickerSelect from "react-native-picker-select"; import { PickerGreySmall } from '../components/PickerGreySmall'; import { useUserStore } from '../context/userContext'; import DialogInput from 'react-native-dialog-input'; @@ -17,6 +13,7 @@ import { MANAGER_USER } from '../../appManagers'; function Settings(props: { navigation: any; }) { const { navigation } = props + const setUser = useUserStore((state) => state.setUser); @@ -51,7 +48,7 @@ function Settings(props: { navigation: any; }) { async function changeSexe(sexe:string){ let userManager = new UserModificationManager(); let tmp=MANAGER_USER.getCurrentUser(); - if (tmp!=null){ + if (tmp!=null && sexe != null){ await userManager.changeSexe(tmp, sexe); setUser(tmp); MANAGER_USER.setCurrentUser(tmp); @@ -61,7 +58,7 @@ function Settings(props: { navigation: any; }) { async function changeNationality(nationality:string){ let userManager = new UserModificationManager(); let tmp=MANAGER_USER.getCurrentUser(); - if (tmp!=null){ + if (tmp!=null && nationality != null){ await userManager.changeNationality(tmp, nationality); setUser(tmp); MANAGER_USER.setCurrentUser(tmp); @@ -91,11 +88,11 @@ function Settings(props: { navigation: any; }) { Nationalité: {useUserStore().user?.getNationality()} - setSelectedNationality(value)} donePress={() => changeNationality(selectedNationality)} values={["Francais", "Anglais"]} /> + setSelectedNationality(value)} donePress={() => changeNationality(selectedNationality)} values={[ { label: 'France', value: 'Francais(e)' }, { label: 'Royaume-Uni', value: 'Anglais(e)' }, { label: 'Espagne', value: 'Espagnol(e)' }, { label: 'Belgique', value: 'Belge' }, { label: 'Allemagne', value: 'Allemand(e)' }, ]}/> Sexe: {useUserStore().user?.getSexe()} - setSelectedSex(value)} donePress={() => changeSexe(selectedSex)} values={["Homme", "Femme", "Autre"]} /> + setSelectedSex(value)} donePress={() => changeSexe(selectedSex)} values={[ { label: 'Homme', value: 'Homme' }, { label: 'Femme', value: 'Femme' }, {label: 'Autre', value: 'Autre' } ]} /> ID: {useUserStore().user?.getId()}