LinkSupportTicketPage.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { Check, Mail } from 'lucide-react'
  2. import Link from 'next/link'
  3. import { useRouter } from 'next/router'
  4. import { useState } from 'react'
  5. import { Button, cn, DialogSectionSeparator } from 'ui'
  6. import { Admonition } from 'ui-patterns'
  7. import { LinkSupportTicketForm } from './LinkSupportTicketForm'
  8. export function LinkSupportTicketPage() {
  9. return (
  10. <div className="mx-auto my-16 max-w-2xl w-full px-4 lg:px-6">
  11. <LinkSupportTicketPageContent />
  12. </div>
  13. )
  14. }
  15. function LinkSupportTicketPageContent() {
  16. const router = useRouter()
  17. const conversationId = router.query.conversationId as string | undefined
  18. const [isSuccess, setIsSuccess] = useState(false)
  19. // Wait for router to be ready before checking for conversationId
  20. if (!router.isReady) {
  21. return null
  22. }
  23. if (!conversationId) {
  24. return (
  25. <Admonition
  26. type="warning"
  27. title="Missing conversation ID"
  28. description="Please provide a conversationId in the URL to link your support ticket."
  29. />
  30. )
  31. }
  32. return (
  33. <div
  34. className={cn(
  35. 'min-w-full w-full space-y-12 rounded-sm border bg-panel-body-light shadow-md border-default'
  36. )}
  37. >
  38. {isSuccess ? (
  39. <LinkSupportTicketSuccess />
  40. ) : (
  41. <LinkSupportTicketForm
  42. conversationId={conversationId}
  43. onSuccess={() => setIsSuccess(true)}
  44. />
  45. )}
  46. </div>
  47. )
  48. }
  49. function LinkSupportTicketSuccess() {
  50. return (
  51. <div className="w-full flex flex-col items-center">
  52. <div className="flex flex-col items-center gap-y-4 py-8">
  53. <div className="relative">
  54. <Mail strokeWidth={1.5} size={60} className="text-brand" />
  55. <div className="h-6 w-6 rounded-full bg-brand absolute bottom-1 -right-1.5 flex items-center justify-center">
  56. <Check strokeWidth={4} size={16} className="text-contrast" />
  57. </div>
  58. </div>
  59. <div className="flex items-center flex-col gap-y-2 text-center">
  60. <h3 className="text-xl">Support ticket linked</h3>
  61. <p className="text-sm text-foreground-light">
  62. Your support conversation has been linked to your account.
  63. </p>
  64. </div>
  65. </div>
  66. <DialogSectionSeparator />
  67. <div className="w-full py-4 px-4 flex items-center justify-end">
  68. <Button asChild type="default">
  69. <Link href="/">Finish</Link>
  70. </Button>
  71. </div>
  72. </div>
  73. )
  74. }