Merge branch 'Persistance' into temp
continuous-integration/drone/push Build is failing Details

temp
Thomas Chazot 2 years ago
commit 75a1b81ccd

@ -4,7 +4,6 @@ import { Provider } from 'react-redux'
import LoaderUserApi from './src/services/userServices/loaderUserApi' import LoaderUserApi from './src/services/userServices/loaderUserApi'
import ManagerUser from './src/services/userServices/ManagerUser' import ManagerUser from './src/services/userServices/ManagerUser'
import FakeSaverUser from './src/services/userServices/fakeSaverUser' import FakeSaverUser from './src/services/userServices/fakeSaverUser'
import { View, Text, Button } from 'react-native';
import React, { useCallback } from 'react'; import React, { useCallback } from 'react';
import { useUserStore } from './userContext'; import { useUserStore } from './userContext';
import stylesScreen from './src/screens/style/screens.style' import stylesScreen from './src/screens/style/screens.style'
@ -22,21 +21,7 @@ export const MANAGER_USER = new ManagerUser(new LoaderUserApi, new FakeSaverUser
const resetUser = useUserStore((state) => state.resetUser); const resetUser = useUserStore((state) => state.resetUser);
const handleUserConnect = useCallback(async () => { const handleUserConnect = useCallback(async () => {
/*
fetch(GET_USER_URL)
.then((res) => {
if (res.status === 200) {
return res.json();
}
throw new Error("Bad User");
})
.then((user) => {
setUser(user);
})
.catch((err) => {
console.log(err);
});
*/
await MANAGER_USER.getLoaderUser().loadByID("14").then((res) => { await MANAGER_USER.getLoaderUser().loadByID("14").then((res) => {
MANAGER_USER.setCurrentUser(res); MANAGER_USER.setCurrentUser(res);
console.log(res); console.log(res);
@ -58,6 +43,12 @@ export const MANAGER_USER = new ManagerUser(new LoaderUserApi, new FakeSaverUser
}, []); }, []);
const test = useCallback(async () => {
const tab = await MANAGER_USER.getLoaderUser().loadAllUser();
MANAGER_USER.setCurrentUser(tab[0]);
setUser(MANAGER_USER.getCurrentUser());
}, []);
return ( return (
<Provider store={store}> <Provider store={store}>
<MainTabNavigator/> <MainTabNavigator/>
@ -66,15 +57,3 @@ export const MANAGER_USER = new ManagerUser(new LoaderUserApi, new FakeSaverUser
} }
const AUser = () => {
const userName = useUserStore((state) => state.user?.getUsername());
const test = useUserStore((state) => state.user?.getCurrentCoins());
return userName === undefined ? (
<Text>Not Connected</Text>
) : (
<View>
<Text>Hello {userName}</Text>
<Text>Money {test}</Text>
</View>
);
};

@ -1,6 +1,6 @@
import { configureStore } from "@reduxjs/toolkit"; import { configureStore } from "@reduxjs/toolkit";
import currentUserReducer from "./features/currentUserSlice";
import credentialErrorsSlice from "./features/credentialErrorsSlice"; import credentialErrorsSlice from "./features/credentialErrorsSlice";
import { getDefaultMiddleware } from '@reduxjs/toolkit'; import { getDefaultMiddleware } from '@reduxjs/toolkit';
const customizedMiddleware = getDefaultMiddleware({ const customizedMiddleware = getDefaultMiddleware({
@ -9,8 +9,8 @@ const customizedMiddleware = getDefaultMiddleware({
const store = configureStore({ const store = configureStore({
reducer: { reducer: {
currentUserManager: currentUserReducer,
credentialErrors: credentialErrorsSlice, credentialErrors: credentialErrorsSlice,
}, },
middleware: (getDefaultMiddleware) => customizedMiddleware, middleware: (getDefaultMiddleware) => customizedMiddleware,
}) })

@ -6,9 +6,6 @@ import { TopBar } from '../components/TopBar';
import { BotBar } from '../components/BotBar'; import { BotBar } from '../components/BotBar';
import { FlatList } from 'react-native-gesture-handler'; import { FlatList } from 'react-native-gesture-handler';
import { ConversationComponent } from '../components/ConversationComponent'; import { ConversationComponent } from '../components/ConversationComponent';
import { useSelector } from 'react-redux';
import { RootState } from '../redux/store';
import { MANAGER_USER } from '../../App';
function Chat(props: { navigation: any; }) { function Chat(props: { navigation: any; }) {
const { navigation } = props const { navigation } = props
@ -20,7 +17,8 @@ function Chat(props: { navigation: any; }) {
nav={navigation} nav={navigation}
/> />
<View style={stylesScreen.bodyStart}> <View style={stylesScreen.bodyStart}>
{/*
{/*
<FlatList <FlatList
data={MANAGER_USER.getCurrentUser().getTabConv()} data={MANAGER_USER.getCurrentUser().getTabConv()}
renderItem={({item}) => <ConversationComponent conv={item} state='Preview'/>} renderItem={({item}) => <ConversationComponent conv={item} state='Preview'/>}

@ -8,8 +8,7 @@ import { BotBar } from '../components/BotBar';
import { SkinComponent } from '../components/Skin'; import { SkinComponent } from '../components/Skin';
import { ButtonGreySmall } from '../components/ButtonGreySmall'; import { ButtonGreySmall } from '../components/ButtonGreySmall';
import { ScreenIndicator } from '../components/ScreenIndicator'; import { ScreenIndicator } from '../components/ScreenIndicator';
import { useSelector } from 'react-redux';
import { RootState } from '../redux/store';
import { MANAGER_USER } from '../../App'; import { MANAGER_USER } from '../../App';
const coin = require('../../assets/Icons/Coin.png') const coin = require('../../assets/Icons/Coin.png')
@ -19,6 +18,7 @@ const coin = require('../../assets/Icons/Coin.png')
function Profile(props: { navigation: any; }) { function Profile(props: { navigation: any; }) {
const { navigation } = props const { navigation } = props
return ( return (
<View style={stylesScreen.container}> <View style={stylesScreen.container}>
<TopBar <TopBar
@ -42,6 +42,7 @@ function Profile(props: { navigation: any; }) {
</View> </View>
<View style={styles.infoView}> <View style={styles.infoView}>
<Text style={styles.infoText}>Total de BobCoin gagnés: {MANAGER_USER.getCurrentUser().getTotalCoins()}</Text> <Text style={styles.infoText}>Total de BobCoin gagnés: {MANAGER_USER.getCurrentUser().getTotalCoins()}</Text>
<Text style={styles.infoText}>Total de BobCoin gagnés: </Text>
</View> </View>
</View> </View>
<BotBar <BotBar

@ -7,13 +7,13 @@ import { TopBar } from '../components/TopBar';
import { ButtonGreySmall } from '../components/ButtonGreySmall'; import { ButtonGreySmall } from '../components/ButtonGreySmall';
import { useDispatch, useSelector } from 'react-redux'; import { useDispatch, useSelector } from 'react-redux';
import { RootState } from '../redux/store'; import { RootState } from '../redux/store';
import DialogInput from "react-native-dialog-input";
import { updatePseudo, updatePassword, updateNationality, updateSex } from "../redux/features/currentUserSlice";
import Dialog from "react-native-dialog" import Dialog from "react-native-dialog"
import RNPickerSelect from "react-native-picker-select"; import RNPickerSelect from "react-native-picker-select";
import { PickerGreySmall } from '../components/PickerGreySmall'; import { PickerGreySmall } from '../components/PickerGreySmall';
import { MANAGER_USER } from '../../App'; import { MANAGER_USER } from '../../App';
import { useUserStore } from '../../userContext'; import { useUserStore } from '../../userContext';
import DialogInput from 'react-native-dialog/lib/Input';
function Settings(props: { navigation: any; }) { function Settings(props: { navigation: any; }) {
const { navigation } = props const { navigation } = props
@ -82,6 +82,7 @@ function Settings(props: { navigation: any; }) {
title="Inserer le nouveau pseudo" title="Inserer le nouveau pseudo"
hintInput ="Pseudo" hintInput ="Pseudo"
submitInput={ (inputText: string) => { changeUsername(inputText); setDialogPseudoVisible(false)} } submitInput={ (inputText: string) => { changeUsername(inputText); setDialogPseudoVisible(false)} }
closeDialog={ () => {setDialogPseudoVisible(false)}}> closeDialog={ () => {setDialogPseudoVisible(false)}}>
</DialogInput> </DialogInput>

@ -20,7 +20,7 @@ function SignIn(props: { navigation: any; }) {
const setUser = useUserStore((state) => state.setUser); const setUser = useUserStore((state) => state.setUser);
const errorList = useSelector((state: RootState) => state.credentialErrors.loginErrorList); const errorList = useSelector((state: RootState) => state.credentialErrors.loginErrorList);
{/*
const [pseudo, setPseudo] = useState(''); const [pseudo, setPseudo] = useState('');
const [password, setPassword] = useState(''); const [password, setPassword] = useState('');
const dispatch=useDispatch(); const dispatch=useDispatch();
@ -29,6 +29,7 @@ function SignIn(props: { navigation: any; }) {
Alert.alert("Pseudo ou Mot de passe incorrect"); Alert.alert("Pseudo ou Mot de passe incorrect");
dispatch(updateIncorrectCredentials(true)); dispatch(updateIncorrectCredentials(true));
} }
*/}
const handleUserConnect = useCallback(async (pseudo: string, password: string) => { const handleUserConnect = useCallback(async (pseudo: string, password: string) => {
@ -49,15 +50,18 @@ function SignIn(props: { navigation: any; }) {
return ( return (
<View style={stylesScreen.container}> <View style={stylesScreen.container}>
<View style={stylesScreen.bodyCenter}> <View style={stylesScreen.bodyCenter}>
{/*
<TextInput style={styles.textInput} placeholder='Login' onChangeText={(val) => setPseudo(val)} autoCapitalize='none' /> <TextInput style={styles.textInput} placeholder='Login' onChangeText={(val) => setPseudo(val)} autoCapitalize='none' />
<TextInput style={styles.textInput} placeholder='Password' onChangeText={(val) => setPassword(val)} autoCapitalize='none' secureTextEntry={true}/> <TextInput style={styles.textInput} placeholder='Password' onChangeText={(val) => setPassword(val)} autoCapitalize='none' secureTextEntry={true}/>
<Pressable style={styles.button} onPress={() => handleUserConnect(pseudo, password)}> <Pressable style={styles.button} onPress={() => handleUserConnect(pseudo, password)}>
<Text style={styles.text}>Se connecter</Text> <Text style={styles.text}>Se connecter</Text>
</Pressable> </Pressable>
*/}
<Pressable onPress={() => navigation.navigate('SignUp')}> <Pressable onPress={() => navigation.navigate('SignUp')}>
<Text style={styles.textLink}>Pas de compte? Inscrivez vous !</Text> <Text style={styles.textLink}>Pas de compte? Inscrivez vous !</Text>
</Pressable> </Pressable>
</View> </View>
{/*
<Dialog.Container visible={false}> <Dialog.Container visible={false}>
<Dialog.Title>Ce pseudo n'exsite pas</Dialog.Title> <Dialog.Title>Ce pseudo n'exsite pas</Dialog.Title>
<Dialog.Button label="Fermer" onPress={() => dispatch(updateIncorrectCredentials(false))} /> <Dialog.Button label="Fermer" onPress={() => dispatch(updateIncorrectCredentials(false))} />
@ -66,6 +70,7 @@ function SignIn(props: { navigation: any; }) {
<Dialog.Title>Mot de passe incorrect</Dialog.Title> <Dialog.Title>Mot de passe incorrect</Dialog.Title>
<Dialog.Button label="Fermer" onPress={() => dispatch(updateIncorrectCredentials(false))} /> <Dialog.Button label="Fermer" onPress={() => dispatch(updateIncorrectCredentials(false))} />
</Dialog.Container> </Dialog.Container>
*/}
</View> </View>
); );

@ -8,8 +8,6 @@ import { FlatList } from 'react-native-gesture-handler';
import { SkinComponent } from '../components/Skin'; import { SkinComponent } from '../components/Skin';
import tabSkinApp from '../constSkin'; import tabSkinApp from '../constSkin';
import { ScreenIndicator } from '../components/ScreenIndicator'; import { ScreenIndicator } from '../components/ScreenIndicator';
import { useSelector } from 'react-redux';
import { RootState } from '../redux/store';

@ -7,8 +7,6 @@ import { BotBar } from '../components/BotBar';
import { FlatList } from 'react-native-gesture-handler'; import { FlatList } from 'react-native-gesture-handler';
import { SkinComponent } from '../components/Skin'; import { SkinComponent } from '../components/Skin';
import { ScreenIndicator } from '../components/ScreenIndicator'; import { ScreenIndicator } from '../components/ScreenIndicator';
import { useSelector } from 'react-redux';
import { RootState } from '../redux/store';
import { MANAGER_USER } from '../../App'; import { MANAGER_USER } from '../../App';
function Store(props: { navigation: any; }) { function Store(props: { navigation: any; }) {

@ -1,3 +1,4 @@
import tabSkinApp from "../../constSkin";
import { Conversation } from "../../core/conversation"; import { Conversation } from "../../core/conversation";
import { Match } from "../../core/match"; import { Match } from "../../core/match";
import { Skin } from "../../core/skin"; import { Skin } from "../../core/skin";
@ -23,21 +24,23 @@ export default class LoaderUserApi implements ILoaderUser{
private axios = require('axios').default; private axios = require('axios').default;
async loadAllUser() : Promise<User[]> { async loadAllUser() : Promise<User[]> {
let test = new Test(true, 0, "wesh", 0); let us:User[]=[];
let test=new Test(false, 1, "a", 1);
await this.axios({ await this.axios({
method: 'get', method: 'get',
url: 'https://jsonplaceholder.typicode.com/todos/1', url: 'https://jsonplaceholder.typicode.com/todos',
params: { params: {
name: "getAllUser", name: "getAllUser",
//Les params genre nom de la fonction en php //Les params genre nom de la fonction en php
} }
}) })
.then(function (response: any) { .then(function (response: any) {
console.log(response.data); if (response.data != null && response.data != undefined){
Object.assign(test, response.data); Object.assign(test, response.data);
console.log(test.id); us.push(new User("17", "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[6], tabSkinApp));
}); }
return []; });
return us;
} }
@ -61,7 +64,7 @@ export default class LoaderUserApi implements ILoaderUser{
}catch (error) { }catch (error) {
console.error(error); console.error(error);
} }
return null; return new User("17", "Bite", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 123, 123324, 12, tabSkinApp[6], tabSkinApp);
} }

Loading…
Cancel
Save