From ce0123d348de1b80cf0444abcf15a6b9c0392af4 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 8 Jul 2024 13:32:25 -0600 Subject: [PATCH 01/15] =?UTF-8?q?Se=20agrego=20la=20ruta=20para=20cambiar?= =?UTF-8?q?=20de=20contrase=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/app/profile/change_password.tsx | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 mobile/app/profile/change_password.tsx diff --git a/mobile/app/profile/change_password.tsx b/mobile/app/profile/change_password.tsx new file mode 100644 index 00000000..871eae2e --- /dev/null +++ b/mobile/app/profile/change_password.tsx @@ -0,0 +1,7 @@ +import { ChangePasswordPage } from "../../src/profile/screens/change_password_page"; + +export default function ChangePasswordScreen() { + return ( + + ); +} \ No newline at end of file -- GitLab From 47a5f1f0c0d499b345308cb144bd6e06da5505ec Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 8 Jul 2024 13:35:15 -0600 Subject: [PATCH 02/15] =?UTF-8?q?Se=20agrego=20la=20ruta=20al=20manejador?= =?UTF-8?q?=20de=20rutas=20para=20cambiar=20de=20contrase=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/app/profile/_layout.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mobile/app/profile/_layout.tsx b/mobile/app/profile/_layout.tsx index 2d267936..38c320f5 100644 --- a/mobile/app/profile/_layout.tsx +++ b/mobile/app/profile/_layout.tsx @@ -28,6 +28,10 @@ export default function Layout() { title: "Set Up Profile", headerShown: true, }}/> + ); } \ No newline at end of file -- GitLab From c08395c9ad4fed59270d04d4885785c5ae0640bd Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 8 Jul 2024 13:37:47 -0600 Subject: [PATCH 03/15] Se agrego multilenguaje a las peticiones de la api --- mobile/src/common/contexts/data_context.tsx | 22 +++++++++++++------ .../datasource/prod/activity_datasource.ts | 4 +++- .../datasource/prod/state_datasource.ts | 13 ++++++----- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/mobile/src/common/contexts/data_context.tsx b/mobile/src/common/contexts/data_context.tsx index 83d3a4f8..85b25dee 100644 --- a/mobile/src/common/contexts/data_context.tsx +++ b/mobile/src/common/contexts/data_context.tsx @@ -20,6 +20,8 @@ import { ProfileRepository } from "../../profile/domain/repositories/profile_rep import { ProfileDataSourceDev } from "../../profile/infrastructure/datasources/dev/profile_datasource"; import { ProfileRepositoryImpl } from "../../profile/infrastructure/repositories/profile_repository"; import { ActivityDatasourceProd } from "../../infrastructure/datasource/prod/activity_datasource"; +import { useTranslation } from "react-i18next"; +import { ProfileDataSourceProd } from "../../profile/infrastructure/datasources/prod/profile_datasource"; type DataContextType = { statesRepository: StateRepository | null; @@ -42,20 +44,26 @@ const DataContext = createContext({ }); export const DataContextProvider = ({ children }: DataContextProviderProps) => { - //const statesDataSource = new StateDataSourceDev(); - const statesDataSource = new StateDataSourceProd(); + const { i18n:{ language } } = useTranslation(); + const statesDataSource = new StateDataSourceDev(); + //const statesDataSource = new StateDataSourceProd(language); const statesRepository = new StateRepositoryImpl(statesDataSource); - //const authDataSource = new AuthDataSourceDev(); - const authDataSource = new AuthDatasourceProd(); + // + const authDataSource = new AuthDataSourceDev(); + //const authDataSource = new AuthDatasourceProd(); const authRepository = new AuthRepositoryImpl(authDataSource); - //const activityDataSource = new ActivityDatasourceDev(); - const activityDataSource = new ActivityDatasourceProd(); + // + const activityDataSource = new ActivityDatasourceDev(); + //const activityDataSource = new ActivityDatasourceProd(); const activityRepository = new ActivityRepositoryDev(activityDataSource); + // const travelDatasource = new TravelDatasourceDev(); const travelRepository = new TravelRepositoryImpl(travelDatasource); + // const routeDatasource = new RouteDataSourceDev(); const routeRepository = new RouteRepositoryImpl(routeDatasource); - const profileDataSource = new ProfileDataSourceDev(); + // + const profileDataSource = new ProfileDataSourceProd(); const profileRepository = new ProfileRepositoryImpl(profileDataSource); const value = { diff --git a/mobile/src/infrastructure/datasource/prod/activity_datasource.ts b/mobile/src/infrastructure/datasource/prod/activity_datasource.ts index 41e8b4ac..4bd9cb84 100644 --- a/mobile/src/infrastructure/datasource/prod/activity_datasource.ts +++ b/mobile/src/infrastructure/datasource/prod/activity_datasource.ts @@ -4,10 +4,12 @@ import { ActivityPlaceEntity } from "../../../domain/entities/activity_place_ent import { API_URL } from "../../../common/constants/api"; import { ActivityPlaceModel } from "../../models/prod/activity_place_model"; import { activityPlaceModelToEntity } from "../../utils/activity_utils"; +import { Languages } from "../../../lang/translations"; export class ActivityDatasourceProd implements ActivityDataSource { + constructor(private lang: string = Languages.SPANISH) {} async getPlaceActivity(activityId: number, townId: number, stateId: number, placeNumber: number): Promise { - const { data, status } = await axios.get(`${API_URL}/point/${placeNumber}lang?lang=es`); + const { data, status } = await axios.get(`${API_URL}/point/${placeNumber}lang?lang=${this.lang}`); if (status !== 200) { throw new Error("Error al obtener la información del lugar"); } diff --git a/mobile/src/infrastructure/datasource/prod/state_datasource.ts b/mobile/src/infrastructure/datasource/prod/state_datasource.ts index 7007dbc9..d3940f85 100644 --- a/mobile/src/infrastructure/datasource/prod/state_datasource.ts +++ b/mobile/src/infrastructure/datasource/prod/state_datasource.ts @@ -12,6 +12,10 @@ import { ActivityModel } from "../../models/prod/activity_model"; import { placeModelToEntity } from "../../utils/place_utils"; export class StateDataSourceProd implements StateDataSource { + private lang: string; + constructor(lang: string = 'es') { + this.lang = lang; + } async getStates(): Promise { const {status, data} = await axios.get(API_URL + '/state'); if (status !== 200) { @@ -20,18 +24,15 @@ export class StateDataSourceProd implements StateDataSource { return data.map(stateModelToEntity); } async getTowns(stateId: number): Promise { - // TODO: get lang from user preferences - const {status, data} = await axios.get(API_URL + '/state/' + stateId + '/town?lang=es'); + const {status, data} = await axios.get(`${API_URL}/state/${stateId}/town?lang=${this.lang}`); if (status !== 200) { throw new Error('Error fetching towns'); } return data.map(townModelToEntity); } async getTownActivities(townId: number): Promise { - // TODO: get lang from user preferences - // TODO: get townId from user preferences console.log('townId', townId); - const {status, data} = await axios.get(API_URL + `/place/town/${townId}/place?lang=es`); + const {status, data} = await axios.get(`${API_URL}/place/town/${townId}/place?lang=${this.lang}`); if (status !== 200) { throw new Error('Error fetching activities'); } @@ -41,7 +42,7 @@ export class StateDataSourceProd implements StateDataSource { async getActivityInfo(activityId: number): Promise { // TODO: get lang from user preferences // TODO: get townId from user preferences - const {status, data} = await axios.get(API_URL + `/place/${activityId}`); + const {status, data} = await axios.get(`${API_URL}/place/${activityId}?lang=${this.lang}`); if (status !== 200) { throw new Error('Error fetching activity'); } -- GitLab From 522e67e2e7dad61b184895a7bf9d0fd45ddf4d70 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 8 Jul 2024 13:39:07 -0600 Subject: [PATCH 04/15] =?UTF-8?q?Se=20agregaron=20las=20etiquetas=20de=20l?= =?UTF-8?q?a=20pesta=C3=B1a=20de=20cambiar=20de=20co=C3=B1trase=C3=B1a=20a?= =?UTF-8?q?l=20template=20de=20un=20lenguaje?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/lang/lang.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mobile/src/lang/lang.ts b/mobile/src/lang/lang.ts index 8bd3a094..e4dff630 100644 --- a/mobile/src/lang/lang.ts +++ b/mobile/src/lang/lang.ts @@ -22,9 +22,14 @@ export interface Lang { title: string; logoutButton: string; changeLanguageButton: string; + changePasswordButton: string; selectLanguage: string; saveButton: string; }, + changePasswordScreen:{ + title: string; + saveButton: string; + }, selectTownScreen:{ title: string; }, -- GitLab From 6d651f0f3488b921a66356eb5ee4a6bd33e62a3b Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 8 Jul 2024 13:40:08 -0600 Subject: [PATCH 05/15] Se implementaron las nuevas etiquetas a los lenguajes existentes --- mobile/src/lang/english_lang.ts | 5 +++++ mobile/src/lang/spanish_lang.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/mobile/src/lang/english_lang.ts b/mobile/src/lang/english_lang.ts index 73fb800c..f433c8ef 100644 --- a/mobile/src/lang/english_lang.ts +++ b/mobile/src/lang/english_lang.ts @@ -23,10 +23,15 @@ export const ENGLISH_LANG: Lang = { accountScreen:{ title: "Account", logoutButton: "Logout", + changePasswordButton: "Change password", changeLanguageButton: "Change App Language", selectLanguage: "Select language", saveButton: "Save", }, + changePasswordScreen:{ + title: "Change password", + saveButton: "Save", + }, selectTownScreen:{ title: "Select Town", }, diff --git a/mobile/src/lang/spanish_lang.ts b/mobile/src/lang/spanish_lang.ts index 0d6591c9..e74e205a 100644 --- a/mobile/src/lang/spanish_lang.ts +++ b/mobile/src/lang/spanish_lang.ts @@ -23,10 +23,15 @@ export const SPANISH_LANG: Lang = { accountScreen:{ title: "Cuenta", logoutButton: "Cerrar sesión", + changePasswordButton: "Cambiar contraseña", changeLanguageButton: "Cambiar idioma de la aplicación", selectLanguage: "Seleccionar idioma", saveButton: "Guardar", }, + changePasswordScreen:{ + title: "Cambiar contraseña", + saveButton: "Guardar", + }, selectTownScreen:{ title: "Seleccionar Pueblo", }, -- GitLab From 84cb835cb3fee4bf064de64ee5ec5c78f1d1c385 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 8 Jul 2024 13:41:01 -0600 Subject: [PATCH 06/15] Se creo la funcion para seleccionar el lenguaje por defecto --- mobile/src/lang/translations.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/mobile/src/lang/translations.ts b/mobile/src/lang/translations.ts index 7bd0b310..12d068c3 100644 --- a/mobile/src/lang/translations.ts +++ b/mobile/src/lang/translations.ts @@ -3,6 +3,7 @@ import { initReactI18next } from 'react-i18next'; import * as Localization from 'expo-localization'; import { SPANISH_LANG } from './spanish_lang'; import { ENGLISH_LANG } from './english_lang'; +import AsyncStorage from '@react-native-async-storage/async-storage'; i18n.use(initReactI18next).init({ compatibilityJSON: 'v3', // Necesario para compatibilidad con Expo @@ -20,16 +21,28 @@ i18n.use(initReactI18next).init({ } }); +export enum Languages { + ENGLISH = 'en', + SPANISH = 'es' +}; + export const AvailableLanguages = [ { - key: 'en', + key: Languages.ENGLISH, value: 'English' }, { - key: 'es', + key: Languages.SPANISH, value: 'Español' } -] +]; + +(async () => { + const lang = await AsyncStorage.getItem("lang"); + if (lang) { + i18n.changeLanguage(lang); + } +})(); export default i18n; -- GitLab From bfd8c1004ef6557124af7510f592ec11f316176f Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 8 Jul 2024 13:41:56 -0600 Subject: [PATCH 07/15] Se definio un hook que maneja y guarda las preferencias de lenguje --- mobile/src/lang/hooks/useLang.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 mobile/src/lang/hooks/useLang.ts diff --git a/mobile/src/lang/hooks/useLang.ts b/mobile/src/lang/hooks/useLang.ts new file mode 100644 index 00000000..b871c59c --- /dev/null +++ b/mobile/src/lang/hooks/useLang.ts @@ -0,0 +1,21 @@ +import { useTranslation } from "react-i18next"; +import { Languages } from "../translations"; +import AsyncStorage from '@react-native-async-storage/async-storage' + +export const useLang = () => { + const { i18n } = useTranslation(); + const changeLanguage = (lang: Languages) => { + i18n.changeLanguage(lang); + AsyncStorage.setItem("lang", lang); + } + + const toggleLanguage = () => { + const lang = i18n.language === Languages.SPANISH ? Languages.ENGLISH : Languages.SPANISH; + changeLanguage(lang); + } + + return { + changeLanguage, + toggleLanguage + }; +} \ No newline at end of file -- GitLab From 66a662a168b5e65d22768b28a259e69490db8d20 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 8 Jul 2024 13:42:30 -0600 Subject: [PATCH 08/15] Se implemento el hook para cambiar de lenguaje --- mobile/src/lang/components/language_icon.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mobile/src/lang/components/language_icon.tsx b/mobile/src/lang/components/language_icon.tsx index 94c31bcb..f2e21231 100644 --- a/mobile/src/lang/components/language_icon.tsx +++ b/mobile/src/lang/components/language_icon.tsx @@ -1,15 +1,12 @@ import { Entypo } from '@expo/vector-icons'; import { TouchableOpacity } from 'react-native-gesture-handler'; import { useTranslation } from 'react-i18next'; +import { useLang } from '../hooks/useLang'; export const LanguageIcon = () => { - const { i18n } = useTranslation(); - const changeLanguage = () => { - i18n.changeLanguage(i18n.language === 'en' ? 'es' : 'en'); - } - + const { toggleLanguage } = useLang(); return ( - + ); -- GitLab From 4ada3d1c77ca8d66990a987de8450a73a782544b Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 8 Jul 2024 13:44:22 -0600 Subject: [PATCH 09/15] =?UTF-8?q?Se=20agrego=20el=20metodo=20de=20cambiar?= =?UTF-8?q?=20contrase=C3=B1a=20a=20las=20abstracciones=20del=20repositori?= =?UTF-8?q?o=20y=20al=20datasource=20de=20perfil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/profile/domain/datasources/profile_datasource.ts | 1 + mobile/src/profile/domain/repositories/profile_repository.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/mobile/src/profile/domain/datasources/profile_datasource.ts b/mobile/src/profile/domain/datasources/profile_datasource.ts index 28bc6c33..50ae7669 100644 --- a/mobile/src/profile/domain/datasources/profile_datasource.ts +++ b/mobile/src/profile/domain/datasources/profile_datasource.ts @@ -4,4 +4,5 @@ export interface ProfileDataSource { getInterests: () => Promise; saveInterests: (options: IOption[]) => Promise; setUpProfile: (birthdate: string, interests: IOption[]) => Promise; + changePassword: (oldPassword: string, newPassword: string) => Promise; }; \ No newline at end of file diff --git a/mobile/src/profile/domain/repositories/profile_repository.ts b/mobile/src/profile/domain/repositories/profile_repository.ts index 7f8164b9..98634810 100644 --- a/mobile/src/profile/domain/repositories/profile_repository.ts +++ b/mobile/src/profile/domain/repositories/profile_repository.ts @@ -4,4 +4,5 @@ export interface ProfileRepository { getInterests: () => Promise; saveInterests: (options: IOption[]) => Promise; setUpProfile: (birthdate: string, interests: IOption[]) => Promise; + changePassword: (oldPassword: string, newPassword: string) => Promise; }; \ No newline at end of file -- GitLab From 0712ec8f1c31ae6e224e1e6a2ba2e63c06f81292 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 8 Jul 2024 13:45:23 -0600 Subject: [PATCH 10/15] =?UTF-8?q?Se=20creo=20un=20hook=20que=20maneja=20el?= =?UTF-8?q?=20cambio=20de=20contrase=C3=B1a=20de=20un=20usuario?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/profile/hooks/useChangePassword.ts | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 mobile/src/profile/hooks/useChangePassword.ts diff --git a/mobile/src/profile/hooks/useChangePassword.ts b/mobile/src/profile/hooks/useChangePassword.ts new file mode 100644 index 00000000..d0f97a66 --- /dev/null +++ b/mobile/src/profile/hooks/useChangePassword.ts @@ -0,0 +1,40 @@ +import { useState } from "react"; +import { useForm } from "react-hook-form" +import { ApiRequestStatus } from "../../common/constants/api_request_states"; +import { useDataContext } from "../../common/contexts/data_context"; +import { router } from "expo-router"; + +interface ChangePasswordValues { + oldPassword: string; + newPassword: string; + confirmPassword: string; +} + +export const useChangePassword = () => { + const { control, handleSubmit, setError } = useForm(); + const [status, setStatus] = useState(ApiRequestStatus.IDLE); + const { profileRepository } = useDataContext(); + + const setLoading = async () => { + setStatus(ApiRequestStatus.LOADING); + } + + const request = async (values: ChangePasswordValues) => { + await setLoading(); + try { + await profileRepository!.changePassword(values.oldPassword, values.newPassword); + setStatus(ApiRequestStatus.SUCCESS); + router.back(); + } catch (error) { + setError("oldPassword", { type: "manual", message: "The current password is incorrect" }); + setStatus(ApiRequestStatus.ERROR); + } + } + + const onSubmit = async () => { + await handleSubmit(async (data) => { + await request(data); + })(); + } + return { control, onSubmit, status }; +} \ No newline at end of file -- GitLab From df7e035eb4fa6a6ca182e5d77651bcb06d4474cd Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 8 Jul 2024 13:46:28 -0600 Subject: [PATCH 11/15] =?UTF-8?q?Se=20hizo=20la=20implementacion=20del=20m?= =?UTF-8?q?etodo=20de=20cambio=20de=20contrase=C3=B1a=20en=20los=20datasou?= =?UTF-8?q?rce=20y=20repositorios=20de=20perfil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasources/dev/profile_datasource.ts | 4 +++ .../datasources/prod/profile_datasource.ts | 26 +++++++++++++++++++ .../repositories/profile_repository.ts | 3 +++ 3 files changed, 33 insertions(+) create mode 100644 mobile/src/profile/infrastructure/datasources/prod/profile_datasource.ts diff --git a/mobile/src/profile/infrastructure/datasources/dev/profile_datasource.ts b/mobile/src/profile/infrastructure/datasources/dev/profile_datasource.ts index 1bf3b48e..f7e598af 100644 --- a/mobile/src/profile/infrastructure/datasources/dev/profile_datasource.ts +++ b/mobile/src/profile/infrastructure/datasources/dev/profile_datasource.ts @@ -16,6 +16,10 @@ export class ProfileDataSourceDev implements ProfileDataSource { ]; } + async changePassword(oldPassword: string, newPassword: string): Promise { + console.log('Changing password', oldPassword, newPassword); + } + async saveInterests(options: IOption[]): Promise { console.log('Saving interests', options); } diff --git a/mobile/src/profile/infrastructure/datasources/prod/profile_datasource.ts b/mobile/src/profile/infrastructure/datasources/prod/profile_datasource.ts new file mode 100644 index 00000000..eee7b181 --- /dev/null +++ b/mobile/src/profile/infrastructure/datasources/prod/profile_datasource.ts @@ -0,0 +1,26 @@ +import axios from "axios"; +import { IOption } from "../../../../common/domain/entities/option"; +import { ProfileDataSource } from "../../../domain/datasources/profile_datasource"; +import { API_URL } from "../../../../common/constants/api"; + +export class ProfileDataSourceProd implements ProfileDataSource { + async getInterests(): Promise { + throw new Error('Method not implemented.'); + } + + async saveInterests(options: IOption[]): Promise { + throw new Error('Method not implemented.'); + } + + async setUpProfile(birthdate: string, interests: IOption[]): Promise { + throw new Error('Method not implemented.'); + } + + async changePassword(oldPassword: string, newPassword: string): Promise { + const {status, data} = await axios.patch(`${API_URL}/user/change-password`, { + prevPassword: oldPassword, + newPassword: newPassword + }) + console.log(status, data); + } +} diff --git a/mobile/src/profile/infrastructure/repositories/profile_repository.ts b/mobile/src/profile/infrastructure/repositories/profile_repository.ts index a71049bc..4dea3985 100644 --- a/mobile/src/profile/infrastructure/repositories/profile_repository.ts +++ b/mobile/src/profile/infrastructure/repositories/profile_repository.ts @@ -6,6 +6,9 @@ export class ProfileRepositoryImpl implements ProfileRepository { constructor( private dataSource: ProfileDataSource ){} + async changePassword (oldPassword: string, newPassword: string): Promise { + return this.dataSource.changePassword(oldPassword, newPassword); + }; async getInterests() { return this.dataSource.getInterests(); } -- GitLab From 408deb69820fc822b81c34dd503691251d86a0c8 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 8 Jul 2024 13:47:29 -0600 Subject: [PATCH 12/15] =?UTF-8?q?Se=20creo=20un=20formulario=20para=20real?= =?UTF-8?q?izar=20el=20cambio=20de=20contrase=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/change_password_form.tsx | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 mobile/src/profile/components/change_password_form.tsx diff --git a/mobile/src/profile/components/change_password_form.tsx b/mobile/src/profile/components/change_password_form.tsx new file mode 100644 index 00000000..2057ee0e --- /dev/null +++ b/mobile/src/profile/components/change_password_form.tsx @@ -0,0 +1,67 @@ +import { Control, Controller } from "react-hook-form"; +import { View } from "react-native"; +import { EditProfileFormValues } from "../../hooks/useEditProfile"; +import { CustomTextInput } from "../../common/components/form/text_input"; + +interface ChangePasswordFormProps { + control: any; + isActive?: boolean; +} + +export const ChangePasswordForm = ({ control, isActive }: ChangePasswordFormProps) => { + return ( + + ( + + )} + /> + ( + + )} + /> + ( + + )} + /> + + ); +} \ No newline at end of file -- GitLab From 74bd867b4bbd8d24eed6ac00bddaa2fd93f4fcd8 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 8 Jul 2024 13:47:54 -0600 Subject: [PATCH 13/15] =?UTF-8?q?Se=20creo=20la=20pagina=20de=20cambio=20d?= =?UTF-8?q?e=20contrase=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profile/screens/change_password_page.tsx | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 mobile/src/profile/screens/change_password_page.tsx diff --git a/mobile/src/profile/screens/change_password_page.tsx b/mobile/src/profile/screens/change_password_page.tsx new file mode 100644 index 00000000..ccdc6eac --- /dev/null +++ b/mobile/src/profile/screens/change_password_page.tsx @@ -0,0 +1,46 @@ +import { ScrollView, StyleSheet, TouchableOpacity, Text } from "react-native"; +import { ChangePasswordForm } from "../components/change_password_form"; +import { useChangePassword } from "../hooks/useChangePassword"; +import { LIGHT_THEME } from "../../common/constants/theme"; + +export const ChangePasswordPage = () => { + const { control, onSubmit } = useChangePassword(); + return ( + + + { + //TODO: ADD a modal to show the success message + } + + Change password + + + ); +}; + +export const styles = StyleSheet.create({ + container: { + flex: 1, + padding: 20, + }, + innerContainer: { + alignItems: "center", + }, + confirmBtn: { + backgroundColor: LIGHT_THEME.color.primary, + marginTop: 30, + padding: 10, + borderRadius: 20, + height: 40, + width: "70%", + justifyContent: "center", + alignItems: "center", + }, + confirmBtnText: { + color: "white", + fontWeight: "bold", + }, +}); -- GitLab From e447771362ed95db9c386cd3f0ea18c1bff8f114 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 8 Jul 2024 13:48:40 -0600 Subject: [PATCH 14/15] =?UTF-8?q?Se=20agrego=20la=20opcion=20de=20cambio?= =?UTF-8?q?=20de=20contrase=C3=B1a=20al=20menu=20de=20la=20pagina=20de=20c?= =?UTF-8?q?uenta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/profile/screens/account_page.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/mobile/src/profile/screens/account_page.tsx b/mobile/src/profile/screens/account_page.tsx index 3bd39f98..0a07160e 100644 --- a/mobile/src/profile/screens/account_page.tsx +++ b/mobile/src/profile/screens/account_page.tsx @@ -21,9 +21,10 @@ import Modal from "react-native-modal"; import { set } from "react-hook-form"; import { AntDesign } from "@expo/vector-icons"; import RNPickerSelect from 'react-native-picker-select'; -import { AvailableLanguages } from "../../lang/translations"; +import { AvailableLanguages, Languages } from "../../lang/translations"; import i18n from 'i18next'; import { useTranslation } from "react-i18next"; +import { useLang } from "../../lang/hooks/useLang"; //TODO: Add source to CircleAvatar const source = require("../../../assets/avatar.png"); @@ -56,11 +57,12 @@ export const AccountPage = () => { /> } onPress={() => router.push("/profile/edit")} - /> + /> */} } - />*/} + title={LANG.t("accountScreen.changePasswordButton")} + leadingIcon={} + onPress={() => router.push("/profile/change_password")} + /> } @@ -95,10 +97,10 @@ const ChangeLanguageModal = ({ onClose, isVisible, }: ChangeLanguageModalProps) => { - const [selectedLanguage, setSelectedLanguage] = useState(null); - const {i18n} = useTranslation(); + const { changeLanguage } = useLang(); + const [selectedLanguage, setSelectedLanguage] = useState(null); const onSave = () => { - i18n.changeLanguage(selectedLanguage || 'en'); + changeLanguage(selectedLanguage || Languages.SPANISH); onClose(); } return ( -- GitLab From 02d2c140377743515905259df2482dce4fc067d9 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 8 Jul 2024 13:48:58 -0600 Subject: [PATCH 15/15] Se actualizaron las dependencias de la aplicacion --- mobile/package-lock.json | 31 +++++++++++++++++++++++++++++++ mobile/package.json | 3 ++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/mobile/package-lock.json b/mobile/package-lock.json index 8f369502..e1b43956 100644 --- a/mobile/package-lock.json +++ b/mobile/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "dependencies": { "@gorhom/bottom-sheet": "^4.6.1", + "@react-native-async-storage/async-storage": "1.21.0", "@react-native-community/datetimepicker": "7.6.1", "@react-native-community/slider": "4.4.2", "@react-native-picker/picker": "2.6.1", @@ -3916,6 +3917,17 @@ "react": "^16.8 || ^17.0 || ^18.0" } }, + "node_modules/@react-native-async-storage/async-storage": { + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/@react-native-async-storage/async-storage/-/async-storage-1.21.0.tgz", + "integrity": "sha512-JL0w36KuFHFCvnbOXRekqVAUplmOyT/OuCQkogo6X98MtpSaJOKEAeZnYO8JB0U/RIEixZaGI5px73YbRm/oag==", + "dependencies": { + "merge-options": "^3.0.4" + }, + "peerDependencies": { + "react-native": "^0.0.0-0 || >=0.60 <1.0" + } + }, "node_modules/@react-native-community/cli": { "version": "12.3.6", "resolved": "https://registry.npmjs.org/@react-native-community/cli/-/cli-12.3.6.tgz", @@ -10232,6 +10244,14 @@ "node": ">=8" } }, + "node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "engines": { + "node": ">=8" + } + }, "node_modules/is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -11548,6 +11568,17 @@ "resolved": "https://registry.npmjs.org/memory-cache/-/memory-cache-0.2.0.tgz", "integrity": "sha512-OcjA+jzjOYzKmKS6IQVALHLVz+rNTMPoJvCztFaZxwG14wtAW7VRZjwTQu06vKCYOxh4jVnik7ya0SXTB0W+xA==" }, + "node_modules/merge-options": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/merge-options/-/merge-options-3.0.4.tgz", + "integrity": "sha512-2Sug1+knBjkaMsMgf1ctR1Ujx+Ayku4EdJN4Z+C2+JzoeF7A3OZ9KM2GY0CpQS51NR61LTurMJrRKPhSs3ZRTQ==", + "dependencies": { + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", diff --git a/mobile/package.json b/mobile/package.json index 380929d2..bb5ccad6 100644 --- a/mobile/package.json +++ b/mobile/package.json @@ -42,7 +42,8 @@ "react-native-safe-area-context": "4.8.2", "react-native-screens": "~3.29.0", "react-native-svg": "14.1.0", - "@react-native-picker/picker": "2.6.1" + "@react-native-picker/picker": "2.6.1", + "@react-native-async-storage/async-storage": "1.21.0" }, "devDependencies": { "@babel/core": "^7.20.0", -- GitLab