From 86dfb88a7df94f8fd12432f98ed1a898e4707676 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Sun, 8 Sep 2024 21:13:23 -0600 Subject: [PATCH 1/8] =?UTF-8?q?Reestructuraci=C3=B3n=20de=20la=20aplicaci?= =?UTF-8?q?=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/package-lock.json | 85 ++++++++++++++++++- mobile/package.json | 4 +- .../{ => activity}/hooks/useGetActivities.ts | 0 .../hooks/useGetActivityInfo.ts | 0 .../hooks/useGetActivityPoint.ts | 0 .../datasources}/dev/activity_datasource.ts | 0 .../datasources}/prod/activity_datasource.ts | 0 .../infrastructure/models}/activity_model.ts | 0 .../models}/activity_place_model.ts | 0 .../infrastructure/models}/tag_model.ts | 0 .../repositories/activity_repository.ts | 0 .../infrastructure/utils/activity_utils.ts | 2 +- .../screens/activity_description_page.tsx | 6 +- .../screens/activity_not_found_page.tsx | 0 .../{ => activity}/utils/activity_route.ts | 0 .../dev/datasources/auth_datasource.ts | 2 +- .../common/components/animated_background.tsx | 2 +- mobile/src/common/components/audio_player.tsx | 2 +- mobile/src/common/constants/api.ts | 2 +- mobile/src/common/contexts/data_context.tsx | 14 +-- .../hooks/useAnimatedSelectedIndex.ts | 0 mobile/src/{ => common}/hooks/useAudio.ts | 0 mobile/src/{ => common}/hooks/useGet.ts | 0 mobile/src/{ => common}/hooks/useQRScanner.ts | 0 .../{ => common}/hooks/useRotationEnabled.ts | 0 .../hooks/useScreenOrientation.ts | 0 .../{utils/dev => common/utils}/delay_time.ts | 0 mobile/src/{ => common}/utils/time.ts | 0 .../components/change_password_form.tsx | 2 +- .../src/{ => profile}/hooks/useEditProfile.ts | 0 .../domain/datasource}/route_datasource.ts | 0 .../domain/repositories/route_repository.ts | 0 .../src/{ => route}/hooks/useGenerateRoute.ts | 4 +- .../datasources}/dev/route_datasource.ts | 0 .../datasources}/prod/route_datasource.ts | 4 +- .../model}/route_activity_model.ts | 0 .../repositories/route_repository.ts | 0 .../infrastructure/utils/route_utils.ts | 4 +- mobile/src/route/screens/route_preview.tsx | 2 +- .../edit_profile/edit_profile_page.tsx | 2 +- mobile/src/screens/scan/scan_page.tsx | 4 +- .../state_selection/state_selection_page.tsx | 2 +- .../town_selection/town_selection_page.tsx | 2 +- .../travel_details/travel_details_page.tsx | 2 +- .../travel_history/travel_history_page.tsx | 2 +- .../hooks/useGetTravelDetails.ts | 4 +- .../hooks/useGetTravelHistory.ts | 4 +- 47 files changed, 121 insertions(+), 36 deletions(-) rename mobile/src/{ => activity}/hooks/useGetActivities.ts (100%) rename mobile/src/{ => activity}/hooks/useGetActivityInfo.ts (100%) rename mobile/src/{ => activity}/hooks/useGetActivityPoint.ts (100%) rename mobile/src/{infrastructure/datasource => activity/infrastructure/datasources}/dev/activity_datasource.ts (100%) rename mobile/src/{infrastructure/datasource => activity/infrastructure/datasources}/prod/activity_datasource.ts (100%) rename mobile/src/{infrastructure/models/prod => activity/infrastructure/models}/activity_model.ts (100%) rename mobile/src/{infrastructure/models/prod => activity/infrastructure/models}/activity_place_model.ts (100%) rename mobile/src/{infrastructure/models/prod => activity/infrastructure/models}/tag_model.ts (100%) rename mobile/src/{ => activity}/infrastructure/repositories/activity_repository.ts (100%) rename mobile/src/{ => activity}/infrastructure/utils/activity_utils.ts (85%) create mode 100644 mobile/src/activity/screens/activity_not_found_page.tsx rename mobile/src/{ => activity}/utils/activity_route.ts (100%) rename mobile/src/{ => common}/hooks/useAnimatedSelectedIndex.ts (100%) rename mobile/src/{ => common}/hooks/useAudio.ts (100%) rename mobile/src/{ => common}/hooks/useGet.ts (100%) rename mobile/src/{ => common}/hooks/useQRScanner.ts (100%) rename mobile/src/{ => common}/hooks/useRotationEnabled.ts (100%) rename mobile/src/{ => common}/hooks/useScreenOrientation.ts (100%) rename mobile/src/{utils/dev => common/utils}/delay_time.ts (100%) rename mobile/src/{ => common}/utils/time.ts (100%) rename mobile/src/{ => profile}/hooks/useEditProfile.ts (100%) rename mobile/src/{domain/datasources => route/domain/datasource}/route_datasource.ts (100%) rename mobile/src/{ => route}/domain/repositories/route_repository.ts (100%) rename mobile/src/{ => route}/hooks/useGenerateRoute.ts (70%) rename mobile/src/{infrastructure/datasource => route/infrastructure/datasources}/dev/route_datasource.ts (100%) rename mobile/src/{infrastructure/datasource => route/infrastructure/datasources}/prod/route_datasource.ts (86%) rename mobile/src/{infrastructure/models/prod => route/infrastructure/model}/route_activity_model.ts (100%) rename mobile/src/{ => route}/infrastructure/repositories/route_repository.ts (100%) rename mobile/src/{ => route}/infrastructure/utils/route_utils.ts (83%) rename mobile/src/{ => travel_history}/hooks/useGetTravelDetails.ts (75%) rename mobile/src/{ => travel_history}/hooks/useGetTravelHistory.ts (90%) diff --git a/mobile/package-lock.json b/mobile/package-lock.json index 0145b231..18b7b912 100644 --- a/mobile/package-lock.json +++ b/mobile/package-lock.json @@ -32,6 +32,7 @@ "i18next": "^23.11.5", "nativewind": "^2.0.11", "react": "18.2.0", + "react-dom": "18.2.0", "react-hook-form": "^7.51.2", "react-i18next": "^14.1.2", "react-native": "0.73.6", @@ -43,7 +44,8 @@ "react-native-reanimated": "~3.6.2", "react-native-safe-area-context": "4.8.2", "react-native-screens": "~3.29.0", - "react-native-svg": "14.1.0" + "react-native-svg": "14.1.0", + "react-native-web": "~0.19.6" }, "devDependencies": { "@babel/core": "^7.20.0", @@ -8000,6 +8002,14 @@ "node": ">=4" } }, + "node_modules/css-in-js-utils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/css-in-js-utils/-/css-in-js-utils-3.1.0.tgz", + "integrity": "sha512-fJAcud6B3rRu+KHYk+Bwf+WFL2MDCJJ1XG9x137tJQ0xYxor7XziQtuGFbWNdqrvF4Tk26O3H73nfVqXt/fW1A==", + "dependencies": { + "hyphenate-style-name": "^1.0.3" + } + }, "node_modules/css-mediaquery": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/css-mediaquery/-/css-mediaquery-0.1.2.tgz", @@ -9113,6 +9123,11 @@ "node": ">=8.6.0" } }, + "node_modules/fast-loops": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/fast-loops/-/fast-loops-1.1.4.tgz", + "integrity": "sha512-8dbd3XWoKCTms18ize6JmQF1SFnnfj5s0B7rRry22EofgMu7B6LKHVh+XfFqFGsqnbH54xgeO83PzpKI+ODhlg==" + }, "node_modules/fast-xml-parser": { "version": "4.3.6", "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.3.6.tgz", @@ -9794,6 +9809,11 @@ "node": ">=10.17.0" } }, + "node_modules/hyphenate-style-name": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.1.0.tgz", + "integrity": "sha512-WDC/ui2VVRrz3jOVi+XtjqkDjiVjTtFaAGiW37k6b+ohyQ5wYDOGkvCZa8+H0nx3gyvv0+BST9xuOgIyGQ00gw==" + }, "node_modules/i18n-js": { "version": "4.4.3", "resolved": "https://registry.npmjs.org/i18n-js/-/i18n-js-4.4.3.tgz", @@ -9927,6 +9947,15 @@ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" }, + "node_modules/inline-style-prefixer": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/inline-style-prefixer/-/inline-style-prefixer-6.0.4.tgz", + "integrity": "sha512-FwXmZC2zbeeS7NzGjJ6pAiqRhXR0ugUShSNb6GApMl6da0/XGc4MOJsoWAywia52EEWbXNSy0pzkwz/+Y+swSg==", + "dependencies": { + "css-in-js-utils": "^3.1.0", + "fast-loops": "^1.1.3" + } + }, "node_modules/internal-ip": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/internal-ip/-/internal-ip-4.3.0.tgz", @@ -13473,6 +13502,26 @@ } } }, + "node_modules/react-dom": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", + "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==", + "dependencies": { + "loose-envify": "^1.1.0", + "scheduler": "^0.23.0" + }, + "peerDependencies": { + "react": "^18.2.0" + } + }, + "node_modules/react-dom/node_modules/scheduler": { + "version": "0.23.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", + "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", + "dependencies": { + "loose-envify": "^1.1.0" + } + }, "node_modules/react-fast-compare": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.2.tgz", @@ -13735,6 +13784,35 @@ "react-native": "*" } }, + "node_modules/react-native-web": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/react-native-web/-/react-native-web-0.19.12.tgz", + "integrity": "sha512-o2T0oztoVDQjztt4YksO9S1XRjoH/AqcSvifgWLrPJgGVbMWsfhILgl6lfUdEamVZzZSVV/2gqDVMAk/qq7mZw==", + "dependencies": { + "@babel/runtime": "^7.18.6", + "@react-native/normalize-colors": "^0.74.1", + "fbjs": "^3.0.4", + "inline-style-prefixer": "^6.0.1", + "memoize-one": "^6.0.0", + "nullthrows": "^1.1.1", + "postcss-value-parser": "^4.2.0", + "styleq": "^0.1.3" + }, + "peerDependencies": { + "react": "^18.0.0", + "react-dom": "^18.0.0" + } + }, + "node_modules/react-native-web/node_modules/@react-native/normalize-colors": { + "version": "0.74.87", + "resolved": "https://registry.npmjs.org/@react-native/normalize-colors/-/normalize-colors-0.74.87.tgz", + "integrity": "sha512-Xh7Nyk/MPefkb0Itl5Z+3oOobeG9lfLb7ZOY2DKpFnoCE1TzBmib9vMNdFaLdSxLIP+Ec6icgKtdzYg8QUPYzA==" + }, + "node_modules/react-native-web/node_modules/memoize-one": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-6.0.0.tgz", + "integrity": "sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw==" + }, "node_modules/react-native/node_modules/@react-native/codegen": { "version": "0.73.3", "resolved": "https://registry.npmjs.org/@react-native/codegen/-/codegen-0.73.3.tgz", @@ -14809,6 +14887,11 @@ "resolved": "https://registry.npmjs.org/structured-headers/-/structured-headers-0.4.1.tgz", "integrity": "sha512-0MP/Cxx5SzeeZ10p/bZI0S6MpgD+yxAhi1BOQ34jgnMXsCq3j1t6tQnZu+KdlL7dvJTLT3g9xN8tl10TqgFMcg==" }, + "node_modules/styleq": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/styleq/-/styleq-0.1.3.tgz", + "integrity": "sha512-3ZUifmCDCQanjeej1f6kyl/BeP/Vae5EYkQ9iJfUm/QwZvlgnZzyflqAsAWYURdtea8Vkvswu2GrC57h3qffcA==" + }, "node_modules/sucrase": { "version": "3.34.0", "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.34.0.tgz", diff --git a/mobile/package.json b/mobile/package.json index 1afc8f73..6b81b65e 100644 --- a/mobile/package.json +++ b/mobile/package.json @@ -44,7 +44,9 @@ "react-native-svg": "14.1.0", "@react-native-picker/picker": "2.6.1", "@react-native-async-storage/async-storage": "1.21.0", - "expo-linear-gradient": "~12.7.2" + "expo-linear-gradient": "~12.7.2", + "react-native-web": "~0.19.6", + "react-dom": "18.2.0" }, "devDependencies": { "@babel/core": "^7.20.0", diff --git a/mobile/src/hooks/useGetActivities.ts b/mobile/src/activity/hooks/useGetActivities.ts similarity index 100% rename from mobile/src/hooks/useGetActivities.ts rename to mobile/src/activity/hooks/useGetActivities.ts diff --git a/mobile/src/hooks/useGetActivityInfo.ts b/mobile/src/activity/hooks/useGetActivityInfo.ts similarity index 100% rename from mobile/src/hooks/useGetActivityInfo.ts rename to mobile/src/activity/hooks/useGetActivityInfo.ts diff --git a/mobile/src/hooks/useGetActivityPoint.ts b/mobile/src/activity/hooks/useGetActivityPoint.ts similarity index 100% rename from mobile/src/hooks/useGetActivityPoint.ts rename to mobile/src/activity/hooks/useGetActivityPoint.ts diff --git a/mobile/src/infrastructure/datasource/dev/activity_datasource.ts b/mobile/src/activity/infrastructure/datasources/dev/activity_datasource.ts similarity index 100% rename from mobile/src/infrastructure/datasource/dev/activity_datasource.ts rename to mobile/src/activity/infrastructure/datasources/dev/activity_datasource.ts diff --git a/mobile/src/infrastructure/datasource/prod/activity_datasource.ts b/mobile/src/activity/infrastructure/datasources/prod/activity_datasource.ts similarity index 100% rename from mobile/src/infrastructure/datasource/prod/activity_datasource.ts rename to mobile/src/activity/infrastructure/datasources/prod/activity_datasource.ts diff --git a/mobile/src/infrastructure/models/prod/activity_model.ts b/mobile/src/activity/infrastructure/models/activity_model.ts similarity index 100% rename from mobile/src/infrastructure/models/prod/activity_model.ts rename to mobile/src/activity/infrastructure/models/activity_model.ts diff --git a/mobile/src/infrastructure/models/prod/activity_place_model.ts b/mobile/src/activity/infrastructure/models/activity_place_model.ts similarity index 100% rename from mobile/src/infrastructure/models/prod/activity_place_model.ts rename to mobile/src/activity/infrastructure/models/activity_place_model.ts diff --git a/mobile/src/infrastructure/models/prod/tag_model.ts b/mobile/src/activity/infrastructure/models/tag_model.ts similarity index 100% rename from mobile/src/infrastructure/models/prod/tag_model.ts rename to mobile/src/activity/infrastructure/models/tag_model.ts diff --git a/mobile/src/infrastructure/repositories/activity_repository.ts b/mobile/src/activity/infrastructure/repositories/activity_repository.ts similarity index 100% rename from mobile/src/infrastructure/repositories/activity_repository.ts rename to mobile/src/activity/infrastructure/repositories/activity_repository.ts diff --git a/mobile/src/infrastructure/utils/activity_utils.ts b/mobile/src/activity/infrastructure/utils/activity_utils.ts similarity index 85% rename from mobile/src/infrastructure/utils/activity_utils.ts rename to mobile/src/activity/infrastructure/utils/activity_utils.ts index 04ec0601..80c7953d 100644 --- a/mobile/src/infrastructure/utils/activity_utils.ts +++ b/mobile/src/activity/infrastructure/utils/activity_utils.ts @@ -1,5 +1,5 @@ import { ActivityPlaceEntity } from "../../activity/domain/entities/activity_place_entity"; -import { ActivityPlaceModel } from "../models/prod/activity_place_model"; +import { ActivityPlaceModel } from "../../activity/infrastructure/models/activity_place_model"; export const activityPlaceModelToEntity = (activity: ActivityPlaceModel): ActivityPlaceEntity => { return { diff --git a/mobile/src/activity/screens/activity_description_page.tsx b/mobile/src/activity/screens/activity_description_page.tsx index 14046fc0..44c4953d 100644 --- a/mobile/src/activity/screens/activity_description_page.tsx +++ b/mobile/src/activity/screens/activity_description_page.tsx @@ -10,16 +10,16 @@ import { } from "react-native"; import { FullPageLoader } from "../../common/components/full_page_loader"; import { ApiRequestStatus } from "../../common/constants/api_request_states"; -import { useGetActivityInfo } from "../../hooks/useGetActivityInfo"; import { router } from "expo-router"; import { Ionicons } from "@expo/vector-icons"; import { useCallback, useEffect, useRef, useState } from "react"; import { ActivityBottomSheet } from "../../activity/components/activity_bottom_sheet"; import * as ScreenOrientation from "expo-screen-orientation"; import { LIGHT_THEME } from "../../common/constants/theme"; -import { useScreenOrientation } from "../../hooks/useScreenOrientation"; -import { useRotationEnabled } from "../../hooks/useRotationEnabled"; +import { useScreenOrientation } from "../../common/hooks/useScreenOrientation"; +import { useRotationEnabled } from "../../common/hooks/useRotationEnabled"; import { FloatingBackButton } from "../../common/components/floating_back_button"; +import { useGetActivityInfo } from "../hooks/useGetActivityInfo"; interface ActivityDescriptionPageProps { activityId: number; } diff --git a/mobile/src/activity/screens/activity_not_found_page.tsx b/mobile/src/activity/screens/activity_not_found_page.tsx new file mode 100644 index 00000000..e69de29b diff --git a/mobile/src/utils/activity_route.ts b/mobile/src/activity/utils/activity_route.ts similarity index 100% rename from mobile/src/utils/activity_route.ts rename to mobile/src/activity/utils/activity_route.ts diff --git a/mobile/src/auth/infrastructure/dev/datasources/auth_datasource.ts b/mobile/src/auth/infrastructure/dev/datasources/auth_datasource.ts index d06b3e59..d95f9800 100644 --- a/mobile/src/auth/infrastructure/dev/datasources/auth_datasource.ts +++ b/mobile/src/auth/infrastructure/dev/datasources/auth_datasource.ts @@ -1,4 +1,4 @@ -import { delay } from '../../../../utils/dev/delay_time'; +import { delay } from '../../../../common/utils/delay_time'; import { AuthDataSource } from '../../../domain/datasources/auth_datasource'; import { LoginInfoEntity } from '../../../domain/entities/login_info_entity'; import { RegisterInfoEntity } from '../../../domain/entities/register_info'; diff --git a/mobile/src/common/components/animated_background.tsx b/mobile/src/common/components/animated_background.tsx index b06ea8e6..99cebaca 100644 --- a/mobile/src/common/components/animated_background.tsx +++ b/mobile/src/common/components/animated_background.tsx @@ -1,6 +1,6 @@ import { Animated, Image, View } from "react-native"; import { PlaceInfoEntity } from "../../domain/entities/place_info_entity"; -import { useAnimatedSelectedIndex } from "../../hooks/useAnimatedSelectedIndex"; +import { useAnimatedSelectedIndex } from "../hooks/useAnimatedSelectedIndex"; import { LinearGradient } from "expo-linear-gradient"; import { LIGHT_THEME } from "../constants/theme"; diff --git a/mobile/src/common/components/audio_player.tsx b/mobile/src/common/components/audio_player.tsx index fd3e59dd..e827c33f 100644 --- a/mobile/src/common/components/audio_player.tsx +++ b/mobile/src/common/components/audio_player.tsx @@ -1,7 +1,7 @@ import { TouchableOpacity, View, StyleSheet, Text } from "react-native"; import { FontAwesome, Feather } from "@expo/vector-icons"; import Slider from "@react-native-community/slider"; -import { millisecondsToHourFormat } from "../../utils/time"; +import { millisecondsToHourFormat } from "../utils/time"; import { LIGHT_THEME } from "../constants/theme"; import { useAudio } from "../contexts/audio_context"; import { useEffect } from "react"; diff --git a/mobile/src/common/constants/api.ts b/mobile/src/common/constants/api.ts index 1ea7e0ee..c4d4fe8d 100644 --- a/mobile/src/common/constants/api.ts +++ b/mobile/src/common/constants/api.ts @@ -1 +1 @@ -export const API_URL = 'http://172.18.48.1:3005'; \ No newline at end of file +export const API_URL = 'http://192.168.0.14:3005'; \ No newline at end of file diff --git a/mobile/src/common/contexts/data_context.tsx b/mobile/src/common/contexts/data_context.tsx index c64a8a9c..4fda7081 100644 --- a/mobile/src/common/contexts/data_context.tsx +++ b/mobile/src/common/contexts/data_context.tsx @@ -6,23 +6,23 @@ import { AuthRepository } from "../../auth/domain/repositories/auth_repository"; import { AuthDataSourceDev } from '../../auth/infrastructure/dev/datasources/auth_datasource'; import { AuthRepositoryImpl } from "../../auth/infrastructure/prod/repositories/auth_repository"; import { AuthDatasourceProd } from '../../auth/infrastructure/prod/datasources/auth_datasource'; -import { ActivityDatasourceDev } from "../../infrastructure/datasource/dev/activity_datasource"; -import { ActivityRepositoryDev } from '../../infrastructure/repositories/activity_repository'; import { TravelDatasourceDev } from "../../infrastructure/datasource/dev/travel_datasource"; import { TravelRepositoryImpl } from "../../infrastructure/repositories/travel_repository"; import { TravelRepository } from "../../domain/repositories/travel_repository"; -import { RouteRepository } from "../../domain/repositories/route_repository"; -import { RouteDataSourceDev } from "../../infrastructure/datasource/dev/route_datasource"; -import { RouteRepositoryImpl } from "../../infrastructure/repositories/route_repository"; +import { RouteRepository } from "../../route/domain/repositories/route_repository"; +import { RouteDataSourceDev } from "../../route/infrastructure/datasources/dev/route_datasource"; +import { RouteRepositoryImpl } from "../../route/infrastructure/repositories/route_repository"; import { StateDataSourceProd } from "../../infrastructure/datasource/prod/state_datasource"; 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"; import { useTranslation } from "react-i18next"; import { ProfileDataSourceProd } from "../../profile/infrastructure/datasources/prod/profile_datasource"; import { ActivityRepository } from "../../activity/domain/repositories/activity_repository"; -import { RouteDatasourceProd } from "../../infrastructure/datasource/prod/route_datasource"; +import { RouteDatasourceProd } from "../../route/infrastructure/datasources/prod/route_datasource"; +import { ActivityRepositoryDev } from "../../activity/infrastructure/repositories/activity_repository"; +import { ActivityDatasourceProd } from "../../activity/infrastructure/datasources/prod/activity_datasource"; +import { ActivityDatasourceDev } from "../../activity/infrastructure/datasources/dev/activity_datasource"; type DataContextType = { statesRepository: StateRepository | null; diff --git a/mobile/src/hooks/useAnimatedSelectedIndex.ts b/mobile/src/common/hooks/useAnimatedSelectedIndex.ts similarity index 100% rename from mobile/src/hooks/useAnimatedSelectedIndex.ts rename to mobile/src/common/hooks/useAnimatedSelectedIndex.ts diff --git a/mobile/src/hooks/useAudio.ts b/mobile/src/common/hooks/useAudio.ts similarity index 100% rename from mobile/src/hooks/useAudio.ts rename to mobile/src/common/hooks/useAudio.ts diff --git a/mobile/src/hooks/useGet.ts b/mobile/src/common/hooks/useGet.ts similarity index 100% rename from mobile/src/hooks/useGet.ts rename to mobile/src/common/hooks/useGet.ts diff --git a/mobile/src/hooks/useQRScanner.ts b/mobile/src/common/hooks/useQRScanner.ts similarity index 100% rename from mobile/src/hooks/useQRScanner.ts rename to mobile/src/common/hooks/useQRScanner.ts diff --git a/mobile/src/hooks/useRotationEnabled.ts b/mobile/src/common/hooks/useRotationEnabled.ts similarity index 100% rename from mobile/src/hooks/useRotationEnabled.ts rename to mobile/src/common/hooks/useRotationEnabled.ts diff --git a/mobile/src/hooks/useScreenOrientation.ts b/mobile/src/common/hooks/useScreenOrientation.ts similarity index 100% rename from mobile/src/hooks/useScreenOrientation.ts rename to mobile/src/common/hooks/useScreenOrientation.ts diff --git a/mobile/src/utils/dev/delay_time.ts b/mobile/src/common/utils/delay_time.ts similarity index 100% rename from mobile/src/utils/dev/delay_time.ts rename to mobile/src/common/utils/delay_time.ts diff --git a/mobile/src/utils/time.ts b/mobile/src/common/utils/time.ts similarity index 100% rename from mobile/src/utils/time.ts rename to mobile/src/common/utils/time.ts diff --git a/mobile/src/profile/components/change_password_form.tsx b/mobile/src/profile/components/change_password_form.tsx index 2057ee0e..3d87fd3a 100644 --- a/mobile/src/profile/components/change_password_form.tsx +++ b/mobile/src/profile/components/change_password_form.tsx @@ -1,6 +1,6 @@ import { Control, Controller } from "react-hook-form"; import { View } from "react-native"; -import { EditProfileFormValues } from "../../hooks/useEditProfile"; +import { EditProfileFormValues } from "../hooks/useEditProfile"; import { CustomTextInput } from "../../common/components/form/text_input"; interface ChangePasswordFormProps { diff --git a/mobile/src/hooks/useEditProfile.ts b/mobile/src/profile/hooks/useEditProfile.ts similarity index 100% rename from mobile/src/hooks/useEditProfile.ts rename to mobile/src/profile/hooks/useEditProfile.ts diff --git a/mobile/src/domain/datasources/route_datasource.ts b/mobile/src/route/domain/datasource/route_datasource.ts similarity index 100% rename from mobile/src/domain/datasources/route_datasource.ts rename to mobile/src/route/domain/datasource/route_datasource.ts diff --git a/mobile/src/domain/repositories/route_repository.ts b/mobile/src/route/domain/repositories/route_repository.ts similarity index 100% rename from mobile/src/domain/repositories/route_repository.ts rename to mobile/src/route/domain/repositories/route_repository.ts diff --git a/mobile/src/hooks/useGenerateRoute.ts b/mobile/src/route/hooks/useGenerateRoute.ts similarity index 70% rename from mobile/src/hooks/useGenerateRoute.ts rename to mobile/src/route/hooks/useGenerateRoute.ts index 0694c2aa..753b1b7b 100644 --- a/mobile/src/hooks/useGenerateRoute.ts +++ b/mobile/src/route/hooks/useGenerateRoute.ts @@ -1,5 +1,5 @@ -import { ActivityRouteEntity } from "../activity/domain/entities/activity_info_entity"; -import { useDataContext } from "../common/contexts/data_context"; +import { ActivityRouteEntity } from "../../activity/domain/entities/activity_info_entity"; +import { useDataContext } from "../../common/contexts/data_context"; import { useGet } from "./useGet"; export const useGenerateRoute = (townId: number) => { diff --git a/mobile/src/infrastructure/datasource/dev/route_datasource.ts b/mobile/src/route/infrastructure/datasources/dev/route_datasource.ts similarity index 100% rename from mobile/src/infrastructure/datasource/dev/route_datasource.ts rename to mobile/src/route/infrastructure/datasources/dev/route_datasource.ts diff --git a/mobile/src/infrastructure/datasource/prod/route_datasource.ts b/mobile/src/route/infrastructure/datasources/prod/route_datasource.ts similarity index 86% rename from mobile/src/infrastructure/datasource/prod/route_datasource.ts rename to mobile/src/route/infrastructure/datasources/prod/route_datasource.ts index fa9735d0..d2aa7653 100644 --- a/mobile/src/infrastructure/datasource/prod/route_datasource.ts +++ b/mobile/src/route/infrastructure/datasources/prod/route_datasource.ts @@ -1,7 +1,7 @@ import axios from "axios"; -import { ActivityRouteEntity } from "../../../activity/domain/entities/activity_info_entity"; +import { ActivityRouteEntity } from "../../../../activity/domain/entities/activity_info_entity"; import { RouteDataSource } from "../../../domain/datasources/route_datasource"; -import { API_URL } from "../../../common/constants/api"; +import { API_URL } from "../../../../common/constants/api"; import { ActivityRouteModel } from "../../models/prod/route_activity_model"; import { activityRouteModelToActivityRouteEntity } from "../../utils/route_utils"; diff --git a/mobile/src/infrastructure/models/prod/route_activity_model.ts b/mobile/src/route/infrastructure/model/route_activity_model.ts similarity index 100% rename from mobile/src/infrastructure/models/prod/route_activity_model.ts rename to mobile/src/route/infrastructure/model/route_activity_model.ts diff --git a/mobile/src/infrastructure/repositories/route_repository.ts b/mobile/src/route/infrastructure/repositories/route_repository.ts similarity index 100% rename from mobile/src/infrastructure/repositories/route_repository.ts rename to mobile/src/route/infrastructure/repositories/route_repository.ts diff --git a/mobile/src/infrastructure/utils/route_utils.ts b/mobile/src/route/infrastructure/utils/route_utils.ts similarity index 83% rename from mobile/src/infrastructure/utils/route_utils.ts rename to mobile/src/route/infrastructure/utils/route_utils.ts index 6daa75f9..2cf8d14a 100644 --- a/mobile/src/infrastructure/utils/route_utils.ts +++ b/mobile/src/route/infrastructure/utils/route_utils.ts @@ -1,5 +1,5 @@ -import { ActivityRouteEntity } from "../../activity/domain/entities/activity_info_entity"; -import { ActivityRouteModel } from "../models/prod/route_activity_model"; +import { ActivityRouteEntity } from "../../../activity/domain/entities/activity_info_entity"; +import { ActivityRouteModel } from "../model/route_activity_model"; export const activityRouteModelToActivityRouteEntity = (activity: ActivityRouteModel): ActivityRouteEntity => { const startTime = new Date(activity.openAt); diff --git a/mobile/src/route/screens/route_preview.tsx b/mobile/src/route/screens/route_preview.tsx index 4c60d997..4596020d 100644 --- a/mobile/src/route/screens/route_preview.tsx +++ b/mobile/src/route/screens/route_preview.tsx @@ -1,5 +1,5 @@ import { View, StyleSheet, Text, FlatList } from "react-native"; -import { useGenerateRoute } from "../../hooks/useGenerateRoute"; +import { useGenerateRoute } from "../hooks/useGenerateRoute"; import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { FullPageLoader } from "../../common/components/full_page_loader"; import { RouteActivityTile } from "../components/route_activity_tile"; diff --git a/mobile/src/screens/edit_profile/edit_profile_page.tsx b/mobile/src/screens/edit_profile/edit_profile_page.tsx index 701b0e0d..c4598b56 100644 --- a/mobile/src/screens/edit_profile/edit_profile_page.tsx +++ b/mobile/src/screens/edit_profile/edit_profile_page.tsx @@ -1,5 +1,5 @@ import { View, Text, StyleSheet } from "react-native"; -import { useEditProfile } from "../../hooks/useEditProfile"; +import { useEditProfile } from "../../profile/hooks/useEditProfile"; import { Controller } from "react-hook-form"; import { useAuth } from "../../auth/contexts/auth_context"; import { CustomTextInput } from "../../common/components/form/text_input"; diff --git a/mobile/src/screens/scan/scan_page.tsx b/mobile/src/screens/scan/scan_page.tsx index 0570d522..25c2c627 100644 --- a/mobile/src/screens/scan/scan_page.tsx +++ b/mobile/src/screens/scan/scan_page.tsx @@ -1,9 +1,9 @@ import { View, Text, Button, StyleSheet, Animated } from "react-native"; -import { useQRScanner } from "../../hooks/useQRScanner"; +import { useQRScanner } from "../../common/hooks/useQRScanner"; import { CameraView } from "expo-camera/next"; import { BarCodeScanningResult } from "expo-camera"; import { useEffect, useRef } from "react"; -import { activityPointRouteValidator } from "../../utils/activity_route"; +import { activityPointRouteValidator } from "../../activity/utils/activity_route"; export default function ScanPage() { const { hasPermission, getPermission, scanning, onQRScanned, qrData } = diff --git a/mobile/src/screens/state_selection/state_selection_page.tsx b/mobile/src/screens/state_selection/state_selection_page.tsx index c46901e1..c489c314 100644 --- a/mobile/src/screens/state_selection/state_selection_page.tsx +++ b/mobile/src/screens/state_selection/state_selection_page.tsx @@ -6,7 +6,7 @@ import { Caroussel } from "../../common/components/caroussel/caroussel"; import { router } from "expo-router"; -import { useAnimatedSelectedIndex } from "../../hooks/useAnimatedSelectedIndex"; +import { useAnimatedSelectedIndex } from "../../common/hooks/useAnimatedSelectedIndex"; import { AnimatedBackground } from "../../common/components/animated_background"; import { ErrorPage } from "../error_page/error_page"; import { LinearGradient } from "expo-linear-gradient"; diff --git a/mobile/src/screens/town_selection/town_selection_page.tsx b/mobile/src/screens/town_selection/town_selection_page.tsx index 09cc498d..a3e7953a 100644 --- a/mobile/src/screens/town_selection/town_selection_page.tsx +++ b/mobile/src/screens/town_selection/town_selection_page.tsx @@ -6,7 +6,7 @@ import { Caroussel } from "../../common/components/caroussel/caroussel"; import { useGetTowns } from "../../hooks/useGetTowns"; import { router } from "expo-router"; import { useCallback, useState } from "react"; -import { useAnimatedSelectedIndex } from "../../hooks/useAnimatedSelectedIndex"; +import { useAnimatedSelectedIndex } from "../../common/hooks/useAnimatedSelectedIndex"; import { AnimatedBackground } from "../../common/components/animated_background"; import BottomSheet, { BottomSheetView } from "@gorhom/bottom-sheet"; import { ErrorPage } from "../error_page/error_page"; diff --git a/mobile/src/screens/travel_details/travel_details_page.tsx b/mobile/src/screens/travel_details/travel_details_page.tsx index f09afa1b..2daaf9ca 100644 --- a/mobile/src/screens/travel_details/travel_details_page.tsx +++ b/mobile/src/screens/travel_details/travel_details_page.tsx @@ -5,7 +5,7 @@ import { Image, Dimensions, } from "react-native"; -import { useGetTravelDetails } from "../../hooks/useGetTravelDetails"; +import { useGetTravelDetails } from "../../travel_history/hooks/useGetTravelDetails"; import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { FullPageLoader } from "../../common/components/full_page_loader"; import { TravelActivityList } from "../../travel_history/components/activity_list"; diff --git a/mobile/src/screens/travel_history/travel_history_page.tsx b/mobile/src/screens/travel_history/travel_history_page.tsx index 5dd1d2a6..6912307e 100644 --- a/mobile/src/screens/travel_history/travel_history_page.tsx +++ b/mobile/src/screens/travel_history/travel_history_page.tsx @@ -2,7 +2,7 @@ import { View, Text, FlatList, StyleSheet, SectionList } from "react-native"; import { TravelHistorySection, useGetTravelHistory, -} from "../../hooks/useGetTravelHistory"; +} from "../../travel_history/hooks/useGetTravelHistory"; import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { FullPageLoader } from "../../common/components/full_page_loader"; import { CustomTileButton } from "../../common/components/custom_tile_button"; diff --git a/mobile/src/hooks/useGetTravelDetails.ts b/mobile/src/travel_history/hooks/useGetTravelDetails.ts similarity index 75% rename from mobile/src/hooks/useGetTravelDetails.ts rename to mobile/src/travel_history/hooks/useGetTravelDetails.ts index ed3d2cbf..de10d16a 100644 --- a/mobile/src/hooks/useGetTravelDetails.ts +++ b/mobile/src/travel_history/hooks/useGetTravelDetails.ts @@ -1,5 +1,5 @@ -import { useDataContext } from "../common/contexts/data_context"; -import { TravelDetails } from "../domain/entities/travel_details"; +import { useDataContext } from "../../common/contexts/data_context"; +import { TravelDetails } from "../../domain/entities/travel_details"; import { useGet } from "./useGet"; interface GetTravelDetailsProps { diff --git a/mobile/src/hooks/useGetTravelHistory.ts b/mobile/src/travel_history/hooks/useGetTravelHistory.ts similarity index 90% rename from mobile/src/hooks/useGetTravelHistory.ts rename to mobile/src/travel_history/hooks/useGetTravelHistory.ts index 69f63e4a..a33ef564 100644 --- a/mobile/src/hooks/useGetTravelHistory.ts +++ b/mobile/src/travel_history/hooks/useGetTravelHistory.ts @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; -import { useDataContext } from "../common/contexts/data_context" -import { Route, TravelHistory } from "../domain/entities/travel_history"; +import { useDataContext } from "../../common/contexts/data_context" +import { Route, TravelHistory } from "../../domain/entities/travel_history"; import { useGet } from "./useGet"; import { useTranslation } from "react-i18next"; export enum TravelHistorySection { -- GitLab From b2cd248e73ee9832fa9ae61cba9a6540f1e36c2d Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 9 Sep 2024 11:36:14 -0600 Subject: [PATCH 2/8] =?UTF-8?q?Reestructuraci=C3=B3n=20de=20la=20aplicaci?= =?UTF-8?q?=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/app/(tabs)/index.tsx | 4 ++-- mobile/app/(tabs)/travel_history.tsx | 3 +-- mobile/app/profile/edit.tsx | 2 +- mobile/app/profile/interests.tsx | 1 - mobile/app/profile/set_up.tsx | 1 - mobile/app/scan.tsx | 2 +- mobile/app/sign_up.tsx | 5 ----- mobile/app/state/[stateId]/index.tsx | 2 +- .../[townId]/activity/[activityId]/travel.tsx | 1 - .../[stateId]/town/[townId]/activity/_layout.tsx | 1 - .../app/state/[stateId]/town/[townId]/index.tsx | 3 +-- mobile/app/travel_history/_layout.tsx | 2 +- mobile/app/travel_history/details/[id].tsx | 2 +- .../domain/entities/activity_info_entity.ts | 2 +- mobile/src/activity/hooks/useGetActivities.ts | 5 +++-- mobile/src/activity/hooks/useGetActivityInfo.ts | 5 +++-- mobile/src/activity/hooks/useGetActivityPoint.ts | 6 +++--- .../datasources/dev/activity_datasource.ts | 4 ++-- .../datasources/prod/activity_datasource.ts | 10 +++++----- .../repositories/activity_repository.ts | 6 +++--- .../infrastructure/utils/activity_utils.ts | 4 ++-- mobile/src/activity/screens/activity_point.tsx | 2 +- .../common/components/animated_background.tsx | 4 ---- .../common/components/caroussel/caroussel.tsx | 3 +-- .../components/caroussel/caroussel_tile.tsx | 2 +- mobile/src/common/contexts/data_context.tsx | 16 ++++++++-------- mobile/src/common/hooks/useGet.ts | 2 +- .../error_page => common/screens}/error_page.tsx | 0 .../scan => common/screens}/scan_page.tsx | 0 .../{screens => common/styles}/page_styles.tsx | 2 +- .../domain/datasources/state_datasource.ts | 3 ++- .../domain/entities/place_info_entity.ts | 0 .../{ => place}/domain/entities/state_entity.ts | 1 + .../{ => place}/domain/entities/town_entity.ts | 0 .../domain/repositories/state_repository.ts | 2 +- mobile/src/{ => place}/hooks/useGetStates.ts | 4 ++-- mobile/src/{ => place}/hooks/useGetTowns.ts | 4 ++-- .../datasources}/dev/state_datasource.ts | 2 +- .../datasources}/prod/state_datasource.ts | 10 +++++----- .../infrastructure/models}/states_model.ts | 0 .../infrastructure/models}/town_model.ts | 0 .../repositories/state_repository.ts | 2 +- .../infrastructure/utils/place_utils.ts | 4 ++-- .../infrastructure/utils/states_utils.ts | 4 ++-- .../infrastructure/utils/town_utils.ts | 4 ++-- .../screens}/state_selection_page.tsx | 6 +++--- .../screens}/town_activities_page.tsx | 2 +- .../screens}/town_selection_page.tsx | 8 ++++---- .../profile/components/change_password_form.tsx | 1 - .../components/multiple_option_pickeer.tsx | 1 - mobile/src/profile/hooks/useChangeInterests.ts | 2 -- mobile/src/profile/hooks/useEditProfile.ts | 2 +- mobile/src/profile/hooks/useGetInterests.ts | 2 +- mobile/src/profile/hooks/useGetUserInterests.ts | 2 +- mobile/src/profile/hooks/useSetUpProfile.ts | 3 --- .../screens}/edit_profile_page.tsx | 0 .../route/domain/datasource/route_datasource.ts | 2 +- .../domain/repositories/route_repository.ts | 2 +- mobile/src/route/hooks/useGenerateRoute.ts | 2 +- mobile/src/route/hooks/useGetRouteActivities.ts | 5 +++-- .../datasources/dev/route_datasource.ts | 4 ++-- .../datasources/prod/route_datasource.ts | 4 ++-- .../infrastructure/model/route_activity_model.ts | 2 +- .../repositories/route_repository.ts | 2 +- mobile/src/route/screens/maps.tsx | 2 +- .../components/activity_list.tsx | 2 +- .../components/share_button.tsx | 0 .../components/travel_details_tile.tsx | 2 +- .../domain/datasources/travel_datasource.ts | 2 +- .../domain/entities/travel_details.ts | 2 +- .../domain/entities/travel_history.ts | 0 .../domain/repositories/travel_repository.ts | 0 .../hooks/useGetTravelDetails.ts | 4 ++-- .../hooks/useGetTravelHistory.ts | 5 +++-- .../datasources}/dev/travel_datasource.ts | 0 .../repositories/travel_repository.ts | 0 .../screens}/travel_details_page.tsx | 4 ++-- .../screens}/travel_history_page.tsx | 2 +- 78 files changed, 101 insertions(+), 118 deletions(-) rename mobile/src/{screens/error_page => common/screens}/error_page.tsx (100%) rename mobile/src/{screens/scan => common/screens}/scan_page.tsx (100%) rename mobile/src/{screens => common/styles}/page_styles.tsx (81%) rename mobile/src/{ => place}/domain/datasources/state_datasource.ts (80%) rename mobile/src/{ => place}/domain/entities/place_info_entity.ts (100%) rename mobile/src/{ => place}/domain/entities/state_entity.ts (99%) rename mobile/src/{ => place}/domain/entities/town_entity.ts (100%) rename mobile/src/{ => place}/domain/repositories/state_repository.ts (80%) rename mobile/src/{ => place}/hooks/useGetStates.ts (75%) rename mobile/src/{ => place}/hooks/useGetTowns.ts (78%) rename mobile/src/{infrastructure/datasource => place/infrastructure/datasources}/dev/state_datasource.ts (97%) rename mobile/src/{infrastructure/datasource => place/infrastructure/datasources}/prod/state_datasource.ts (85%) rename mobile/src/{infrastructure/models/prod => place/infrastructure/models}/states_model.ts (100%) rename mobile/src/{infrastructure/models/prod => place/infrastructure/models}/town_model.ts (100%) rename mobile/src/{ => place}/infrastructure/repositories/state_repository.ts (90%) rename mobile/src/{ => place}/infrastructure/utils/place_utils.ts (70%) rename mobile/src/{ => place}/infrastructure/utils/states_utils.ts (70%) rename mobile/src/{ => place}/infrastructure/utils/town_utils.ts (75%) rename mobile/src/{screens/state_selection => place/screens}/state_selection_page.tsx (93%) rename mobile/src/{screens/town_activities => place/screens}/town_activities_page.tsx (96%) rename mobile/src/{screens/town_selection => place/screens}/town_selection_page.tsx (91%) rename mobile/src/{screens/edit_profile => profile/screens}/edit_profile_page.tsx (100%) rename mobile/src/{travel_history => travel}/components/activity_list.tsx (96%) rename mobile/src/{travel_history => travel}/components/share_button.tsx (100%) rename mobile/src/{travel_history => travel}/components/travel_details_tile.tsx (95%) rename mobile/src/{ => travel}/domain/datasources/travel_datasource.ts (76%) rename mobile/src/{ => travel}/domain/entities/travel_details.ts (76%) rename mobile/src/{ => travel}/domain/entities/travel_history.ts (100%) rename mobile/src/{ => travel}/domain/repositories/travel_repository.ts (100%) rename mobile/src/{travel_history => travel}/hooks/useGetTravelDetails.ts (79%) rename mobile/src/{travel_history => travel}/hooks/useGetTravelHistory.ts (92%) rename mobile/src/{infrastructure/datasource => travel/infrastructure/datasources}/dev/travel_datasource.ts (100%) rename mobile/src/{ => travel}/infrastructure/repositories/travel_repository.ts (100%) rename mobile/src/{screens/travel_details => travel/screens}/travel_details_page.tsx (91%) rename mobile/src/{screens/travel_history => travel/screens}/travel_history_page.tsx (98%) diff --git a/mobile/app/(tabs)/index.tsx b/mobile/app/(tabs)/index.tsx index e29e42d6..27b15825 100644 --- a/mobile/app/(tabs)/index.tsx +++ b/mobile/app/(tabs)/index.tsx @@ -1,5 +1,5 @@ -import { DataContextProvider } from '../../src/common/contexts/data_context'; -import { StateSelectionPage } from '../../src/screens/state_selection/state_selection_page'; +import { StateSelectionPage } from "../../src/place/screens/state_selection_page"; + export default function Main () { return ( diff --git a/mobile/app/(tabs)/travel_history.tsx b/mobile/app/(tabs)/travel_history.tsx index 3b9c3e21..6d70fe79 100644 --- a/mobile/app/(tabs)/travel_history.tsx +++ b/mobile/app/(tabs)/travel_history.tsx @@ -1,5 +1,4 @@ -import { View } from "react-native"; -import { TravelHistoryPage } from "../../src/screens/travel_history/travel_history_page"; +import { TravelHistoryPage } from "../../src/travel/screens/travel_history_page"; export default function TravelHistoryScreen() { return ( diff --git a/mobile/app/profile/edit.tsx b/mobile/app/profile/edit.tsx index bc3f55f0..7cfa3836 100644 --- a/mobile/app/profile/edit.tsx +++ b/mobile/app/profile/edit.tsx @@ -1,4 +1,4 @@ -import { EditProfilePage } from "../../src/screens/edit_profile/edit_profile_page"; +import { EditProfilePage } from "../../src/profile/screens/edit_profile_page"; export default function EditProfileScreen() { return ( diff --git a/mobile/app/profile/interests.tsx b/mobile/app/profile/interests.tsx index 3e947d44..bcbf6f88 100644 --- a/mobile/app/profile/interests.tsx +++ b/mobile/app/profile/interests.tsx @@ -1,4 +1,3 @@ -import { View } from "react-native"; import { ChangeInterestsScreen } from "../../src/profile/screens/change_interests_screen"; export default function Interests() { diff --git a/mobile/app/profile/set_up.tsx b/mobile/app/profile/set_up.tsx index 25d4ff29..adfef27f 100644 --- a/mobile/app/profile/set_up.tsx +++ b/mobile/app/profile/set_up.tsx @@ -1,4 +1,3 @@ -import { View } from "react-native"; import { FirstTimeComfigScreen } from "../../src/profile/screens/first_time_config_screen"; export default function SetUp() { diff --git a/mobile/app/scan.tsx b/mobile/app/scan.tsx index 16a0619e..05eb641d 100644 --- a/mobile/app/scan.tsx +++ b/mobile/app/scan.tsx @@ -1,4 +1,4 @@ -import ScanPage from "../src/screens/scan/scan_page"; +import ScanPage from "../src/common/screens/scan_page"; export default function ScanScreen() { return ( diff --git a/mobile/app/sign_up.tsx b/mobile/app/sign_up.tsx index 23250b1a..1bb309f1 100644 --- a/mobile/app/sign_up.tsx +++ b/mobile/app/sign_up.tsx @@ -1,9 +1,4 @@ -import { View, StyleSheet, Image, Text, Button } from "react-native"; -import { LIGHT_THEME } from "../src/common/constants/theme"; -import { SignUpForm } from "../src/auth/components/sign_up_form"; -import { router } from "expo-router"; import { SignUpPage } from "../src/auth/pages/sign_up_page"; -const loginImage = require("../assets/login-image.jpg"); const SignUp = () => { return ( diff --git a/mobile/app/state/[stateId]/index.tsx b/mobile/app/state/[stateId]/index.tsx index 61456b99..abd59017 100644 --- a/mobile/app/state/[stateId]/index.tsx +++ b/mobile/app/state/[stateId]/index.tsx @@ -1,5 +1,5 @@ import { useLocalSearchParams } from "expo-router"; -import { TownSelectionPage } from "../../../src/screens/town_selection/town_selection_page"; +import { TownSelectionPage } from "../../../src/place/screens/town_selection_page"; export default function Index() { const { stateId } = useLocalSearchParams<{stateId: string}>(); diff --git a/mobile/app/state/[stateId]/town/[townId]/activity/[activityId]/travel.tsx b/mobile/app/state/[stateId]/town/[townId]/activity/[activityId]/travel.tsx index 3d1967ca..73a529b3 100644 --- a/mobile/app/state/[stateId]/town/[townId]/activity/[activityId]/travel.tsx +++ b/mobile/app/state/[stateId]/town/[townId]/activity/[activityId]/travel.tsx @@ -1,5 +1,4 @@ import { useLocalSearchParams } from "expo-router"; -import { View, Text } from "react-native"; import { ActivityPointScreen } from "../../../../../../../src/activity/screens/activity_point"; diff --git a/mobile/app/state/[stateId]/town/[townId]/activity/_layout.tsx b/mobile/app/state/[stateId]/town/[townId]/activity/_layout.tsx index 7fb512f0..cdf22644 100644 --- a/mobile/app/state/[stateId]/town/[townId]/activity/_layout.tsx +++ b/mobile/app/state/[stateId]/town/[townId]/activity/_layout.tsx @@ -1,5 +1,4 @@ import { Stack } from "expo-router"; -import { LIGHT_THEME } from "../../../../../../src/common/constants/theme"; export default function ActivitySelectionScreen() { return ( diff --git a/mobile/app/state/[stateId]/town/[townId]/index.tsx b/mobile/app/state/[stateId]/town/[townId]/index.tsx index 49bcbfa4..c1d31d40 100644 --- a/mobile/app/state/[stateId]/town/[townId]/index.tsx +++ b/mobile/app/state/[stateId]/town/[townId]/index.tsx @@ -1,6 +1,5 @@ import { useLocalSearchParams } from "expo-router"; -import { TownSelectionPage } from "../../../../../src/screens/town_selection/town_selection_page"; -import { TownActivitiesPage } from "../../../../../src/screens/town_activities/town_activities_page"; +import { TownActivitiesPage } from "../../../../../src/place/screens/town_activities_page"; export default function TownSelectionScreen() { const { stateId, townId } = useLocalSearchParams<{stateId: string, townId: string}>(); diff --git a/mobile/app/travel_history/_layout.tsx b/mobile/app/travel_history/_layout.tsx index b04fb967..7d638cb2 100644 --- a/mobile/app/travel_history/_layout.tsx +++ b/mobile/app/travel_history/_layout.tsx @@ -1,7 +1,7 @@ import { Stack } from "expo-router"; import { LIGHT_THEME } from "../../src/common/constants/theme"; import { Button } from "react-native"; -import { ShareButton } from "../../src/travel_history/components/share_button"; +import { ShareButton } from "../../src/travel/components/share_button"; export default function Layout() { return ( diff --git a/mobile/app/travel_history/details/[id].tsx b/mobile/app/travel_history/details/[id].tsx index 282857b3..920de5c5 100644 --- a/mobile/app/travel_history/details/[id].tsx +++ b/mobile/app/travel_history/details/[id].tsx @@ -1,6 +1,6 @@ import { useLocalSearchParams } from "expo-router"; import { View, Text } from "react-native"; -import { TravelDetailsPage } from "../../../src/screens/travel_details/travel_details_page"; +import { TravelDetailsPage } from "../../../src/travel/screens/travel_details_page"; export default function Details() { const { id } = useLocalSearchParams<{ id: string }>(); diff --git a/mobile/src/activity/domain/entities/activity_info_entity.ts b/mobile/src/activity/domain/entities/activity_info_entity.ts index 84457d39..93fef1d4 100644 --- a/mobile/src/activity/domain/entities/activity_info_entity.ts +++ b/mobile/src/activity/domain/entities/activity_info_entity.ts @@ -1,4 +1,4 @@ -import { PlaceInfoEntity } from "../../../domain/entities/place_info_entity"; +import { PlaceInfoEntity } from "../../../place/domain/entities/place_info_entity"; export interface ActivityInfoEntity extends PlaceInfoEntity { diff --git a/mobile/src/activity/hooks/useGetActivities.ts b/mobile/src/activity/hooks/useGetActivities.ts index f6e39305..d7492936 100644 --- a/mobile/src/activity/hooks/useGetActivities.ts +++ b/mobile/src/activity/hooks/useGetActivities.ts @@ -1,6 +1,7 @@ -import { useDataContext } from "../common/contexts/data_context"; +import { useDataContext } from "../../common/contexts/data_context"; +import { useGet } from "../../common/hooks/useGet"; import { ActivityInfoEntity } from "../domain/entities/activity_info_entity"; -import { useGet } from "./useGet" + export const useGetActivities = (townId: number) => { const { statesRepository } = useDataContext(); diff --git a/mobile/src/activity/hooks/useGetActivityInfo.ts b/mobile/src/activity/hooks/useGetActivityInfo.ts index 2120efa7..9265b260 100644 --- a/mobile/src/activity/hooks/useGetActivityInfo.ts +++ b/mobile/src/activity/hooks/useGetActivityInfo.ts @@ -1,6 +1,7 @@ -import { useDataContext } from "../common/contexts/data_context"; +import { useDataContext } from "../../common/contexts/data_context"; +import { useGet } from "../../common/hooks/useGet"; import { ActivityInfoEntity } from "../domain/entities/activity_info_entity"; -import { useGet } from "./useGet"; + export const useGetActivityInfo = (activityId: number) => { const { statesRepository } = useDataContext(); diff --git a/mobile/src/activity/hooks/useGetActivityPoint.ts b/mobile/src/activity/hooks/useGetActivityPoint.ts index 91816d2d..7667f364 100644 --- a/mobile/src/activity/hooks/useGetActivityPoint.ts +++ b/mobile/src/activity/hooks/useGetActivityPoint.ts @@ -1,6 +1,6 @@ -import { useDataContext } from "../common/contexts/data_context" -import { ActivityPlaceEntity } from "../activity/domain/entities/activity_place_entity"; -import { useGet } from "./useGet"; +import { useDataContext } from "../../common/contexts/data_context"; +import { useGet } from "../../common/hooks/useGet"; +import { ActivityPlaceEntity } from "../domain/entities/activity_place_entity"; interface UseGetActivityPointProps { stateId: number; diff --git a/mobile/src/activity/infrastructure/datasources/dev/activity_datasource.ts b/mobile/src/activity/infrastructure/datasources/dev/activity_datasource.ts index e6731af7..77d9c9c2 100644 --- a/mobile/src/activity/infrastructure/datasources/dev/activity_datasource.ts +++ b/mobile/src/activity/infrastructure/datasources/dev/activity_datasource.ts @@ -1,5 +1,5 @@ -import { ActivityDataSource } from "../../../activity/domain/datasources/activity_datasource"; -import { ActivityPlaceEntity } from "../../../activity/domain/entities/activity_place_entity"; +import { ActivityDataSource } from "../../../domain/datasources/activity_datasource"; +import { ActivityPlaceEntity } from "../../../domain/entities/activity_place_entity"; export class ActivityDatasourceDev implements ActivityDataSource { async rankActivity(activityId: number, rank: number): Promise { diff --git a/mobile/src/activity/infrastructure/datasources/prod/activity_datasource.ts b/mobile/src/activity/infrastructure/datasources/prod/activity_datasource.ts index 45bf6d02..4bfae0ff 100644 --- a/mobile/src/activity/infrastructure/datasources/prod/activity_datasource.ts +++ b/mobile/src/activity/infrastructure/datasources/prod/activity_datasource.ts @@ -1,10 +1,10 @@ import axios from "axios"; -import { ActivityPlaceEntity } from "../../../activity/domain/entities/activity_place_entity"; -import { API_URL } from "../../../common/constants/api"; -import { ActivityPlaceModel } from "../../models/prod/activity_place_model"; +import { ActivityDataSource } from "../../../domain/datasources/activity_datasource"; +import { Languages } from "../../../../lang/translations"; +import { ActivityPlaceModel } from "../../models/activity_place_model"; import { activityPlaceModelToEntity } from "../../utils/activity_utils"; -import { Languages } from "../../../lang/translations"; -import { ActivityDataSource } from "../../../activity/domain/datasources/activity_datasource"; +import { API_URL } from "../../../../common/constants/api"; +import { ActivityPlaceEntity } from "../../../domain/entities/activity_place_entity"; export class ActivityDatasourceProd implements ActivityDataSource { constructor(private lang: string = Languages.SPANISH) {} diff --git a/mobile/src/activity/infrastructure/repositories/activity_repository.ts b/mobile/src/activity/infrastructure/repositories/activity_repository.ts index eb51e198..ae90b7e9 100644 --- a/mobile/src/activity/infrastructure/repositories/activity_repository.ts +++ b/mobile/src/activity/infrastructure/repositories/activity_repository.ts @@ -1,6 +1,6 @@ -import { ActivityDataSource } from "../../activity/domain/datasources/activity_datasource"; -import { ActivityPlaceEntity } from "../../activity/domain/entities/activity_place_entity"; -import { ActivityRepository } from "../../activity/domain/repositories/activity_repository"; +import { ActivityDataSource } from "../../domain/datasources/activity_datasource"; +import { ActivityPlaceEntity } from "../../domain/entities/activity_place_entity"; +import { ActivityRepository } from "../../domain/repositories/activity_repository"; export class ActivityRepositoryDev implements ActivityRepository { constructor( diff --git a/mobile/src/activity/infrastructure/utils/activity_utils.ts b/mobile/src/activity/infrastructure/utils/activity_utils.ts index 80c7953d..b16a1092 100644 --- a/mobile/src/activity/infrastructure/utils/activity_utils.ts +++ b/mobile/src/activity/infrastructure/utils/activity_utils.ts @@ -1,5 +1,5 @@ -import { ActivityPlaceEntity } from "../../activity/domain/entities/activity_place_entity"; -import { ActivityPlaceModel } from "../../activity/infrastructure/models/activity_place_model"; +import { ActivityPlaceEntity } from "../../domain/entities/activity_place_entity"; +import { ActivityPlaceModel } from "../models/activity_place_model"; export const activityPlaceModelToEntity = (activity: ActivityPlaceModel): ActivityPlaceEntity => { return { diff --git a/mobile/src/activity/screens/activity_point.tsx b/mobile/src/activity/screens/activity_point.tsx index b8bd8eaa..2def317f 100644 --- a/mobile/src/activity/screens/activity_point.tsx +++ b/mobile/src/activity/screens/activity_point.tsx @@ -1,7 +1,6 @@ import { Image, Text, View, StyleSheet, BackHandler } from "react-native"; import { FullPageLoader } from "../../common/components/full_page_loader"; import { ApiRequestStatus } from "../../common/constants/api_request_states"; -import { useGetActivityPoint } from "../../hooks/useGetActivityPoint"; import { ScrollView } from "react-native-gesture-handler"; import { AudioPlayer } from "../../common/components/audio_player"; import { TouchableOpacity } from "@gorhom/bottom-sheet"; @@ -12,6 +11,7 @@ import { memo, useEffect, useState } from "react"; import { StarRatingForm } from "../../common/components/rating_page/star_rating_form"; import { FullPageRating } from "../../common/components/rating_page/full_page_rating"; import { useRankActivity } from "../hooks/useRankActivity"; +import { useGetActivityPoint } from "../hooks/useGetActivityPoint"; interface ActivityPointScreenProps { stateId: number; diff --git a/mobile/src/common/components/animated_background.tsx b/mobile/src/common/components/animated_background.tsx index 99cebaca..7363b799 100644 --- a/mobile/src/common/components/animated_background.tsx +++ b/mobile/src/common/components/animated_background.tsx @@ -1,8 +1,4 @@ import { Animated, Image, View } from "react-native"; -import { PlaceInfoEntity } from "../../domain/entities/place_info_entity"; -import { useAnimatedSelectedIndex } from "../hooks/useAnimatedSelectedIndex"; -import { LinearGradient } from "expo-linear-gradient"; -import { LIGHT_THEME } from "../constants/theme"; interface AnimatedBackgroundProps { imageUri?: string; diff --git a/mobile/src/common/components/caroussel/caroussel.tsx b/mobile/src/common/components/caroussel/caroussel.tsx index edcdd508..a5d04b33 100644 --- a/mobile/src/common/components/caroussel/caroussel.tsx +++ b/mobile/src/common/components/caroussel/caroussel.tsx @@ -7,9 +7,8 @@ import { NativeSyntheticEvent, NativeScrollEvent, } from "react-native"; -import { PlaceInfoEntity } from "../../../domain/entities/place_info_entity"; +import { PlaceInfoEntity } from "../../../place/domain/entities/place_info_entity"; import { useRef } from "react"; -import { StateDataSource } from "../../../domain/datasources/state_datasource"; import { CarousselTile } from "./caroussel_tile"; import { router } from "expo-router"; import { BLANK_ITEM_WIDTH, ITEM_WIDTH } from "../../constants/caroussel"; diff --git a/mobile/src/common/components/caroussel/caroussel_tile.tsx b/mobile/src/common/components/caroussel/caroussel_tile.tsx index e4caa023..97222a72 100644 --- a/mobile/src/common/components/caroussel/caroussel_tile.tsx +++ b/mobile/src/common/components/caroussel/caroussel_tile.tsx @@ -7,7 +7,7 @@ import { Text, TouchableOpacity, } from "react-native"; -import { PlaceInfoEntity } from "../../../domain/entities/place_info_entity"; +import { PlaceInfoEntity } from "../../../place/domain/entities/place_info_entity"; import { Link } from "expo-router"; import { ITEM_HEIGHT, ITEM_WIDTH } from "../../constants/caroussel"; diff --git a/mobile/src/common/contexts/data_context.tsx b/mobile/src/common/contexts/data_context.tsx index 4fda7081..e82b1959 100644 --- a/mobile/src/common/contexts/data_context.tsx +++ b/mobile/src/common/contexts/data_context.tsx @@ -1,18 +1,13 @@ import { createContext, PropsWithChildren, useContext } from "react"; -import { StateRepository } from "../../domain/repositories/state_repository"; -import { StateRepositoryImpl } from "../../infrastructure/repositories/state_repository"; -import { StateDataSourceDev } from "../../infrastructure/datasource/dev/state_datasource"; +import { StateRepositoryImpl } from "../../place/infrastructure/repositories/state_repository"; +import { StateDataSourceDev } from "../../place/infrastructure/datasources/dev/state_datasource"; import { AuthRepository } from "../../auth/domain/repositories/auth_repository"; import { AuthDataSourceDev } from '../../auth/infrastructure/dev/datasources/auth_datasource'; import { AuthRepositoryImpl } from "../../auth/infrastructure/prod/repositories/auth_repository"; -import { AuthDatasourceProd } from '../../auth/infrastructure/prod/datasources/auth_datasource'; -import { TravelDatasourceDev } from "../../infrastructure/datasource/dev/travel_datasource"; -import { TravelRepositoryImpl } from "../../infrastructure/repositories/travel_repository"; -import { TravelRepository } from "../../domain/repositories/travel_repository"; import { RouteRepository } from "../../route/domain/repositories/route_repository"; import { RouteDataSourceDev } from "../../route/infrastructure/datasources/dev/route_datasource"; import { RouteRepositoryImpl } from "../../route/infrastructure/repositories/route_repository"; -import { StateDataSourceProd } from "../../infrastructure/datasource/prod/state_datasource"; +import { StateDataSourceProd } from "../../place/infrastructure/datasources/prod/state_datasource"; 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"; @@ -23,6 +18,11 @@ import { RouteDatasourceProd } from "../../route/infrastructure/datasources/prod import { ActivityRepositoryDev } from "../../activity/infrastructure/repositories/activity_repository"; import { ActivityDatasourceProd } from "../../activity/infrastructure/datasources/prod/activity_datasource"; import { ActivityDatasourceDev } from "../../activity/infrastructure/datasources/dev/activity_datasource"; +import { StateRepository } from "../../place/domain/repositories/state_repository"; +import { TravelRepository } from "../../travel/domain/repositories/travel_repository"; +import { TravelRepositoryImpl } from "../../travel/infrastructure/repositories/travel_repository"; +import { AuthDatasourceProd } from "../../auth/infrastructure/prod/datasources/auth_datasource"; +import { TravelDatasourceDev } from "../../travel/infrastructure/datasources/dev/travel_datasource"; type DataContextType = { statesRepository: StateRepository | null; diff --git a/mobile/src/common/hooks/useGet.ts b/mobile/src/common/hooks/useGet.ts index dead195e..eb72d1c0 100644 --- a/mobile/src/common/hooks/useGet.ts +++ b/mobile/src/common/hooks/useGet.ts @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; -import { ApiRequestStatus } from "../common/constants/api_request_states"; import { set } from "react-hook-form"; +import { ApiRequestStatus } from "../constants/api_request_states"; export const useGet = (callback: () => Promise) => { const [data, setData] = useState(null); diff --git a/mobile/src/screens/error_page/error_page.tsx b/mobile/src/common/screens/error_page.tsx similarity index 100% rename from mobile/src/screens/error_page/error_page.tsx rename to mobile/src/common/screens/error_page.tsx diff --git a/mobile/src/screens/scan/scan_page.tsx b/mobile/src/common/screens/scan_page.tsx similarity index 100% rename from mobile/src/screens/scan/scan_page.tsx rename to mobile/src/common/screens/scan_page.tsx diff --git a/mobile/src/screens/page_styles.tsx b/mobile/src/common/styles/page_styles.tsx similarity index 81% rename from mobile/src/screens/page_styles.tsx rename to mobile/src/common/styles/page_styles.tsx index 90ee7303..6603f928 100644 --- a/mobile/src/screens/page_styles.tsx +++ b/mobile/src/common/styles/page_styles.tsx @@ -1,5 +1,5 @@ import { StyleSheet } from "react-native" -import { LIGHT_THEME } from "../common/constants/theme"; +import { LIGHT_THEME } from "../constants/theme"; export const pageStyles = StyleSheet.create({ page_container: { diff --git a/mobile/src/domain/datasources/state_datasource.ts b/mobile/src/place/domain/datasources/state_datasource.ts similarity index 80% rename from mobile/src/domain/datasources/state_datasource.ts rename to mobile/src/place/domain/datasources/state_datasource.ts index 460a0110..99f1c973 100644 --- a/mobile/src/domain/datasources/state_datasource.ts +++ b/mobile/src/place/domain/datasources/state_datasource.ts @@ -1,4 +1,5 @@ -import { ActivityInfoEntity } from "../../activity/domain/entities/activity_info_entity"; + +import { ActivityInfoEntity } from "../../../activity/domain/entities/activity_info_entity"; import { StateEntity } from "../entities/state_entity"; import { TownEntity } from "../entities/town_entity"; diff --git a/mobile/src/domain/entities/place_info_entity.ts b/mobile/src/place/domain/entities/place_info_entity.ts similarity index 100% rename from mobile/src/domain/entities/place_info_entity.ts rename to mobile/src/place/domain/entities/place_info_entity.ts diff --git a/mobile/src/domain/entities/state_entity.ts b/mobile/src/place/domain/entities/state_entity.ts similarity index 99% rename from mobile/src/domain/entities/state_entity.ts rename to mobile/src/place/domain/entities/state_entity.ts index 50921456..3a303208 100644 --- a/mobile/src/domain/entities/state_entity.ts +++ b/mobile/src/place/domain/entities/state_entity.ts @@ -1,3 +1,4 @@ import { PlaceInfoEntity } from "./place_info_entity"; + export interface StateEntity extends PlaceInfoEntity{} \ No newline at end of file diff --git a/mobile/src/domain/entities/town_entity.ts b/mobile/src/place/domain/entities/town_entity.ts similarity index 100% rename from mobile/src/domain/entities/town_entity.ts rename to mobile/src/place/domain/entities/town_entity.ts diff --git a/mobile/src/domain/repositories/state_repository.ts b/mobile/src/place/domain/repositories/state_repository.ts similarity index 80% rename from mobile/src/domain/repositories/state_repository.ts rename to mobile/src/place/domain/repositories/state_repository.ts index 9c145089..f6e9b14f 100644 --- a/mobile/src/domain/repositories/state_repository.ts +++ b/mobile/src/place/domain/repositories/state_repository.ts @@ -1,4 +1,4 @@ -import { ActivityInfoEntity } from "../entities/activity_info_entity"; +import { ActivityInfoEntity } from "../../../activity/domain/entities/activity_info_entity"; import { StateEntity } from "../entities/state_entity"; import { TownEntity } from "../entities/town_entity"; diff --git a/mobile/src/hooks/useGetStates.ts b/mobile/src/place/hooks/useGetStates.ts similarity index 75% rename from mobile/src/hooks/useGetStates.ts rename to mobile/src/place/hooks/useGetStates.ts index 6d8e9d9c..bd84104a 100644 --- a/mobile/src/hooks/useGetStates.ts +++ b/mobile/src/place/hooks/useGetStates.ts @@ -1,6 +1,6 @@ -import { useDataContext } from "../common/contexts/data_context"; +import { useDataContext } from "../../common/contexts/data_context"; +import { useGet } from "../../common/hooks/useGet"; import { StateEntity } from '../domain/entities/state_entity'; -import { useGet } from "./useGet" export const useGetStates = () => { const { statesRepository } = useDataContext(); diff --git a/mobile/src/hooks/useGetTowns.ts b/mobile/src/place/hooks/useGetTowns.ts similarity index 78% rename from mobile/src/hooks/useGetTowns.ts rename to mobile/src/place/hooks/useGetTowns.ts index ae7c22ed..d6b296d0 100644 --- a/mobile/src/hooks/useGetTowns.ts +++ b/mobile/src/place/hooks/useGetTowns.ts @@ -1,7 +1,7 @@ -import { useDataContext } from "../common/contexts/data_context"; +import { useDataContext } from "../../common/contexts/data_context"; +import { useGet } from "../../common/hooks/useGet"; import { StateEntity } from '../domain/entities/state_entity'; import { TownEntity } from "../domain/entities/town_entity"; -import { useGet } from "./useGet" export const useGetTowns = (stateId: number) => { const { statesRepository } = useDataContext(); diff --git a/mobile/src/infrastructure/datasource/dev/state_datasource.ts b/mobile/src/place/infrastructure/datasources/dev/state_datasource.ts similarity index 97% rename from mobile/src/infrastructure/datasource/dev/state_datasource.ts rename to mobile/src/place/infrastructure/datasources/dev/state_datasource.ts index 0fb31de1..31c0f590 100644 --- a/mobile/src/infrastructure/datasource/dev/state_datasource.ts +++ b/mobile/src/place/infrastructure/datasources/dev/state_datasource.ts @@ -1,5 +1,5 @@ +import { ActivityInfoEntity } from '../../../../activity/domain/entities/activity_info_entity'; import { StateDataSource } from '../../../domain/datasources/state_datasource'; -import { ActivityInfoEntity } from '../../../domain/entities/activity_info_entity'; import { StateEntity } from '../../../domain/entities/state_entity'; import { TownEntity } from '../../../domain/entities/town_entity'; diff --git a/mobile/src/infrastructure/datasource/prod/state_datasource.ts b/mobile/src/place/infrastructure/datasources/prod/state_datasource.ts similarity index 85% rename from mobile/src/infrastructure/datasource/prod/state_datasource.ts rename to mobile/src/place/infrastructure/datasources/prod/state_datasource.ts index 6f7380f4..aa0c8a42 100644 --- a/mobile/src/infrastructure/datasource/prod/state_datasource.ts +++ b/mobile/src/place/infrastructure/datasources/prod/state_datasource.ts @@ -2,14 +2,14 @@ import axios from "axios"; import { StateDataSource } from "../../../domain/datasources/state_datasource"; import { StateEntity } from "../../../domain/entities/state_entity"; import { TownEntity } from "../../../domain/entities/town_entity"; -import { API_URL } from "../../../common/constants/api"; -import { StateModel } from "../../models/prod/states_model"; +import { API_URL } from "../../../../common/constants/api"; +import { StateModel } from "../../models/states_model"; import { stateModelToEntity } from "../../utils/states_utils"; -import { TownModel } from "../../models/prod/town_model"; +import { TownModel } from "../../models/town_model"; import { townModelToEntity } from "../../utils/town_utils"; -import { ActivityModel } from "../../models/prod/activity_model"; import { placeModelToEntity } from "../../utils/place_utils"; -import { ActivityInfoEntity } from "../../../activity/domain/entities/activity_info_entity"; +import { ActivityInfoEntity } from "../../../../activity/domain/entities/activity_info_entity"; +import { ActivityModel } from "../../../../activity/infrastructure/models/activity_model"; export class StateDataSourceProd implements StateDataSource { private lang: string; diff --git a/mobile/src/infrastructure/models/prod/states_model.ts b/mobile/src/place/infrastructure/models/states_model.ts similarity index 100% rename from mobile/src/infrastructure/models/prod/states_model.ts rename to mobile/src/place/infrastructure/models/states_model.ts diff --git a/mobile/src/infrastructure/models/prod/town_model.ts b/mobile/src/place/infrastructure/models/town_model.ts similarity index 100% rename from mobile/src/infrastructure/models/prod/town_model.ts rename to mobile/src/place/infrastructure/models/town_model.ts diff --git a/mobile/src/infrastructure/repositories/state_repository.ts b/mobile/src/place/infrastructure/repositories/state_repository.ts similarity index 90% rename from mobile/src/infrastructure/repositories/state_repository.ts rename to mobile/src/place/infrastructure/repositories/state_repository.ts index 87ab8568..a58adcbf 100644 --- a/mobile/src/infrastructure/repositories/state_repository.ts +++ b/mobile/src/place/infrastructure/repositories/state_repository.ts @@ -1,5 +1,5 @@ +import { ActivityInfoEntity } from "../../../activity/domain/entities/activity_info_entity"; import { StateDataSource } from "../../domain/datasources/state_datasource"; -import { ActivityInfoEntity } from "../../domain/entities/activity_info_entity"; import { StateEntity } from "../../domain/entities/state_entity"; import { TownEntity } from "../../domain/entities/town_entity"; import { StateRepository } from "../../domain/repositories/state_repository"; diff --git a/mobile/src/infrastructure/utils/place_utils.ts b/mobile/src/place/infrastructure/utils/place_utils.ts similarity index 70% rename from mobile/src/infrastructure/utils/place_utils.ts rename to mobile/src/place/infrastructure/utils/place_utils.ts index d0937a3b..51c7c336 100644 --- a/mobile/src/infrastructure/utils/place_utils.ts +++ b/mobile/src/place/infrastructure/utils/place_utils.ts @@ -1,5 +1,5 @@ -import { ActivityInfoEntity } from "../../domain/entities/activity_info_entity"; -import { ActivityModel } from "../models/prod/activity_model"; +import { ActivityInfoEntity } from "../../../activity/domain/entities/activity_info_entity" +import { ActivityModel } from "../../../activity/infrastructure/models/activity_model" export const placeModelToEntity = (placeModel: ActivityModel): ActivityInfoEntity => { return { diff --git a/mobile/src/infrastructure/utils/states_utils.ts b/mobile/src/place/infrastructure/utils/states_utils.ts similarity index 70% rename from mobile/src/infrastructure/utils/states_utils.ts rename to mobile/src/place/infrastructure/utils/states_utils.ts index 2f9022a9..9a7e82a7 100644 --- a/mobile/src/infrastructure/utils/states_utils.ts +++ b/mobile/src/place/infrastructure/utils/states_utils.ts @@ -1,6 +1,6 @@ -import { API_URL } from "../../common/constants/api"; +import { API_URL } from "../../../common/constants/api"; import { StateEntity } from "../../domain/entities/state_entity"; -import { StateModel } from "../models/prod/states_model"; +import { StateModel } from "../models/states_model"; export const stateModelToEntity = (stateModel: StateModel): StateEntity => { return { diff --git a/mobile/src/infrastructure/utils/town_utils.ts b/mobile/src/place/infrastructure/utils/town_utils.ts similarity index 75% rename from mobile/src/infrastructure/utils/town_utils.ts rename to mobile/src/place/infrastructure/utils/town_utils.ts index a531744f..aef32d86 100644 --- a/mobile/src/infrastructure/utils/town_utils.ts +++ b/mobile/src/place/infrastructure/utils/town_utils.ts @@ -1,6 +1,6 @@ -import { API_URL } from "../../common/constants/api"; +import { API_URL } from "../../../common/constants/api"; import { TownEntity } from "../../domain/entities/town_entity"; -import { TownModel } from "../models/prod/town_model"; +import { TownModel } from "../models/town_model"; export const townModelToEntity = (townModel: TownModel): TownEntity => { return { diff --git a/mobile/src/screens/state_selection/state_selection_page.tsx b/mobile/src/place/screens/state_selection_page.tsx similarity index 93% rename from mobile/src/screens/state_selection/state_selection_page.tsx rename to mobile/src/place/screens/state_selection_page.tsx index c489c314..f7fffa71 100644 --- a/mobile/src/screens/state_selection/state_selection_page.tsx +++ b/mobile/src/place/screens/state_selection_page.tsx @@ -1,6 +1,5 @@ import { View, ActivityIndicator, Text } from "react-native"; -import { pageStyles } from "../page_styles"; -import { useGetStates } from "../../hooks/useGetStates"; +import { useGetStates } from "../hooks/useGetStates"; import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { Caroussel @@ -8,12 +7,13 @@ import { import { router } from "expo-router"; import { useAnimatedSelectedIndex } from "../../common/hooks/useAnimatedSelectedIndex"; import { AnimatedBackground } from "../../common/components/animated_background"; -import { ErrorPage } from "../error_page/error_page"; +import { ErrorPage } from "../../common/screens/error_page"; import { LinearGradient } from "expo-linear-gradient"; import { LIGHT_THEME } from "../../common/constants/theme"; import { useDataContext } from "../../common/contexts/data_context"; import { useAuth } from "../../auth/contexts/auth_context"; import { CARROUSEL_HEIGHT, CARROUSEL_WIDTH } from "../../common/constants/caroussel"; +import { pageStyles } from "../../common/styles/page_styles"; export const StateSelectionPage = () => { const { data, requestStatus, refresh } = useGetStates(); diff --git a/mobile/src/screens/town_activities/town_activities_page.tsx b/mobile/src/place/screens/town_activities_page.tsx similarity index 96% rename from mobile/src/screens/town_activities/town_activities_page.tsx rename to mobile/src/place/screens/town_activities_page.tsx index f21fe167..dfce705f 100644 --- a/mobile/src/screens/town_activities/town_activities_page.tsx +++ b/mobile/src/place/screens/town_activities_page.tsx @@ -9,12 +9,12 @@ import { } from "react-native"; import { FullPageLoader } from "../../common/components/full_page_loader"; import { ApiRequestStatus } from "../../common/constants/api_request_states"; -import { useGetActivities } from "../../hooks/useGetActivities"; import { ActivityTile } from "../../activity/components/activity_tile"; import { LIGHT_THEME } from "../../common/constants/theme"; import { router } from "expo-router"; import { FloatingEndActionButton } from "../../common/components/floating_end_action_button"; import { useState } from "react"; +import { useGetActivities } from "../../activity/hooks/useGetActivities"; interface TownActivitiesPageProps { townId: number; diff --git a/mobile/src/screens/town_selection/town_selection_page.tsx b/mobile/src/place/screens/town_selection_page.tsx similarity index 91% rename from mobile/src/screens/town_selection/town_selection_page.tsx rename to mobile/src/place/screens/town_selection_page.tsx index a3e7953a..ed479c9a 100644 --- a/mobile/src/screens/town_selection/town_selection_page.tsx +++ b/mobile/src/place/screens/town_selection_page.tsx @@ -1,15 +1,15 @@ import { View, Text, ActivityIndicator, StyleSheet } from "react-native"; -import { pageStyles } from "../page_styles"; -import { useGetStates } from "../../hooks/useGetStates"; +import { useGetStates } from "../hooks/useGetStates"; import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { Caroussel } from "../../common/components/caroussel/caroussel"; -import { useGetTowns } from "../../hooks/useGetTowns"; +import { useGetTowns } from "../hooks/useGetTowns"; import { router } from "expo-router"; import { useCallback, useState } from "react"; import { useAnimatedSelectedIndex } from "../../common/hooks/useAnimatedSelectedIndex"; import { AnimatedBackground } from "../../common/components/animated_background"; import BottomSheet, { BottomSheetView } from "@gorhom/bottom-sheet"; -import { ErrorPage } from "../error_page/error_page"; +import { ErrorPage } from "../../common/screens/error_page"; +import { pageStyles } from "../../common/styles/page_styles"; interface TownSelectionPageProps { stateId: number; diff --git a/mobile/src/profile/components/change_password_form.tsx b/mobile/src/profile/components/change_password_form.tsx index 3d87fd3a..31f6bf70 100644 --- a/mobile/src/profile/components/change_password_form.tsx +++ b/mobile/src/profile/components/change_password_form.tsx @@ -1,6 +1,5 @@ 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 { diff --git a/mobile/src/profile/components/multiple_option_pickeer.tsx b/mobile/src/profile/components/multiple_option_pickeer.tsx index 3383f8ff..3cb12426 100644 --- a/mobile/src/profile/components/multiple_option_pickeer.tsx +++ b/mobile/src/profile/components/multiple_option_pickeer.tsx @@ -1,4 +1,3 @@ -import { useState } from "react"; import { ScrollView, Text, TouchableOpacity, StyleSheet, View } from "react-native"; import { LIGHT_THEME } from "../../common/constants/theme"; import { IOption } from "../../common/domain/entities/option"; diff --git a/mobile/src/profile/hooks/useChangeInterests.ts b/mobile/src/profile/hooks/useChangeInterests.ts index cb1449f7..e5ca5841 100644 --- a/mobile/src/profile/hooks/useChangeInterests.ts +++ b/mobile/src/profile/hooks/useChangeInterests.ts @@ -1,7 +1,5 @@ import { useEffect, useState } from "react"; -import { useGetInterests } from "./useGetInterests"; import { IOption } from "../../common/domain/entities/option"; -import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { useDataContext } from "../../common/contexts/data_context"; diff --git a/mobile/src/profile/hooks/useEditProfile.ts b/mobile/src/profile/hooks/useEditProfile.ts index 0efe1bbc..b67a2bc5 100644 --- a/mobile/src/profile/hooks/useEditProfile.ts +++ b/mobile/src/profile/hooks/useEditProfile.ts @@ -1,5 +1,5 @@ import { useState } from "react"; -import { set, useForm } from "react-hook-form"; +import { useForm } from "react-hook-form"; import * as ImagePicker from "expo-image-picker"; export type EditProfileFormValues = { diff --git a/mobile/src/profile/hooks/useGetInterests.ts b/mobile/src/profile/hooks/useGetInterests.ts index 4c1a885d..b91a036a 100644 --- a/mobile/src/profile/hooks/useGetInterests.ts +++ b/mobile/src/profile/hooks/useGetInterests.ts @@ -1,5 +1,5 @@ import { useDataContext } from "../../common/contexts/data_context" -import { useGet } from "../../hooks/useGet"; +import { useGet } from "../../common/hooks/useGet"; export const useGetInterests = () => { const { profileRepository } = useDataContext(); diff --git a/mobile/src/profile/hooks/useGetUserInterests.ts b/mobile/src/profile/hooks/useGetUserInterests.ts index a14556c1..41303823 100644 --- a/mobile/src/profile/hooks/useGetUserInterests.ts +++ b/mobile/src/profile/hooks/useGetUserInterests.ts @@ -1,6 +1,6 @@ import { useDataContext } from "../../common/contexts/data_context" import { IOption } from "../../common/domain/entities/option" -import { useGet } from "../../hooks/useGet" +import { useGet } from "../../common/hooks/useGet" export const useGetUserInterests = () => { const { profileRepository } = useDataContext() diff --git a/mobile/src/profile/hooks/useSetUpProfile.ts b/mobile/src/profile/hooks/useSetUpProfile.ts index bc04cd8a..1e806dab 100644 --- a/mobile/src/profile/hooks/useSetUpProfile.ts +++ b/mobile/src/profile/hooks/useSetUpProfile.ts @@ -1,9 +1,6 @@ -import { set, useForm } from "react-hook-form"; 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"; import { useChangeInterests } from "./useChangeInterests"; diff --git a/mobile/src/screens/edit_profile/edit_profile_page.tsx b/mobile/src/profile/screens/edit_profile_page.tsx similarity index 100% rename from mobile/src/screens/edit_profile/edit_profile_page.tsx rename to mobile/src/profile/screens/edit_profile_page.tsx diff --git a/mobile/src/route/domain/datasource/route_datasource.ts b/mobile/src/route/domain/datasource/route_datasource.ts index 38fcd2aa..e897c740 100644 --- a/mobile/src/route/domain/datasource/route_datasource.ts +++ b/mobile/src/route/domain/datasource/route_datasource.ts @@ -1,4 +1,4 @@ -import { ActivityRouteEntity } from "../../activity/domain/entities/activity_info_entity"; +import { ActivityRouteEntity } from "../../../activity/domain/entities/activity_info_entity"; export interface RouteDataSource { diff --git a/mobile/src/route/domain/repositories/route_repository.ts b/mobile/src/route/domain/repositories/route_repository.ts index f2667ab3..b655d59b 100644 --- a/mobile/src/route/domain/repositories/route_repository.ts +++ b/mobile/src/route/domain/repositories/route_repository.ts @@ -1,4 +1,4 @@ -import { ActivityRouteEntity } from "../entities/activity_info_entity"; +import { ActivityRouteEntity } from "../../../activity/domain/entities/activity_info_entity"; export interface RouteRepository { generateRoute: (townId: number) => Promise; diff --git a/mobile/src/route/hooks/useGenerateRoute.ts b/mobile/src/route/hooks/useGenerateRoute.ts index 753b1b7b..a685b512 100644 --- a/mobile/src/route/hooks/useGenerateRoute.ts +++ b/mobile/src/route/hooks/useGenerateRoute.ts @@ -1,6 +1,6 @@ import { ActivityRouteEntity } from "../../activity/domain/entities/activity_info_entity"; import { useDataContext } from "../../common/contexts/data_context"; -import { useGet } from "./useGet"; +import { useGet } from "../../common/hooks/useGet"; export const useGenerateRoute = (townId: number) => { const { routeRepository } = useDataContext(); diff --git a/mobile/src/route/hooks/useGetRouteActivities.ts b/mobile/src/route/hooks/useGetRouteActivities.ts index e1ed69fd..0e9063f9 100644 --- a/mobile/src/route/hooks/useGetRouteActivities.ts +++ b/mobile/src/route/hooks/useGetRouteActivities.ts @@ -1,6 +1,7 @@ +import { ActivityRouteEntity } from "../../activity/domain/entities/activity_info_entity"; import { useDataContext } from "../../common/contexts/data_context" -import { ActivityRouteEntity } from "../../domain/entities/activity_info_entity"; -import { useGet } from "../../hooks/useGet"; +import { useGet } from "../../common/hooks/useGet"; + export const useGetRouteActivities = (routeId: number) => { const { routeRepository } = useDataContext(); diff --git a/mobile/src/route/infrastructure/datasources/dev/route_datasource.ts b/mobile/src/route/infrastructure/datasources/dev/route_datasource.ts index 8f04ae0c..13d0bb05 100644 --- a/mobile/src/route/infrastructure/datasources/dev/route_datasource.ts +++ b/mobile/src/route/infrastructure/datasources/dev/route_datasource.ts @@ -1,5 +1,5 @@ -import { RouteDataSource } from "../../../domain/datasources/route_datasource"; -import { ActivityInfoEntity, ActivityRouteEntity } from "../../../domain/entities/activity_info_entity"; +import { ActivityInfoEntity, ActivityRouteEntity } from "../../../../activity/domain/entities/activity_info_entity"; +import { RouteDataSource } from "../../../domain/datasource/route_datasource"; export class RouteDataSourceDev implements RouteDataSource { async generateRoute(townId: number): Promise { diff --git a/mobile/src/route/infrastructure/datasources/prod/route_datasource.ts b/mobile/src/route/infrastructure/datasources/prod/route_datasource.ts index d2aa7653..84674dcd 100644 --- a/mobile/src/route/infrastructure/datasources/prod/route_datasource.ts +++ b/mobile/src/route/infrastructure/datasources/prod/route_datasource.ts @@ -1,9 +1,9 @@ import axios from "axios"; import { ActivityRouteEntity } from "../../../../activity/domain/entities/activity_info_entity"; -import { RouteDataSource } from "../../../domain/datasources/route_datasource"; import { API_URL } from "../../../../common/constants/api"; -import { ActivityRouteModel } from "../../models/prod/route_activity_model"; import { activityRouteModelToActivityRouteEntity } from "../../utils/route_utils"; +import { RouteDataSource } from "../../../domain/datasource/route_datasource"; +import { ActivityRouteModel } from "../../model/route_activity_model"; export class RouteDatasourceProd implements RouteDataSource { private readonly language: string; diff --git a/mobile/src/route/infrastructure/model/route_activity_model.ts b/mobile/src/route/infrastructure/model/route_activity_model.ts index 6a35ae09..1fefea9f 100644 --- a/mobile/src/route/infrastructure/model/route_activity_model.ts +++ b/mobile/src/route/infrastructure/model/route_activity_model.ts @@ -1,4 +1,4 @@ -import { TagModel } from "./tag_model"; +import { TagModel } from "../../../activity/infrastructure/models/tag_model"; export interface ActivityRouteModel { address: string; diff --git a/mobile/src/route/infrastructure/repositories/route_repository.ts b/mobile/src/route/infrastructure/repositories/route_repository.ts index b6b33140..dea92db5 100644 --- a/mobile/src/route/infrastructure/repositories/route_repository.ts +++ b/mobile/src/route/infrastructure/repositories/route_repository.ts @@ -1,4 +1,4 @@ -import { RouteDataSource } from "../../domain/datasources/route_datasource"; +import { RouteDataSource } from "../../domain/datasource/route_datasource"; import { RouteRepository } from "../../domain/repositories/route_repository"; export class RouteRepositoryImpl implements RouteRepository { diff --git a/mobile/src/route/screens/maps.tsx b/mobile/src/route/screens/maps.tsx index 8ba63e59..17a4deb0 100644 --- a/mobile/src/route/screens/maps.tsx +++ b/mobile/src/route/screens/maps.tsx @@ -2,11 +2,11 @@ import MapView from "react-native-maps"; import { View } from "react-native"; import { router, useFocusEffect } from "expo-router"; import { CustomMapMarker } from "../components/maps/custom_map_marker"; -import { ActivityRouteEntity } from "../../domain/entities/activity_info_entity"; import { useGetRouteActivities } from "../hooks/useGetRouteActivities"; import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { FullPageLoader } from "../../common/components/full_page_loader"; import { useRef } from "react"; +import { ActivityRouteEntity } from "../../activity/domain/entities/activity_info_entity"; interface MapsPageProps { routeId: number; diff --git a/mobile/src/travel_history/components/activity_list.tsx b/mobile/src/travel/components/activity_list.tsx similarity index 96% rename from mobile/src/travel_history/components/activity_list.tsx rename to mobile/src/travel/components/activity_list.tsx index 5e1849c2..466c7b02 100644 --- a/mobile/src/travel_history/components/activity_list.tsx +++ b/mobile/src/travel/components/activity_list.tsx @@ -7,8 +7,8 @@ import { Animated, StyleSheet, } from "react-native"; -import { TravelHistoryActivity } from "../../domain/entities/travel_details"; import { TravelDetailsTile } from "./travel_details_tile"; +import { TravelHistoryActivity } from "../domain/entities/travel_details"; const HORIZONTAL_SPACING = 20; const VERTICAL_SPACING = 10; diff --git a/mobile/src/travel_history/components/share_button.tsx b/mobile/src/travel/components/share_button.tsx similarity index 100% rename from mobile/src/travel_history/components/share_button.tsx rename to mobile/src/travel/components/share_button.tsx diff --git a/mobile/src/travel_history/components/travel_details_tile.tsx b/mobile/src/travel/components/travel_details_tile.tsx similarity index 95% rename from mobile/src/travel_history/components/travel_details_tile.tsx rename to mobile/src/travel/components/travel_details_tile.tsx index 3e9e07f1..309f0270 100644 --- a/mobile/src/travel_history/components/travel_details_tile.tsx +++ b/mobile/src/travel/components/travel_details_tile.tsx @@ -1,6 +1,6 @@ import { Animated, Image, View, Text, StyleSheet } from "react-native"; -import { TravelHistoryActivity } from "../../domain/entities/travel_details"; import { AntDesign } from "@expo/vector-icons"; +import { TravelHistoryActivity } from "../domain/entities/travel_details"; interface TravelDetailsTileProps { item: TravelHistoryActivity; diff --git a/mobile/src/domain/datasources/travel_datasource.ts b/mobile/src/travel/domain/datasources/travel_datasource.ts similarity index 76% rename from mobile/src/domain/datasources/travel_datasource.ts rename to mobile/src/travel/domain/datasources/travel_datasource.ts index a5b2697a..4d46e6cd 100644 --- a/mobile/src/domain/datasources/travel_datasource.ts +++ b/mobile/src/travel/domain/datasources/travel_datasource.ts @@ -1,4 +1,4 @@ -import { TravelDetails } from "../entities/travel_details"; +import { TravelDetails, } from "../entities/travel_details"; import { TravelHistory } from "../entities/travel_history"; export interface TravelDataSource { diff --git a/mobile/src/domain/entities/travel_details.ts b/mobile/src/travel/domain/entities/travel_details.ts similarity index 76% rename from mobile/src/domain/entities/travel_details.ts rename to mobile/src/travel/domain/entities/travel_details.ts index fd4bdcb6..6ab94783 100644 --- a/mobile/src/domain/entities/travel_details.ts +++ b/mobile/src/travel/domain/entities/travel_details.ts @@ -1,4 +1,4 @@ -import { PlaceInfoEntity } from "./place_info_entity"; +import { PlaceInfoEntity } from "../../../place/domain/entities/place_info_entity"; import { Route } from "./travel_history"; export interface TravelDetails { diff --git a/mobile/src/domain/entities/travel_history.ts b/mobile/src/travel/domain/entities/travel_history.ts similarity index 100% rename from mobile/src/domain/entities/travel_history.ts rename to mobile/src/travel/domain/entities/travel_history.ts diff --git a/mobile/src/domain/repositories/travel_repository.ts b/mobile/src/travel/domain/repositories/travel_repository.ts similarity index 100% rename from mobile/src/domain/repositories/travel_repository.ts rename to mobile/src/travel/domain/repositories/travel_repository.ts diff --git a/mobile/src/travel_history/hooks/useGetTravelDetails.ts b/mobile/src/travel/hooks/useGetTravelDetails.ts similarity index 79% rename from mobile/src/travel_history/hooks/useGetTravelDetails.ts rename to mobile/src/travel/hooks/useGetTravelDetails.ts index de10d16a..4987c8db 100644 --- a/mobile/src/travel_history/hooks/useGetTravelDetails.ts +++ b/mobile/src/travel/hooks/useGetTravelDetails.ts @@ -1,6 +1,6 @@ import { useDataContext } from "../../common/contexts/data_context"; -import { TravelDetails } from "../../domain/entities/travel_details"; -import { useGet } from "./useGet"; +import { useGet } from "../../common/hooks/useGet"; +import { TravelDetails } from "../domain/entities/travel_details"; interface GetTravelDetailsProps { id: number; diff --git a/mobile/src/travel_history/hooks/useGetTravelHistory.ts b/mobile/src/travel/hooks/useGetTravelHistory.ts similarity index 92% rename from mobile/src/travel_history/hooks/useGetTravelHistory.ts rename to mobile/src/travel/hooks/useGetTravelHistory.ts index a33ef564..5ea05044 100644 --- a/mobile/src/travel_history/hooks/useGetTravelHistory.ts +++ b/mobile/src/travel/hooks/useGetTravelHistory.ts @@ -1,8 +1,9 @@ import { useEffect, useState } from "react"; import { useDataContext } from "../../common/contexts/data_context" -import { Route, TravelHistory } from "../../domain/entities/travel_history"; -import { useGet } from "./useGet"; +import { Route, TravelHistory } from "../domain/entities/travel_history"; + import { useTranslation } from "react-i18next"; +import { useGet } from "../../common/hooks/useGet"; export enum TravelHistorySection { ACTIVE = "Active Travels", PAST = "Past Travels", diff --git a/mobile/src/infrastructure/datasource/dev/travel_datasource.ts b/mobile/src/travel/infrastructure/datasources/dev/travel_datasource.ts similarity index 100% rename from mobile/src/infrastructure/datasource/dev/travel_datasource.ts rename to mobile/src/travel/infrastructure/datasources/dev/travel_datasource.ts diff --git a/mobile/src/infrastructure/repositories/travel_repository.ts b/mobile/src/travel/infrastructure/repositories/travel_repository.ts similarity index 100% rename from mobile/src/infrastructure/repositories/travel_repository.ts rename to mobile/src/travel/infrastructure/repositories/travel_repository.ts diff --git a/mobile/src/screens/travel_details/travel_details_page.tsx b/mobile/src/travel/screens/travel_details_page.tsx similarity index 91% rename from mobile/src/screens/travel_details/travel_details_page.tsx rename to mobile/src/travel/screens/travel_details_page.tsx index 2daaf9ca..67dfea93 100644 --- a/mobile/src/screens/travel_details/travel_details_page.tsx +++ b/mobile/src/travel/screens/travel_details_page.tsx @@ -5,10 +5,10 @@ import { Image, Dimensions, } from "react-native"; -import { useGetTravelDetails } from "../../travel_history/hooks/useGetTravelDetails"; +import { useGetTravelDetails } from "../../travel/hooks/useGetTravelDetails"; import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { FullPageLoader } from "../../common/components/full_page_loader"; -import { TravelActivityList } from "../../travel_history/components/activity_list"; +import { TravelActivityList } from "../../travel/components/activity_list"; interface TravelDetailsPageProps { id: number; diff --git a/mobile/src/screens/travel_history/travel_history_page.tsx b/mobile/src/travel/screens/travel_history_page.tsx similarity index 98% rename from mobile/src/screens/travel_history/travel_history_page.tsx rename to mobile/src/travel/screens/travel_history_page.tsx index 6912307e..eaf43b1a 100644 --- a/mobile/src/screens/travel_history/travel_history_page.tsx +++ b/mobile/src/travel/screens/travel_history_page.tsx @@ -2,7 +2,7 @@ import { View, Text, FlatList, StyleSheet, SectionList } from "react-native"; import { TravelHistorySection, useGetTravelHistory, -} from "../../travel_history/hooks/useGetTravelHistory"; +} from "../../travel/hooks/useGetTravelHistory"; import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { FullPageLoader } from "../../common/components/full_page_loader"; import { CustomTileButton } from "../../common/components/custom_tile_button"; -- GitLab From f31f3dafedb4e481db8ec064a724c9078f9abfee Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 9 Sep 2024 13:07:22 -0600 Subject: [PATCH 3/8] =?UTF-8?q?Se=20cre=C3=B3=20la=20entidad=20para=20repr?= =?UTF-8?q?esentar=20la=20informaci=C3=B3n=20para=20resetear=20la=20contra?= =?UTF-8?q?se=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/auth/domain/entities/reset_password_entity.ts | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 mobile/src/auth/domain/entities/reset_password_entity.ts diff --git a/mobile/src/auth/domain/entities/reset_password_entity.ts b/mobile/src/auth/domain/entities/reset_password_entity.ts new file mode 100644 index 00000000..3e8e0901 --- /dev/null +++ b/mobile/src/auth/domain/entities/reset_password_entity.ts @@ -0,0 +1,5 @@ +export interface ResetPasswordInfoEntity { + email: string; + newPassword: string; + code: string; +} \ No newline at end of file -- GitLab From 7f43387fd9269376dc2f6f87ac69eed3d5ce93f6 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 9 Sep 2024 13:08:34 -0600 Subject: [PATCH 4/8] =?UTF-8?q?Se=20actualiz=C3=B3=20la=20informaci=C3=B3n?= =?UTF-8?q?=20necesaria=20para=20resetear=20una=20contrase=C3=B1a=20en=20l?= =?UTF-8?q?a=20capa=20de=20dominio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/auth/domain/datasources/auth_datasource.ts | 3 ++- mobile/src/auth/domain/repositories/auth_repository.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mobile/src/auth/domain/datasources/auth_datasource.ts b/mobile/src/auth/domain/datasources/auth_datasource.ts index 589ebc64..fb64d748 100644 --- a/mobile/src/auth/domain/datasources/auth_datasource.ts +++ b/mobile/src/auth/domain/datasources/auth_datasource.ts @@ -1,10 +1,11 @@ import { LoginInfoEntity } from "../entities/login_info_entity"; import { RegisterInfoEntity } from "../entities/register_info"; +import { ResetPasswordInfoEntity } from "../entities/reset_password_entity"; import { UserInfoEntity } from "../entities/user_info_entity"; export interface AuthDataSource { login: (email: string, password: string) => Promise; register: (user: RegisterInfoEntity) => Promise; getResetCode: (email: string) => Promise; - resetPassword: (code: string) => Promise; + resetPassword: (resetInfo: ResetPasswordInfoEntity) => Promise; } \ No newline at end of file diff --git a/mobile/src/auth/domain/repositories/auth_repository.ts b/mobile/src/auth/domain/repositories/auth_repository.ts index e65719dd..9f4750f8 100644 --- a/mobile/src/auth/domain/repositories/auth_repository.ts +++ b/mobile/src/auth/domain/repositories/auth_repository.ts @@ -1,10 +1,10 @@ import { LoginInfoEntity } from "../entities/login_info_entity"; import { RegisterInfoEntity } from "../entities/register_info"; -import { UserInfoEntity } from '../entities/user_info_entity'; +import { ResetPasswordInfoEntity } from "../entities/reset_password_entity"; export interface AuthRepository { login: (email: string, password: string) => Promise; register: (user: RegisterInfoEntity) => Promise; getResetCode: (email: string) => Promise; - resetPassword: (code: string) => Promise; + resetPassword: (resetInfo: ResetPasswordInfoEntity) => Promise; } \ No newline at end of file -- GitLab From e3bd1629109133986ac8580042929e8c8c963a43 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 9 Sep 2024 13:09:02 -0600 Subject: [PATCH 5/8] =?UTF-8?q?Se=20implementaron=20los=20m=C3=A9todos=20p?= =?UTF-8?q?ara=20cambiar=20de=20contrase=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dev/datasources/auth_datasource.ts | 3 ++- .../prod/datasources/auth_datasource.ts | 25 ++++++++++++++++--- .../prod/repositories/auth_repository.ts | 5 ++-- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/mobile/src/auth/infrastructure/dev/datasources/auth_datasource.ts b/mobile/src/auth/infrastructure/dev/datasources/auth_datasource.ts index d95f9800..3a9bbf92 100644 --- a/mobile/src/auth/infrastructure/dev/datasources/auth_datasource.ts +++ b/mobile/src/auth/infrastructure/dev/datasources/auth_datasource.ts @@ -2,12 +2,13 @@ import { delay } from '../../../../common/utils/delay_time'; import { AuthDataSource } from '../../../domain/datasources/auth_datasource'; import { LoginInfoEntity } from '../../../domain/entities/login_info_entity'; import { RegisterInfoEntity } from '../../../domain/entities/register_info'; +import { ResetPasswordInfoEntity } from '../../../domain/entities/reset_password_entity'; import { UserInfoEntity } from '../../../domain/entities/user_info_entity'; export class AuthDataSourceDev implements AuthDataSource { getResetCode (email: string): Promise{ throw new Error("Method not implemented."); } - resetPassword (code: string): Promise { + resetPassword (resetInfo: ResetPasswordInfoEntity): Promise { throw new Error("Method not implemented."); } async login(email: string, password: string): Promise{ diff --git a/mobile/src/auth/infrastructure/prod/datasources/auth_datasource.ts b/mobile/src/auth/infrastructure/prod/datasources/auth_datasource.ts index 9cd0ed4e..48937de3 100644 --- a/mobile/src/auth/infrastructure/prod/datasources/auth_datasource.ts +++ b/mobile/src/auth/infrastructure/prod/datasources/auth_datasource.ts @@ -7,13 +7,30 @@ import { API_URL } from "../../../../common/constants/api"; import { LoginUserModel } from "../models/login_user_model"; import { UserInfoEntity } from "../../../domain/entities/user_info_entity"; import { RegisterResponseModel } from "../models/register_user_model"; +import { ResetPasswordInfoEntity } from "../../../domain/entities/reset_password_entity"; export class AuthDatasourceProd implements AuthDataSource { - getResetCode (email: string): Promise { - throw new Error("Method not implemented."); + async getResetCode (email: string): Promise { + const {status} = await axios.post(`${API_URL}/user/get-reset-code`, { + email + }); + + if (status !== 201) { + throw new Error("Error fetching new reset code"); + } } - resetPassword (code: string): Promise { - throw new Error("Method not implemented."); + async resetPassword (resetInfo: ResetPasswordInfoEntity): Promise { + const resetInfoModel = { + email: resetInfo.email, + resetCode: resetInfo.code, + newPassword: resetInfo.newPassword + } + + const {status} = await axios.post(`${API_URL}/user/reset-password`, resetInfoModel); + + if (status !== 201) { + throw new Error("Error reset Password"); + } } login: (email: string, password: string) => Promise = async (email, password) => { const loginInfo: LoginUserModel = { diff --git a/mobile/src/auth/infrastructure/prod/repositories/auth_repository.ts b/mobile/src/auth/infrastructure/prod/repositories/auth_repository.ts index 21590753..33d46bba 100644 --- a/mobile/src/auth/infrastructure/prod/repositories/auth_repository.ts +++ b/mobile/src/auth/infrastructure/prod/repositories/auth_repository.ts @@ -1,5 +1,6 @@ import { AuthDataSource } from '../../../domain/datasources/auth_datasource'; import { RegisterInfoEntity } from '../../../domain/entities/register_info'; +import { ResetPasswordInfoEntity } from '../../../domain/entities/reset_password_entity'; import { UserInfoEntity } from '../../../domain/entities/user_info_entity'; import { AuthRepository } from '../../../domain/repositories/auth_repository'; export class AuthRepositoryImpl implements AuthRepository { @@ -8,8 +9,8 @@ export class AuthRepositoryImpl implements AuthRepository { getResetCode (email: string) { return this.authDataSource.getResetCode(email); } - resetPassword (code: string) { - return this.authDataSource.resetPassword(code); + resetPassword (resetInfo: ResetPasswordInfoEntity) { + return this.authDataSource.resetPassword(resetInfo); } async login(email: string, password: string) { return await this.authDataSource.login(email, password); -- GitLab From d22e0ca5699af3b9c2ffa03fa554212431482d95 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 9 Sep 2024 15:56:20 -0600 Subject: [PATCH 6/8] =?UTF-8?q?Se=20agreg=C3=B3=20el=20manejo=20de=20error?= =?UTF-8?q?es=20del=20formulario=20de=20reseteo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/auth/components/password_form.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/mobile/src/auth/components/password_form.tsx b/mobile/src/auth/components/password_form.tsx index 49c16b4e..674595f0 100644 --- a/mobile/src/auth/components/password_form.tsx +++ b/mobile/src/auth/components/password_form.tsx @@ -13,12 +13,29 @@ export const PasswordForm = ({ control }: PasswordFormProps) => { ( + render={({ field: { onChange, onBlur, value }, formState: {errors} }) => ( onChange(value), + }} + /> + )} + /> + ( + onChange(value), }} -- GitLab From 44c7e41a2b811b4d7475c70f776e7cd65f3d4ffc Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 9 Sep 2024 15:58:41 -0600 Subject: [PATCH 7/8] =?UTF-8?q?Se=20complet=C3=B3=20el=20flujo=20para=20re?= =?UTF-8?q?setear=20la=20contrase=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/auth/pages/reset_password_page.tsx | 58 ++++++++++++++++--- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/mobile/src/auth/pages/reset_password_page.tsx b/mobile/src/auth/pages/reset_password_page.tsx index 26b69503..ec1172d1 100644 --- a/mobile/src/auth/pages/reset_password_page.tsx +++ b/mobile/src/auth/pages/reset_password_page.tsx @@ -7,6 +7,8 @@ import { useDataContext } from "../../common/contexts/data_context"; import { useForm } from "react-hook-form"; import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { PasswordForm } from "../components/password_form"; +import { router } from "expo-router"; +import { FullPageLoader } from "../../common/components/full_page_loader"; interface ResetPasswordSlide { slide: JSX.Element; @@ -17,15 +19,31 @@ interface ResetPasswordSlide { export interface ResetPasswordFormValues { email: string; newPassword: string; + newPasswordConfirmation: string; code: string; } +export enum ChangePaswordError { + PASSWORD_MISMATCH, + UNDEFINED +} + +export class ResetPasswordError extends Error { + public readonly type: ChangePaswordError; + constructor( type: ChangePaswordError, message? :string,){ + super(message); + this.type = type; + } + +} + export const useResetPassword = () => { const { authRepository } = useDataContext(); const { control, handleSubmit, getValues, setError, setValue } = useForm({ defaultValues: { email: "", newPassword: "", + newPasswordConfirmation: "", code: "", } }); @@ -37,7 +55,8 @@ export const useResetPassword = () => { const getResetCode = async () => { await setLoading(); - if (getValues().email) { + if (!getValues().email) { + console.log(getValues()) setError("email", { type: "manual", message: "Email is required" }); throw new Error("Email is required"); } @@ -46,15 +65,30 @@ export const useResetPassword = () => { }; const validSubmit = async (data: ResetPasswordFormValues) => { - console.log("Valid Submit", data); + try { + await setLoading(); + if (data.newPassword !== data.newPasswordConfirmation) { + setError("newPasswordConfirmation", { type: "manual", message: "Passwords do not match" }); + return; + } + await authRepository!.resetPassword({ + newPassword: data.newPassword, + code: data.code, + email: data.email + }) + router.replace("/login"); + } catch(error) { + if (error instanceof ResetPasswordError && error.type == ChangePaswordError.UNDEFINED) { + throw new Error(); + } + } }; const errorSubmit = async () => { - + throw new Error(); }; const onSubmit = async () => { - await setLoading(); await handleSubmit(validSubmit, errorSubmit)(); }; @@ -62,17 +96,18 @@ export const useResetPassword = () => { control, getResetCode, setValue, - onSubmit + onSubmit, + status }; } const useResetPasswordControl = () => { - const { control, getResetCode, setValue, onSubmit } = useResetPassword(); + const { control, getResetCode, setValue, onSubmit, status: requestStatus } = useResetPassword(); const slides: ResetPasswordSlide[] = [ { slide: , callback: async () => { - //await getResetCode(); + await getResetCode(); } }, { @@ -121,12 +156,17 @@ const useResetPasswordControl = () => { setIsLast(step === slides.length - 1); }, [step]); - return { onNext, onFinish, slide: slide.slide, isFirst, isLast, onPrevious }; + return { onNext, onFinish, slide: slide.slide, isFirst, isLast, onPrevious, requestStatus }; }; export const ResetPasswordPage = () => { - const { onNext, onFinish, slide, isFirst, isLast, onPrevious } = + const { onNext, onFinish, slide, isFirst, isLast, onPrevious, requestStatus } = useResetPasswordControl(); + + + if (requestStatus === ApiRequestStatus.LOADING) { + return + } return ( {slide} -- GitLab From 84c78b4ffdb5fec7899aed1a103bcce6cb3345ae Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 9 Sep 2024 16:07:02 -0600 Subject: [PATCH 8/8] =?UTF-8?q?Refactorizaci=C3=B3n=20de=20la=20p=C3=A1gin?= =?UTF-8?q?a=20de=20reseteo=20de=20contrase=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/auth/errors/reset_password_error.ts | 12 ++ mobile/src/auth/hooks/useResetPassword.ts | 77 ++++++++ .../auth/hooks/useResetPasswordControl.tsx | 83 +++++++++ mobile/src/auth/pages/reset_password_page.tsx | 174 ++---------------- 4 files changed, 184 insertions(+), 162 deletions(-) create mode 100644 mobile/src/auth/errors/reset_password_error.ts create mode 100644 mobile/src/auth/hooks/useResetPassword.ts create mode 100644 mobile/src/auth/hooks/useResetPasswordControl.tsx diff --git a/mobile/src/auth/errors/reset_password_error.ts b/mobile/src/auth/errors/reset_password_error.ts new file mode 100644 index 00000000..71d52b68 --- /dev/null +++ b/mobile/src/auth/errors/reset_password_error.ts @@ -0,0 +1,12 @@ +export enum ChangePaswordError { + PASSWORD_MISMATCH, + UNDEFINED +} + +export class ResetPasswordError extends Error { + public readonly type: ChangePaswordError; + constructor(type: ChangePaswordError, message?: string,) { + super(message); + this.type = type; + } +} \ No newline at end of file diff --git a/mobile/src/auth/hooks/useResetPassword.ts b/mobile/src/auth/hooks/useResetPassword.ts new file mode 100644 index 00000000..5b168e71 --- /dev/null +++ b/mobile/src/auth/hooks/useResetPassword.ts @@ -0,0 +1,77 @@ +import { useForm } from "react-hook-form"; +import { useDataContext } from "../../common/contexts/data_context"; +import { useState } from "react"; +import { ApiRequestStatus } from "../../common/constants/api_request_states"; +import { router } from "expo-router"; +import { ChangePaswordError, ResetPasswordError } from "../errors/reset_password_error"; + +export interface ResetPasswordFormValues { + email: string; + newPassword: string; + newPasswordConfirmation: string; + code: string; +} + +export const useResetPassword = () => { + const { authRepository } = useDataContext(); + const { control, handleSubmit, getValues, setError, setValue } = useForm({ + defaultValues: { + email: "", + newPassword: "", + newPasswordConfirmation: "", + code: "", + } + }); + const [status, setStatus] = useState(ApiRequestStatus.IDLE); + + const setLoading = async () => { + setStatus(ApiRequestStatus.LOADING); + }; + + const getResetCode = async () => { + await setLoading(); + if (!getValues().email) { + console.log(getValues()) + setError("email", { type: "manual", message: "Email is required" }); + throw new Error("Email is required"); + } + await authRepository!.getResetCode(getValues().email); + setStatus(ApiRequestStatus.SUCCESS); + }; + + const validSubmit = async (data: ResetPasswordFormValues) => { + try { + await setLoading(); + if (data.newPassword !== data.newPasswordConfirmation) { + setError("newPasswordConfirmation", { type: "manual", message: "Passwords do not match" }); + return; + } + await authRepository!.resetPassword({ + newPassword: data.newPassword, + code: data.code, + email: data.email + }) + router.replace("/login"); + } catch (error) { + if (error instanceof ResetPasswordError && error.type == ChangePaswordError.UNDEFINED) { + throw new Error(); + } + } + }; + + const errorSubmit = async () => { + throw new Error(); + }; + + const onSubmit = async () => { + await handleSubmit(validSubmit, errorSubmit)(); + }; + + return { + control, + getResetCode, + setValue, + onSubmit, + status + }; +} diff --git a/mobile/src/auth/hooks/useResetPasswordControl.tsx b/mobile/src/auth/hooks/useResetPasswordControl.tsx new file mode 100644 index 00000000..6b96a532 --- /dev/null +++ b/mobile/src/auth/hooks/useResetPasswordControl.tsx @@ -0,0 +1,83 @@ +import { useEffect, useState } from "react"; +import { ResetPasswordForm } from "../components/reset_password_form"; +import { CodeForm } from "../components/code_form"; +import { PasswordForm } from "../components/password_form"; +import { useResetPassword } from "./useResetPassword"; + +interface ResetPasswordSlide { + slide: JSX.Element; + callback: () => Promise; + onError?: () => void; +} + +export const useResetPasswordControl = () => { + const { + control, + getResetCode, + setValue, + onSubmit, + status: requestStatus, + } = useResetPassword(); + const slides: ResetPasswordSlide[] = [ + { + slide: , + callback: async () => { + await getResetCode(); + }, + }, + { + slide: , + callback: async () => { + console.log("Reset Password 1"); + }, + }, + { + slide: , + callback: async () => { + onSubmit(); + }, + }, + ]; + const [step, setStep] = useState(0); + const [slide, setSlide] = useState(slides[step]); + const [isLast, setIsLast] = useState(step === slides.length - 1); + const [isFirst, setIsFirst] = useState(step === 0); + + const onNext = async () => { + try { + await slide.callback(); + setStep(step + 1); + } catch (error) { + console.log(error); + slide.onError && slide.onError(); + } + }; + + const onPrevious = () => { + setStep(step - 1); + }; + + const onFinish = () => { + try { + slide.callback(); + } catch (e) { + slide.onError && slide.onError(); + } + }; + + useEffect(() => { + setSlide(slides[step]); + setIsFirst(step === 0); + setIsLast(step === slides.length - 1); + }, [step]); + + return { + onNext, + onFinish, + slide: slide.slide, + isFirst, + isLast, + onPrevious, + requestStatus, + }; +}; diff --git a/mobile/src/auth/pages/reset_password_page.tsx b/mobile/src/auth/pages/reset_password_page.tsx index ec1172d1..05154267 100644 --- a/mobile/src/auth/pages/reset_password_page.tsx +++ b/mobile/src/auth/pages/reset_password_page.tsx @@ -1,172 +1,22 @@ -import { useEffect, useState, useCallback } from "react"; import { SlideControl } from "../../common/components/slide_control"; -import { ResetPasswordForm } from "../components/reset_password_form"; import { View, StyleSheet } from "react-native"; -import { CodeForm } from "../components/code_form"; -import { useDataContext } from "../../common/contexts/data_context"; -import { useForm } from "react-hook-form"; import { ApiRequestStatus } from "../../common/constants/api_request_states"; -import { PasswordForm } from "../components/password_form"; -import { router } from "expo-router"; import { FullPageLoader } from "../../common/components/full_page_loader"; - -interface ResetPasswordSlide { - slide: JSX.Element; - callback: () => Promise; - onError?: () => void; -} - -export interface ResetPasswordFormValues { - email: string; - newPassword: string; - newPasswordConfirmation: string; - code: string; -} - -export enum ChangePaswordError { - PASSWORD_MISMATCH, - UNDEFINED -} - -export class ResetPasswordError extends Error { - public readonly type: ChangePaswordError; - constructor( type: ChangePaswordError, message? :string,){ - super(message); - this.type = type; - } - -} - -export const useResetPassword = () => { - const { authRepository } = useDataContext(); - const { control, handleSubmit, getValues, setError, setValue } = useForm({ - defaultValues: { - email: "", - newPassword: "", - newPasswordConfirmation: "", - code: "", - } - }); - const [status, setStatus] = useState(ApiRequestStatus.IDLE); - - const setLoading = async () => { - setStatus(ApiRequestStatus.LOADING); - }; - - const getResetCode = async () => { - await setLoading(); - if (!getValues().email) { - console.log(getValues()) - setError("email", { type: "manual", message: "Email is required" }); - throw new Error("Email is required"); - } - await authRepository!.getResetCode(getValues().email); - setStatus(ApiRequestStatus.SUCCESS); - }; - - const validSubmit = async (data: ResetPasswordFormValues) => { - try { - await setLoading(); - if (data.newPassword !== data.newPasswordConfirmation) { - setError("newPasswordConfirmation", { type: "manual", message: "Passwords do not match" }); - return; - } - await authRepository!.resetPassword({ - newPassword: data.newPassword, - code: data.code, - email: data.email - }) - router.replace("/login"); - } catch(error) { - if (error instanceof ResetPasswordError && error.type == ChangePaswordError.UNDEFINED) { - throw new Error(); - } - } - }; - - const errorSubmit = async () => { - throw new Error(); - }; - - const onSubmit = async () => { - await handleSubmit(validSubmit, errorSubmit)(); - }; - - return { - control, - getResetCode, - setValue, - onSubmit, - status - }; -} - -const useResetPasswordControl = () => { - const { control, getResetCode, setValue, onSubmit, status: requestStatus } = useResetPassword(); - const slides: ResetPasswordSlide[] = [ - { - slide: , - callback: async () => { - await getResetCode(); - } - }, - { - slide: , - callback: async () => { - console.log("Reset Password 1"); - } - }, - { - slide: , - callback: async () => { - onSubmit(); - } - } - ]; - const [step, setStep] = useState(0); - const [slide, setSlide] = useState(slides[step]); - const [isLast, setIsLast] = useState(step === slides.length - 1); - const [isFirst, setIsFirst] = useState(step === 0); - - const onNext = async () => { - try { - await slide.callback(); - setStep(step + 1); - } catch (error) { - console.log(error); - slide.onError && slide.onError(); - } - }; - - const onPrevious = () => { - setStep(step - 1); - }; - - const onFinish = () => { - try { - slide.callback(); - } catch (e) { - slide.onError && slide.onError(); - } - }; - - useEffect(() => { - setSlide(slides[step]); - setIsFirst(step === 0); - setIsLast(step === slides.length - 1); - }, [step]); - - return { onNext, onFinish, slide: slide.slide, isFirst, isLast, onPrevious, requestStatus }; -}; +import { useResetPasswordControl } from "../hooks/useResetPasswordControl"; export const ResetPasswordPage = () => { - const { onNext, onFinish, slide, isFirst, isLast, onPrevious, requestStatus } = - useResetPasswordControl(); - - + const { + onNext, + onFinish, + slide, + isFirst, + isLast, + onPrevious, + requestStatus, + } = useResetPasswordControl(); if (requestStatus === ApiRequestStatus.LOADING) { - return - } + return ; + } return ( {slide} -- GitLab