Files
Frontend/src/app/components/cache-information.tsx

25 lines
783 B
TypeScript
Raw Normal View History

2024-04-19 21:19:14 +01:00
import { Cache } from "mcutils-library";
import React, { ReactElement, ReactNode } from "react";
import { Popover, PopoverContent, PopoverTrigger } from "@/app/components/ui/popover";
import moment from "moment";
type CacheInformationProps = {
cache: Cache;
children?: ReactNode;
};
export function CacheInformation({ cache, children }: CacheInformationProps): ReactElement {
const isCached = cache.cached;
const cacheTime = cache.cachedTime;
return (
<Popover>
<PopoverTrigger asChild>{children}</PopoverTrigger>
<PopoverContent>
<p className={isCached ? "text-green-400" : "text-red-400"}>{isCached ? "Cached" : "Not Cached"}</p>
{cacheTime !== -1 && <p>{moment(cacheTime).calendar()}</p>}
</PopoverContent>
</Popover>
);
}