'use client'; import { useFetch } from '@gitroom/helpers/utils/custom.fetch'; import useSWR from 'swr'; import { FC, useCallback, useState } from 'react'; import clsx from 'clsx'; import { useClickAway } from '@uidotdev/usehooks'; function replaceLinks(text: string) { const urlRegex = /(\bhttps?:\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/gi; return text.replace(urlRegex, '$1'); } export const ShowNotification: FC<{ notification: { createdAt: string; content: string }; lastReadNotification: string; }> = (props) => { const { notification } = props; const [newNotification] = useState( new Date(notification.createdAt) > new Date(props.lastReadNotification) ); return (
); }; export const NotificationOpenComponent = () => { const fetch = useFetch(); const loadNotifications = useCallback(async () => { return await (await fetch('/notifications/list')).json(); }, []); const { data, isLoading } = useSWR('notifications', loadNotifications); return (