InsertBeforeRemoveChildErrorHandler.tsx 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import { SupportCategories } from '@supabase/shared-types/out/constants'
  2. import { Blocks, ExternalLink } from 'lucide-react'
  3. import { useRouter } from 'next/router'
  4. import { Button } from 'ui'
  5. import { SupportLink } from '@/components/interfaces/Support/SupportLink'
  6. import { detectBrowser } from '@/lib/helpers'
  7. interface InsertBeforeRemoveChildErrorHandlerProps {
  8. message: string
  9. sentryIssueId: string
  10. urlMessage: string
  11. isRemoveChildError: boolean
  12. isInsertBeforeError?: boolean
  13. }
  14. export const InsertBeforeRemoveChildErrorHandler = ({
  15. message,
  16. sentryIssueId,
  17. urlMessage,
  18. isRemoveChildError,
  19. isInsertBeforeError,
  20. }: InsertBeforeRemoveChildErrorHandlerProps) => {
  21. const router = useRouter()
  22. const browser = detectBrowser()
  23. return (
  24. <>
  25. <div className="flex flex-col gap-y-4 text-left py-2 w-full">
  26. <div className="flex items-center gap-x-3">
  27. <p className="text-lg font-bold">Sorry! A browser extension may have caused an error.</p>
  28. <Blocks className="text-foreground-lighter" />
  29. </div>
  30. <div className="flex flex-col gap-y-2">
  31. <p className="text-sm text-foreground-light">
  32. Browser translation tools (like Chrome's built-in Translate) or some third-party browser
  33. extensions are known to cause errors when using the Briven Dashboard.
  34. </p>
  35. <p className="text-sm text-foreground-light">
  36. We highly recommend{' '}
  37. <span className="text-foreground">
  38. {browser === 'Chrome'
  39. ? 'disabling Chrome Translate or certain browser extensions'
  40. : 'avoiding the use of browser translation tools or disabling certain extensions'}
  41. </span>{' '}
  42. while using the Briven Dashboard to avoid running into this error. Try to refresh the
  43. browser to see if it occurs again.
  44. </p>
  45. </div>
  46. <p className="text-foreground-lighter text-sm">Error: {message}</p>
  47. </div>
  48. <div className="flex gap-x-2 justify-center items-center">
  49. <Button asChild type="default" icon={<ExternalLink />}>
  50. <a
  51. target="_blank"
  52. rel="noreferrer"
  53. href={
  54. isRemoveChildError
  55. ? 'https://github.com/facebook/react/issues/17256'
  56. : isInsertBeforeError
  57. ? 'https://github.com/facebook/react/issues/24865'
  58. : '/'
  59. }
  60. >
  61. More information
  62. </a>
  63. </Button>
  64. <Button type="outline" onClick={() => router.reload()}>
  65. Refresh page
  66. </Button>
  67. </div>
  68. <SupportLink
  69. className="text-center text-xs text-foreground-lighter hover:text-foreground-light transition"
  70. queryParams={{
  71. category: SupportCategories.DASHBOARD_BUG,
  72. subject: `Client error: Failed to execute '${isRemoveChildError ? 'removeChild' : 'insertBefore'}' on 'Node'`,
  73. sid: sentryIssueId,
  74. error: urlMessage,
  75. }}
  76. >
  77. Still stuck?
  78. </SupportLink>
  79. </>
  80. )
  81. }