Commit aa8018c3 authored by Lorenzo Trujillo Rojas's avatar Lorenzo Trujillo Rojas
Browse files

Se agregó soporte multilenguaje a la página de historial de viajes

parent 5a4c0d69
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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[];
}
@@ -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
@@ -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);
        }