Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
pettinarip committed Oct 16, 2024
1 parent 492c95f commit 307d4b6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
19 changes: 9 additions & 10 deletions src/components/BigNumber/index.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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 (
<div
className={cn(
Expand All @@ -56,7 +54,8 @@ const BigNumber = ({
</p>
{lastUpdated && (
<p className="mt-2">
{t("last-updated")}: {lastUpdatedDisplay}
{t("last-updated")}:{" "}
{new Date(lastUpdated).toISOString()}
</p>
)}
</>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils/data/cacheAsyncFn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function cacheAsyncFn<T>(
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
Expand Down
29 changes: 15 additions & 14 deletions src/lib/utils/data/dataLoader.ts
Original file line number Diff line number Diff line change
@@ -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<T> = () => Promise<T>

Expand Down Expand Up @@ -32,19 +31,21 @@ export function dataLoader<T extends unknown[]>(
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 () => {
Expand Down

0 comments on commit 307d4b6

Please sign in to comment.