From 1a8d9fb331512ddb5ce6a35f76128fb2cccb4118 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Thu, 18 Apr 2024 10:22:06 -0600 Subject: [PATCH 1/3] Se creo el modelo que representa la respuesta del backend --- .../infrastructure/models/prod/register_user_model.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mobile/src/infrastructure/models/prod/register_user_model.ts b/mobile/src/infrastructure/models/prod/register_user_model.ts index 259450eb..5098002a 100644 --- a/mobile/src/infrastructure/models/prod/register_user_model.ts +++ b/mobile/src/infrastructure/models/prod/register_user_model.ts @@ -4,4 +4,14 @@ export interface RegisterUserModel { name: string; lastName: string; birthDate: string; +} + +export interface RegisterResponseModel { + user: { + userId: number; + email: string; + name: string; + lastName: string; + token: string; + } } \ No newline at end of file -- GitLab From ba08b62a49d2264a21de0bdbe5fe2e509e500b66 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Thu, 18 Apr 2024 10:22:47 -0600 Subject: [PATCH 2/3] =?UTF-8?q?Se=20aplic=C3=B3=20el=20nuevo=20modelo=20de?= =?UTF-8?q?=20respuesta=20del=20backend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasource/prod/auth_datasource.ts | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/mobile/src/infrastructure/datasource/prod/auth_datasource.ts b/mobile/src/infrastructure/datasource/prod/auth_datasource.ts index 123b1890..37714d19 100644 --- a/mobile/src/infrastructure/datasource/prod/auth_datasource.ts +++ b/mobile/src/infrastructure/datasource/prod/auth_datasource.ts @@ -6,6 +6,7 @@ import { userRegisterEntityToUserRegisterModel } from "../../utils/prod/user_uti import { API_URL } from "../../../constants/api"; import { LoginUserModel } from "../../models/prod/login_user_model"; import { UserInfoEntity } from "../../../domain/entities/user_info_entity"; +import { RegisterResponseModel } from "../../models/prod/register_user_model"; export class AuthDatasourceProd implements AuthDataSource { login: (email: string, password: string) => Promise = async (email, password) => { @@ -14,32 +15,35 @@ export class AuthDatasourceProd implements AuthDataSource { password }; //TODO: Hacer el login info model y el user info model cuando se termine la documentación - const { data, status } = await axios.post<{ token: string, user: UserInfoEntity }>(`${API_URL}/user/signin`, loginInfo); - if (status !== 200) { + const { data, status } = await axios.post(`${API_URL}/user/signin`, loginInfo); + if (status !== 201) { throw new Error("Error logging in"); } const loginResponse: LoginInfoEntity = { - token: data.token, - user: data.user + token: data.user.token, + user: { + id: data.user.userId, + email: data.user.email, + name: data.user.name, + lastName: data.user.lastName, + } } return loginResponse; }; register: (user: RegisterInfoEntity) => Promise = async (user) => { const newUser = userRegisterEntityToUserRegisterModel(user); - const { data, status } = await axios.post<{ token: string }>(`${API_URL}/user/signup`, newUser); - //TODO: Falta regresar el id del usuario + const { data, status } = await axios.post(`${API_URL}/user/signup`, newUser); if (status !== 201) { throw new Error("Error registering user"); } const registeredUser: LoginInfoEntity = { - token: data.token, + token: data.user.token, user: { - id: 1, - email: newUser.email, - name: newUser.name, - lastName: newUser.lastName, - birthDate: new Date(newUser.birthDate) + id: data.user.userId, + email: data.user.email, + name: data.user.name, + lastName: data.user.lastName } } return registeredUser; -- GitLab From 36b66c21875639c309dca5322e9ada124995ee59 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Thu, 18 Apr 2024 10:23:04 -0600 Subject: [PATCH 3/3] =?UTF-8?q?Se=20cabi=C3=B3=20el=20contexto=20de=20desa?= =?UTF-8?q?rrollo=20a=20produccion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/contexts/data_context.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/src/contexts/data_context.tsx b/mobile/src/contexts/data_context.tsx index 8ec516ce..e216b1c8 100644 --- a/mobile/src/contexts/data_context.tsx +++ b/mobile/src/contexts/data_context.tsx @@ -22,7 +22,7 @@ const DataContext = createContext({ export const DataContextProvider = ({ children }: DataContextProviderProps) => { const statesDataSource = new StateDataSourceDev(); const statesRepository = new StateRepositoryImpl(statesDataSource); - const authDataSource = new AuthDataSourceDev(); + const authDataSource = new AuthDatasourceProd(); const authRepository = new AuthRepositoryImpl(authDataSource); -- GitLab