SupportAccessToggle.tsx 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // End of third-party imports
  2. import { SupportCategories } from '@supabase/shared-types/out/constants'
  3. import { ChevronRight } from 'lucide-react'
  4. import Link from 'next/link'
  5. import type { UseFormReturn } from 'react-hook-form'
  6. import { Badge, Collapsible, CollapsibleContent, CollapsibleTrigger, FormField, Switch } from 'ui'
  7. import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
  8. import type { ExtendedSupportCategories } from './Support.constants'
  9. import type { SupportFormValues } from './SupportForm.schema'
  10. export const DISABLE_SUPPORT_ACCESS_CATEGORIES: ExtendedSupportCategories[] = [
  11. SupportCategories.ACCOUNT_DELETION,
  12. SupportCategories.SALES_ENQUIRY,
  13. SupportCategories.REFUND,
  14. ]
  15. interface SupportAccessToggleProps {
  16. form: UseFormReturn<SupportFormValues>
  17. align?: 'left' | 'right'
  18. className?: string
  19. }
  20. export function SupportAccessToggle({ form, align = 'left', className }: SupportAccessToggleProps) {
  21. return (
  22. <FormField
  23. name="allowSupportAccess"
  24. control={form.control}
  25. render={({ field }) => {
  26. return (
  27. <FormItemLayout
  28. hideMessage
  29. name="allowSupportAccess"
  30. className={className}
  31. layout="flex"
  32. align={align}
  33. label={
  34. <div className="flex items-center gap-x-2">
  35. <span className="text-foreground">Allow support access to your project</span>
  36. <Badge>Recommended</Badge>
  37. </div>
  38. }
  39. description={
  40. <div className="flex flex-col">
  41. <span className="text-foreground-light">
  42. Human support and AI diagnostic access.
  43. </span>
  44. <Collapsible className="mt-2">
  45. <CollapsibleTrigger
  46. className={
  47. 'group flex items-center gap-x-1 group-data-open:text-foreground hover:text-foreground transition'
  48. }
  49. >
  50. <ChevronRight
  51. size={14}
  52. className="transition-all group-data-open:rotate-90 text-foreground-muted -ml-1"
  53. />
  54. <span className="text-sm">More information</span>
  55. </CollapsibleTrigger>
  56. <CollapsibleContent className="text-sm text-foreground-light mt-2 space-y-2">
  57. <p>
  58. By enabling this, you grant permission for our support team to access your
  59. project temporarily and, if applicable, to use AI tools to assist in
  60. diagnosing and resolving issues. This access may involve analyzing database
  61. configurations, query performance, and other relevant data to expedite
  62. troubleshooting and enhance support accuracy.
  63. </p>
  64. <p>
  65. We are committed to maintaining strict data privacy and security standards in
  66. all support activities.{' '}
  67. <Link
  68. href="https://supabase.com/privacy"
  69. target="_blank"
  70. rel="noreferrer"
  71. className="text-foreground-light underline hover:text-foreground transition"
  72. >
  73. Privacy Policy
  74. </Link>
  75. </p>
  76. </CollapsibleContent>
  77. </Collapsible>
  78. </div>
  79. }
  80. >
  81. <Switch
  82. size="large"
  83. id="allowSupportAccess"
  84. checked={field.value}
  85. onCheckedChange={field.onChange}
  86. />
  87. </FormItemLayout>
  88. )
  89. }}
  90. />
  91. )
  92. }