minor fixes
This commit is contained in:
parent
6b2803864e
commit
20687d8551
@ -1,6 +1,7 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { makeRequest } from "../api";
|
import { makeRequest } from "../api";
|
||||||
import { Tariff, GetTariffsResponse } from "../model/tariff";
|
import { Tariff, GetTariffsResponse } from "../model/tariff";
|
||||||
|
import { devlog } from "../utils";
|
||||||
|
|
||||||
|
|
||||||
export function useTariffs({ url, tariffsPerPage, apiPage, onNewTariffs, onError }: {
|
export function useTariffs({ url, tariffsPerPage, apiPage, onNewTariffs, onError }: {
|
||||||
@ -22,13 +23,13 @@ export function useTariffs({ url, tariffsPerPage, apiPage, onNewTariffs, onError
|
|||||||
useToken: true,
|
useToken: true,
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
// devlog("GetTicketsResponse", result);
|
devlog("GetTariffsResponse", result);
|
||||||
if (result.tariffs.length > 0) {
|
if (result.tariffs.length > 0) {
|
||||||
onNewTariffs(result.tariffs);
|
onNewTariffs(result.tariffs);
|
||||||
setFetchState("idle");
|
setFetchState("idle");
|
||||||
} else setFetchState("all fetched");
|
} else setFetchState("all fetched");
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.log("Error fetching tariffs", error);
|
devlog("Error fetching tariffs", error);
|
||||||
onError(error);
|
onError(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ export function useTickets({ url, ticketsPerPage, ticketApiPage, onNewTickets, o
|
|||||||
setFetchState("idle");
|
setFetchState("idle");
|
||||||
} else setFetchState("all fetched");
|
} else setFetchState("all fetched");
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.log("Error fetching tickets", error);
|
devlog("Error fetching tickets", error);
|
||||||
onError(error);
|
onError(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user