500.tsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import { LOCAL_STORAGE_KEYS } from 'common'
  2. import { NextPage } from 'next'
  3. import { useTheme } from 'next-themes'
  4. import Image from 'next/legacy/image'
  5. import Link from 'next/link'
  6. import { useRouter } from 'next/router'
  7. import { Button } from 'ui'
  8. import { SupportLink } from '@/components/interfaces/Support/SupportLink'
  9. import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
  10. import { useSignOut } from '@/lib/auth'
  11. const Error500: NextPage = () => {
  12. const router = useRouter()
  13. const signOut = useSignOut()
  14. const { resolvedTheme } = useTheme()
  15. const [lastVisitedOrganization] = useLocalStorageQuery(
  16. LOCAL_STORAGE_KEYS.LAST_VISITED_ORGANIZATION,
  17. ''
  18. )
  19. const onClickLogout = async () => {
  20. await signOut()
  21. await router.push('/sign-in')
  22. router.reload()
  23. }
  24. return (
  25. <div className="relative mx-auto flex flex-1 w-full flex-col items-center justify-center space-y-6">
  26. <div className="absolute top-0 mx-auto w-full max-w-7xl px-8 pt-6 sm:px-6 lg:px-8">
  27. <nav className="relative flex items-center justify-between sm:h-10">
  28. <div className="flex shrink-0 grow items-center lg:grow-0">
  29. <div className="flex w-full items-center justify-between md:w-auto">
  30. <Link href="/projects">
  31. <Image
  32. src={
  33. resolvedTheme?.includes('dark')
  34. ? `${router.basePath}/img/briven-dark.svg`
  35. : `${router.basePath}/img/briven-light.svg`
  36. }
  37. alt=""
  38. height={24}
  39. width={120}
  40. />
  41. </Link>
  42. </div>
  43. </div>
  44. </nav>
  45. </div>
  46. <div className="flex w-[320px] flex-col items-center justify-center space-y-3">
  47. <h4 className="text-lg">Something went wrong 🤕</h4>
  48. <p className="text-center">
  49. Sorry about that, please try again later or feel free to reach out to us if the problem
  50. persists.
  51. </p>
  52. </div>
  53. <div className="flex items-center space-x-4">
  54. {router.pathname !== '/organizations' ? (
  55. <Button asChild>
  56. <Link
  57. href={
  58. !!lastVisitedOrganization ? `/org/${lastVisitedOrganization}` : '/organizations'
  59. }
  60. >
  61. Head back
  62. </Link>
  63. </Button>
  64. ) : (
  65. <Button onClick={onClickLogout}>Head back</Button>
  66. )}
  67. <Button type="secondary" asChild>
  68. <SupportLink>Submit a support request</SupportLink>
  69. </Button>
  70. </div>
  71. </div>
  72. )
  73. }
  74. export default Error500