Skip to content

The open alternative to Salesforce, designed for AI.

705 B
Raw Blame
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { useLingui } from '@lingui/react/macro';
import { dateLocaleState } from '@/localization/states/dateLocaleState';
import { beautifyPastDateRelativeToNow } from '~/utils/date-utils';

export const useGetAddedRelativeDateDescription = () => {
  const { t } = useLingui();
  const { localeCatalog } = useAtomStateValue(dateLocaleState);

  const getAddedRelativeDateDescription = (createdAt: string) => {
    const beautifiedCreatedAt = beautifyPastDateRelativeToNow(
      createdAt,
      localeCatalog,
    );
    return t`Added ${beautifiedCreatedAt}`;
  };

  return { getAddedRelativeDateDescription };
};