Files
Frontend/src/app/components/cache-information.tsx
Liam 97c1b88370
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 1m27s
add cache info buttons
2024-04-19 21:19:14 +01:00

25 lines
783 B
TypeScript

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>
);
}