import { Archive, ArchiveRestoreIcon, ExternalLink } from 'lucide-react' import Link from 'next/link' import { Button } from 'ui' import { Markdown } from '@/components/interfaces/Markdown' import { Notification, NotificationData } from '@/data/notifications/notifications-v2-query' import { useOrganizationsQuery } from '@/data/organizations/organizations-query' import { useProjectDetailQuery } from '@/data/projects/project-detail-query' interface NotificationDetailProps { notification: Notification onUpdateStatus: (id: string, status: 'archived' | 'seen') => void } export const NotificationDetail = ({ notification, onUpdateStatus }: NotificationDetailProps) => { const data = notification.data as NotificationData const { data: project } = useProjectDetailQuery({ ref: data.project_ref }) const { data: organizations } = useOrganizationsQuery() const organization = data.org_slug !== undefined ? organizations?.find((org) => org.slug === data.org_slug) : project !== undefined ? organizations?.find((org) => org.id === project.organization_id) : undefined const onButtonAction = (type?: string) => { // [Joshen] Implement accordingly - BE team will need to give us a heads up on this console.log('Action', type) } return (
{(project !== undefined || organization !== undefined) && ( <>

Context

{organization !== undefined && ( {organization.name} )} {project !== undefined && ( {project.name} )}
)} {data.message !== undefined && ( <>

Message

)}

Actions

{(data.actions ?? []).map((action, idx) => { const key = `${notification.id}-action-${idx}` if (action.url !== undefined) { const url = action.url.includes('[ref]') ? action.url.replace('[ref]', project?.ref ?? '_') : action.url.includes('[slug]') ? action.url.replace('[slug]', organization?.slug ?? '_') : action.url return ( ) } else if (action.action_type !== undefined) { return ( ) } else { return null } })} {notification.status === 'archived' ? ( ) : ( )}
) }