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 ManagerUser from './src/services/userServices/ManagerUser'
import FakeSaverUser from './src/services/userServices/fakeSaverUser'
import { View, Text, Button } from 'react-native';
import React, { useCallback } from 'react';
import { useUserStore } from './userContext';
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 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) => {
MANAGER_USER.setCurrentUser(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 (
<Provider store={store}>
<MainTabNavigator/>
@ -65,16 +56,4 @@ 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 currentUserReducer from "./features/currentUserSlice";
import credentialErrorsSlice from "./features/credentialErrorsSlice";
import { getDefaultMiddleware } from '@reduxjs/toolkit';
const customizedMiddleware = getDefaultMiddleware({
@ -9,8 +9,8 @@ const customizedMiddleware = getDefaultMiddleware({
const store = configureStore({
reducer: {
currentUserManager: currentUserReducer,
credentialErrors: credentialErrorsSlice,
},
middleware: (getDefaultMiddleware) => customizedMiddleware,
})

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

@ -8,8 +8,7 @@ import { BotBar } from '../components/BotBar';
import { SkinComponent } from '../components/Skin';
import { ButtonGreySmall } from '../components/ButtonGreySmall';
import { ScreenIndicator } from '../components/ScreenIndicator';
import { useSelector } from 'react-redux';
import { RootState } from '../redux/store';
import { MANAGER_USER } from '../../App';
const coin = require('../../assets/Icons/Coin.png')
@ -19,6 +18,7 @@ const coin = require('../../assets/Icons/Coin.png')
function Profile(props: { navigation: any; }) {
const { navigation } = props
return (
<View style={stylesScreen.container}>
<TopBar
@ -42,6 +42,7 @@ function Profile(props: { navigation: any; }) {
</View>
<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: </Text>
</View>
</View>
<BotBar

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

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

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

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