From 307d4b65673c22b0a9cf943475aae4a655c7d8c5 Mon Sep 17 00:00:00 2001 From: Pablo Pettinari Date: Wed, 16 Oct 2024 16:26:12 +0200 Subject: [PATCH] test --- src/components/BigNumber/index.tsx | 19 +++++++++---------- src/lib/utils/data/cacheAsyncFn.ts | 2 +- src/lib/utils/data/dataLoader.ts | 29 +++++++++++++++-------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/components/BigNumber/index.tsx b/src/components/BigNumber/index.tsx index 4d1c954290f..5917fa167a3 100644 --- a/src/components/BigNumber/index.tsx +++ b/src/components/BigNumber/index.tsx @@ -1,10 +1,8 @@ import { type ReactNode } from "react" -import { useRouter } from "next/router" import { useTranslation } from "next-i18next" import { MdInfoOutline } from "react-icons/md" import { cn } from "@/lib/utils/cn" -import { isValidDate } from "@/lib/utils/date" import Tooltip from "../Tooltip" import Link from "../ui/Link" @@ -27,13 +25,13 @@ const BigNumber = ({ className, }: BigNumberProps) => { const { t } = useTranslation("common") - const { locale } = useRouter() - const lastUpdatedDisplay = - lastUpdated && isValidDate(lastUpdated) - ? new Intl.DateTimeFormat(locale, { - dateStyle: "medium", - }).format(new Date(lastUpdated)) - : "" + // const { locale } = useRouter() + // // const lastUpdatedDisplay = + // // lastUpdated && isValidDate(lastUpdated) + // // ? new Intl.DateTimeFormat(locale, { + // // dateStyle: "medium", + // // }).format(new Date(lastUpdated)) + // // : "" return (
{lastUpdated && (

- {t("last-updated")}: {lastUpdatedDisplay} + {t("last-updated")}:{" "} + {new Date(lastUpdated).toISOString()}

)} diff --git a/src/lib/utils/data/cacheAsyncFn.ts b/src/lib/utils/data/cacheAsyncFn.ts index d93b0268d9a..6f322ca4169 100644 --- a/src/lib/utils/data/cacheAsyncFn.ts +++ b/src/lib/utils/data/cacheAsyncFn.ts @@ -45,7 +45,7 @@ export function cacheAsyncFn( const value = await fn() // Store in memory cache - memoryCache[key] = { value: value, timestamp: now } + memoryCache[key] = { value, timestamp: now } console.log("Function result cached", key) return value as T diff --git a/src/lib/utils/data/dataLoader.ts b/src/lib/utils/data/dataLoader.ts index 68b6b54e531..7229891466a 100644 --- a/src/lib/utils/data/dataLoader.ts +++ b/src/lib/utils/data/dataLoader.ts @@ -1,7 +1,6 @@ import { cacheAsyncFn } from "./cacheAsyncFn" -import { loadMockData } from "./loadMockData" -const USE_MOCK_DATA = process.env.USE_MOCK_DATA === "true" +// const USE_MOCK_DATA = process.env.USE_MOCK_DATA === "true" type DataLoaderFunction = () => Promise @@ -32,19 +31,21 @@ export function dataLoader( const cachedLoader = cacheAsyncFn(key, loader, { cacheTimeout, }) - return async () => { - try { - if (USE_MOCK_DATA) { - console.log("Using mock data for", key) - return await loadMockData(key) - } - return await cachedLoader() - } catch (error) { - console.error(`Error in dataLoader for key "${key}":`, error) - throw error - } - } + return cachedLoader + // return async () => { + // try { + // if (USE_MOCK_DATA) { + // console.log("Using mock data for", key) + // return await loadMockData(key) + // } + + // return await cachedLoader() + // } catch (error) { + // console.error(`Error in dataLoader for key "${key}":`, error) + // throw error + // } + // } }) return async () => {