AdvisorDetail.tsx 1.4 KB

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