diff --git a/front/API.ts b/front/API.ts index 50e6222..5ceb906 100644 --- a/front/API.ts +++ b/front/API.ts @@ -146,6 +146,14 @@ export default class API { return response.access_token; } + public static async transformGuestToUser(registrationInput: RegistrationInput): Promise { + await API.fetch({ + route: "/auth/me", + body: registrationInput, + method: "PUT", + }); + } + /*** * Retrieve information of the currently authentified user */ diff --git a/front/i18n/Translations.ts b/front/i18n/Translations.ts index 7db1f6b..bdf85f0 100644 --- a/front/i18n/Translations.ts +++ b/front/i18n/Translations.ts @@ -119,6 +119,25 @@ export const en = { SettingsCategoryEmail: 'Email', SettingsCategoryGoogle: 'Google', SettingsCategoryPiano: 'Piano', + SettingsCategoryGuest: 'Guest', + + transformGuestToUserExplanations: 'You can transform your guest account to a user account by providing a username and a password. You will then be able to save your progress and access your profile.', + SettingsNotificationsPushNotifications: 'Push', + SettingsNotificationsEmailNotifications: 'Email', + SettingsNotificationsTrainingReminder: 'Training reminder', + SettingsNotificationsReleaseAlert: 'Release alert', + + dataCollection: 'Data collection', + customAds: 'Custom ads', + recommendations: 'Recommendations', + + SettingsPreferencesTheme: 'Theme', + SettingsPreferencesLanguage: 'Language', + SettingsPreferencesDifficulty: 'Difficulty', + SettingsPreferencesColorblindMode: 'Colorblind mode', + SettingsPreferencesMicVolume: 'Mic volume', + SettingsPreferencesDevice: 'Device', + }; export const fr: typeof en = { @@ -238,6 +257,25 @@ export const fr: typeof en = { SettingsCategoryEmail: 'Email', SettingsCategoryGoogle: 'Google', SettingsCategoryPiano: 'Piano', + + transformGuestToUserExplanations: 'Vous êtes actuellement connecté en tant qu\'invité. Vous pouvez créer un compte pour sauvegarder vos données et profiter de toutes les fonctionnalités de Chromacase.', + SettingsCategoryGuest: 'Invité', + SettingsNotificationsEmailNotifications: 'Email', + SettingsNotificationsPushNotifications: 'Notifications push', + SettingsNotificationsReleaseAlert: 'Alertes de nouvelles Sorties', + SettingsNotificationsTrainingReminder: 'Rappel d\'entrainement', + + SettingsPreferencesColorblindMode: 'Mode daltonien', + SettingsPreferencesDevice: 'Appareil', + SettingsPreferencesDifficulty: 'Difficulté', + SettingsPreferencesLanguage: 'Langue', + SettingsPreferencesTheme: 'Thème', + SettingsPreferencesMicVolume: 'Volume du micro', + + dataCollection: 'Collecte de données', + recommendations: 'Recommandations', + customAds: 'Publicités personnalisées', + }; export const sp: typeof en = { @@ -360,4 +398,22 @@ export const sp: typeof en = { SettingsCategorySecurity: 'Seguridad', SettingsCategoryEmail: 'Email', SettingsCategoryGoogle: 'Google', + + transformGuestToUserExplanations: 'Actualmente estás conectado como invitado. Puedes crear una cuenta para guardar tus datos y disfrutar de todas las funciones de Chromacase.', + SettingsCategoryGuest: 'Invitado', + SettingsNotificationsEmailNotifications: 'Email', + SettingsNotificationsPushNotifications: 'Notificaciones push', + SettingsNotificationsReleaseAlert: 'Alertas de nuevas Sorties', + SettingsNotificationsTrainingReminder: 'Recordatorio de entrenamiento', + + SettingsPreferencesColorblindMode: 'Modo daltoniano', + SettingsPreferencesDevice: 'Dispositivo', + SettingsPreferencesDifficulty: 'Dificultad', + SettingsPreferencesLanguage: 'Idioma', + SettingsPreferencesTheme: 'Tema', + SettingsPreferencesMicVolume: 'Volumen del micrófono', + + dataCollection: 'Recopilación de datos', + recommendations: 'Recomendaciones', + customAds: 'Anuncios personalizados', }; \ No newline at end of file diff --git a/front/views/settings/GuestToUserView.tsx b/front/views/settings/GuestToUserView.tsx index 4f62a5e..72d7700 100644 --- a/front/views/settings/GuestToUserView.tsx +++ b/front/views/settings/GuestToUserView.tsx @@ -1,38 +1,34 @@ import React from "react"; import SignUpForm from "../../components/forms/signupform"; -import { Center } from "native-base"; +import { Center, Heading, Text } from "native-base"; import API, { APIError } from "../../API"; import { translate } from "../../i18n/i18n"; -import { useDispatch } from "../../state/Store"; -import { setAccessToken } from "../../state/UserSlice"; const handleSubmit = async ( username: string, password: string, - email: string, - apiSetter: (token: string) => void + email: string ) => { - let res: string; try { - res = await API.createAccount({ username, password, email }); + await API.transformGuestToUser({ username, password, email }); } catch (error) { if (error instanceof APIError) return translate(error.userMessage); if (error instanceof Error) return error.message; return translate("unknownError"); } - apiSetter(res); return translate("loggedIn"); }; const GuestToUserView = () => { - const dispatch = useDispatch(); return (
+ {translate("signUp")} + + {translate("transformGuestToUserExplanations")} + - handleSubmit(username, password, email, (token) => - dispatch(setAccessToken(token)) - ) + handleSubmit(username, password, email) } />
diff --git a/front/views/settings/NotificationView.tsx b/front/views/settings/NotificationView.tsx index 82e50de..cdf93ea 100644 --- a/front/views/settings/NotificationView.tsx +++ b/front/views/settings/NotificationView.tsx @@ -40,7 +40,7 @@ const NotificationsView = ({ navigation }) => { elements={[ { type: "toggle", - title: "Push notifications", + title: translate("SettingsNotificationsPushNotifications"), data: { value: pushNotifications, onToggle: () => { @@ -55,7 +55,7 @@ const NotificationsView = ({ navigation }) => { }, { type: "toggle", - title: "Email notifications", + title: translate("SettingsNotificationsEmailNotifications"), data: { value: emailNotifications, onToggle: () => { @@ -70,7 +70,7 @@ const NotificationsView = ({ navigation }) => { }, { type: "toggle", - title: "Training reminder", + title: translate("SettingsNotificationsTrainingReminder"), data: { value: trainingReminder, onToggle: () => { @@ -85,7 +85,7 @@ const NotificationsView = ({ navigation }) => { }, { type: "toggle", - title: "New songs", + title: translate("SettingsNotificationsReleaseAlert"), data: { value: releaseAlert, onToggle: () => { diff --git a/front/views/settings/PreferencesView.tsx b/front/views/settings/PreferencesView.tsx index c226f46..4b63bbd 100644 --- a/front/views/settings/PreferencesView.tsx +++ b/front/views/settings/PreferencesView.tsx @@ -43,7 +43,7 @@ const PreferencesView = ({ navigation }) => { elements={[ { type: "dropdown", - title: "Theme", + title: translate("SettingsPreferencesTheme"), data: { value: settings.colorScheme, defaultValue: "system", @@ -61,7 +61,7 @@ const PreferencesView = ({ navigation }) => { }, { type: "dropdown", - title: "Language", + title: translate("SettingsPreferencesLanguage"), data: { value: language, defaultValue: DefaultLanguage, @@ -71,14 +71,13 @@ const PreferencesView = ({ navigation }) => { options: [ { label: "Français", value: "fr" }, { label: "English", value: "en" }, - { label: "Italiano", value: "it" }, { label: "Espanol", value: "sp" }, ], }, }, { type: "dropdown", - title: "Difficulty", + title: translate("SettingsPreferencesDifficulty"), data: { value: settings.preferedLevel, defaultValue: "medium", @@ -103,7 +102,7 @@ const PreferencesView = ({ navigation }) => { elements={[ { type: "toggle", - title: "Color blind mode", + title: translate("SettingsPreferencesColorblindMode"), data: { value: settings.colorBlind, onToggle: () => { @@ -122,7 +121,7 @@ const PreferencesView = ({ navigation }) => { elements={[ { type: "range", - title: "Mic volume", + title: translate("SettingsPreferencesMicVolume"), data: { value: settings.micLevel, min: 0, @@ -135,7 +134,7 @@ const PreferencesView = ({ navigation }) => { }, { type: "dropdown", - title: "Device", + title: translate("SettingsPreferencesDevice"), data: { value: settings.preferedInputName || "0", defaultValue: "0", diff --git a/front/views/settings/SettingsProfileView.tsx b/front/views/settings/SettingsProfileView.tsx index ba805eb..9e73a6a 100644 --- a/front/views/settings/SettingsProfileView.tsx +++ b/front/views/settings/SettingsProfileView.tsx @@ -231,7 +231,7 @@ const ProfileSettings = ({ navigation }: { navigation: any }) => {