added partyPlayed into the user metrics model and added a dummy profile setting view page

This commit is contained in:
Clément Le Bihan
2023-04-05 01:20:03 +02:00
parent 4e26925113
commit 9dfc2881a2
6 changed files with 66 additions and 26 deletions

View File

@@ -154,7 +154,9 @@ export default class API {
email: user.email as string,
xp: 0,
premium: false,
metrics: {},
metrics: {
partyPlayed: user.partyPlayed as number,
},
settings: {
preferences: {
deviceId: 1,

View File

@@ -107,6 +107,9 @@ export const en = {
changeEmail: 'Change email',
oldEmail: 'Old email',
newEmail: 'New email',
passwordUpdated: 'Password updated',
emailUpdated: 'Email updated',
};
export const fr: typeof en = {
@@ -141,7 +144,7 @@ export const fr: typeof en = {
mostPlayedSong: 'Chanson la plus jouée : ',
goodNotesPlayed: 'Bonnes notes jouées : ',
longestCombo: 'Combo le plus long : ',
favoriteGenre: 'Genre favorit : ',
favoriteGenre: 'Genre favori : ',
// Difficulty settings
diffBtn: 'Difficulté',
@@ -214,6 +217,9 @@ export const fr: typeof en = {
errAlrdExst: "Utilisateur existe déjà",
unknownError: 'Erreur inconnue',
errIncrrct: 'Identifiant incorrect',
passwordUpdated: 'Mot de passe mis à jour',
emailUpdated: 'Email mis à jour',
};
export const sp: typeof en = {
@@ -320,9 +326,12 @@ export const sp: typeof en = {
errAlrdExst: "Ya existe",
errIncrrct: "credenciales incorrectas",
changePassword: 'Change password',
oldPassword: 'Old password',
newPassword: 'New password',
confirmNewPassword: 'Confirm new password',
submitBtn: 'Submit',
changePassword: 'Cambio de contraseña',
oldPassword: 'Contraseña anterior',
newPassword: 'Nueva contraseña',
confirmNewPassword: 'Confirmar nueva contraseña',
submitBtn: 'Enviar',
passwordUpdated: 'Contraseña actualizada',
emailUpdated: 'Email actualizado',
};

View File

@@ -1,5 +1,5 @@
interface Metrics {
partyPlayed: number;
}
export default Metrics;

View File

@@ -89,7 +89,7 @@ const ProfileView = () => {
<PlayerStats/>
<Box w="10%" paddingY={10} paddingLeft={5} paddingRight={50} zIndex={1}>
<TextButton
onPress={() => navigation.navigate('Settings')}
onPress={() => navigation.navigate('Settings', {screen: 'Profile'})}
style={{margin: 10}}
translate={{ translationKey: 'settingsBtn' }}
/>

View File

@@ -0,0 +1,42 @@
import API from "../../API";
import { useDispatch } from "react-redux";
import { unsetAccessToken } from "../../state/UserSlice";
import React, { useEffect, useState } from "react";
import { Column, Text, Button, Icon, Box, Center, Heading } from "native-base";
import User from "../../models/User";
import TextButton from "../../components/TextButton";
const ProfileSettings = ({ navigation }: { navigation: any }) => {
const [user, setUser] = useState<User | null>(null);
const dispatch = useDispatch();
useEffect(() => {
API.getUserInfo().then((user) => {
setUser(user);
});
}, []);
return (
<Center style={{ flex: 1}}>
{user && (
<Column>
<Heading>Profile Settings</Heading>
<Text>Username: {user.name}</Text>
<Text>ID: {user.id}</Text>
<Text>Email: {user.email}</Text>
<Text>Party played: {user.metrics.partyPlayed}</Text>
<Text>XP: {user.xp}</Text>
</Column>
)}
<TextButton onPress={() => dispatch(unsetAccessToken())} translate={{
translationKey: "signOutBtn",
}} />
</Center>
);
};
export default ProfileSettings;

View File

@@ -13,6 +13,7 @@ import createTabRowNavigator from '../../components/navigators/TabRowNavigator';
import { FontAwesome } from '@expo/vector-icons';
import ChangePasswordForm from '../../components/forms/changePasswordForm';
import ChangeEmailForm from '../../components/forms/changeEmailForm';
import ProfileSettings from './SettingsProfileView';
import API, { APIError } from '../../API';
@@ -22,7 +23,7 @@ const SettingsStack = createNativeStackNavigator();
const handleChangeEmail = async (newEmail: string): Promise<string> => {
try {
let response = await API.updateUserEmail(newEmail);
return translate('emailChanged');
return translate('emailUpdated');
} catch (e) {
throw e;
}
@@ -31,7 +32,7 @@ const handleChangeEmail = async (newEmail: string): Promise<string> => {
const handleChangePassword = async (oldPassword: string, newPassword: string): Promise<string> => {
try {
let response = await API.updateUserPassword(oldPassword, newPassword);
return translate('passwordChanged');
return translate('passwordUpdated');
} catch (e) {
throw e;
}
@@ -253,27 +254,13 @@ const SetttingsNavigator = () => {
{/* I'm doing this to be able to land on the summary of settings when clicking on settings and directly to the
wanted settings page if needed so I need to do special work with the 0 index */}
<TabRow.Screen name='InternalDefault' component={Box} />
<TabRow.Screen name='Main' component={MainView} options={{ title: "Profil", iconProvider: FontAwesome, iconName: "user" }} />
<TabRow.Screen name='Profile' component={ProfileSettings} options={{ title: "Profil", iconProvider: FontAwesome, iconName: "user" }} />
<TabRow.Screen name='Preferences' component={PreferencesView} />
<TabRow.Screen name='Notifications' component={NotificationsView} />
<TabRow.Screen name='Privacy' component={PrivacyView} />
<TabRow.Screen name='ChangePassword' component={ChangePasswordView} />
<TabRow.Screen name='ChangeEmail' component={ChangeEmailView} />
<TabRow.Screen name='GoogleAccount' component={GoogleAccountView} />
<TabRow.Screen name='2Main' component={MainView} options={{ title: "Profil", iconProvider: FontAwesome, iconName: "user" }} />
<TabRow.Screen name='2Preferences' component={PreferencesView} />
<TabRow.Screen name='2Notifications' component={NotificationsView} />
<TabRow.Screen name='2Privacy' component={PrivacyView} />
<TabRow.Screen name='2ChangePassword' component={ChangePasswordView} />
<TabRow.Screen name='2ChangeEmail' component={ChangeEmailView} />
<TabRow.Screen name='2GoogleAccount' component={GoogleAccountView} />
<TabRow.Screen name='3Main' component={MainView} options={{ title: "Profil", iconProvider: FontAwesome, iconName: "user" }} />
<TabRow.Screen name='3Preferences' component={PreferencesView} />
<TabRow.Screen name='3Notifications' component={NotificationsView} />
<TabRow.Screen name='3Privacy' component={PrivacyView} />
<TabRow.Screen name='3ChangePassword' component={ChangePasswordView} />
<TabRow.Screen name='3ChangeEmail' component={ChangeEmailView} />
<TabRow.Screen name='3GoogleAccount' component={GoogleAccountView} />
</TabRow.Navigator>
)
}