Success.tsx 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { Check, Mail } from 'lucide-react'
  2. import Link from 'next/link'
  3. import { Button, IconDiscord, Separator } from 'ui'
  4. import { NO_PROJECT_MARKER } from './SupportForm.utils'
  5. import { useProjectDetailQuery } from '@/data/projects/project-detail-query'
  6. import { useProfile } from '@/lib/profile'
  7. interface SuccessProps {
  8. sentCategory?: string
  9. selectedProject?: string
  10. onFinish?: () => void
  11. finishLabel?: string
  12. }
  13. export const Success = ({
  14. sentCategory = '',
  15. selectedProject = NO_PROJECT_MARKER,
  16. onFinish,
  17. finishLabel = 'Finish',
  18. }: SuccessProps) => {
  19. const { profile } = useProfile()
  20. const respondToEmail = profile?.primary_email ?? 'your email'
  21. const { data: project } = useProjectDetailQuery(
  22. { ref: selectedProject },
  23. { enabled: selectedProject !== NO_PROJECT_MARKER }
  24. )
  25. const projectName = project ? project.name : 'No specific project'
  26. const categoriesToShowAdditionalResources = ['Problem', 'Unresponsive', 'Performance']
  27. return (
  28. <div className="mt-10 max-w-[620px] flex flex-col items-center space-y-4">
  29. <div className="relative">
  30. <Mail strokeWidth={1.5} size={32} className="text-brand" />
  31. <div className="absolute -bottom-1 -right-1.5 flex h-4 w-4 items-center justify-center rounded-full bg-brand">
  32. <Check strokeWidth={4} size={16} className="text-contrast" />
  33. </div>
  34. </div>
  35. <div className="flex items-center flex-col space-y-2 text-center p-4">
  36. <h3 className="text-xl">Support request sent</h3>
  37. <p className="text-sm text-foreground-light text-balance">
  38. {selectedProject !== NO_PROJECT_MARKER && (
  39. <>
  40. Your ticket has been logged for the project{' '}
  41. <span className="text-foreground font-medium">{projectName}</span> with project ID:{' '}
  42. <span className="text-foreground font-medium">{selectedProject}</span>.
  43. </>
  44. )}{' '}
  45. We will reach out to you at{' '}
  46. <span className="text-foreground font-medium">{respondToEmail}</span>.
  47. </p>
  48. </div>
  49. {categoriesToShowAdditionalResources.includes(sentCategory) && (
  50. <>
  51. <div className="my-10! w-full">
  52. <Separator />
  53. </div>
  54. <div className="flex flex-col items-center px-12 space-y-2 text-center">
  55. <h4 className="text-lg font-normal">Tap into our community</h4>
  56. <p className="text-sm text-foreground-light text-balance">
  57. Our Discord community can help with code-related issues. Many questions are answered
  58. in minutes.
  59. </p>
  60. </div>
  61. <Button
  62. asChild
  63. type="default"
  64. icon={<IconDiscord size={16} fill="hsl(var(--background-default))" />}
  65. >
  66. <Link href={'https://discord.supabase.com/'} target="_blank">
  67. Join us on Discord
  68. </Link>
  69. </Button>
  70. </>
  71. )}
  72. <div className="mt-10! w-full">
  73. <Separator />
  74. </div>
  75. <div className="w-full pb-4 px-4 flex items-center justify-end">
  76. {onFinish ? (
  77. <Button type="default" onClick={onFinish}>
  78. {finishLabel}
  79. </Button>
  80. ) : (
  81. <Button asChild type="default">
  82. <Link href="/">{finishLabel}</Link>
  83. </Button>
  84. )}
  85. </div>
  86. </div>
  87. )
  88. }