ISO27001.tsx 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 ISO27001 = () => {
  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: hasAccessToISO27001, isLoading: isLoadingEntitlement } = useCheckEntitlements(
  30. 'security.iso27001_certificate'
  31. )
  32. const [isOpen, setIsOpen] = useState(false)
  33. const fetchISO27001 = async (orgSlug: string) => {
  34. try {
  35. const link = await getDocument({ orgSlug, docType: 'iso27001-certificate' })
  36. if (link?.fileUrl) window.open(link.fileUrl, '_blank')
  37. setIsOpen(false)
  38. } catch (error: unknown) {
  39. const message = error instanceof Error ? error.message : 'Unknown error occurred'
  40. toast.error(`Failed to download ISO 27001 certificate: ${message}`)
  41. }
  42. }
  43. const handleDownloadClick = () => {
  44. if (!slug) return
  45. sendEvent({
  46. action: 'document_view_button_clicked',
  47. properties: { documentName: 'ISO27001' },
  48. groups: { organization: slug },
  49. })
  50. setIsOpen(true)
  51. }
  52. return (
  53. <ScaffoldSection className="py-12">
  54. <ScaffoldSectionDetail>
  55. <h4 className="mb-5">ISO 27001</h4>
  56. <div className="space-y-2 text-sm text-foreground-light [&_p]:m-0">
  57. <p>
  58. Organizations on Team Plan or above have access to our most recent ISO 27001
  59. certificate.
  60. </p>
  61. </div>
  62. </ScaffoldSectionDetail>
  63. <ScaffoldSectionContent>
  64. {isLoadingPermissions || isLoadingEntitlement ? (
  65. <div className="@lg:flex items-center justify-center h-full">
  66. <ShimmeringLoader className="w-24" />
  67. </div>
  68. ) : !canReadSubscriptions ? (
  69. <NoPermission resourceText="access our ISO 27001 certificate" />
  70. ) : !hasAccessToISO27001 ? (
  71. <div className="@lg:flex items-center justify-center h-full">
  72. <UpgradePlanButton
  73. variant="default"
  74. plan="Team"
  75. source="org-documents-iso27001"
  76. featureProposition="download the ISO 27001 certificate"
  77. />
  78. </div>
  79. ) : (
  80. <div className="@lg:flex items-center justify-center h-full">
  81. <Button
  82. type="default"
  83. icon={<Download />}
  84. onClick={handleDownloadClick}
  85. disabled={!slug}
  86. >
  87. Download ISO 27001 Certificate
  88. </Button>
  89. </div>
  90. )}
  91. <ConfirmationModal
  92. visible={isOpen}
  93. size="large"
  94. title="Non-Disclosure Agreement to access Briven's ISO 27001 Certificate"
  95. confirmLabel="I agree"
  96. confirmLabelLoading="Downloading"
  97. onCancel={() => setIsOpen(false)}
  98. onConfirm={() => {
  99. if (slug) fetchISO27001(slug)
  100. }}
  101. >
  102. <ol className="list-decimal list-inside text-sm text-foreground-light pl-30">
  103. <li>The information that you are about to access is confidential.</li>
  104. <li>
  105. Your access to our ISO 27001 materials is governed by confidentiality obligations
  106. contained in the agreement between Briven, Inc ("Briven", "we", "our" or "us") and
  107. the Briven customer that has authorized you to access our platform to obtain this
  108. information (our "Customer").
  109. </li>
  110. <li>
  111. You must ensure that you treat the information in our ISO 27001 materials in
  112. accordance with those confidentiality obligations, as communicated to you by the
  113. Customer.
  114. </li>
  115. <li>
  116. By clicking "I agree" below or otherwise accessing our ISO 27001 materials, you:
  117. <ol className="list-[lower-roman] list-inside pl-4">
  118. <li>acknowledge that you have read and understood this Confidentiality Notice;</li>
  119. <li>
  120. confirm that you have been authorized by the Customer to access this information,
  121. and your use of our ISO 27001 materials is subject to the confidentiality
  122. obligations owed by the Customer to us.
  123. </li>
  124. </ol>
  125. </li>
  126. <li>
  127. This Confidentiality Notice does not substitute or supersede any agreement between us
  128. and the Customer, or any internal rules or policies that the Customer requires you to
  129. comply with in your access to and use of confidential information. However, your
  130. failure to comply with this Confidentiality Notice may be used to determine whether
  131. the Customer has complied with its confidentiality obligations to us.
  132. </li>
  133. </ol>
  134. </ConfirmationModal>
  135. </ScaffoldSectionContent>
  136. </ScaffoldSection>
  137. )
  138. }