SOC2.tsx 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. // @ts-nocheck
  2. import { PermissionAction } from '@supabase/shared-types/out/constants'
  3. import { Download } from 'lucide-react'
  4. import { useState } from 'react'
  5. import { toast } from 'sonner'
  6. import { Button } from 'ui'
  7. import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
  8. import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
  9. import {
  10. ScaffoldSection,
  11. ScaffoldSectionContent,
  12. ScaffoldSectionDetail,
  13. } from '@/components/layouts/Scaffold'
  14. import NoPermission from '@/components/ui/NoPermission'
  15. import { UpgradePlanButton } from '@/components/ui/UpgradePlanButton'
  16. import { getDocument } from '@/data/documents/document-query'
  17. import { useSendEventMutation } from '@/data/telemetry/send-event-mutation'
  18. import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
  19. import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
  20. import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
  21. export const SOC2 = () => {
  22. const { data: organization } = useSelectedOrganizationQuery()
  23. const slug = organization?.slug
  24. const { mutate: sendEvent } = useSendEventMutation()
  25. const { can: canReadSubscriptions, isLoading: isLoadingPermissions } = useAsyncCheckPermissions(
  26. PermissionAction.BILLING_READ,
  27. 'stripe.subscriptions'
  28. )
  29. const { hasAccess: hasAccessToSoc2Report, isLoading: isLoadingEntitlement } =
  30. useCheckEntitlements('security.soc2_report')
  31. const [isOpen, setIsOpen] = useState(false)
  32. const fetchSOC2 = async (orgSlug: string) => {
  33. try {
  34. const soc2Link = await getDocument({ orgSlug, docType: 'soc2-type-2-report' })
  35. if (soc2Link?.fileUrl) window.open(soc2Link.fileUrl, '_blank')
  36. setIsOpen(false)
  37. } catch (error: unknown) {
  38. const message = error instanceof Error ? error.message : 'Unknown error occurred'
  39. toast.error(`Failed to download SOC2 report: ${message}`)
  40. }
  41. }
  42. const handleDownloadClick = () => {
  43. if (!slug) return
  44. sendEvent({
  45. action: 'document_view_button_clicked',
  46. properties: { documentName: 'SOC2' },
  47. groups: { organization: slug },
  48. })
  49. setIsOpen(true)
  50. }
  51. return (
  52. <ScaffoldSection className="py-12">
  53. <ScaffoldSectionDetail>
  54. <h4 className="mb-5">SOC2 Type 2</h4>
  55. <div className="space-y-2 text-sm text-foreground-light [&_p]:m-0">
  56. <p>
  57. Organizations on Team Plan or above have access to our most recent SOC2 Type 2 report.
  58. </p>
  59. </div>
  60. </ScaffoldSectionDetail>
  61. <ScaffoldSectionContent>
  62. {isLoadingPermissions || isLoadingEntitlement ? (
  63. <div className="@lg:flex items-center justify-center h-full">
  64. <ShimmeringLoader className="w-24" />
  65. </div>
  66. ) : !canReadSubscriptions ? (
  67. <NoPermission resourceText="access our SOC2 Type 2 report" />
  68. ) : !hasAccessToSoc2Report ? (
  69. <div className="@lg:flex items-center justify-center h-full">
  70. <UpgradePlanButton
  71. variant="default"
  72. plan="Team"
  73. source="org-documents-soc2"
  74. featureProposition="download the SOC2 Type 2report"
  75. />
  76. </div>
  77. ) : (
  78. <div className="@lg:flex items-center justify-center h-full">
  79. <Button
  80. type="default"
  81. icon={<Download />}
  82. onClick={handleDownloadClick}
  83. disabled={!slug}
  84. >
  85. Download SOC2 Type 2 Report
  86. </Button>
  87. </div>
  88. )}
  89. <ConfirmationModal
  90. visible={isOpen}
  91. size="large"
  92. title="Non-Disclosure Agreement to access Briven's SOC2 Report"
  93. confirmLabel="I agree"
  94. confirmLabelLoading="Downloading"
  95. onCancel={() => setIsOpen(false)}
  96. onConfirm={() => {
  97. if (slug) fetchSOC2(slug)
  98. }}
  99. >
  100. <ol className="list-decimal list-inside text-sm text-foreground-light pl-30">
  101. <li>The information that you are about to access is confidential.</li>
  102. <li>
  103. Your access to our SOC 2 materials is governed by confidentiality obligations
  104. contained in the agreement between Briven, Inc ("Briven", "we", "our" or "us") and
  105. the Briven customer that has authorized you to access our platform to obtain this
  106. information (our "Customer").
  107. </li>
  108. <li>
  109. You must ensure that you treat the information in our SOC 2 materials in accordance
  110. with those confidentiality obligations, as communicated to you by the Customer.
  111. </li>
  112. <li>
  113. By clicking "I agree" below or otherwise accessing our SOC 2 materials, you:
  114. <ol className="list-[lower-roman] list-inside pl-4">
  115. <li>acknowledge that you have read and understood this Confidentiality Notice;</li>
  116. <li>
  117. confirm that you have been authorized by the Customer to access this information,
  118. and your use of our SOC 2 materials is subject to the confidentiality obligations
  119. owed by the Customer to us.
  120. </li>
  121. </ol>
  122. </li>
  123. <li>
  124. This Confidentiality Notice does not substitute or supersede any agreement between us
  125. and the Customer, or any internal rules or policies that the Customer requires you to
  126. comply with in your access to and use of confidential information. However, your
  127. failure to comply with this Confidentiality Notice may be used to determine whether
  128. the Customer has complied with its confidentiality obligations to us.
  129. </li>
  130. </ol>
  131. </ConfirmationModal>
  132. </ScaffoldSectionContent>
  133. </ScaffoldSection>
  134. )
  135. }