Files
HiveGrid-Wireframes/hivegrid-cloud/apps/web/app/components/entities/rows/cells/RowFolioCell.tsx
T

42 lines
1.2 KiB
TypeScript

import { Link } from "react-router";
import { useLocaleFormatters } from "~/locale/format";
export default function RowFolioCell({ prefix, folio, href, onClick }: { prefix: string; folio: number; href?: string; onClick?: () => void }) {
const formatters = useLocaleFormatters();
const folioText = formatters.number(folio ?? 0, {
maximumFractionDigits: 0,
minimumIntegerDigits: 4,
useGrouping: false,
});
const text = `${prefix}-${folioText}`;
return (
<>
{href ? (
<Link
to={href}
onClick={(e) => {
e.stopPropagation();
}}
className="hover border-border text-muted-foreground hover:text-foreground bg-secondary rounded-md border border-b px-1 py-0.5 text-center text-sm hover:underline"
>
{text}
</Link>
) : onClick ? (
<button
type="button"
onClick={(e) => {
e.stopPropagation();
onClick();
}}
className="hover border-border text-muted-foreground hover:text-foreground bg-secondary rounded-md border border-b px-1 py-0.5 text-center text-sm hover:underline"
>
{text}
</button>
) : (
<div>{text}</div>
)}
</>
);
}