import { formatDistance } from "date-fns";
import { useTranslation } from "react-i18next";
import { Link } from "react-router";
import { Image } from "~/components/Image";
import type { LoaderNotification } from "~/components/layout/NotificationPopover";
import {
mapMetaForTranslation,
notificationLink,
notificationNavIcon,
} from "~/features/notifications/notifications-utils";
import { databaseTimestampToDate } from "~/utils/dates";
import { navIconUrl } from "~/utils/urls";
import styles from "./NotificationList.module.css";
export function NotificationsList({ children }: { children: React.ReactNode }) {
return
{children}
;
}
export function NotificationItem({
notification,
}: {
notification: LoaderNotification;
}) {
const { t, i18n } = useTranslation(["common"]);
return (
{!notification.seen ? : null}
{t(
`common:notifications.text.${notification.type}`,
mapMetaForTranslation(notification, i18n.language),
)}
{formatDistance(
databaseTimestampToDate(notification.createdAt),
new Date(),
{
addSuffix: true,
},
)}
);
}
export function NotificationItemDivider() {
return
;
}
function NotificationImage({
notification,
children,
}: {
notification: LoaderNotification;
children: React.ReactNode;
}) {
if (notification.pictureUrl) {
return (
{children}
);
}
return (
{children}
);
}