From 3c8c7f43f1bf3aeeb8472df9e5feea4ff13089f4 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:22:56 -0600 Subject: [PATCH 01/18] =?UTF-8?q?Se=20agreg=C3=B3=20la=20posibilidad=20de?= =?UTF-8?q?=20refrescar=20los=20datos=20de=20una=20peticion=20get?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/hooks/useGet.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mobile/src/hooks/useGet.ts b/mobile/src/hooks/useGet.ts index 77a31116..dead195e 100644 --- a/mobile/src/hooks/useGet.ts +++ b/mobile/src/hooks/useGet.ts @@ -1,5 +1,6 @@ import { useEffect, useState } from "react"; import { ApiRequestStatus } from "../common/constants/api_request_states"; +import { set } from "react-hook-form"; export const useGet = (callback: () => Promise) => { const [data, setData] = useState(null); @@ -9,6 +10,7 @@ export const useGet = (callback: () => Promise) => { const fetchData = async () => { try { + await setLoading(); const response = await callback(); setData(response); setRequestStatus(ApiRequestStatus.SUCCESS); -- GitLab From df95d3845ffc9982b95a616bc63c62f8b522f5ab Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:23:53 -0600 Subject: [PATCH 02/18] Se actualizo la logica para obtener un audio de un point --- mobile/src/common/components/audio_player.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mobile/src/common/components/audio_player.tsx b/mobile/src/common/components/audio_player.tsx index 6de5d55c..fd3e59dd 100644 --- a/mobile/src/common/components/audio_player.tsx +++ b/mobile/src/common/components/audio_player.tsx @@ -5,21 +5,20 @@ import { millisecondsToHourFormat } from "../../utils/time"; import { LIGHT_THEME } from "../constants/theme"; import { useAudio } from "../contexts/audio_context"; import { useEffect } from "react"; +import { API_URL } from "../constants/api"; const audio = require("./../../../assets/audio_prueba.mp3"); interface AudioPlayerProps { - audioUrl: string; - title: string; - description: string; + pointId: number; } -export const AudioPlayer = () => { +export const AudioPlayer = ({ pointId }: AudioPlayerProps) => { const { loadAudio, position, togglePlay, isPlaying, duration, onValueChange } = useAudio(); useEffect(() => { - loadAudio(audio); + loadAudio({ uri: `${API_URL}/point/${pointId}/audio?lang=es`}); }, []); return ( -- GitLab From 57c22fb18dc64200afd56cd338e699451ac9890c Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:25:01 -0600 Subject: [PATCH 03/18] Se cambio el cntexto de desarrollo a produccion para las actividades --- mobile/src/common/contexts/data_context.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mobile/src/common/contexts/data_context.tsx b/mobile/src/common/contexts/data_context.tsx index a9f0f4b4..83d3a4f8 100644 --- a/mobile/src/common/contexts/data_context.tsx +++ b/mobile/src/common/contexts/data_context.tsx @@ -19,6 +19,7 @@ import { StateDataSourceProd } from "../../infrastructure/datasource/prod/state_ import { ProfileRepository } from "../../profile/domain/repositories/profile_repository"; 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"; type DataContextType = { statesRepository: StateRepository | null; @@ -41,11 +42,14 @@ const DataContext = createContext({ }); export const DataContextProvider = ({ children }: DataContextProviderProps) => { - const statesDataSource = new StateDataSourceDev(); + //const statesDataSource = new StateDataSourceDev(); + const statesDataSource = new StateDataSourceProd(); const statesRepository = new StateRepositoryImpl(statesDataSource); - const authDataSource = new AuthDataSourceDev(); + //const authDataSource = new AuthDataSourceDev(); + const authDataSource = new AuthDatasourceProd(); const authRepository = new AuthRepositoryImpl(authDataSource); - const activityDataSource = new ActivityDatasourceDev(); + //const activityDataSource = new ActivityDatasourceDev(); + const activityDataSource = new ActivityDatasourceProd(); const activityRepository = new ActivityRepositoryDev(activityDataSource); const travelDatasource = new TravelDatasourceDev(); const travelRepository = new TravelRepositoryImpl(travelDatasource); -- GitLab From 7a9a4fc30c5afef8f36e7ef758f20e78e7d56fcf Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:25:43 -0600 Subject: [PATCH 04/18] =?UTF-8?q?Se=20incluy=C3=B3=20la=20propiedad=20refr?= =?UTF-8?q?esh=20al=20hook=20que=20obtiene=20los=20estados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/hooks/useGetStates.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mobile/src/hooks/useGetStates.ts b/mobile/src/hooks/useGetStates.ts index e098e988..6d8e9d9c 100644 --- a/mobile/src/hooks/useGetStates.ts +++ b/mobile/src/hooks/useGetStates.ts @@ -8,7 +8,7 @@ export const useGetStates = () => { const callback = async () =>{ return await statesRepository?.getStates() || []; } - const { requestStatus, data } = useGet(callback); + const { requestStatus, data, refresh } = useGet(callback); - return { requestStatus, data }; + return { requestStatus, data, refresh }; } \ No newline at end of file -- GitLab From e9e243f00d183a91b0610d1c532ed301e4584a52 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:26:30 -0600 Subject: [PATCH 05/18] Se agrego la propiedad refresh al hook que obtiene los pueblos de un estado --- mobile/src/hooks/useGetTowns.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mobile/src/hooks/useGetTowns.ts b/mobile/src/hooks/useGetTowns.ts index de59d039..ae7c22ed 100644 --- a/mobile/src/hooks/useGetTowns.ts +++ b/mobile/src/hooks/useGetTowns.ts @@ -9,7 +9,7 @@ export const useGetTowns = (stateId: number) => { const callback = async () =>{ return await statesRepository?.getTowns(stateId) || []; } - const { requestStatus, data } = useGet(callback); + const { requestStatus, data, refresh } = useGet(callback); - return { requestStatus, data }; + return { requestStatus, data, refresh }; } \ No newline at end of file -- GitLab From 396c7d507cfe1694af3db4ed4dbdde2812caaeb1 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:27:30 -0600 Subject: [PATCH 06/18] Se agrego el datasource de produccion para obtener un point --- .../datasource/prod/activity_datasource.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 mobile/src/infrastructure/datasource/prod/activity_datasource.ts diff --git a/mobile/src/infrastructure/datasource/prod/activity_datasource.ts b/mobile/src/infrastructure/datasource/prod/activity_datasource.ts new file mode 100644 index 00000000..41e8b4ac --- /dev/null +++ b/mobile/src/infrastructure/datasource/prod/activity_datasource.ts @@ -0,0 +1,16 @@ +import axios from "axios"; +import { ActivityDataSource } from "../../../domain/datasources/activity_datasource"; +import { ActivityPlaceEntity } from "../../../domain/entities/activity_place_entity"; +import { API_URL } from "../../../common/constants/api"; +import { ActivityPlaceModel } from "../../models/prod/activity_place_model"; +import { activityPlaceModelToEntity } from "../../utils/activity_utils"; + +export class ActivityDatasourceProd implements ActivityDataSource { + async getPlaceActivity(activityId: number, townId: number, stateId: number, placeNumber: number): Promise { + const { data, status } = await axios.get(`${API_URL}/point/${placeNumber}lang?lang=es`); + if (status !== 200) { + throw new Error("Error al obtener la información del lugar"); + } + return activityPlaceModelToEntity(data); + } +} \ No newline at end of file -- GitLab From b7c30838d1fbccc58481f7e8aba39f667877591f Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:29:17 -0600 Subject: [PATCH 07/18] =?UTF-8?q?Se=20implementaron=20los=20metodos=20de?= =?UTF-8?q?=20obtener=20pueblos=20y=20obtener=20actividades=20en=20el=20da?= =?UTF-8?q?tasource=20de=20producci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasource/prod/state_datasource.ts | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/mobile/src/infrastructure/datasource/prod/state_datasource.ts b/mobile/src/infrastructure/datasource/prod/state_datasource.ts index 6f2c329d..7007dbc9 100644 --- a/mobile/src/infrastructure/datasource/prod/state_datasource.ts +++ b/mobile/src/infrastructure/datasource/prod/state_datasource.ts @@ -6,6 +6,10 @@ import { TownEntity } from "../../../domain/entities/town_entity"; import { API_URL } from "../../../common/constants/api"; import { StateModel } from "../../models/prod/states_model"; import { stateModelToEntity } from "../../utils/states_utils"; +import { TownModel } from "../../models/prod/town_model"; +import { townModelToEntity } from "../../utils/town_utils"; +import { ActivityModel } from "../../models/prod/activity_model"; +import { placeModelToEntity } from "../../utils/place_utils"; export class StateDataSourceProd implements StateDataSource { async getStates(): Promise { @@ -15,14 +19,33 @@ export class StateDataSourceProd implements StateDataSource { } return data.map(stateModelToEntity); } - getTowns(stateId: number): Promise { - throw new Error("Method not implemented."); + async getTowns(stateId: number): Promise { + // TODO: get lang from user preferences + const {status, data} = await axios.get(API_URL + '/state/' + stateId + '/town?lang=es'); + if (status !== 200) { + throw new Error('Error fetching towns'); + } + return data.map(townModelToEntity); } - getTownActivities(townId: number): Promise { - throw new Error("Method not implemented."); + 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`); + if (status !== 200) { + throw new Error('Error fetching activities'); + } + console.log('data', data); + return data.map(placeModelToEntity); } - getActivityInfo(activityId: number): Promise { - throw new Error("Method not implemented."); + 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}`); + if (status !== 200) { + throw new Error('Error fetching activity'); + } + return placeModelToEntity(data); } } \ No newline at end of file -- GitLab From b9195b5290cfff6c5d03ccbced00c9bf42ec3c9c Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:29:48 -0600 Subject: [PATCH 08/18] Se creo el modelo de api que repesenta un point --- .../infrastructure/models/prod/activity_model.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 mobile/src/infrastructure/models/prod/activity_model.ts diff --git a/mobile/src/infrastructure/models/prod/activity_model.ts b/mobile/src/infrastructure/models/prod/activity_model.ts new file mode 100644 index 00000000..228e187d --- /dev/null +++ b/mobile/src/infrastructure/models/prod/activity_model.ts @@ -0,0 +1,13 @@ +export interface ActivityModel { + idTown: number; + idPlace: number; + available: string; + description: string; + coords: string; + imageName: string; + name: string; + openAt: number; + closeAt: number; + startDate: Date | null; + endDate: Date | null; +} -- GitLab From 05e104efa3eb6fc760a802c1b5d7ac9096879bf8 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:30:18 -0600 Subject: [PATCH 09/18] Se creo el modelo de api que representa un place --- .../infrastructure/models/prod/activity_place_model.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 mobile/src/infrastructure/models/prod/activity_place_model.ts diff --git a/mobile/src/infrastructure/models/prod/activity_place_model.ts b/mobile/src/infrastructure/models/prod/activity_place_model.ts new file mode 100644 index 00000000..d69d3f4e --- /dev/null +++ b/mobile/src/infrastructure/models/prod/activity_place_model.ts @@ -0,0 +1,8 @@ +export interface ActivityPlaceModel { + idPoint: number; + idPlace: number; + name: string; + imageName: string; + content: string; + directions: string; +} -- GitLab From 2cfb9d4ea3e9031bc443cd45a8f0e60626415b00 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:30:54 -0600 Subject: [PATCH 10/18] =?UTF-8?q?Se=20agreg=C3=B3=20el=20modelo=20de=20api?= =?UTF-8?q?=20que=20representa=20un=20town?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/infrastructure/models/prod/town_model.ts | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 mobile/src/infrastructure/models/prod/town_model.ts diff --git a/mobile/src/infrastructure/models/prod/town_model.ts b/mobile/src/infrastructure/models/prod/town_model.ts new file mode 100644 index 00000000..230dc588 --- /dev/null +++ b/mobile/src/infrastructure/models/prod/town_model.ts @@ -0,0 +1,7 @@ +export interface TownModel { + townId: number, + name: string, + imageName: string, + description: string, + stateId: number +} \ No newline at end of file -- GitLab From 335951f28aaba6188f839f5495979a1531465a3f Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:31:51 -0600 Subject: [PATCH 11/18] =?UTF-8?q?Se=20cre=C3=B3=20una=20funci=C3=B3n=20que?= =?UTF-8?q?=20convierte=20de=20activity=20model=20a=20activity=20entity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/infrastructure/utils/place_utils.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 mobile/src/infrastructure/utils/place_utils.ts diff --git a/mobile/src/infrastructure/utils/place_utils.ts b/mobile/src/infrastructure/utils/place_utils.ts new file mode 100644 index 00000000..3e16b116 --- /dev/null +++ b/mobile/src/infrastructure/utils/place_utils.ts @@ -0,0 +1,15 @@ +import { ActivityInfoEntity } from "../../domain/entities/activity_info_entity"; +import { ActivityModel } from "../models/prod/activity_model"; + +export const placeModelToEntity = (placeModel: ActivityModel): ActivityInfoEntity => { + return { + id: placeModel.idPlace, + name: placeModel.name, + imageUri: placeModel.imageName, + description: placeModel.description, + location: placeModel.coords, + townId: placeModel.idTown, + available: 'open', + tags: undefined, + } +} \ No newline at end of file -- GitLab From a9186774b74075ee8127d280d13c540c32ee597c Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:33:25 -0600 Subject: [PATCH 12/18] =?UTF-8?q?Se=20cre=C3=B3=20una=20funci=C3=B3n=20que?= =?UTF-8?q?=20convierte=20de=20activity=20place=20model=20a=20activity=20p?= =?UTF-8?q?lace=20entity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infrastructure/utils/activity_utils.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 mobile/src/infrastructure/utils/activity_utils.ts diff --git a/mobile/src/infrastructure/utils/activity_utils.ts b/mobile/src/infrastructure/utils/activity_utils.ts new file mode 100644 index 00000000..2ce6415a --- /dev/null +++ b/mobile/src/infrastructure/utils/activity_utils.ts @@ -0,0 +1,20 @@ +import { ActivityPlaceEntity } from "../../domain/entities/activity_place_entity"; +import { ActivityPlaceModel } from "../models/prod/activity_place_model"; + +export const activityPlaceModelToEntity = (activity: ActivityPlaceModel): ActivityPlaceEntity => { + return { + idPlaceActivity: activity.idPoint, + name: activity.name, + number: activity.idPlace, + idPlace: activity.idPlace, + imageUrl: activity.imageName, + directions: { + content: activity.directions, + speakUrl: "" + }, + content: { + content: activity.content, + speakUrl: "" + } + } +}; \ No newline at end of file -- GitLab From a422ad5d2982f9a97e51f3d42c4843cab8930c9a Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:34:31 -0600 Subject: [PATCH 13/18] =?UTF-8?q?Se=20elimin=C3=B3=20la=20soluci=C3=B3n=20?= =?UTF-8?q?temporal=20de=20la=20url=20de=20la=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/infrastructure/utils/states_utils.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/mobile/src/infrastructure/utils/states_utils.ts b/mobile/src/infrastructure/utils/states_utils.ts index 40836164..2f9022a9 100644 --- a/mobile/src/infrastructure/utils/states_utils.ts +++ b/mobile/src/infrastructure/utils/states_utils.ts @@ -3,12 +3,6 @@ import { StateEntity } from "../../domain/entities/state_entity"; import { StateModel } from "../models/prod/states_model"; export const stateModelToEntity = (stateModel: StateModel): StateEntity => { - //TODO: Fix this - let imageURL = stateModel.imageURL.split('/'); - imageURL = imageURL.filter((item) => item !== '' && item !== 'http:' && item !== 'https:'); - imageURL[0] = API_URL; - stateModel.imageURL = imageURL.join('/'); - console.log(stateModel.imageURL); return { id: stateModel.stateId, name: stateModel.name, -- GitLab From be4139782444e23019dd8f33ef03709b0270c6bc Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:35:15 -0600 Subject: [PATCH 14/18] =?UTF-8?q?Se=20cre=C3=B3=20una=20funcion=20que=20co?= =?UTF-8?q?nvierte=20de=20town=20model=20a=20town=20entity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/infrastructure/utils/town_utils.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 mobile/src/infrastructure/utils/town_utils.ts diff --git a/mobile/src/infrastructure/utils/town_utils.ts b/mobile/src/infrastructure/utils/town_utils.ts new file mode 100644 index 00000000..a531744f --- /dev/null +++ b/mobile/src/infrastructure/utils/town_utils.ts @@ -0,0 +1,13 @@ +import { API_URL } from "../../common/constants/api"; +import { TownEntity } from "../../domain/entities/town_entity"; +import { TownModel } from "../models/prod/town_model"; + +export const townModelToEntity = (townModel: TownModel): TownEntity => { + return { + id: townModel.townId, + name: townModel.name, + imageUri: townModel.imageName, + description: townModel.description, + stateId: townModel.stateId + } +} \ No newline at end of file -- GitLab From 43daafdbab41d1514a922dd60ed134f29b36f6a4 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:37:55 -0600 Subject: [PATCH 15/18] =?UTF-8?q?Se=20agreg=C3=B3=20la=20logica=20para=20q?= =?UTF-8?q?ue=20solo=20se=20muestre=20el=20setup=20de=20perfil=20la=20prim?= =?UTF-8?q?era=20vez=20que=20se=20abre=20la=20aplicacion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/profile/hooks/useSetUpProfile.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mobile/src/profile/hooks/useSetUpProfile.ts b/mobile/src/profile/hooks/useSetUpProfile.ts index e0ef97be..9acb8838 100644 --- a/mobile/src/profile/hooks/useSetUpProfile.ts +++ b/mobile/src/profile/hooks/useSetUpProfile.ts @@ -3,6 +3,9 @@ import { useGetInterests } from "./useGetInterests"; import { IOption } from "../../common/domain/entities/option"; import { useEffect, useState } from "react"; import { ApiRequestStatus } from "../../common/constants/api_request_states"; +import { useDataContext } from "../../common/contexts/data_context"; +import { useSetUp } from "../../common/contexts/set_up_context"; +import { router } from "expo-router"; export type SetUpProfileFormValues = { interests: number[]; @@ -11,6 +14,7 @@ export type SetUpProfileFormValues = { export const useSetUpProfile = () => { const { control, handleSubmit, setValue } = useForm(); + const { setFirstTime } = useSetUp(); const { interests: allCategories, requestStatus } = useGetInterests(); // TODO: Si se agregan mas campos que requieran datos de la API, debemos procurar que todos los request status esten en success const [interests, setInterests] = useState([]); @@ -39,6 +43,8 @@ export const useSetUpProfile = () => { //TODO: Verificar si se enviará la fecha de nacimiento y los intereses en el mismo request o por separado console.log(data); })(); + await setFirstTime(); + router.replace("(tabs)"); }; return { control, onSubmit, toogleInterest, interests, requestStatus }; }; -- GitLab From 7a5c65afd1c54b89e55d540128a7d8767fdd887f Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:38:39 -0600 Subject: [PATCH 16/18] =?UTF-8?q?Se=20agreg=C3=B3=20las=20direcciones=20a?= =?UTF-8?q?=20un=20point?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/screens/activity_point/activity_point.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mobile/src/screens/activity_point/activity_point.tsx b/mobile/src/screens/activity_point/activity_point.tsx index 7035470f..1a6ebe75 100644 --- a/mobile/src/screens/activity_point/activity_point.tsx +++ b/mobile/src/screens/activity_point/activity_point.tsx @@ -66,6 +66,14 @@ export const ActivityPointScreen = memo(({ {data.content.content} + { + data.directions && ( + <> + Directions + {data.directions.content} + + ) + } {!data.directions && ( End Activity @@ -73,8 +81,7 @@ export const ActivityPointScreen = memo(({ )} - + ); }); -- GitLab From 87562138a1299fd2967cdfb4310b6c50d4071410 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:39:12 -0600 Subject: [PATCH 17/18] =?UTF-8?q?Se=20cre=C3=B3=20una=20pagina=20gen=C3=A9?= =?UTF-8?q?rica=20de=20error=20para=20las=20peticiones=20get?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/screens/error_page/error_page.tsx | 44 ++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 mobile/src/screens/error_page/error_page.tsx diff --git a/mobile/src/screens/error_page/error_page.tsx b/mobile/src/screens/error_page/error_page.tsx new file mode 100644 index 00000000..f6d618e8 --- /dev/null +++ b/mobile/src/screens/error_page/error_page.tsx @@ -0,0 +1,44 @@ +import { View, Text, StyleSheet } from "react-native"; +import { MaterialIcons } from "@expo/vector-icons"; +import { TouchableOpacity } from "react-native-gesture-handler"; + +interface ErrorPageProps { + refresh?: () => void; +} + +export const ErrorPage = ({ refresh }: ErrorPageProps) => { + return ( + + + + Ups, algo salio mal, revisa tu conexión a internet o intentalo más + tarde... + + {refresh && ( + + + Reintentar + + )} + + ); +}; + +const styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: "center", + alignItems: "center", + gap: 20, + }, + text: { + width: "60%", + textAlign: "center", + }, + refreshButton: { + flexDirection: "row", + justifyContent: "center", + alignItems: "center", + gap: 5, + }, +}); -- GitLab From 2354a586a4abd9c5dedeadb853eb95c08eaf9d42 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sat, 29 Jun 2024 10:40:26 -0600 Subject: [PATCH 18/18] =?UTF-8?q?Se=20agreg=C3=B3=20una=20pagina=20generic?= =?UTF-8?q?a=20de=20error=20al=20obtener=20pueblos=20y=20estados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/screens/state_selection/state_selection_page.tsx | 7 +++---- mobile/src/screens/town_selection/town_selection_page.tsx | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/mobile/src/screens/state_selection/state_selection_page.tsx b/mobile/src/screens/state_selection/state_selection_page.tsx index bdc42c14..358e2ab7 100644 --- a/mobile/src/screens/state_selection/state_selection_page.tsx +++ b/mobile/src/screens/state_selection/state_selection_page.tsx @@ -6,9 +6,10 @@ import { Caroussel } from "../../common/components/caroussel/caroussel"; import { router } from "expo-router"; import { useAnimatedSelectedIndex } from "../../hooks/useAnimatedSelectedIndex"; import { AnimatedBackground } from "../../common/components/animated_background"; +import { ErrorPage } from "../error_page/error_page"; export const StateSelectionPage = () => { - const { data, requestStatus } = useGetStates(); + const { data, requestStatus, refresh } = useGetStates(); const { selectedStateIndex, onIndexChange, backgroundImageAnimation } = useAnimatedSelectedIndex(200, 200); @@ -22,9 +23,7 @@ export const StateSelectionPage = () => { if (requestStatus === ApiRequestStatus.ERROR || !data) { return ( - - Something went wrong - + ); } diff --git a/mobile/src/screens/town_selection/town_selection_page.tsx b/mobile/src/screens/town_selection/town_selection_page.tsx index 84e4d48b..09cc498d 100644 --- a/mobile/src/screens/town_selection/town_selection_page.tsx +++ b/mobile/src/screens/town_selection/town_selection_page.tsx @@ -9,6 +9,7 @@ import { useCallback, useState } from "react"; import { useAnimatedSelectedIndex } from "../../hooks/useAnimatedSelectedIndex"; import { AnimatedBackground } from "../../common/components/animated_background"; import BottomSheet, { BottomSheetView } from "@gorhom/bottom-sheet"; +import { ErrorPage } from "../error_page/error_page"; interface TownSelectionPageProps { stateId: number; @@ -17,7 +18,7 @@ interface TownSelectionPageProps { const snapPoints = ["15%", "50%"]; export const TownSelectionPage = ({ stateId }: TownSelectionPageProps) => { - const { data, requestStatus } = useGetTowns(stateId); + const { data, requestStatus, refresh } = useGetTowns(stateId); const { selectedStateIndex, onIndexChange, backgroundImageAnimation } = useAnimatedSelectedIndex(200, 200); @@ -31,9 +32,7 @@ export const TownSelectionPage = ({ stateId }: TownSelectionPageProps) => { if (requestStatus === ApiRequestStatus.ERROR || !data) { return ( - - Something went wrong - + ); } -- GitLab