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