Loading mobile/src/hooks/useGetTravelHistory.ts +5 −2 Original line number Diff line number Diff line Loading @@ -2,12 +2,14 @@ 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 { useTranslation } from "react-i18next"; export enum TravelHistorySection { ACTIVE = "Active Travels", PAST = "Past Travels", } interface SectionItem { type: string; title: string; data: Route[]; } Loading @@ -15,6 +17,7 @@ interface SectionItem { export const useGetTravelHistory = () => { const { travelRepository } = useDataContext(); const [preparedData, setPreparedData] = useState<SectionItem[] | null>(null); const LANG = useTranslation(); const callback = () => travelRepository!.getTravelHistory(); const { data, requestStatus } = useGet<TravelHistory>(callback); //TODO: Cambiar la destructuración múltiple de pastTravels Loading @@ -23,8 +26,8 @@ export const useGetTravelHistory = () => { const pastTravels = [...data.pastTravels, ...data.pastTravels, ...data.pastTravels, ...data.pastTravels, ...data.pastTravels, ...data.pastTravels,]; const activeTravels = data.activeTravel ? [data.activeTravel] : []; const preparedData = [ { title: TravelHistorySection.ACTIVE, data: activeTravels }, { title: TravelHistorySection.PAST, data: pastTravels }, { type: TravelHistorySection.ACTIVE, data: activeTravels, title: LANG.t("travelHistoryScreen.activeTravelsLabel") }, { type: TravelHistorySection.PAST, data: pastTravels, title: LANG.t("travelHistoryScreen.pastTravelsLabel") }, ]; setPreparedData(preparedData); } Loading Loading
mobile/src/hooks/useGetTravelHistory.ts +5 −2 Original line number Diff line number Diff line Loading @@ -2,12 +2,14 @@ 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 { useTranslation } from "react-i18next"; export enum TravelHistorySection { ACTIVE = "Active Travels", PAST = "Past Travels", } interface SectionItem { type: string; title: string; data: Route[]; } Loading @@ -15,6 +17,7 @@ interface SectionItem { export const useGetTravelHistory = () => { const { travelRepository } = useDataContext(); const [preparedData, setPreparedData] = useState<SectionItem[] | null>(null); const LANG = useTranslation(); const callback = () => travelRepository!.getTravelHistory(); const { data, requestStatus } = useGet<TravelHistory>(callback); //TODO: Cambiar la destructuración múltiple de pastTravels Loading @@ -23,8 +26,8 @@ export const useGetTravelHistory = () => { const pastTravels = [...data.pastTravels, ...data.pastTravels, ...data.pastTravels, ...data.pastTravels, ...data.pastTravels, ...data.pastTravels,]; const activeTravels = data.activeTravel ? [data.activeTravel] : []; const preparedData = [ { title: TravelHistorySection.ACTIVE, data: activeTravels }, { title: TravelHistorySection.PAST, data: pastTravels }, { type: TravelHistorySection.ACTIVE, data: activeTravels, title: LANG.t("travelHistoryScreen.activeTravelsLabel") }, { type: TravelHistorySection.PAST, data: pastTravels, title: LANG.t("travelHistoryScreen.pastTravelsLabel") }, ]; setPreparedData(preparedData); } Loading