Loading web/src/data/datasources/prod/place_datasource.ts +43 −3 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ import axios from "axios"; import { APIUrl } from "../../../constants/api_url"; import { PlaceDatasourceInf } from "../../../infraestructure/datasources/place_datasource"; import { AvailableDays, Place } from "../../../infraestructure/entities/place"; import { PlaceModel } from "../../models/prod/PlaceModel"; export class PlaceDatasourceProd implements PlaceDatasourceInf{ async registerPlace(form: Place): Promise<void> { Loading @@ -9,9 +10,9 @@ export class PlaceDatasourceProd implements PlaceDatasourceInf{ formToSend.append('available', form.available); formToSend.append('idTown', String(form.idTown)); formToSend.append('name', form.name); formToSend.append('descriptionES', form.descriptions[0]); formToSend.append('descriptionEN', form.descriptions[1]); formToSend.append('image', form.imagesList[0]); formToSend.append('descriptionES', form.descriptions?.[0] ?? ''); formToSend.append('descriptionEN', form.descriptions?.[1] ?? ''); formToSend.append('image', form.imagesList?.[0] ?? ''); formToSend.append('latitude', String(form.latitude)); formToSend.append('longitude', String(form.longitude)); formToSend.append('openAt', String(form.openAt)); Loading @@ -28,4 +29,43 @@ export class PlaceDatasourceProd implements PlaceDatasourceInf{ await axios.post(APIUrl + '/place', formToSend,{headers}); } async getPlacesByTown(idTown: number): Promise<Place[]> { const {data} = await axios.get<PlaceModel[]>(APIUrl+`/place/town/${idTown}/place`, { params: { lang: 'ES' } }); const places = data.map((value) => { let availableDays = AvailableDays.WEEKEND; switch(value.available){ case AvailableDays.ALL_DAYS: availableDays = AvailableDays.ALL_DAYS; break; case AvailableDays.CUSTOM: availableDays = AvailableDays.CUSTOM; break; case AvailableDays.WEEKDAYS: availableDays = AvailableDays.WEEKDAYS; break; default: availableDays = AvailableDays.WEEKEND; break; } const place: Place = { idTown : value.idTown, idPlace : value.idPlace, available : availableDays, latitude: value.latitude, longitude: value.longitude, name: value.name, openAt: value.openAt, closeAt: value.closeAt } return place; }) return places; } } No newline at end of file web/src/data/repositories/prod/place_repository.ts +4 −0 Original line number Diff line number Diff line Loading @@ -9,4 +9,8 @@ export class PlaceRepositoryProd implements PlaceRepositoryInf{ async registerPlace(form: Place): Promise<void> { return this.datasouce.registerPlace(form); } async getPlacesByTown(idTown: number): Promise<Place[]> { return this.datasouce.getPlacesByTown(idTown); } } No newline at end of file web/src/infraestructure/datasources/place_datasource.ts +1 −0 Original line number Diff line number Diff line Loading @@ -2,4 +2,5 @@ import { Place } from "../entities/place"; export interface PlaceDatasourceInf{ registerPlace(form: Place): Promise<void>; getPlacesByTown(idTown: number): Promise<Place[]>; } No newline at end of file web/src/infraestructure/repositories/place_repository.ts +1 −0 Original line number Diff line number Diff line Loading @@ -2,4 +2,5 @@ import { Place } from "../entities/place"; export interface PlaceRepositoryInf{ registerPlace(form: Place): Promise<void>; getPlacesByTown(idTown: number): Promise<Place[]>; } No newline at end of file Loading
web/src/data/datasources/prod/place_datasource.ts +43 −3 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ import axios from "axios"; import { APIUrl } from "../../../constants/api_url"; import { PlaceDatasourceInf } from "../../../infraestructure/datasources/place_datasource"; import { AvailableDays, Place } from "../../../infraestructure/entities/place"; import { PlaceModel } from "../../models/prod/PlaceModel"; export class PlaceDatasourceProd implements PlaceDatasourceInf{ async registerPlace(form: Place): Promise<void> { Loading @@ -9,9 +10,9 @@ export class PlaceDatasourceProd implements PlaceDatasourceInf{ formToSend.append('available', form.available); formToSend.append('idTown', String(form.idTown)); formToSend.append('name', form.name); formToSend.append('descriptionES', form.descriptions[0]); formToSend.append('descriptionEN', form.descriptions[1]); formToSend.append('image', form.imagesList[0]); formToSend.append('descriptionES', form.descriptions?.[0] ?? ''); formToSend.append('descriptionEN', form.descriptions?.[1] ?? ''); formToSend.append('image', form.imagesList?.[0] ?? ''); formToSend.append('latitude', String(form.latitude)); formToSend.append('longitude', String(form.longitude)); formToSend.append('openAt', String(form.openAt)); Loading @@ -28,4 +29,43 @@ export class PlaceDatasourceProd implements PlaceDatasourceInf{ await axios.post(APIUrl + '/place', formToSend,{headers}); } async getPlacesByTown(idTown: number): Promise<Place[]> { const {data} = await axios.get<PlaceModel[]>(APIUrl+`/place/town/${idTown}/place`, { params: { lang: 'ES' } }); const places = data.map((value) => { let availableDays = AvailableDays.WEEKEND; switch(value.available){ case AvailableDays.ALL_DAYS: availableDays = AvailableDays.ALL_DAYS; break; case AvailableDays.CUSTOM: availableDays = AvailableDays.CUSTOM; break; case AvailableDays.WEEKDAYS: availableDays = AvailableDays.WEEKDAYS; break; default: availableDays = AvailableDays.WEEKEND; break; } const place: Place = { idTown : value.idTown, idPlace : value.idPlace, available : availableDays, latitude: value.latitude, longitude: value.longitude, name: value.name, openAt: value.openAt, closeAt: value.closeAt } return place; }) return places; } } No newline at end of file
web/src/data/repositories/prod/place_repository.ts +4 −0 Original line number Diff line number Diff line Loading @@ -9,4 +9,8 @@ export class PlaceRepositoryProd implements PlaceRepositoryInf{ async registerPlace(form: Place): Promise<void> { return this.datasouce.registerPlace(form); } async getPlacesByTown(idTown: number): Promise<Place[]> { return this.datasouce.getPlacesByTown(idTown); } } No newline at end of file
web/src/infraestructure/datasources/place_datasource.ts +1 −0 Original line number Diff line number Diff line Loading @@ -2,4 +2,5 @@ import { Place } from "../entities/place"; export interface PlaceDatasourceInf{ registerPlace(form: Place): Promise<void>; getPlacesByTown(idTown: number): Promise<Place[]>; } No newline at end of file
web/src/infraestructure/repositories/place_repository.ts +1 −0 Original line number Diff line number Diff line Loading @@ -2,4 +2,5 @@ import { Place } from "../entities/place"; export interface PlaceRepositoryInf{ registerPlace(form: Place): Promise<void>; getPlacesByTown(idTown: number): Promise<Place[]>; } No newline at end of file