import dayjs from 'dayjs' import { FC } from 'react' import { Notification, NotificationStatus } from '@supabase/shared-types/out/notifications' import { useStore } from 'hooks' import { Project } from 'types' import { formatNotificationCTAText, formatNotificationText } from './NotificationRows.utils' import NotificationActions from './NotificationActions' interface Props { notification: Notification onSelectRestartProject: (project: Project, notification: Notification) => void } const NotificationRow: FC = ({ notification, onSelectRestartProject }) => { const { app } = useStore() const [project] = app.projects.list((project: Project) => project.id === notification.project_id) const insertedAt = dayjs(notification.inserted_at).format('DD MMM YYYY, HH:mma') const availableActions = notification.meta?.actions_available ?? [] return (
{notification.notification_status !== NotificationStatus.Seen && (
)}

{formatNotificationText(project, notification)}

{formatNotificationCTAText(availableActions)}

{insertedAt}

{availableActions.length > 0 && ( onSelectRestartProject(project, notification)} /> )}
) } export default NotificationRow