diff --git a/src/components/FieldWithHistory.js b/src/components/FieldWithHistory.js index 20b77d9..4d688da 100644 --- a/src/components/FieldWithHistory.js +++ b/src/components/FieldWithHistory.js @@ -4,6 +4,8 @@ import { useState, useEffect } from "react"; import Tooltip from "@/components/ui/Tooltip"; import { formatDate } from "@/lib/utils"; import { useTranslation } from "@/lib/i18n"; +import { formatDistanceToNow } from "date-fns"; +import { pl, enUS } from "date-fns/locale"; export default function FieldWithHistory({ tableName, @@ -14,11 +16,14 @@ export default function FieldWithHistory({ label = null, className = "", }) { - const { t } = useTranslation(); + const { t, language } = useTranslation(); const [hasHistory, setHasHistory] = useState(false); const [history, setHistory] = useState([]); const [loading, setLoading] = useState(true); + // Get locale for date-fns + const locale = language === 'pl' ? pl : enUS; + useEffect(() => { const fetchHistory = async () => { try { @@ -59,33 +64,95 @@ export default function FieldWithHistory({ // Create tooltip content const tooltipContent = history.length > 0 && ( -
{getDisplayValue(currentValue)}
{hasHistory && (