AdvisorDetail.tsx53 lines · main
1import { noop } from 'lodash'
2
3import type { AdvisorItem } from './AdvisorPanel.types'
4import { AdvisorSignalDetail } from './AdvisorSignalDetail'
5import { NotificationDetail } from './NotificationDetail'
6import { LintDetail } from '@/components/interfaces/Linter/LintDetail'
7import type { Lint } from '@/data/lint/lint-query'
8import type { Notification } from '@/data/notifications/notifications-v2-query'
9
10interface AdvisorDetailProps {
11 item: AdvisorItem
12 projectRef: string
13 onUpdateNotificationStatus?: (id: string, status: 'archived' | 'seen') => void
14 onAfterLintAction?: () => void
15}
16
17export const AdvisorDetail = ({
18 item,
19 projectRef,
20 onUpdateNotificationStatus = noop,
21 onAfterLintAction,
22}: AdvisorDetailProps) => {
23 if (item.source === 'lint') {
24 const lint = item.original as Lint
25 return (
26 <div className="px-6 py-6">
27 <LintDetail lint={lint} projectRef={projectRef} onAfterAction={onAfterLintAction} />
28 </div>
29 )
30 }
31
32 if (item.source === 'signal') {
33 return (
34 <div className="px-6 py-6">
35 <AdvisorSignalDetail item={item} />
36 </div>
37 )
38 }
39
40 if (item.source === 'notification') {
41 const notification = item.original as Notification
42 return (
43 <div className="px-6 py-6">
44 <NotificationDetail
45 notification={notification}
46 onUpdateStatus={onUpdateNotificationStatus}
47 />
48 </div>
49 )
50 }
51
52 return null
53}